use of io.vertigo.dynamox.search.dsl.model.DslQuery in project vertigo by KleeGroup.
the class DslExpressionRule method handle.
/**
* {@inheritDoc}
*/
@Override
protected DslExpression handle(final List<Object> parsing) {
String preExpression = ((Optional<String>) parsing.get(0)).orElse("") + parsing.get(1);
final String postExpression;
final Optional<DslField> field;
final Optional<DslMultiField> multiField;
final PegChoice fields = (PegChoice) parsing.get(2);
switch(fields.getChoiceIndex()) {
case 0:
field = Optional.of((DslField) fields.getValue());
multiField = Optional.empty();
postExpression = "";
break;
case 1:
final List<Object> multiFieldParsing = (List<Object>) fields.getValue();
preExpression = DslUtil.concat(preExpression, (String) multiFieldParsing.get(0));
multiField = Optional.of((DslMultiField) multiFieldParsing.get(1));
postExpression = (String) multiFieldParsing.get(2);
field = Optional.empty();
break;
default:
throw new IllegalArgumentException("case " + fields.getChoiceIndex() + " not implemented");
}
final PegChoice queries = (PegChoice) parsing.get(4);
final DslQuery query = (DslQuery) queries.getValue();
return new DslExpression(preExpression, field, multiField, query, postExpression);
}
use of io.vertigo.dynamox.search.dsl.model.DslQuery in project vertigo by KleeGroup.
the class DslListFilterBuilder method appendMultiQuery.
private void appendMultiQuery(final StringBuilder query, final DslBlockQuery dslMultiQueryDefinition, final DslExpression expressionDefinition, final StringBuilder parentQuery) {
final StringBuilder expressionMultiQuery = new StringBuilder();
for (final DslQuery dslQuery : dslMultiQueryDefinition.getQueries()) {
appendQuery(parentQuery, expressionDefinition, expressionMultiQuery, dslQuery);
}
flushSubQueryToQuery(query, dslMultiQueryDefinition.getPreBody(), dslMultiQueryDefinition.getPostBody(), true, expressionMultiQuery);
}
use of io.vertigo.dynamox.search.dsl.model.DslQuery in project vertigo by KleeGroup.
the class DslListFilterBuilder method appendExpression.
private void appendExpression(final StringBuilder query, final DslExpression expressionDefinition) {
final StringBuilder expressionQuery = new StringBuilder();
final DslQuery dslQuery = expressionDefinition.getQuery();
appendQuery(query, expressionDefinition, expressionQuery, dslQuery);
flushExpressionToQuery(query, expressionDefinition, expressionQuery);
}
use of io.vertigo.dynamox.search.dsl.model.DslQuery in project vertigo by KleeGroup.
the class DslListFilterBuilder method appendRangeQuery.
private void appendRangeQuery(final StringBuilder query, final DslRangeQuery dslQuery, final DslExpression expressionDefinition) {
final DslQuery startQueryDefinition = dslQuery.getStartQueryDefinitions();
final DslQuery endQueryDefinition = dslQuery.getEndQueryDefinitions();
final StringBuilder startRangeQuery = new StringBuilder();
if (startQueryDefinition instanceof DslTermQuery) {
// null because, can't use upper output
appendTermQuery(startRangeQuery, (DslTermQuery) startQueryDefinition, expressionDefinition, null);
} else if (startQueryDefinition instanceof DslFixedQuery) {
appendFixedQuery(startRangeQuery, (DslFixedQuery) startQueryDefinition);
}
final StringBuilder endRangeQuery = new StringBuilder();
if (endQueryDefinition instanceof DslTermQuery) {
// null because, can't use upper output
appendTermQuery(endRangeQuery, (DslTermQuery) endQueryDefinition, expressionDefinition, null);
} else if (endQueryDefinition instanceof DslFixedQuery) {
appendFixedQuery(endRangeQuery, (DslFixedQuery) endQueryDefinition);
}
// flush Range Query
final String startRangeStr = startRangeQuery.length() > 0 ? startRangeQuery.toString() : "*";
final String endRangeStr = endRangeQuery.length() > 0 ? endRangeQuery.toString() : "*";
if (!"*".equals(startRangeStr) || !"*".equals(endRangeStr)) {
query.append(dslQuery.getPreBody()).append(dslQuery.getStartRange()).append(startRangeStr).append(// toUpperCase car ES n'interprete pas correctement en lowercase
" TO ").append(endRangeStr).append(dslQuery.getEndRange()).append(dslQuery.getPostBody());
}
}
use of io.vertigo.dynamox.search.dsl.model.DslQuery in project vertigo by KleeGroup.
the class DslRangeQueryRule method handle.
/**
* {@inheritDoc}
*/
@Override
protected DslRangeQuery handle(final List<Object> parsing) {
final String preQuery = (String) parsing.get(0);
final PegChoice startChoice = (PegChoice) parsing.get(1);
final PegChoice startTermQuery = (PegChoice) parsing.get(2);
final DslQuery startQueryDefinitions;
if (startTermQuery.getChoiceIndex() == 0) {
startQueryDefinitions = new DslFixedQuery("*");
} else {
startQueryDefinitions = (DslQuery) startTermQuery.getValue();
}
final PegChoice endTermQuery = (PegChoice) parsing.get(6);
final DslQuery endQueryDefinitions;
if (endTermQuery.getChoiceIndex() == 0) {
endQueryDefinitions = new DslFixedQuery("*");
} else {
endQueryDefinitions = (DslQuery) endTermQuery.getValue();
}
final PegChoice endChoice = (PegChoice) parsing.get(8);
final String postQuery = (String) parsing.get(9);
final String startRange = (String) startChoice.getValue();
final String endRange = (String) endChoice.getValue();
return new DslRangeQuery(preQuery, startRange, startQueryDefinitions, endQueryDefinitions, endRange, postQuery);
}
Aggregations