Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal#union()

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal#union() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiscoverHibernateConfigurationRuleProvider.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public ConditionBuilder when()
{
    QueryGremlinCriterion doctypeSearchCriterion = new QueryGremlinCriterion()
    {
        @Override
        public void query(GraphRewrite event, GraphTraversal<?, Vertex> pipeline)
        {
            pipeline.has(DoctypeMetaModel.PROPERTY_PUBLIC_ID, Text.textRegex(REGEX_HIBERNATE));

            Traversal<?, ?> systemIDQuery = event.getGraphContext().getQuery(DoctypeMetaModel.class)
                        .getRawTraversal()
                        .has(DoctypeMetaModel.PROPERTY_SYSTEM_ID, Text.textRegex(REGEX_HIBERNATE));
            GraphTraversal<Vertex, Vertex> systemIdPipeline = new GraphTraversalSource(event.getGraphContext().getGraph()).V(systemIDQuery.toList());

            pipeline.union(systemIdPipeline);

            pipeline.dedup();
        }
    };

    return Query.fromType(DoctypeMetaModel.class).piped(doctypeSearchCriterion);
}
 
Example 2
Source File: DiscoverHibernateMappingRuleProvider.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public ConditionBuilder when()
{

    QueryGremlinCriterion doctypeSearchCriterion = new QueryGremlinCriterion()
    {
        @Override
        public void query(GraphRewrite event, GraphTraversal<?, Vertex> pipeline)
        {
            pipeline.has(DoctypeMetaModel.PROPERTY_PUBLIC_ID, Text.textRegex(REGEX_HIBERNATE));

            Traversal<?, ?> systemIDQuery = event.getGraphContext().getQuery(DoctypeMetaModel.class)
                        .getRawTraversal().has(DoctypeMetaModel.PROPERTY_SYSTEM_ID, Text.textRegex(REGEX_HIBERNATE));
            GraphTraversal<Vertex, Vertex> systemIdPipeline = new GraphTraversalSource(event.getGraphContext().getGraph()).V(systemIDQuery.toList());

            pipeline.union(systemIdPipeline);

            pipeline.dedup();
        }
    };

    return Query.fromType(DoctypeMetaModel.class).piped(doctypeSearchCriterion);
}
 
Example 3
Source File: TraceTraversalSourceDsl.java    From jaeger-analytics-java with Apache License 2.0 5 votes vote down vote up
public GraphTraversal<Vertex, Vertex> hasAnyTag(String... keys) {
  GraphTraversal traversal = this.clone().V();
  List<GraphTraversal> traversals = new ArrayList<>(keys.length);
  for (String key: keys) {
    traversals.add(this.clone().V().has(key));
  }
  return traversal.union(traversals.toArray(new GraphTraversal[0]));
}
 
Example 4
Source File: Fragments.java    From grakn with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * A type-safe way to do `a.union(b, c)`, as `Fragments.union(a, ImmutableSet.of(b, c))`.
 * This avoids issues with unchecked varargs.
 */
static <S, E1, E2> GraphTraversal<S, E2> union(
        GraphTraversal<S, ? extends E1> start, Iterable<GraphTraversal<? super E1, ? extends E2>> traversals) {
    // This is safe, because we know all the arguments are of the right type
    //noinspection unchecked
    GraphTraversal<E1, E2>[] array = (GraphTraversal<E1, E2>[]) Iterables.toArray(traversals, GraphTraversal.class);

    return start.union(array);
}
 
Example 5
Source File: ValueOperation.java    From grakn with GNU Affero General Public License v3.0 5 votes vote down vote up
public <S, E> GraphTraversal<S, E> apply(GraphTraversal<S, E> traversal) {
    List<GraphTraversal<?, E>> valueTraversals = new ArrayList<>();
    AttributeType.ValueType<?> valueType = AttributeType.ValueType.of(value().getClass());
    for (AttributeType.ValueType<?> comparableValueType : valueType.comparableValueTypes()) {
        Schema.VertexProperty property = Schema.VertexProperty.ofValueType(comparableValueType);
        valueTraversals.add(__.has(property.name(), predicate()));
    }

    GraphTraversal<?, E>[] array = (GraphTraversal<?, E>[]) Iterables.toArray(valueTraversals, GraphTraversal.class);

    return traversal.union(array);
}