@Override public Edge addEdge(Vertex outVertex, Vertex inVertex, String label, Visibility visibility, Authorizations authorizations) { return prepareEdge(outVertex, inVertex, label, visibility).save(authorizations); }
Vertex v3 = graph.addVertex("v3", VISIBILITY_A, AUTHORIZATIONS_A); graph.prepareEdge("e1", v1, v2, "", VISIBILITY_A) .setProperty("prop1", "e1", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e1a", v1, v2, "", VISIBILITY_A) .setProperty("prop1", "e1a", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e2", v1, v3, "", VISIBILITY_A) .setProperty("prop1", "e2", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e3", v2, v3, "", VISIBILITY_A) .setProperty("prop1", "e3", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B);
.addPropertyValue("propid1a", "prop1", "value1a", VISIBILITY_A) .addPropertyValue("propid1b", "prop1", "value1b", VISIBILITY_A) .addPropertyValue("propid2a", "prop2", "value2a", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); graph.prepareEdge("e1", v1, v2, "edge1", VISIBILITY_A) .addPropertyValue("key1", "prop1", "value1", VISIBILITY_A) .save(AUTHORIZATIONS_A); graph.flush();
Vertex v3 = graph.addVertex("v3", VISIBILITY_A, AUTHORIZATIONS_A); graph.prepareEdge("e1", v1, v2, "", VISIBILITY_A) .setProperty("prop1", "e1", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e1a", v1, v2, "", VISIBILITY_A) .setProperty("prop1", "e1a", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e2", v1, v3, "", VISIBILITY_A) .setProperty("prop1", "e2", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e3", v2, v3, "", VISIBILITY_A) .setProperty("prop1", "e3", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B);
Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); graph.prepareEdge("e1", v1, v2, "edge1", VISIBILITY_A) .addPropertyValue("key1", "prop1", "value1", VISIBILITY_A) .save(AUTHORIZATIONS_A); graph.flush();
@Override public Edge addEdge(String edgeId, Vertex outVertex, Vertex inVertex, String label, Visibility visibility, Authorizations authorizations) { return prepareEdge(edgeId, outVertex, inVertex, label, visibility).save(authorizations); }
@Test public void testDisableEdgeIndexing() throws NoSuchFieldException, IllegalAccessException { if (!disableEdgeIndexing(graph)) { LOGGER.info("skipping " + SearchIndex.class.getSimpleName() + " doesn't support disabling index"); return; } Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.prepareVertex("v2", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e1", v1, v2, "edge", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Iterable<Edge> edges = graph.query(AUTHORIZATIONS_A) .has("prop1", "value1") .edges(); assertEquals(0, count(edges)); }
@Override public Edge addEdge(Vertex outVertex, Vertex inVertex, String label, Visibility visibility, Authorizations authorizations) { return prepareEdge(outVertex, inVertex, label, visibility).save(authorizations); }
@Test public void testDisableEdgeIndexing() throws NoSuchFieldException, IllegalAccessException { if (!disableEdgeIndexing(graph)) { LOGGER.info("skipping " + SearchIndex.class.getSimpleName() + " doesn't support disabling index"); return; } Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.prepareVertex("v2", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e1", v1, v2, "edge", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Iterable<Edge> edges = graph.query(AUTHORIZATIONS_A) .has("prop1", "value1") .edges(); assertEquals(0, count(edges)); }
@Override public Edge addEdge(String edgeId, Vertex outVertex, Vertex inVertex, String label, Visibility visibility, Authorizations authorizations) { return prepareEdge(edgeId, outVertex, inVertex, label, visibility).save(authorizations); }
@Test public void testGraphQueryEdgeHasWithSecurity() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.prepareVertex("v2", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); Vertex v3 = graph.prepareVertex("v3", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e1", v1, v2, "edge", VISIBILITY_A) .setProperty("age", 25, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e2", v1, v3, "edge", VISIBILITY_A) .setProperty("age", 25, VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); Iterable<Edge> edges = graph.query(AUTHORIZATIONS_A) .has("age", Compare.EQUAL, 25) .edges(); assertEquals(1, count(edges)); }
public Edge addEdge(String edgeId, Vertex outVertex, Vertex inVertex, String label, Visibility visibility, Authorizations authorizations) { return prepareEdge(edgeId, outVertex, inVertex, label, visibility).save(authorizations); }
@Test public void testGraphQueryEdgeHasWithSecurity() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.prepareVertex("v2", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); Vertex v3 = graph.prepareVertex("v3", VISIBILITY_A).save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e1", v1, v2, "edge", VISIBILITY_A) .setProperty("age", 25, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e2", v1, v3, "edge", VISIBILITY_A) .setProperty("age", 25, VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); Iterable<Edge> edges = graph.query(AUTHORIZATIONS_A) .has("age", Compare.EQUAL, 25) .edges(); assertEquals(1, count(edges)); }
private Edge restoreEdge(Graph graph, JSONObject json, Authorizations authorizations) { Visibility visibility = jsonToVisibility(json); String edgeId = json.getString("id"); String outVertexId = json.getString("outVertexId"); String inVertexId = json.getString("inVertexId"); String label = json.getString("label"); Vertex outVertex = graph.getVertex(outVertexId, authorizations); Vertex inVertex = graph.getVertex(inVertexId, authorizations); EdgeBuilder e = graph.prepareEdge(edgeId, outVertex, inVertex, label, visibility); jsonToProperties(json, e); return e.save(authorizations); }
@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")) ); }
.save(AUTHORIZATIONS_A_AND_B);
@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")) ); }
.save(AUTHORIZATIONS_A_AND_B);
@Test public void testAddEdgeWithoutIndexing() { if (isDefaultSearchIndex()) { return; } Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); graph.prepareEdge("e1", v1, v2, "label1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_A) .setIndexHint(IndexHint.DO_NOT_INDEX) .save(AUTHORIZATIONS_A); graph.flush(); Iterable<Edge> edges = graph.query(AUTHORIZATIONS_A_AND_B) .has("prop1", "value1") .edges(); assertEdgeIds(edges, new String[]{}); }
@Test public void testAddEdgeWithoutIndexing() { if (isDefaultSearchIndex()) { return; } Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A); graph.prepareEdge("e1", v1, v2, "label1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_A) .setIndexHint(IndexHint.DO_NOT_INDEX) .save(AUTHORIZATIONS_A); graph.flush(); Iterable<Edge> edges = graph.query(AUTHORIZATIONS_A_AND_B) .has("prop1", "value1") .edges(); assertEdgeIds(edges, new String[]{}); }