Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.Step#removeLabel()

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.Step#removeLabel() . 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: WhereTraversalBuilder.java    From sparql-gremlin with Apache License 2.0 5 votes vote down vote up
public static GraphTraversal<?, ?> transform(final E_Exists expression) {
    final OpBGP opBGP = (OpBGP) expression.getGraphPattern();
    final List<Triple> triples = opBGP.getPattern().getList();
    if (triples.size() != 1) throw new IllegalStateException("Unhandled EXISTS pattern");
    final GraphTraversal<?, ?> traversal = TraversalBuilder.transform(triples.get(0));
    final Step endStep = traversal.asAdmin().getEndStep();
    final String label = (String) endStep.getLabels().iterator().next();
    endStep.removeLabel(label);
    return traversal;
}
 
Example 2
Source File: WhereTraversalBuilder.java    From sparql-gremlin with Apache License 2.0 5 votes vote down vote up
public static GraphTraversal<?, ?> transform(final E_NotExists expression) {
    final OpBGP opBGP = (OpBGP) expression.getGraphPattern();
    final List<Triple> triples = opBGP.getPattern().getList();
    if (triples.size() != 1) throw new IllegalStateException("Unhandled NOT EXISTS pattern");
    final GraphTraversal<?, ?> traversal = TraversalBuilder.transform(triples.get(0));
    final Step endStep = traversal.asAdmin().getEndStep();
    final String label = (String) endStep.getLabels().iterator().next();
    endStep.removeLabel(label);
    return __.not(traversal);
}
 
Example 3
Source File: TraversalHelper.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public static void copyLabels(final Step<?, ?> fromStep, final Step<?, ?> toStep, final boolean moveLabels) {
    if (!fromStep.getLabels().isEmpty()) {
        for (final String label : moveLabels ? new LinkedHashSet<>(fromStep.getLabels()) : fromStep.getLabels()) {
            toStep.addLabel(label);
            if (moveLabels)
                fromStep.removeLabel(label);
        }
    }
}
 
Example 4
Source File: StandardVerificationStrategy.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (!traversal.getStrategies().getStrategy(ComputerFinalizationStrategy.class).isPresent() &&
            !traversal.getStrategies().getStrategy(ComputerVerificationStrategy.class).isPresent()) {
        if (!TraversalHelper.getStepsOfAssignableClass(VertexComputing.class, traversal).isEmpty())
            throw new VerificationException("VertexComputing steps must be executed with a GraphComputer: " + TraversalHelper.getStepsOfAssignableClass(VertexComputing.class, traversal), traversal);
    }

    for (final Step<?, ?> step : traversal.getSteps()) {
        for (String label : new HashSet<>(step.getLabels())) {
            if (Graph.Hidden.isHidden(label))
                step.removeLabel(label);
        }
        if (step instanceof ReducingBarrierStep && step.getTraversal().getParent() instanceof RepeatStep && step.getTraversal().getParent().getGlobalChildren().get(0).getSteps().contains(step))
            throw new VerificationException("The parent of a reducing barrier can not be repeat()-step: " + step, traversal);
    }

    // The ProfileSideEffectStep must be one of the following
    // (1) the last step
    // (2) 2nd last step when accompanied by the cap step or none step (i.e. iterate() to nothing)
    // (3) 3rd to last when the traversal ends with a RequirementsStep.
    final Step<?, ?> endStep = traversal.asAdmin().getEndStep();
    if (TraversalHelper.hasStepOfClass(ProfileSideEffectStep.class, traversal) &&
            !(endStep instanceof ProfileSideEffectStep ||
                    (endStep instanceof SideEffectCapStep && endStep.getPreviousStep() instanceof ProfileSideEffectStep) ||
                    (endStep instanceof NoneStep && endStep.getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep) ||
                    (endStep instanceof RequirementsStep && endStep.getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep) ||
                    (endStep instanceof RequirementsStep && endStep.getPreviousStep() instanceof NoneStep && endStep.getPreviousStep().getPreviousStep() instanceof SideEffectCapStep && endStep.getPreviousStep().getPreviousStep().getPreviousStep() instanceof ProfileSideEffectStep))) {
        throw new VerificationException("When specified, the profile()-Step must be the last step or followed only by the cap()-step.", traversal);
    }

    if (TraversalHelper.getStepsOfClass(ProfileSideEffectStep.class, traversal).size() > 1) {
        throw new VerificationException("The profile()-Step cannot be specified multiple times.", traversal);
    }
}
 
Example 5
Source File: WhereTraversalBuilder.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private static GraphTraversal<?, ?> transform(final E_Exists expression) {
    final OpBGP opBGP = (OpBGP) expression.getGraphPattern();
    final List<Triple> triples = opBGP.getPattern().getList();
    if (triples.size() != 1) throw new IllegalStateException("Unhandled EXISTS pattern");
    final GraphTraversal<?, ?> traversal = TraversalBuilder.transform(triples.get(0));
    final Step endStep = traversal.asAdmin().getEndStep();
    final String label = (String) endStep.getLabels().iterator().next();
    endStep.removeLabel(label);
    return traversal;
}
 
Example 6
Source File: WhereTraversalBuilder.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private static GraphTraversal<?, ?> transform(final E_NotExists expression) {
    final OpBGP opBGP = (OpBGP) expression.getGraphPattern();
    final List<Triple> triples = opBGP.getPattern().getList();
    if (triples.size() != 1) throw new IllegalStateException("Unhandled NOT EXISTS pattern");
    final GraphTraversal<?, ?> traversal = TraversalBuilder.transform(triples.get(0));
    final Step endStep = traversal.asAdmin().getEndStep();
    final String label = (String) endStep.getLabels().iterator().next();
    endStep.removeLabel(label);
    return __.not(traversal);
}