use of org.geotoolkit.ogc.xml.v100.LiteralType in project flytekit-java by flyteorg.
the class JacksonSdkType method toLiteralMap.
@Override
public Map<String, Literal> toLiteralMap(T value) {
try {
JsonNode tree = OBJECT_MAPPER.valueToTree(value);
Map<String, LiteralType> literalTypeMap = getVariableMap().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, x -> x.getValue().literalType()));
// The previous trick with JavaType and withValueHandler did't work because
// Jackson caches serializers, without considering valueHandler as significant part
// of the caching key.
JsonParser tokens = OBJECT_MAPPER.treeAsTokens(tree);
tokens.nextToken();
LiteralMapDeserializer deserializer = new LiteralMapDeserializer(literalTypeMap);
// this is how OBJECT_MAPPER creates deserialization context, otherwise, nested deserializers
// don't work
DefaultDeserializationContext cctx = ((DefaultDeserializationContext) OBJECT_MAPPER.getDeserializationContext()).createInstance(OBJECT_MAPPER.getDeserializationConfig(), tokens, OBJECT_MAPPER.getInjectableValues());
JacksonLiteralMap jacksonLiteralMap = deserializer.deserialize(tokens, cctx);
return jacksonLiteralMap.getLiteralMap();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.geotoolkit.ogc.xml.v100.LiteralType in project flytekit-java by flyteorg.
the class SdkLaunchPlan method verifyMatchedInput.
private void verifyMatchedInput(Map<String, LiteralType> newInputTypes, String inputType) {
for (Map.Entry<String, LiteralType> lpInputType : newInputTypes.entrySet()) {
String inputName = lpInputType.getKey();
LiteralType lpType = lpInputType.getValue();
LiteralType wfType = workflowInputTypeMap().get(inputName);
if (wfType == null) {
String message = String.format("unexpected %s input %s", inputType, inputName);
throw new IllegalArgumentException(message);
}
if (!lpType.equals(wfType)) {
String message = String.format("invalid %s input wrong type %s, expected %s, got %s instead", inputType, inputName, wfType, lpType);
throw new IllegalArgumentException(message);
}
}
}
use of org.geotoolkit.ogc.xml.v100.LiteralType in project flytekit-java by flyteorg.
the class SdkBindingData method ofStruct.
public static SdkBindingData ofStruct(SdkStruct struct) {
BindingData bindingData = BindingData.ofScalar(Scalar.ofGeneric(struct.struct()));
LiteralType literalType = LiteralType.ofSimpleType(SimpleType.STRUCT);
return create(bindingData, literalType);
}
use of org.geotoolkit.ogc.xml.v100.LiteralType in project geotoolkit by Geomatys.
the class FilterFactoryImpl method equal.
@Override
public BinaryComparisonOperator<Object> equal(final Expression<Object, ?> expr1, final Expression<Object, ?> expr2) {
LiteralType lit = null;
PropertyNameType propName = null;
if (expr1 instanceof PropertyNameType) {
propName = (PropertyNameType) expr1;
} else if (expr2 instanceof PropertyNameType) {
propName = (PropertyNameType) expr2;
}
if (expr1 instanceof LiteralType) {
lit = (LiteralType) expr1;
} else if (expr2 instanceof LiteralType) {
lit = (LiteralType) expr2;
}
return new PropertyIsEqualToType(lit, propName, null);
}
use of org.geotoolkit.ogc.xml.v100.LiteralType in project geotoolkit by Geomatys.
the class FilterFactoryImpl method less.
@Override
public BinaryComparisonOperator<Object> less(final Expression<Object, ?> expr1, final Expression<Object, ?> expr2, final boolean matchCase, final MatchAction action) {
LiteralType lit = null;
PropertyNameType propName = null;
if (expr1 instanceof PropertyNameType) {
propName = (PropertyNameType) expr1;
} else if (expr2 instanceof PropertyNameType) {
propName = (PropertyNameType) expr2;
}
if (expr1 instanceof LiteralType) {
lit = (LiteralType) expr1;
} else if (expr2 instanceof LiteralType) {
lit = (LiteralType) expr2;
}
return new PropertyIsLessThanType(lit, propName, matchCase);
}
Aggregations