IDEMPIERE-5773 - Fixed bug on advance detail not adding the parenthesis on detail tab queries (#2062)

* IDEMPIERE-5773 - Refactor FindWindow code that discovers the right and left bracket value

* IDEMPIERE-5773 - Refactor FindWindow code that discovers the right and left bracket value - Improve method name

* IDEMPIERE-5773 - Fixed bug on advance detail not adding the parenthesis on detail tab queries
This commit is contained in:
Diego Ruiz 2023-10-18 09:00:37 +02:00 committed by GitHub
parent bb3856dbb0
commit 46c7c4c06d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 5 deletions

View File

@ -2264,15 +2264,18 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
exists.append(PO.getUUIDColumnName(m_tableName));
else
exists.append(m_tableName).append("_ID ");
ColumnSQL = exists.toString() + " AND " + ColumnSQL;
exists.append(" AND ")
.append(getLeftBracketValue(row))
.append(ColumnSQL);
ColumnSQL = exists.toString();
}
isExists = true;
}
}
// Left brackets
Listbox listLeftBracket = (Listbox)row.getFellow("listLeftBracket"+row.getId());
String lBrackets = listLeftBracket.getSelectedItem().getValue().toString();
String lBrackets = getLeftBracketValue(row);
if (lBrackets != null) {
openBrackets += lBrackets.length();
if (isExists && !lBrackets.isEmpty()) {
@ -2283,8 +2286,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
lBrackets = "";
}
// Right brackets
Listbox listRightBracket = (Listbox)row.getFellow("listRightBracket"+row.getId());
String rBrackets = listRightBracket.getSelectedItem().getValue().toString();
String rBrackets = getRightBracketValue(row);
if (rBrackets != null) {
openBrackets -= rBrackets.length();
if(isCompositeExists && !rBrackets.isEmpty())
@ -2469,6 +2471,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
if(!isCompositeExists)
where += ")";
where += getRightBracketValue(row);
m_query.addRestriction(where, and, not, isExistCondition, openBrackets);
} else {
m_query.addRestriction (ColumnSQL, Operator, parsedValue,
@ -2490,6 +2494,28 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
} // cmd_saveAdvanced
/**
* Returns the value selected for the left bracket list item
* in the current row
* @param row
* @return empty, (, (( or (((
*/
private String getLeftBracketValue(ListItem row) {
Listbox listLeftBracket = (Listbox)row.getFellow("listLeftBracket"+row.getId());
return listLeftBracket.getSelectedItem().getValue().toString();
}
/**
* Returns the value selected for the right bracket list item
* in the current row
* @param row
* @return empty, ), )) or )))
*/
private String getRightBracketValue(ListItem row) {
Listbox listRightBracket = (Listbox)row.getFellow("listRightBracket"+row.getId());
return listRightBracket.getSelectedItem().getValue().toString();
}
/**
* Append values to code
* @param code