use of org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP 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");
}
use of org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP 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);
}
use of org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP in project unipop by unipop-graph.
the class JdbcPredicatesTranslator method handleConnectiveP.
private Condition handleConnectiveP(String key, ConnectiveP predicate) {
List<P> predicates = predicate.getPredicates();
List<Condition> queries = predicates.stream().map(p -> {
if (p instanceof ConnectiveP)
return handleConnectiveP(key, (ConnectiveP) p);
Object pValue = p.getValue();
BiPredicate pBiPredicate = p.getBiPredicate();
return predicateToQuery(key, pValue, pBiPredicate);
}).collect(Collectors.toList());
Condition condition = queries.get(0);
if (predicate instanceof AndP) {
for (int i = 1; i < queries.size(); i++) {
condition = condition.and(queries.get(i));
}
} else if (predicate instanceof OrP) {
for (int i = 1; i < queries.size(); i++) {
condition = condition.or(queries.get(i));
}
} else
throw new IllegalArgumentException("Connective predicate not supported by unipop");
return condition;
}
use of org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP in project unipop by unipop-graph.
the class DateFieldPropertySchema method toPredicate.
@Override
public PredicatesHolder toPredicate(HasContainer has) {
if (has.getPredicate() instanceof ConnectiveP) {
List<P> predicates = ((ConnectiveP) has.getPredicate()).getPredicates();
predicates.forEach(p -> {
Object dateValue = p.getValue();
Date parsedDate = fromDisplay(dateValue.toString());
String formattedDate = toSource(parsedDate);
p.setValue(formattedDate);
});
return PredicatesHolderFactory.predicate(new HasContainer(this.field, has.getPredicate()));
}
Object dateValue = has.getValue();
Date parsedDate = fromDisplay(dateValue.toString());
String formattedDate = toSource(parsedDate);
P predicated = has.getPredicate().clone();
predicated.setValue(formattedDate);
return PredicatesHolderFactory.predicate(new HasContainer(this.field, predicated));
}
Aggregations