Search in sources :

Example 6 with MutationListener

use of org.apache.tinkerpop.gremlin.process.traversal.step.util.event.MutationListener in project sqlg by pietermartin.

the class TestDropStepTruncate method before.

@Before
public void before() throws Exception {
    super.before();
    configuration.setProperty("implement.foreign.keys", this.fkOn);
    this.removedVertices.clear();
    if (this.mutatingCallback) {
        final MutationListener listener = new AbstractMutationListener() {

            @Override
            public void vertexRemoved(final Vertex vertex) {
                removedVertices.add(vertex);
            }

            @Override
            public void edgeRemoved(final Edge edge) {
                removedEdges.add(edge);
            }
        };
        final EventStrategy.Builder builder = EventStrategy.build().addListener(listener);
        eventStrategy = builder.create();
        this.dropTraversal = this.sqlgGraph.traversal();
        if (this.mutatingCallback) {
            this.dropTraversal = this.dropTraversal.withStrategies(this.eventStrategy);
        }
    } else {
        this.dropTraversal = this.sqlgGraph.traversal();
    }
}
Also used : MutationListener(org.apache.tinkerpop.gremlin.process.traversal.step.util.event.MutationListener) EventStrategy(org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy) Before(org.junit.Before)

Aggregations

MutationListener (org.apache.tinkerpop.gremlin.process.traversal.step.util.event.MutationListener)6 EventStrategy (org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Before (org.junit.Before)3 Test (org.junit.Test)3 BaseTest (org.umlg.sqlg.test.BaseTest)3 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)2 ReferenceVertex (org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex)2 AbstractGremlinTest (org.apache.tinkerpop.gremlin.AbstractGremlinTest)1