private void setPredicateValues(final P<Object> predicate, final Traverser.Admin<S> traverser, final Iterator<String> selectKeysIterator) { if (predicate instanceof ConnectiveP) ((ConnectiveP<Object>) predicate).getPredicates().forEach(p -> this.setPredicateValues(p, traverser, selectKeysIterator)); else predicate.setValue(TraversalUtil.applyNullable((S) this.getScopeValue(Pop.last, selectKeysIterator.next(), traverser), this.traversalRing.next())); }
private static void convPredicateValue(HugeGraph graph, HasContainer has) { // No need to convert if key is sysprop if (isSysProp(has.getKey())) { return; } PropertyKey pkey = graph.propertyKey(has.getKey()); List<P<Object>> leafPredicates = new ArrayList<>(); collectPredicates(leafPredicates, ImmutableList.of(has.getPredicate())); for (P<Object> predicate : leafPredicates) { Object value = validPredicateValue(predicate.getValue(), pkey); predicate.setValue(value); } }
public HasContainer(final String key, final P<?> predicate) { this.key = key; this.predicate = predicate; if (!this.key.equals(T.id.getAccessor())) testingIdString = false; else { // the values should be homogenous if a collection is submitted final Object predicateValue = this.predicate.getValue(); // enforce a homogenous collection of values when testing ids enforceHomogenousCollectionIfPresent(predicateValue); // grab an instance of a value which is either the first item in a homogeneous collection or the value itself final Object valueInstance = this.predicate.getValue() instanceof Collection ? ((Collection) this.predicate.getValue()).isEmpty() ? new Object() : ((Collection) this.predicate.getValue()).toArray()[0] : this.predicate.getValue(); // if the key being evaluated is id then the has() test can evaluate as a toString() representation of the // identifier. this could be done in the test() method but it seems cheaper to do the conversion once in // the constructor. the original value in P is maintained separately this.testingIdString = this.key.equals(T.id.getAccessor()) && valueInstance instanceof String; if (this.testingIdString) this.predicate.setValue(this.predicate.getValue() instanceof Collection ? IteratorUtils.set(IteratorUtils.map(((Collection<Object>) this.predicate.getValue()).iterator(), Object::toString)) : this.predicate.getValue().toString()); } }
private void setPredicateValues(final P<Object> predicate, final Traverser.Admin<S> traverser, final Iterator<String> selectKeysIterator) { if (predicate instanceof ConnectiveP) ((ConnectiveP<Object>) predicate).getPredicates().forEach(p -> this.setPredicateValues(p, traverser, selectKeysIterator)); else predicate.setValue(TraversalUtil.applyNullable((S) this.getScopeValue(Pop.last, selectKeysIterator.next(), traverser), this.traversalRing.next())); }
private static void convPredicateValue(HugeGraph graph, HasContainer has) { // No need to convert if key is sysprop if (isSysProp(has.getKey())) { return; } PropertyKey pkey = graph.propertyKey(has.getKey()); List<P<Object>> leafPredicates = new ArrayList<>(); collectPredicates(leafPredicates, ImmutableList.of(has.getPredicate())); for (P<Object> predicate : leafPredicates) { Object value = validPredicateValue(predicate.getValue(), pkey); predicate.setValue(value); } }
public HasContainer(final String key, final P<?> predicate) { this.key = key; this.predicate = predicate; if (!this.key.equals(T.id.getAccessor())) testingIdString = false; else { // the values should be homogenous if a collection is submitted final Object predicateValue = this.predicate.getValue(); // enforce a homogenous collection of values when testing ids enforceHomogenousCollectionIfPresent(predicateValue); // grab an instance of a value which is either the first item in a homogeneous collection or the value itself final Object valueInstance = this.predicate.getValue() instanceof Collection ? ((Collection) this.predicate.getValue()).isEmpty() ? new Object() : ((Collection) this.predicate.getValue()).toArray()[0] : this.predicate.getValue(); // if the key being evaluated is id then the has() test can evaluate as a toString() representation of the // identifier. this could be done in the test() method but it seems cheaper to do the conversion once in // the constructor. the original value in P is maintained separately this.testingIdString = this.key.equals(T.id.getAccessor()) && valueInstance instanceof String; if (this.testingIdString) this.predicate.setValue(this.predicate.getValue() instanceof Collection ? IteratorUtils.set(IteratorUtils.map(((Collection<Object>) this.predicate.getValue()).iterator(), Object::toString)) : this.predicate.getValue().toString()); } }
@Override public PredicatesHolder toPredicate(HasContainer has) { P predicate; if (has != null && !test(has.getPredicate())) { return PredicatesHolderFactory.abort(); } else if (has != null) { predicate = has.getPredicate().clone(); if (reverseAlias != null) { Object predicateValue = predicate.getValue(); if (reverseAlias.containsKey(predicateValue.toString())){ predicate.setValue(reverseAlias.get(predicateValue.toString())); } } } else if (include != null) { predicate = P.within(include); } else if (exclude != null) { predicate = P.without(exclude); } else return PredicatesHolderFactory.empty(); P translatedPredicate = type.translate(predicate); HasContainer hasContainer = new HasContainer(this.field, translatedPredicate); return PredicatesHolderFactory.predicate(hasContainer); }
@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)); }
return true; ((P<Collection<Object>>) (hasContainer.getPredicate())).setValue(ok);
return true; ((P<Collection<Object>>) (hasContainer.getPredicate())).setValue(ok);