use of io.vertigo.dynamo.domain.metamodel.DataType in project vertigo by KleeGroup.
the class ESSearchRequestBuilder method rangeFacetToAggregationBuilder.
private static AggregationBuilder rangeFacetToAggregationBuilder(final FacetDefinition facetDefinition, final DtField dtField) {
// facette par range
final DataType dataType = dtField.getDomain().getDataType();
if (dataType == DataType.Date) {
return dateRangeFacetToAggregationBuilder(facetDefinition, dtField);
} else if (dataType.isNumber()) {
return numberRangeFacetToAggregationBuilder(facetDefinition, dtField);
}
final List<KeyedFilter> filters = new ArrayList<>();
for (final FacetValue facetRange : facetDefinition.getFacetRanges()) {
final String filterValue = facetRange.getListFilter().getFilterValue();
Assertion.checkState(filterValue.contains(dtField.getName()), "RangeFilter query ({1}) should use defined fieldName {0}", dtField.getName(), filterValue);
filters.add(new KeyedFilter(filterValue, QueryBuilders.queryStringQuery(filterValue)));
}
return AggregationBuilders.filters(facetDefinition.getName(), filters.toArray(new KeyedFilter[filters.size()]));
}
use of io.vertigo.dynamo.domain.metamodel.DataType in project vertigo by KleeGroup.
the class AbstractSearchLoader method getLowestIdValue.
private P getLowestIdValue(final DtDefinition dtDefinition) {
final DtField idField = dtDefinition.getIdField().get();
final DataType idDataType = idField.getDomain().getDataType();
P pkValue;
switch(idDataType) {
case Integer:
pkValue = (P) Integer.valueOf(-1);
break;
case Long:
pkValue = (P) Long.valueOf(-1);
break;
case String:
pkValue = (P) "";
break;
case BigDecimal:
case DataStream:
case Boolean:
case Double:
case Date:
default:
throw new IllegalArgumentException("Type's PK " + idDataType.name() + " of " + dtDefinition.getClassSimpleName() + " is not supported, prefer int, long or String ID.");
}
return pkValue;
}
use of io.vertigo.dynamo.domain.metamodel.DataType in project vertigo by KleeGroup.
the class ESSearchRequestBuilder method rangeFacetToAggregationBuilder.
private static AggregationBuilder<?> rangeFacetToAggregationBuilder(final FacetDefinition facetDefinition, final DtField dtField) {
// facette par range
final DataType dataType = dtField.getDomain().getDataType();
if (dataType == DataType.Date) {
return dateRangeFacetToAggregationBuilder(facetDefinition, dtField);
} else if (dataType.isNumber()) {
return numberRangeFacetToAggregationBuilder(facetDefinition, dtField);
}
final FiltersAggregationBuilder filters = AggregationBuilders.filters(facetDefinition.getName());
for (final FacetValue facetRange : facetDefinition.getFacetRanges()) {
final String filterValue = facetRange.getListFilter().getFilterValue();
Assertion.checkState(filterValue.contains(dtField.getName()), "RangeFilter query ({1}) should use defined fieldName {0}", dtField.getName(), filterValue);
filters.filter(filterValue, QueryBuilders.queryStringQuery(filterValue));
}
return filters;
}
use of io.vertigo.dynamo.domain.metamodel.DataType in project vertigo by KleeGroup.
the class DomainDynamicRegistry method createDomain.
private static Domain createDomain(final DefinitionSpace definitionSpace, final DslDefinition xdomain) {
final String domainName = xdomain.getName();
final List<String> constraintNames = xdomain.getDefinitionLinkNames("constraint");
final String type = xdomain.getDefinitionLinkName("dataType");
final Boolean multiple = (Boolean) xdomain.getPropertyValue(KspProperty.MULTIPLE);
final Properties properties = extractProperties(xdomain);
final DomainBuilder domainBuilder;
if ("DtObject".equals(type)) {
domainBuilder = Domain.builder(domainName, properties.getValue(DtProperty.TYPE), false);
} else if ("DtList".equals(type)) {
domainBuilder = Domain.builder(domainName, properties.getValue(DtProperty.TYPE), true);
} else {
final DataType dataType = DataType.valueOf(type);
domainBuilder = Domain.builder(domainName, dataType, multiple == null ? false : multiple);
// only primitive can have a formatter
final boolean hasFormatter = !xdomain.getDefinitionLinkNames("formatter").isEmpty();
if (hasFormatter) {
final String formatterName = xdomain.getDefinitionLinkName("formatter");
final FormatterDefinition formatterDefinition = definitionSpace.resolve(formatterName, FormatterDefinition.class);
// ---
domainBuilder.withFormatter(formatterDefinition);
}
}
return domainBuilder.withConstraints(createConstraints(definitionSpace, constraintNames)).withProperties(properties).build();
}
use of io.vertigo.dynamo.domain.metamodel.DataType in project vertigo by KleeGroup.
the class DtListPatternFilterUtil method createDtListFilterForPattern.
static <D extends DtObject> Predicate<D> createDtListFilterForPattern(final FilterPattern filterPattern, final String[] parsedFilter, final DtDefinition dtDefinition) {
Assertion.checkNotNull(filterPattern);
Assertion.checkNotNull(parsedFilter);
Assertion.checkNotNull(dtDefinition);
// -----
// Si on trouve un pattern, on passe sur du code spécifique
// attention parsedFilter[0] = filtre entier
final String fieldName = parsedFilter[1];
final DtField dtField = dtDefinition.getField(fieldName);
final DataType dataType = dtField.getDomain().getDataType();
switch(filterPattern) {
case Range:
return createDtListRangeFilter(parsedFilter, fieldName, dataType);
case Term:
return createDtListTermFilter(parsedFilter, fieldName, dataType);
default:
throw new VSystemException("La chaine de filtrage: {0} , ne respecte pas la syntaxe {1}.", parsedFilter[0], filterPattern.getPattern().pattern());
}
}
Aggregations