Java Code Examples for cz.jirutka.rsql.parser.ast.ComparisonNode#getOperator()
The following examples show how to use
cz.jirutka.rsql.parser.ast.ComparisonNode#getOperator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SortRSQLNodeTraveller.java From pnc with Apache License 2.0 | 6 votes |
@Override public SortInfo visit(ComparisonNode node) { SortingDirection sortingDirection; List<String> sortingFields = new ArrayList<>(); if (node.getOperator().equals(ASC)) { sortingDirection = SortInfo.SortingDirection.ASC; } else if (node.getOperator().equals(DESC)) { sortingDirection = SortInfo.SortingDirection.DESC; } else { throw new UnsupportedOperationException("Unsupported sorting: " + node.getOperator()); } logger.trace("Sorting direction - {}, arguments {}", sortingDirection, node.getArguments()); for (String argument : node.getArguments()) { if ("id".equals(argument)) { // Disable sorting by id throw new RSQLException("Sorting by id is not supported."); } sortingFields.add(toPath.apply(RSQLSelectorPath.get(argument))); } return new DefaultSortInfo(sortingDirection, sortingFields); }
Example 2
Source File: BasicTypeFilterVisitor.java From gemini with Apache License 2.0 | 5 votes |
public QueryWithParams visit(EntityField field, ComparisonNode node, FilterVisitorContext filterVisitorContext) { ComparisonOperator operator = node.getOperator(); List<String> arguments = node.getArguments(); QueryWithParams singleArg = handleSingleArgumentOperator(field, operator, arguments, filterVisitorContext); if (singleArg != null) return singleArg; QueryWithParams multipleArg = handleMultipleArgumentOperator(field, operator, arguments, filterVisitorContext); if (multipleArg == null) { throw new GeminiRuntimeException(String.format("Filter not impemented for type %s", field.getType())); } return multipleArg; }
Example 3
Source File: RSQLComplexConverter.java From rsql-jpa-specification with MIT License | 5 votes |
@Override public Void visit(ComparisonNode node, Map<String, MultiValueMap<String, String>> map) { log.debug("visit(node:{},map:{})", node, map); String key = node.getSelector(); ComparisonOperator operator = node.getOperator(); MultiValueMap<String, String> operatorMap = map.computeIfAbsent(key, k -> CollectionUtils.toMultiValueMap(new HashMap<>())); for (String ops : operator.getSymbols()) { operatorMap.addAll(ops, node.getArguments()); } return null; }