mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #672 from harshanL/cloud-3.1.0
Fix for Advanced Search Issue #670
This commit is contained in:
commit
75bcc720d6
@ -35,6 +35,7 @@ public class QueryBuilderImpl implements QueryBuilder {
|
||||
|
||||
private static final Log log = LogFactory.getLog(QueryBuilderImpl.class);
|
||||
private final String WILDCARD_OPERATOR = "%";
|
||||
private final String OR_OPERATOR = "OR";
|
||||
private String current_username;
|
||||
private boolean isDeviceAdminUser;
|
||||
|
||||
@ -131,7 +132,7 @@ public class QueryBuilderImpl implements QueryBuilder {
|
||||
for (Condition con : conditions) {
|
||||
if (Utils.checkDeviceDetailsColumns(con.getKey())) {
|
||||
if (con.operator.equals(WILDCARD_OPERATOR)) {
|
||||
querySuffix = querySuffix + " OR DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey())
|
||||
querySuffix = querySuffix + " AND DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey())
|
||||
+ " LIKE ? ";
|
||||
ValueType type = new ValueType();
|
||||
type.setColumnType(ValueType.columnType.STRING);
|
||||
@ -215,6 +216,11 @@ public class QueryBuilderImpl implements QueryBuilder {
|
||||
} catch (Exception e) {
|
||||
throw new InvalidOperatorException("Error occurred while building the sql", e);
|
||||
}
|
||||
if (!querySuffix.isEmpty()) {
|
||||
//Replacing the first OR operator as it's unnecessary
|
||||
querySuffix = querySuffix.replaceFirst(OR_OPERATOR, "");
|
||||
querySuffix = " AND (" + querySuffix + ")";
|
||||
}
|
||||
return querySuffix;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user