add command IN and NOT_IN for a filter to the dashboard
This commit is contained in:
parent
45c5703f2f
commit
58f4c7420d
@ -38,6 +38,8 @@ public class StringFilterPredicate implements SimpleKeyFilterPredicate<String> {
|
|||||||
STARTS_WITH,
|
STARTS_WITH,
|
||||||
ENDS_WITH,
|
ENDS_WITH,
|
||||||
CONTAINS,
|
CONTAINS,
|
||||||
NOT_CONTAINS
|
NOT_CONTAINS,
|
||||||
|
IN,
|
||||||
|
NOT_IN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -537,6 +537,7 @@ public class EntityKeyMapping {
|
|||||||
value = value.toLowerCase();
|
value = value.toLowerCase();
|
||||||
operationField = String.format("lower(%s)", operationField);
|
operationField = String.format("lower(%s)", operationField);
|
||||||
}
|
}
|
||||||
|
List<String> values = new ArrayList<>();
|
||||||
switch (stringFilterPredicate.getOperation()) {
|
switch (stringFilterPredicate.getOperation()) {
|
||||||
case EQUAL:
|
case EQUAL:
|
||||||
stringOperationQuery = String.format("%s = :%s)", operationField, paramName);
|
stringOperationQuery = String.format("%s = :%s)", operationField, paramName);
|
||||||
@ -560,8 +561,29 @@ public class EntityKeyMapping {
|
|||||||
value = "%" + value + "%";
|
value = "%" + value + "%";
|
||||||
stringOperationQuery = String.format("%s not like :%s or %s is null)", operationField, paramName, operationField);
|
stringOperationQuery = String.format("%s not like :%s or %s is null)", operationField, paramName, operationField);
|
||||||
break;
|
break;
|
||||||
|
case IN:
|
||||||
|
value = value.replaceAll("'","").replaceAll("\"", "");
|
||||||
|
values = List.of(value.trim().split("\\s*,\\s*"));
|
||||||
|
System.out.println(value);
|
||||||
|
stringOperationQuery = String.format("%s in (:%s))", operationField, paramName);
|
||||||
|
break;
|
||||||
|
case NOT_IN:
|
||||||
|
value = value.replaceAll("'","").replaceAll("\"", "");
|
||||||
|
values = List.of(value.trim().split("\\s*,\\s*"));
|
||||||
|
System.out.println(value);
|
||||||
|
stringOperationQuery = String.format("%s not in (:%s))", operationField, paramName);
|
||||||
}
|
}
|
||||||
|
switch (stringFilterPredicate.getOperation()) {
|
||||||
|
case IN:
|
||||||
|
case NOT_IN:
|
||||||
|
for (String str : values) {
|
||||||
|
System.out.println(str);
|
||||||
|
}
|
||||||
|
ctx.addStringListParameter(paramName, values);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
ctx.addStringParameter(paramName, value);
|
ctx.addStringParameter(paramName, value);
|
||||||
|
}
|
||||||
return String.format("((%s is not null and %s)", field, stringOperationQuery);
|
return String.format("((%s is not null and %s)", field, stringOperationQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -226,7 +226,9 @@ export enum StringOperation {
|
|||||||
STARTS_WITH = 'STARTS_WITH',
|
STARTS_WITH = 'STARTS_WITH',
|
||||||
ENDS_WITH = 'ENDS_WITH',
|
ENDS_WITH = 'ENDS_WITH',
|
||||||
CONTAINS = 'CONTAINS',
|
CONTAINS = 'CONTAINS',
|
||||||
NOT_CONTAINS = 'NOT_CONTAINS'
|
NOT_CONTAINS = 'NOT_CONTAINS',
|
||||||
|
IN = 'CONTAINS',
|
||||||
|
NOT_IN = 'NOT_CONTAINS'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const stringOperationTranslationMap = new Map<StringOperation, string>(
|
export const stringOperationTranslationMap = new Map<StringOperation, string>(
|
||||||
@ -236,7 +238,9 @@ export const stringOperationTranslationMap = new Map<StringOperation, string>(
|
|||||||
[StringOperation.STARTS_WITH, 'filter.operation.starts-with'],
|
[StringOperation.STARTS_WITH, 'filter.operation.starts-with'],
|
||||||
[StringOperation.ENDS_WITH, 'filter.operation.ends-with'],
|
[StringOperation.ENDS_WITH, 'filter.operation.ends-with'],
|
||||||
[StringOperation.CONTAINS, 'filter.operation.contains'],
|
[StringOperation.CONTAINS, 'filter.operation.contains'],
|
||||||
[StringOperation.NOT_CONTAINS, 'filter.operation.not-contains']
|
[StringOperation.NOT_CONTAINS, 'filter.operation.not-contains'],
|
||||||
|
[StringOperation.IN, 'filter.operation.in'],
|
||||||
|
[StringOperation.NOT_IN, 'filter.operation.not-in']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -2003,7 +2003,9 @@
|
|||||||
"greater-or-equal": "greater or equal",
|
"greater-or-equal": "greater or equal",
|
||||||
"less-or-equal": "less or equal",
|
"less-or-equal": "less or equal",
|
||||||
"and": "and",
|
"and": "and",
|
||||||
"or": "or"
|
"or": "or",
|
||||||
|
"in": "in",
|
||||||
|
"not-in": "not in"
|
||||||
},
|
},
|
||||||
"ignore-case": "ignore case",
|
"ignore-case": "ignore case",
|
||||||
"value": "Value",
|
"value": "Value",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user