@Override public Vertex addVertex(String vertexId, Visibility visibility, Authorizations authorizations) { return prepareVertex(vertexId, visibility).save(authorizations); }
@Override public Vertex addVertex(Visibility visibility, Authorizations authorizations) { return prepareVertex(visibility).save(authorizations); }
@Override public Vertex addVertex(Visibility visibility, Authorizations authorizations) { return prepareVertex(visibility).save(authorizations); }
@Override public Vertex addVertex(String vertexId, Visibility visibility, Authorizations authorizations) { return prepareVertex(vertexId, visibility).save(authorizations); }
@Override public Vertex addVertex(String vertexId, Visibility vertexVisibility, Authorizations authorizations) { return prepareVertex(vertexId, vertexVisibility).save(authorizations); }
private Vertex restoreVertex(Graph graph, JSONObject json, Authorizations authorizations) { Visibility visibility = jsonToVisibility(json); String vertexId = json.getString("id"); VertexBuilder v = graph.prepareVertex(vertexId, visibility); jsonToProperties(json, v); return v.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)); }
@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)); }
@Test public void testVertexBoost() throws Exception { if (!isEdgeBoostSupported()) { LOGGER.warn("Boost not supported"); 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); Vertex v3 = graph.prepareVertex("v3", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.addEdge("e1", v3, v2, "link", VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); v1.prepareMutation().save(AUTHORIZATIONS_A_AND_B); v2.prepareMutation().save(AUTHORIZATIONS_A_AND_B); v3.prepareMutation().save(AUTHORIZATIONS_A_AND_B); assertVertexIds(graph.query(AUTHORIZATIONS_A).vertices(), new String[]{"v2", "v3", "v1"}); }
@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)); }
@Test public void testVertexBoost() throws Exception { if (!isEdgeBoostSupported()) { LOGGER.warn("Boost not supported"); 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); Vertex v3 = graph.prepareVertex("v3", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.addEdge("e1", v3, v2, "link", VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); v1.prepareMutation().save(AUTHORIZATIONS_A_AND_B); v2.prepareMutation().save(AUTHORIZATIONS_A_AND_B); v3.prepareMutation().save(AUTHORIZATIONS_A_AND_B); assertVertexIds(graph.query(AUTHORIZATIONS_A).vertices(), new String[]{"v2", "v3", "v1"}); }
@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)); }
graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("age", 25, VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.prepareVertex("v2", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); Vertex v3 = graph.prepareVertex("v3", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.addEdge("v2tov3", v2, v3, "", VISIBILITY_EMPTY, AUTHORIZATIONS_A_AND_B); graph.flush();
@Test public void testChangeVisibilityVertex() { graph.prepareVertex("v1", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A); v1.prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertNull(v1); v1 = graph.getVertex("v1", AUTHORIZATIONS_B); assertNotNull(v1); // change to same visibility v1 = graph.getVertex("v1", AUTHORIZATIONS_B); v1.prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertNull(v1); v1 = graph.getVertex("v1", AUTHORIZATIONS_B); assertNotNull(v1); }
@Test public void testChangeVisibilityVertex() { graph.prepareVertex("v1", VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A); v1.prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertNull(v1); v1 = graph.getVertex("v1", AUTHORIZATIONS_B); assertNotNull(v1); // change to same visibility v1 = graph.getVertex("v1", AUTHORIZATIONS_B); v1.prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertNull(v1); v1 = graph.getVertex("v1", AUTHORIZATIONS_B); assertNotNull(v1); }