Search in sources :

Example 1 with DslFixedQuery

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;
}
Also used : DslFixedQuery(io.vertigo.dynamox.search.dsl.model.DslFixedQuery) DslExpression(io.vertigo.dynamox.search.dsl.model.DslExpression) ArrayList(java.util.ArrayList) DslField(io.vertigo.dynamox.search.dsl.model.DslField)

Example 2 with DslFixedQuery

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());
    }
}
Also used : DslFixedQuery(io.vertigo.dynamox.search.dsl.model.DslFixedQuery) DslTermQuery(io.vertigo.dynamox.search.dsl.model.DslTermQuery) DslQuery(io.vertigo.dynamox.search.dsl.model.DslQuery)

Example 3 with DslFixedQuery

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);
}
Also used : DslFixedQuery(io.vertigo.dynamox.search.dsl.model.DslFixedQuery) DslRangeQuery(io.vertigo.dynamox.search.dsl.model.DslRangeQuery) PegChoice(io.vertigo.commons.peg.PegChoice) DslQuery(io.vertigo.dynamox.search.dsl.model.DslQuery)

Aggregations

DslFixedQuery (io.vertigo.dynamox.search.dsl.model.DslFixedQuery)3 DslQuery (io.vertigo.dynamox.search.dsl.model.DslQuery)2 PegChoice (io.vertigo.commons.peg.PegChoice)1 DslExpression (io.vertigo.dynamox.search.dsl.model.DslExpression)1 DslField (io.vertigo.dynamox.search.dsl.model.DslField)1 DslRangeQuery (io.vertigo.dynamox.search.dsl.model.DslRangeQuery)1 DslTermQuery (io.vertigo.dynamox.search.dsl.model.DslTermQuery)1 ArrayList (java.util.ArrayList)1