use of io.vertigo.dynamox.search.dsl.model.DslFixedQuery in project vertigo by KleeGroup.
the class DslListFilterBuilder method flattenMultiToMonoFieldExpressionDefinition.
private static List<DslExpression> flattenMultiToMonoFieldExpressionDefinition(final DslTermQuery dslTermDefinition, final DslUserCriteria userCriteria, final String criteriaValue, final DslMultiField dslMultiField) {
final List<DslExpression> monoFieldExpressionDefinitions = new ArrayList<>();
for (final DslField dslField : dslMultiField.getFields()) {
final DslField monoFieldDefinition = new DslField(firstNotEmpty(dslField.getPreBody(), dslMultiField.getPreBody()), dslField.getFieldName(), "");
final DslExpression monoFieldExpressionDefinition = new DslExpression(monoFieldExpressionDefinitions.isEmpty() ? "" : " ", Optional.of(monoFieldDefinition), Optional.empty(), new DslFixedQuery(concat(criteriaValue, firstNotEmpty(userCriteria.getOverridedPostModifier(), dslTermDefinition.getPostTerm()))), firstNotEmpty(dslField.getPostBody(), dslMultiField.getPostBody()));
monoFieldExpressionDefinitions.add(monoFieldExpressionDefinition);
}
return monoFieldExpressionDefinitions;
}
use of io.vertigo.dynamox.search.dsl.model.DslFixedQuery 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.DslFixedQuery 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