Java Code Examples for org.apache.tinkerpop.gremlin.structure.Edge#label()
The following examples show how to use
org.apache.tinkerpop.gremlin.structure.Edge#label() .
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: MainGraphConnectorHelper.java From egeria with Apache License 2.0 | 5 votes |
/** * Map a Tinkerpop edge to the Open Lineage format. * * @param originalEdge The edge to be mapped * @return The edge in the Open Lineage format. */ private LineageEdge abstractEdge(Edge originalEdge) { String sourceNodeID = originalEdge.outVertex().property(PROPERTY_KEY_ENTITY_NODE_ID).value().toString(); String destinationNodeId = originalEdge.inVertex().property(PROPERTY_KEY_ENTITY_NODE_ID).value().toString(); LineageEdge lineageEdge = new LineageEdge(originalEdge.label(), sourceNodeID, destinationNodeId); return lineageEdge; }
Example 2
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldDetachPropertyOfEdgeWhenChanged() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v); final String label = e.label(); final Object inId = v.id(); final Object outId = v.id(); e.property("to-change", "no!"); final MutationListener listener = new AbstractMutationListener() { @Override public void edgePropertyChanged(final Edge element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(DetachedEdge.class)); assertEquals(label, element.label()); assertEquals(inId, element.inVertex().id()); assertEquals(outId, element.outVertex().id()); assertEquals("no!", oldValue.value()); assertEquals("to-change", oldValue.key()); assertEquals("yay!", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.E(e).property("to-change","yay!").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.E(e).properties())); assertThat(triggered.get(), is(true)); }
Example 3
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldDetachPropertyOfEdgeWhenNew() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v); final String label = e.label(); final Object inId = v.id(); final Object outId = v.id(); e.property("to-change", "no!"); final MutationListener listener = new AbstractMutationListener() { @Override public void edgePropertyChanged(final Edge element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(DetachedEdge.class)); assertEquals(label, element.label()); assertEquals(inId, element.inVertex().id()); assertEquals(outId, element.outVertex().id()); assertThat(oldValue, instanceOf(KeyedProperty.class)); assertEquals("new", oldValue.key()); assertEquals("yay!", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.E(e).property("new","yay!").iterate(); tryCommit(graph); assertEquals(2, IteratorUtils.count(g.E(e).properties())); assertThat(triggered.get(), is(true)); }
Example 4
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldDetachEdgeWhenRemoved() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v, "dropped", "yay!"); final String label = e.label(); final Object inId = v.id(); final Object outId = v.id(); final MutationListener listener = new AbstractMutationListener() { @Override public void edgeRemoved(final Edge element) { assertThat(element, instanceOf(DetachedEdge.class)); assertEquals(label, element.label()); assertEquals(inId, element.inVertex().id()); assertEquals(outId, element.outVertex().id()); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.E(e).drop().iterate(); tryCommit(graph); assertVertexEdgeCounts(graph, 1, 0); assertThat(triggered.get(), is(true)); }
Example 5
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldReferencePropertyOfEdgeWhenChanged() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v); final String label = e.label(); final Object inId = v.id(); final Object outId = v.id(); e.property("to-change", "no!"); final MutationListener listener = new AbstractMutationListener() { @Override public void edgePropertyChanged(final Edge element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(ReferenceEdge.class)); assertEquals(label, element.label()); assertEquals(inId, element.inVertex().id()); assertEquals(outId, element.outVertex().id()); assertEquals("no!", oldValue.value()); assertEquals("to-change", oldValue.key()); assertEquals("yay!", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.E(e).property("to-change","yay!").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.E(e).properties())); assertThat(triggered.get(), is(true)); }
Example 6
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldReferencePropertyOfEdgeWhenNew() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v); final String label = e.label(); final Object inId = v.id(); final Object outId = v.id(); e.property("to-change", "no!"); final MutationListener listener = new AbstractMutationListener() { @Override public void edgePropertyChanged(final Edge element, final Property oldValue, final Object setValue) { assertThat(element, instanceOf(ReferenceEdge.class)); assertEquals(label, element.label()); assertEquals(inId, element.inVertex().id()); assertEquals(outId, element.outVertex().id()); assertThat(oldValue, instanceOf(KeyedProperty.class)); assertEquals("new", oldValue.key()); assertEquals("yay!", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.E(e).property("new","yay!").iterate(); tryCommit(graph); assertEquals(2, IteratorUtils.count(g.E(e).properties())); assertThat(triggered.get(), is(true)); }
Example 7
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldReferenceEdgeWhenRemoved() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v, "dropped", "yay!"); final String label = e.label(); final Object inId = v.id(); final Object outId = v.id(); final MutationListener listener = new AbstractMutationListener() { @Override public void edgeRemoved(final Edge element) { assertThat(element, instanceOf(ReferenceEdge.class)); assertEquals(label, element.label()); assertEquals(inId, element.inVertex().id()); assertEquals(outId, element.outVertex().id()); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.E(e).drop().iterate(); tryCommit(graph); assertVertexEdgeCounts(graph, 1, 0); assertThat(triggered.get(), is(true)); }
Example 8
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldUseActualPropertyOfEdgeWhenChanged() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v); final String label = e.label(); final Object inId = v.id(); final Object outId = v.id(); e.property("to-change", "no!"); final MutationListener listener = new AbstractMutationListener() { @Override public void edgePropertyChanged(final Edge element, final Property oldValue, final Object setValue) { assertEquals(e, element); assertEquals(label, element.label()); assertEquals(inId, element.inVertex().id()); assertEquals(outId, element.outVertex().id()); assertEquals("no!", oldValue.value()); assertEquals("to-change", oldValue.key()); assertEquals("yay!", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.E(e).property("to-change","yay!").iterate(); tryCommit(graph); assertEquals(1, IteratorUtils.count(g.E(e).properties())); assertThat(triggered.get(), is(true)); }
Example 9
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldUseActualPropertyOfEdgeWhenNew() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v); final String label = e.label(); final Object inId = v.id(); final Object outId = v.id(); e.property("to-change", "no!"); final MutationListener listener = new AbstractMutationListener() { @Override public void edgePropertyChanged(final Edge element, final Property oldValue, final Object setValue) { assertEquals(e, element); assertEquals(label, element.label()); assertEquals(inId, element.inVertex().id()); assertEquals(outId, element.outVertex().id()); assertThat(oldValue, instanceOf(KeyedProperty.class)); assertEquals("new", oldValue.key()); assertEquals("yay!", setValue); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.E(e).property("new","yay!").iterate(); tryCommit(graph); assertEquals(2, IteratorUtils.count(g.E(e).properties())); assertThat(triggered.get(), is(true)); }
Example 10
Source File: EventStrategyProcessTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE) public void shouldUseActualEdgeWhenRemoved() { final AtomicBoolean triggered = new AtomicBoolean(false); final Vertex v = graph.addVertex(); final Edge e = v.addEdge("self", v, "dropped", "yay!"); final String label = e.label(); final Object inId = v.id(); final Object outId = v.id(); final MutationListener listener = new AbstractMutationListener() { @Override public void edgeRemoved(final Edge element) { assertEquals(e, element); assertEquals(label, element.label()); assertEquals(inId, element.inVertex().id()); assertEquals(outId, element.outVertex().id()); triggered.set(true); } }; final EventStrategy.Builder builder = EventStrategy.build().addListener(listener).detach(EventStrategy.Detachment.REFERENCE); if (graph.features().graph().supportsTransactions()) builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph)); final EventStrategy eventStrategy = builder.create(); final GraphTraversalSource gts = create(eventStrategy); gts.E(e).drop().iterate(); tryCommit(graph); assertVertexEdgeCounts(graph, 1, 0); assertThat(triggered.get(), is(true)); }
Example 11
Source File: EdgeSerializer.java From tinkergraph-gremlin with Apache License 2.0 | 4 votes |
@Override protected String getLabel(Edge edge) { return edge.label(); }
Example 12
Source File: StringFactory.java From tinkerpop with Apache License 2.0 | 4 votes |
/** * Construct the representation for a {@link Edge}. */ public static String edgeString(final Edge edge) { return E + L_BRACKET + edge.id() + R_BRACKET + L_BRACKET + edge.outVertex().id() + DASH + edge.label() + ARROW + edge.inVertex().id() + R_BRACKET; }
Example 13
Source File: Link.java From timbuctoo with GNU General Public License v3.0 | 4 votes |
public Link(Edge edge, int source, int target) { this.source = source; this.target = target; this.type = edge.label(); }