Search in sources :

Example 1 with ExistsP

use of org.unipop.process.predicate.ExistsP in project unipop by unipop-graph.

the class FilterHelper method createFilter.

public static QueryBuilder createFilter(HasContainer container) {
    String key = container.getKey();
    P predicate = container.getPredicate();
    Object value = predicate.getValue();
    BiPredicate<?, ?> biPredicate = predicate.getBiPredicate();
    if (key.equals("_id"))
        return getIdsFilter(value);
    else if (key.equals("_type"))
        return getTypeFilter(container);
    else if (predicate instanceof ConnectiveP) {
        return handleConnectiveP(key, (ConnectiveP) predicate);
    } else if (biPredicate != null) {
        return predicateToQuery(key, value, biPredicate);
    } else if (predicate instanceof ExistsP)
        return QueryBuilders.existsQuery(key);
    else
        throw new IllegalArgumentException("HasContainer not supported by unipop");
}
Also used : AndP(org.apache.tinkerpop.gremlin.process.traversal.util.AndP) ExistsP(org.unipop.process.predicate.ExistsP) OrP(org.apache.tinkerpop.gremlin.process.traversal.util.OrP) ConnectiveP(org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP) P(org.apache.tinkerpop.gremlin.process.traversal.P) ExistsP(org.unipop.process.predicate.ExistsP) ConnectiveP(org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP)

Example 2 with ExistsP

use of org.unipop.process.predicate.ExistsP in project unipop by unipop-graph.

the class JdbcPredicatesTranslator method extractCondition.

private Condition extractCondition(HasContainer hasContainer) {
    String key = hasContainer.getKey();
    P predicate = hasContainer.getPredicate();
    Object value = predicate.getValue();
    BiPredicate<?, ?> biPredicate = predicate.getBiPredicate();
    Field<Object> field = field(key);
    if (predicate instanceof ConnectiveP) {
        return handleConnectiveP(key, (ConnectiveP) predicate);
    } else if (predicate instanceof ExistsP) {
        return field.isNotNull();
    } else
        return predicateToQuery(key, value, biPredicate);
}
Also used : AndP(org.apache.tinkerpop.gremlin.process.traversal.util.AndP) ExistsP(org.unipop.process.predicate.ExistsP) OrP(org.apache.tinkerpop.gremlin.process.traversal.util.OrP) ConnectiveP(org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP) P(org.apache.tinkerpop.gremlin.process.traversal.P) ExistsP(org.unipop.process.predicate.ExistsP) ConnectiveP(org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP)

Aggregations

P (org.apache.tinkerpop.gremlin.process.traversal.P)2 AndP (org.apache.tinkerpop.gremlin.process.traversal.util.AndP)2 ConnectiveP (org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP)2 OrP (org.apache.tinkerpop.gremlin.process.traversal.util.OrP)2 ExistsP (org.unipop.process.predicate.ExistsP)2