@Override public boolean equals(Object obj) { if (!(obj instanceof AddPropertyEvent)) { return false; } AddPropertyEvent other = (AddPropertyEvent) obj; return getElement().equals(other.getElement()) && getProperty().equals(other.getProperty()) && super.equals(obj); } }
fireGraphEvent(new AddPropertyEvent(InMemoryGraph.this, inMemoryElement, property));
@Override public String toString() { return "AddPropertyEvent{element=" + getElement() + ", property=" + property + '}'; }
@Override public int hashCode() { return getProperty().hashCode(); }
new AddPropertyEvent(graph, vertexAdded, vertexAdded.getProperty("prop1")), new AddPropertyEvent(graph, vertexAdded, vertexAdded.getProperty("prop2")) ); graphEvents.clear(); assertEquals("value1Mutation", v.getPropertyValues("prop1Mutation").iterator().next()); assertEvents( new AddPropertyEvent(graph, vertexAdded, vertexAdded.getProperty("prop1Mutation")) );
@Override public String toString() { return "AddPropertyEvent{element=" + getElement() + ", property=" + property + '}'; }
@Override public int hashCode() { return getProperty().hashCode(); }
new AddPropertyEvent(graph, vertexAdded, vertexAdded.getProperty("prop1")), new AddPropertyEvent(graph, vertexAdded, vertexAdded.getProperty("prop2")) ); graphEvents.clear(); assertEquals("value1Mutation", v.getPropertyValues("prop1Mutation").iterator().next()); assertEvents( new AddPropertyEvent(graph, vertexAdded, vertexAdded.getProperty("prop1Mutation")) );
@Override public boolean equals(Object obj) { if (!(obj instanceof AddPropertyEvent)) { return false; } AddPropertyEvent other = (AddPropertyEvent) obj; return getElement().equals(other.getElement()) && getProperty().equals(other.getProperty()) && super.equals(obj); } }
@Test public void testAddEdgeWithProperties() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); Edge addedEdge = graph.prepareEdge("e1", v1, v2, "label1", VISIBILITY_A) .setProperty("propA", "valueA", VISIBILITY_A) .setProperty("propB", "valueB", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); Edge e = graph.getEdge("e1", AUTHORIZATIONS_A); assertEquals(1, count(e.getProperties())); assertEquals("valueA", e.getPropertyValues("propA").iterator().next()); assertEquals(0, count(e.getPropertyValues("propB"))); e = graph.getEdge("e1", AUTHORIZATIONS_A_AND_B); assertEquals(2, count(e.getProperties())); assertEquals("valueA", e.getPropertyValues("propA").iterator().next()); assertEquals("valueB", e.getPropertyValues("propB").iterator().next()); assertEquals("valueA", e.getPropertyValue("propA")); assertEquals("valueB", e.getPropertyValue("propB")); graph.flush(); assertEvents( new AddVertexEvent(graph, v1), new AddVertexEvent(graph, v2), new AddEdgeEvent(graph, addedEdge), new AddPropertyEvent(graph, addedEdge, addedEdge.getProperty("propA")), new AddPropertyEvent(graph, addedEdge, addedEdge.getProperty("propB")) ); }
@Test public void testAddEdgeWithProperties() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); Edge addedEdge = graph.prepareEdge("e1", v1, v2, "label1", VISIBILITY_A) .setProperty("propA", "valueA", VISIBILITY_A) .setProperty("propB", "valueB", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); Edge e = graph.getEdge("e1", AUTHORIZATIONS_A); assertEquals(1, count(e.getProperties())); assertEquals("valueA", e.getPropertyValues("propA").iterator().next()); assertEquals(0, count(e.getPropertyValues("propB"))); e = graph.getEdge("e1", AUTHORIZATIONS_A_AND_B); assertEquals(2, count(e.getProperties())); assertEquals("valueA", e.getPropertyValues("propA").iterator().next()); assertEquals("valueB", e.getPropertyValues("propB").iterator().next()); assertEquals("valueA", e.getPropertyValue("propA")); assertEquals("valueB", e.getPropertyValue("propB")); graph.flush(); assertEvents( new AddVertexEvent(graph, v1), new AddVertexEvent(graph, v2), new AddEdgeEvent(graph, addedEdge), new AddPropertyEvent(graph, addedEdge, addedEdge.getProperty("propA")), new AddPropertyEvent(graph, addedEdge, addedEdge.getProperty("propB")) ); }
@Override public Vertex save(Authorizations authorizations) { AccumuloVertex vertex = new AccumuloVertex( AccumuloGraph.this, getVertexId(), getVisibility(), getProperties(), getPropertyRemoves(), null, authorizations, System.currentTimeMillis() ); elementMutationBuilder.saveVertex(vertex); if (getIndexHint() != IndexHint.DO_NOT_INDEX) { getSearchIndex().addElement(AccumuloGraph.this, vertex, authorizations); } if (hasEventListeners()) { queueEvent(new AddVertexEvent(AccumuloGraph.this, vertex)); for (Property property : getProperties()) { queueEvent(new AddPropertyEvent(AccumuloGraph.this, vertex, property)); } for (PropertyRemoveMutation propertyRemoveMutation : getPropertyRemoves()) { queueEvent(new RemovePropertyEvent(AccumuloGraph.this, vertex, propertyRemoveMutation)); } } return vertex; } };
@Override public Vertex save(Authorizations authorizations) { InMemoryVertex newVertex = new InMemoryVertex(InMemoryGraph.this, getVertexId(), getVisibility(), getProperties(), getPropertyRemoves(), null, authorizations); // to more closely simulate how accumulo works. add a potentially sparse (in case of an update) vertex to the search index. if (getIndexHint() != IndexHint.DO_NOT_INDEX) { getSearchIndex().addElement(InMemoryGraph.this, newVertex, authorizations); } InMemoryVertex existingVertex = (InMemoryVertex) getVertex(getVertexId(), authorizations); InMemoryVertex vertex = InMemoryVertex.updateOrCreate(InMemoryGraph.this, existingVertex, newVertex, authorizations); vertices.put(getVertexId(), vertex); if (hasEventListeners()) { fireGraphEvent(new AddVertexEvent(InMemoryGraph.this, vertex)); for (Property property : getProperties()) { fireGraphEvent(new AddPropertyEvent(InMemoryGraph.this, vertex, property)); } for (PropertyRemoveMutation propertyRemoveMutation : getPropertyRemoves()) { fireGraphEvent(new RemovePropertyEvent(InMemoryGraph.this, vertex, propertyRemoveMutation)); } } return vertex; } };
fireGraphEvent(new AddEdgeEvent(InMemoryGraph.this, edge)); for (Property property : edgeBuilder.getProperties()) { fireGraphEvent(new AddPropertyEvent(InMemoryGraph.this, edge, property));
@Test public void testRemoveVertexWithProperties() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); Property prop1 = v1.getProperty("prop1"); assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A))); graph.removeVertex(v1, AUTHORIZATIONS_A); assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A_AND_B))); graph.flush(); assertEvents( new AddVertexEvent(graph, v1), new AddPropertyEvent(graph, v1, prop1), new RemoveVertexEvent(graph, v1) ); }
@Test public void testRemoveVertexWithProperties() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); Property prop1 = v1.getProperty("prop1"); assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A))); graph.removeVertex(v1, AUTHORIZATIONS_A); assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A_AND_B))); graph.flush(); assertEvents( new AddVertexEvent(graph, v1), new AddPropertyEvent(graph, v1, prop1), new RemoveVertexEvent(graph, v1) ); }
queueEvent(new AddEdgeEvent(AccumuloGraph.this, edge)); for (Property property : edgeBuilder.getProperties()) { queueEvent(new AddPropertyEvent(AccumuloGraph.this, edge, property));
queueEvent(new AddPropertyEvent(AccumuloGraph.this, element, property));