use of ai.grakn.concept.AttributeType.DataType in project grakn by graknlabs.
the class ComparatorPredicate method applyPredicate.
@Override
public final <S, E> GraphTraversal<S, E> applyPredicate(GraphTraversal<S, E> traversal) {
var.ifPresent(theVar -> {
// Compare to another variable
String thisVar = UUID.randomUUID().toString();
Var otherVar = theVar.var();
String otherValue = UUID.randomUUID().toString();
Traversal[] traversals = Stream.of(VALUE_PROPERTIES).map(prop -> __.values(prop).as(otherValue).select(thisVar).values(prop).where(gremlinPredicate(otherValue))).toArray(Traversal[]::new);
traversal.as(thisVar).select(otherVar.name()).or(traversals).select(thisVar);
});
persistedValue().ifPresent(theValue -> {
// Compare to a given value
DataType<?> dataType = DataType.SUPPORTED_TYPES.get(value().get().getClass().getTypeName());
Schema.VertexProperty property = dataType.getVertexProperty();
traversal.has(property.name(), gremlinPredicate(theValue));
});
return traversal;
}
Aggregations