@Override public void deleteVertex(Vertex vertex, Authorizations authorizations) { if (!((InMemoryVertex) vertex).canRead(authorizations)) { return; } List<Edge> edgesToDelete = IterableUtils.toList(vertex.getEdges(Direction.BOTH, authorizations)); for (Edge edgeToDelete : edgesToDelete) { deleteEdge(edgeToDelete, authorizations); } deleteAllExtendedDataForElement(vertex, authorizations); this.vertices.remove(vertex.getId()); getSearchIndex().deleteElement(this, vertex, authorizations); if (hasEventListeners()) { fireGraphEvent(new DeleteVertexEvent(this, vertex)); } }
@Override public void deleteVertex(Vertex vertex, Authorizations authorizations) { checkNotNull(vertex, "vertex cannot be null"); Span trace = Trace.start("deleteVertex"); trace.data("vertexId", vertex.getId()); try { getSearchIndex().deleteElement(this, vertex, authorizations); // Delete all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, authorizations)) { deleteEdge(edge, authorizations); } deleteAllExtendedDataForElement(vertex, authorizations); addMutations(VertexiumObjectType.VERTEX, getDeleteRowMutation(vertex.getId())); if (hasEventListeners()) { queueEvent(new DeleteVertexEvent(this, vertex)); } } finally { trace.stop(); } }
@Override public void deleteVertex(Vertex vertex, Authorizations authorizations) { checkNotNull(vertex, "vertex cannot be null"); Span trace = Trace.start("deleteVertex"); trace.data("vertexId", vertex.getId()); try { getSearchIndex().deleteElement(this, vertex, authorizations); // Delete all edges that this vertex participates. for (Edge edge : vertex.getEdges(Direction.BOTH, authorizations)) { deleteEdge(edge, authorizations); } deleteAllExtendedDataForElement(vertex, authorizations); addMutations(VertexiumObjectType.VERTEX, getDeleteRowMutation(vertex.getId())); if (hasEventListeners()) { queueEvent(new DeleteVertexEvent(this, vertex)); } } finally { trace.stop(); } }
@Test public void testDeleteVertexWithProperties() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Property prop1 = v1.getProperty("prop1"); Assert.assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A))); graph.deleteVertex("v1", AUTHORIZATIONS_A); graph.flush(); Assert.assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A_AND_B))); assertEvents( new AddVertexEvent(graph, v1), new AddPropertyEvent(graph, v1, prop1), new DeleteVertexEvent(graph, v1) ); }
@Override public int hashCode() { return getVertex().hashCode(); }
@Test public void testDeleteVertexWithProperties() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Property prop1 = v1.getProperty("prop1"); Assert.assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A))); graph.deleteVertex("v1", AUTHORIZATIONS_A); graph.flush(); Assert.assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A_AND_B))); assertEvents( new AddVertexEvent(graph, v1), new AddPropertyEvent(graph, v1, prop1), new DeleteVertexEvent(graph, v1) ); }
@Override public int hashCode() { return getVertex().hashCode(); }