Search in sources :

Example 46 with LiteralType

use of org.geotoolkit.ogc.xml.v110.LiteralType in project geo-platform by geosdi.

the class BaseBinaryStrategy method createBinaryComparisonTypeForDate.

/**
 * @param queryRestrictionDTO
 * @return {@link BinaryComparisonOpType}
 */
protected BinaryComparisonOpType createBinaryComparisonTypeForDate(QueryRestrictionDTO queryRestrictionDTO) {
    return new BinaryComparisonOpType() {

        {
            PropertyNameType propertyNameType = new PropertyNameType();
            propertyNameType.setContent(asList(queryRestrictionDTO.getAttribute().getName()));
            FunctionType functionType = new FunctionType();
            functionType.setName("dateParse");
            LiteralType literalType = new LiteralType();
            literalType.setContent(asList(queryRestrictionDTO.getRestriction()));
            LiteralType literalTypeFormat = new LiteralType();
            literalTypeFormat.setContent(dateFormatStrategyFinder.findDateFormat(queryRestrictionDTO.getAttribute()));
            List<JAXBElement<?>> functionElements = new ArrayList<>(2);
            functionElements.add(filterFactory.createLiteral(literalTypeFormat));
            functionElements.add(filterFactory.createLiteral(literalType));
            functionType.setExpression(functionElements);
            List<JAXBElement<?>> elements = new ArrayList<>(2);
            elements.add(filterFactory.createPropertyName(propertyNameType));
            elements.add(filterFactory.createFunction(functionType));
            super.setExpression(elements);
        }
    };
}
Also used : FunctionType(org.geosdi.geoplatform.xml.filter.v110.FunctionType) ArrayList(java.util.ArrayList) LiteralType(org.geosdi.geoplatform.xml.filter.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) BinaryComparisonOpType(org.geosdi.geoplatform.xml.filter.v110.BinaryComparisonOpType) PropertyNameType(org.geosdi.geoplatform.xml.filter.v110.PropertyNameType)

Example 47 with LiteralType

use of org.geotoolkit.ogc.xml.v110.LiteralType in project geo-platform by geosdi.

the class BaseBinaryStrategy method createBinaryComparisonType.

/**
 * @param queryRestrictionDTO
 * @return {@link BinaryComparisonOpType}
 */
protected BinaryComparisonOpType createBinaryComparisonType(QueryRestrictionDTO queryRestrictionDTO) {
    return new BinaryComparisonOpType() {

        {
            PropertyNameType propertyNameType = new PropertyNameType();
            propertyNameType.setContent(asList(queryRestrictionDTO.getAttribute().getName()));
            LiteralType literalType = new LiteralType();
            literalType.setContent(asList(queryRestrictionDTO.getRestriction()));
            List<JAXBElement<?>> elements = new ArrayList<>(2);
            elements.add(filterFactory.createPropertyName(propertyNameType));
            elements.add(filterFactory.createLiteral(literalType));
            super.setExpression(elements);
        }
    };
}
Also used : ArrayList(java.util.ArrayList) LiteralType(org.geosdi.geoplatform.xml.filter.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) BinaryComparisonOpType(org.geosdi.geoplatform.xml.filter.v110.BinaryComparisonOpType) PropertyNameType(org.geosdi.geoplatform.xml.filter.v110.PropertyNameType)

Example 48 with LiteralType

use of org.geotoolkit.ogc.xml.v110.LiteralType in project flytekit-java by flyteorg.

the class VariableMapVisitor method property.

@Override
public void property(BeanProperty prop) {
    JavaType handledType = getHandledType(prop);
    LiteralType literalType = toLiteralType(handledType);
    Variable variable = Variable.builder().description("").literalType(literalType).build();
    builder.put(prop.getName(), variable);
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) Variable(org.flyte.api.v1.Variable) LiteralType(org.flyte.api.v1.LiteralType)

