use of io.vertigo.dynamox.search.dsl.model.DslField 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.DslField in project vertigo by KleeGroup.
the class DslMultiFieldRule method handle.
/**
* {@inheritDoc}
*/
@Override
protected DslMultiField handle(final List<Object> parsing) {
// (String) parsing.get(0);
final String preMultiField = "";
final List<DslField> fields = new ArrayList<>();
// ---
// On récupère le premier mot qui est obligatoire.
final DslField firstField = (DslField) parsing.get(2);
fields.add(firstField);
// On récupère le produit de la règle many
final List<List<Object>> many = (List<List<Object>>) parsing.get(3);
for (final List<Object> row : many) {
fields.add((DslField) row.get(3));
}
// ---
// (String) parsing.get(7);
final String postMultiField = "";
return new DslMultiField(preMultiField, fields, postMultiField);
}
use of io.vertigo.dynamox.search.dsl.model.DslField in project vertigo by KleeGroup.
the class DslListFilterBuilder method appendCompactFields.
private void appendCompactFields(final StringBuilder query, final DslExpression expressionDefinition, final StringBuilder expressionQuery, final DslQuery dslQuery) {
String expressionSep = "";
final DslMultiField dslMultiField = expressionDefinition.getMultiField().get();
for (final DslField dslField : dslMultiField.getFields()) {
final DslField monoFieldDefinition = new DslField(firstNotEmpty(dslField.getPreBody(), dslMultiField.getPreBody()), dslField.getFieldName(), firstNotEmpty(dslField.getPostBody(), dslMultiField.getPostBody()));
final DslExpression monoFieldExpressionDefinition = new DslExpression(concat(expressionSep, expressionDefinition.getPreBody()), Optional.of(monoFieldDefinition), Optional.empty(), dslQuery, expressionDefinition.getPostBody());
appendTermQuery(expressionQuery, (DslTermQuery) dslQuery, monoFieldExpressionDefinition, query);
flushExpressionToQuery(query, monoFieldExpressionDefinition, expressionQuery);
expressionSep = " ";
}
}
use of io.vertigo.dynamox.search.dsl.model.DslField 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;
}
Aggregations