use of org.geotoolkit.ows.xml.v110.ValueType in project entity-service by hypertrace.
the class MapFilteringExpressionConverter method convert.
@Override
public FilterTypeExpression convert(final ColumnIdentifier columnIdentifier, final Operator operator, final LiteralConstant constant, final RequestContext requestContext) throws ConversionException {
if (!SUPPORTED_OPERATORS.contains(operator)) {
throw new ConversionException(String.format("Operator %s is not supported", operator));
}
final String id = columnIdentifier.getColumnName();
final String subDocPath = getSubDocPathById(entityAttributeMapping, id, requestContext);
final Value value = constant.getValue();
final ValueType valueType = value.getValueType();
final Map<?, ?> map = valueOneOfAccessor.access(value, valueType);
if (map.isEmpty()) {
throw new ConversionException("Conversion of empty-map is unsupported");
}
final IdentifierConverter identifierConverter = identifierConverterFactory.getIdentifierConverter(id, subDocPath, valueType, requestContext);
final IdentifierConversionMetadata metadata = IdentifierConversionMetadata.builder().subDocPath(subDocPath).operator(operator).valueType(valueType).build();
final String suffixedSubDocPath = identifierConverter.convert(metadata, requestContext);
final List<RelationalExpression> expressions = new ArrayList<>();
for (final Map.Entry<?, ?> entry : map.entrySet()) {
final IdentifierExpression lhs = IdentifierExpression.of(String.format(suffixedSubDocPath, entry.getKey()));
final RelationalOperator relationalOperator = convertOperator(operator);
final ConstantExpression rhs = valueHelper.convertToConstantExpression(value, entry.getKey());
final RelationalExpression expression = RelationalExpression.of(lhs, relationalOperator, rhs);
expressions.add(expression);
}
if (expressions.size() == 1) {
return expressions.get(0);
}
return LogicalExpression.builder().operator(LogicalOperator.AND).operands(expressions).build();
}
use of org.geotoolkit.ows.xml.v110.ValueType in project entity-service by hypertrace.
the class NullFilteringExpressionConverter method convert.
@Override
public FilterTypeExpression convert(final ColumnIdentifier columnIdentifier, final Operator operator, final LiteralConstant constant, final RequestContext requestContext) throws ConversionException {
final String id = columnIdentifier.getColumnName();
final String subDocPath = getSubDocPathById(entityAttributeMapping, id, requestContext);
final Value value = constant.getValue();
final ValueType valueType = value.getValueType();
final IdentifierConverter identifierConverter = identifierConverterFactory.getIdentifierConverter(id, subDocPath, valueType, requestContext);
final IdentifierConversionMetadata metadata = IdentifierConversionMetadata.builder().subDocPath(subDocPath).operator(operator).valueType(valueType).build();
final String suffixedSubDocPath = identifierConverter.convert(metadata, requestContext);
final IdentifierExpression identifierExpression = IdentifierExpression.of(suffixedSubDocPath);
final RelationalOperator relationalOperator = convertOperator(operator);
final ConstantExpression constantExpression = constantExpressionConverter.convert(constant, requestContext);
RelationalExpression relationalExpression = RelationalExpression.of(identifierExpression, relationalOperator, constantExpression);
switch(operator) {
// 'field' EQ 'null' -> 'field' EQ 'null' || 'field' NOT_EXISTS
case EQ:
RelationalExpression nonExistenceRelationalExpression = RelationalExpression.of(identifierExpression, convertOperator(Operator.NOT_EXISTS), constantExpression);
return LogicalExpression.builder().operator(LogicalOperator.OR).operands(List.of(nonExistenceRelationalExpression, relationalExpression)).build();
default:
return relationalExpression;
}
}
use of org.geotoolkit.ows.xml.v110.ValueType in project entity-service by hypertrace.
the class PrimitiveFilteringExpressionConverter method convert.
@Override
public FilterTypeExpression convert(final ColumnIdentifier columnIdentifier, final Operator operator, final LiteralConstant constant, final RequestContext requestContext) throws ConversionException {
final String id = columnIdentifier.getColumnName();
final String subDocPath = getSubDocPathById(entityAttributeMapping, id, requestContext);
final Value value = constant.getValue();
final ValueType valueType = value.getValueType();
final IdentifierConverter identifierConverter = identifierConverterFactory.getIdentifierConverter(id, subDocPath, valueType, requestContext);
final IdentifierConversionMetadata metadata = IdentifierConversionMetadata.builder().subDocPath(subDocPath).operator(operator).valueType(valueType).build();
final String suffixedSubDocPath = identifierConverter.convert(metadata, requestContext);
final IdentifierExpression identifierExpression = IdentifierExpression.of(suffixedSubDocPath);
final RelationalOperator relationalOperator = convertOperator(operator);
final ConstantExpression constantExpression = constantExpressionConverter.convert(constant, requestContext);
return RelationalExpression.of(identifierExpression, relationalOperator, constantExpression);
}
use of org.geotoolkit.ows.xml.v110.ValueType in project entity-service by hypertrace.
the class ArrayGetter method getValue.
@Override
public Value getValue(final JsonNode jsonNode) throws ConversionException {
final Iterator<JsonNode> elements = jsonNode.elements();
final List<Value> values = new ArrayList<>();
while (elements.hasNext()) {
final JsonNode node = elements.next();
final Value value;
if (nestedValueGetter.matches(node)) {
value = nestedValueGetter.getValue(node);
} else if (directValueGetter.matches(node)) {
value = directValueGetter.getValue(node);
} else {
throw new ConversionException(String.format("Unexpected node (%s) found", node));
}
values.add(value);
}
final ValueType primitiveType = values.stream().map(Value::getValueType).findFirst().orElse(STRING);
final ValueType type = valueHelper.getArrayValueType(primitiveType);
final Value.Builder valueBuilder = Value.newBuilder().setValueType(type);
switch(type) {
case STRING_ARRAY:
values.stream().map(Value::getString).forEach(valueBuilder::addStringArray);
break;
case INT_ARRAY:
values.stream().map(Value::getInt).forEach(valueBuilder::addIntArray);
break;
case LONG_ARRAY:
values.stream().map(Value::getLong).forEach(valueBuilder::addLongArray);
break;
case FLOAT_ARRAY:
values.stream().map(Value::getFloat).forEach(valueBuilder::addFloatArray);
break;
case DOUBLE_ARRAY:
values.stream().map(Value::getDouble).forEach(valueBuilder::addDoubleArray);
break;
case BYTES_ARRAY:
values.stream().map(Value::getBytes).forEach(valueBuilder::addBytesArray);
break;
case BOOLEAN_ARRAY:
values.stream().map(Value::getBoolean).forEach(valueBuilder::addBooleanArray);
break;
default:
throw new ConversionException(String.format("Unknown array type: %s", type));
}
return valueBuilder.build();
}
use of org.geotoolkit.ows.xml.v110.ValueType in project ddf by codice.
the class MockWfsServer method getFilterCapabilities.
public static FilterCapabilities getFilterCapabilities() {
FilterCapabilities capabilities = new FilterCapabilities();
ConformanceType conformance = new ConformanceType();
for (CONFORMANCE_CONSTRAINTS constraint : CONFORMANCE_CONSTRAINTS.values()) {
DomainType domain = new DomainType();
NoValues noValues = new NoValues();
domain.setNoValues(noValues);
ValueType value = new ValueType();
value.setValue("TRUE");
domain.setDefaultValue(value);
domain.setName(constraint.toString());
conformance.getConstraint().add(domain);
}
capabilities.setConformance(conformance);
ScalarCapabilitiesType scalar = new ScalarCapabilitiesType();
scalar.setLogicalOperators(new LogicalOperators());
scalar.setComparisonOperators(new ComparisonOperatorsType());
for (COMPARISON_OPERATORS compOp : COMPARISON_OPERATORS.values()) {
ComparisonOperatorType operator = new ComparisonOperatorType();
operator.setName(compOp.toString());
scalar.getComparisonOperators().getComparisonOperator().add(operator);
}
capabilities.setScalarCapabilities(scalar);
SpatialCapabilitiesType spatial = new SpatialCapabilitiesType();
spatial.setSpatialOperators(new SpatialOperatorsType());
for (SPATIAL_OPERATORS spatialOp : SPATIAL_OPERATORS.values()) {
SpatialOperatorType operator = new SpatialOperatorType();
operator.setName(spatialOp.toString());
spatial.getSpatialOperators().getSpatialOperator().add(operator);
}
GeometryOperandsType geometryOperands = new GeometryOperandsType();
List<QName> qnames = Arrays.asList(Wfs20Constants.POINT, Wfs20Constants.ENVELOPE, Wfs20Constants.POLYGON, Wfs20Constants.LINESTRING);
for (QName qName : qnames) {
GeometryOperand operand = new GeometryOperand();
operand.setName(qName);
geometryOperands.getGeometryOperand().add(operand);
}
spatial.setGeometryOperands(geometryOperands);
capabilities.setSpatialCapabilities(spatial);
TemporalCapabilitiesType temporal = new TemporalCapabilitiesType();
temporal.setTemporalOperators(new TemporalOperatorsType());
for (TEMPORAL_OPERATORS temporalOp : TEMPORAL_OPERATORS.values()) {
TemporalOperatorType operator = new TemporalOperatorType();
operator.setName(temporalOp.toString());
temporal.getTemporalOperators().getTemporalOperator().add(operator);
}
TemporalOperandsType temporalOperands = new TemporalOperandsType();
List<QName> timeQNames = Arrays.asList(new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimePeriod"), new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimeInstant"));
for (QName qName : timeQNames) {
TemporalOperand operand = new TemporalOperand();
operand.setName(qName);
temporalOperands.getTemporalOperand().add(operand);
}
temporal.setTemporalOperands(temporalOperands);
capabilities.setTemporalCapabilities(temporal);
return capabilities;
}
Aggregations