Example 49 with LiteralType

use of org.geotoolkit.ogc.xml.v110.LiteralType in project flytekit-java by flyteorg.

the class Compiler method validateApply.

static List<CompilerError> validateApply(String nodeId, Map<String, SdkBindingData> inputs, Map<String, Variable> variableMap) {
    List<CompilerError> errors = new ArrayList<>();
    Set<String> allKeys = new HashSet<>();
    allKeys.addAll(inputs.keySet());
    allKeys.addAll(variableMap.keySet());
    for (String key : allKeys) {
        SdkBindingData input = inputs.get(key);
        Variable variable = variableMap.get(key);
        if (variable == null) {
            String message = String.format("Variable [%s] not found on node [%s].", key, nodeId);
            errors.add(CompilerError.create(CompilerError.Kind.VARIABLE_NAME_NOT_FOUND, nodeId, message));
            continue;
        }
        if (input == null) {
            String message = String.format("Parameter not bound [%s].", key);
            errors.add(CompilerError.create(CompilerError.Kind.PARAMETER_NOT_BOUND, nodeId, message));
            continue;
        }
        LiteralType actualType = input.type();
        LiteralType expectedType = variable.literalType();
        if (!actualType.equals(expectedType)) {
            String message = String.format("Variable [%s] (type [%s]) doesn't match expected type [%s].", key, actualType, expectedType);
            errors.add(CompilerError.create(CompilerError.Kind.MISMATCHING_TYPES, nodeId, message));
        }
    }
    return errors;
}
Also used : Variable(org.flyte.api.v1.Variable) ArrayList(java.util.ArrayList) LiteralType(org.flyte.api.v1.LiteralType) HashSet(java.util.HashSet)

Example 50 with LiteralType

use of org.geotoolkit.ogc.xml.v110.LiteralType in project flytekit-java by flyteorg.

the class LiteralMapDeserializer method deserialize.

@Override
public JacksonLiteralMap deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    Map<String, Literal> literalMap = new HashMap<>();
    verifyToken(p, JsonToken.START_OBJECT);
    p.nextToken();
    while (p.currentToken() != JsonToken.END_OBJECT) {
        verifyToken(p, JsonToken.FIELD_NAME);
        String fieldName = p.currentName();
        LiteralType literalType = literalTypeMap.get(fieldName);
        if (literalType == null) {
            throw new IllegalStateException("Unexpected field [" + fieldName + "]");
        }
        p.nextToken();
        literalMap.put(fieldName, deserialize(p, ctxt, literalType));
        p.nextToken();
    }
    return new JacksonLiteralMap(unmodifiableMap(literalMap));
}
Also used : HashMap(java.util.HashMap) Literal(org.flyte.api.v1.Literal) LiteralType(org.flyte.api.v1.LiteralType)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)40 LiteralType (org.geotoolkit.ogc.xml.v110.LiteralType)40 PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)40 Literal (org.opengis.filter.Literal)35 Marshaller (javax.xml.bind.Marshaller)34 Unmarshaller (javax.xml.bind.Unmarshaller)34 Test (org.junit.Test)34 ValueReference (org.opengis.filter.ValueReference)34 Filter (org.opengis.filter.Filter)26 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)21 LiteralType (org.geotoolkit.ogc.xml.v100.LiteralType)17 PropertyNameType (org.geotoolkit.ogc.xml.v100.PropertyNameType)16 FilterType (org.geotoolkit.ogc.xml.v110.FilterType)14 FilterType (org.geotoolkit.ogc.xml.v100.FilterType)11 Expression (org.opengis.filter.Expression)11 LiteralType (org.flyte.api.v1.LiteralType)10 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v100.BinaryComparisonOpType)9 ComparisonOpsType (org.geotoolkit.ogc.xml.v100.ComparisonOpsType)9 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType)9 LogicalOperator (org.opengis.filter.LogicalOperator)9