org.securegraph.Vertex类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(20.0k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中org.securegraph.Vertex类的一些代码示例,展示了Vertex类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex类的具体详情如下:
包路径:org.securegraph.Vertex
类名称:Vertex

Vertex介绍

暂无

代码示例

代码示例来源:origin: org.securegraph/securegraph-test

  1. @Override
  2. protected String convert(Vertex o) {
  3. return o.getId();
  4. }
  5. });

代码示例来源:origin: org.securegraph/securegraph-core

  1. private void findPathsRecursive(List<Path> foundPaths, final Vertex sourceVertex, Vertex destVertex, int hops, int totalHops, Set<String> seenVertices, Path currentPath, ProgressCallback progressCallback, final Authorizations authorizations) {
  2. // if this is our first source vertex report progress back to the progress callback
  3. boolean firstLevelRecursion = hops == totalHops;
  4. seenVertices.add(sourceVertex.getId());
  5. if (sourceVertex.getId().equals(destVertex.getId())) {
  6. foundPaths.add(currentPath);
  7. } else if (hops > 0) {
  8. Iterable<Vertex> vertices = sourceVertex.getVertices(Direction.BOTH, authorizations);
  9. int vertexCount = 0;
  10. if (firstLevelRecursion) {
  11. vertices = toList(vertices);
  12. vertexCount = ((List<Vertex>) vertices).size();
  13. }
  14. int i = 0;
  15. for (Vertex child : vertices) {
  16. if (firstLevelRecursion) {
  17. // this will never get to 100% since i starts at 0. which is good. 100% signifies done and we still have work to do.
  18. double progressPercent = (double) i / (double) vertexCount;
  19. progressCallback.progress(progressPercent, ProgressCallback.Step.SEARCHING_EDGES, i + 1, vertexCount);
  20. }
  21. if (!seenVertices.contains(child.getId())) {
  22. findPathsRecursive(foundPaths, child, destVertex, hops - 1, totalHops, seenVertices, new Path(currentPath, child.getId()), progressCallback, authorizations);
  23. }
  24. i++;
  25. }
  26. }
  27. seenVertices.remove(sourceVertex.getId());
  28. }
  29. }

代码示例来源:origin: org.securegraph.examples/examples-base

  1. public static JSONObject vertexToJson(Vertex vertex) {
  2. JSONObject json = new JSONObject();
  3. json.put("id", vertex.getId());
  4. JSONArray propertiesJson = new JSONArray();
  5. for (Property property : vertex.getProperties()) {
  6. propertiesJson.put(propertyYoJson(property));
  7. }
  8. json.put("properties", propertiesJson);
  9. return json;
  10. }

代码示例来源:origin: lumifyio/securegraph

  1. public VertexBuilder prepareVertex(Vertex vertex) {
  2. return prepareVertex(vertex.getId(), vertex.getVisibility());
  3. }

代码示例来源:origin: lumifyio/securegraph

  1. @Override
  2. public void removeVertex(Vertex vertex, Authorizations authorizations) {
  3. if (!((InMemoryVertex) vertex).canRead(authorizations)) {
  4. return;
  5. }
  6. List<Edge> edgesToRemove = toList(vertex.getEdges(Direction.BOTH, authorizations));
  7. for (Edge edgeToRemove : edgesToRemove) {
  8. removeEdge(edgeToRemove, authorizations);
  9. }
  10. this.vertices.remove(vertex.getId());
  11. getSearchIndex().removeElement(this, vertex, authorizations);
  12. if (hasEventListeners()) {
  13. fireGraphEvent(new RemoveVertexEvent(this, vertex));
  14. }
  15. }

代码示例来源:origin: org.securegraph/securegraph-blueprints

  1. @Override
  2. public Iterable<Edge> getEdges(Direction direction, final String... labels) {
  3. final org.securegraph.Direction sgDirection = SecureGraphBlueprintsConvert.toSecureGraph(direction);
  4. final Authorizations authorizations = getGraph().getAuthorizationsProvider().getAuthorizations();
  5. return new ConvertingIterable<org.securegraph.Edge, Edge>(getSecureGraphElement().getEdges(sgDirection, labels, authorizations)) {
  6. @Override
  7. protected Edge convert(org.securegraph.Edge edge) {
  8. return SecureGraphBlueprintsEdge.create(getGraph(), edge, authorizations);
  9. }
  10. };
  11. }

代码示例来源:origin: org.securegraph/securegraph-test

  1. @Test
  2. public void testGetEdge() {
  3. Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
  4. Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
  5. graph.addEdge("e1to2label1", v1, v2, "label1", VISIBILITY_A, AUTHORIZATIONS_A);
  6. graph.addEdge("e1to2label2", v1, v2, "label2", VISIBILITY_A, AUTHORIZATIONS_A);
  7. graph.addEdge("e2to1", v2.getId(), v1.getId(), "label1", VISIBILITY_A, AUTHORIZATIONS_A);
  8. v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
  9. assertEquals(3, count(v1.getEdges(Direction.BOTH, AUTHORIZATIONS_A)));
  10. assertEquals(2, count(v1.getEdges(Direction.OUT, AUTHORIZATIONS_A)));
  11. assertEquals(1, count(v1.getEdges(Direction.IN, AUTHORIZATIONS_A)));
  12. assertEquals(3, count(v1.getEdges(v2, Direction.BOTH, AUTHORIZATIONS_A)));
  13. assertEquals(2, count(v1.getEdges(v2, Direction.OUT, AUTHORIZATIONS_A)));
  14. assertEquals(1, count(v1.getEdges(v2, Direction.IN, AUTHORIZATIONS_A)));
  15. assertEquals(2, count(v1.getEdges(v2, Direction.BOTH, "label1", AUTHORIZATIONS_A)));
  16. assertEquals(1, count(v1.getEdges(v2, Direction.OUT, "label1", AUTHORIZATIONS_A)));
  17. assertEquals(1, count(v1.getEdges(v2, Direction.IN, "label1", AUTHORIZATIONS_A)));
  18. assertEquals(3, count(v1.getEdges(v2, Direction.BOTH, new String[]{"label1", "label2"}, AUTHORIZATIONS_A)));
  19. assertEquals(2, count(v1.getEdges(v2, Direction.OUT, new String[]{"label1", "label2"}, AUTHORIZATIONS_A)));
  20. assertEquals(1, count(v1.getEdges(v2, Direction.IN, new String[]{"label1", "label2"}, AUTHORIZATIONS_A)));
  21. assertArrayEquals(new String[]{"label1", "label2"}, toArray(v1.getEdgeLabels(Direction.OUT, AUTHORIZATIONS_A), String.class));
  22. assertArrayEquals(new String[]{"label1"}, toArray(v1.getEdgeLabels(Direction.IN, AUTHORIZATIONS_A), String.class));
  23. assertArrayEquals(new String[]{"label1", "label2"}, toArray(v1.getEdgeLabels(Direction.BOTH, AUTHORIZATIONS_A), String.class));
  24. }

代码示例来源:origin: org.securegraph/securegraph-test

  1. @Test
  2. public void testGetVerticesFromVertex() {
  3. Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
  4. Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
  5. Vertex v3 = graph.addVertex("v3", VISIBILITY_A, AUTHORIZATIONS_A);
  6. Vertex v4 = graph.addVertex("v4", VISIBILITY_A, AUTHORIZATIONS_A);
  7. graph.addEdge(v1, v2, "knows", VISIBILITY_A, AUTHORIZATIONS_A);
  8. graph.addEdge(v1, v3, "knows", VISIBILITY_A, AUTHORIZATIONS_A);
  9. graph.addEdge(v1, v4, "knows", VISIBILITY_A, AUTHORIZATIONS_A);
  10. graph.addEdge(v2, v3, "knows", VISIBILITY_A, AUTHORIZATIONS_A);
  11. v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
  12. assertEquals(3, count(v1.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
  13. assertEquals(3, count(v1.getVertices(Direction.OUT, AUTHORIZATIONS_A)));
  14. assertEquals(0, count(v1.getVertices(Direction.IN, AUTHORIZATIONS_A)));
  15. v2 = graph.getVertex("v2", AUTHORIZATIONS_A);
  16. assertEquals(2, count(v2.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
  17. assertEquals(1, count(v2.getVertices(Direction.OUT, AUTHORIZATIONS_A)));
  18. assertEquals(1, count(v2.getVertices(Direction.IN, AUTHORIZATIONS_A)));
  19. v3 = graph.getVertex("v3", AUTHORIZATIONS_A);
  20. assertEquals(2, count(v3.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
  21. assertEquals(0, count(v3.getVertices(Direction.OUT, AUTHORIZATIONS_A)));
  22. assertEquals(2, count(v3.getVertices(Direction.IN, AUTHORIZATIONS_A)));
  23. v4 = graph.getVertex("v4", AUTHORIZATIONS_A);
  24. assertEquals(1, count(v4.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
  25. assertEquals(0, count(v4.getVertices(Direction.OUT, AUTHORIZATIONS_A)));
  26. assertEquals(1, count(v4.getVertices(Direction.IN, AUTHORIZATIONS_A)));
  27. }

代码示例来源:origin: org.securegraph/securegraph-core

  1. private void findPathsSetIntersection(List<Path> foundPaths, Vertex sourceVertex, Vertex destVertex, ProgressCallback progressCallback, Authorizations authorizations) {
  2. String sourceVertexId = sourceVertex.getId();
  3. String destVertexId = destVertex.getId();
  4. progressCallback.progress(0.1, ProgressCallback.Step.SEARCHING_SOURCE_VERTEX_EDGES);
  5. Set<String> sourceVertexConnectedVertexIds = toSet(sourceVertex.getVertexIds(Direction.BOTH, authorizations));
  6. progressCallback.progress(0.3, ProgressCallback.Step.SEARCHING_DESTINATION_VERTEX_EDGES);
  7. Set<String> destVertexConnectedVertexIds = toSet(destVertex.getVertexIds(Direction.BOTH, authorizations));
  8. progressCallback.progress(0.6, ProgressCallback.Step.MERGING_EDGES);
  9. sourceVertexConnectedVertexIds.retainAll(destVertexConnectedVertexIds);
  10. progressCallback.progress(0.9, ProgressCallback.Step.ADDING_PATHS);
  11. for (String connectedVertexId : sourceVertexConnectedVertexIds) {
  12. foundPaths.add(new Path(sourceVertexId, connectedVertexId, destVertexId));
  13. }
  14. }

代码示例来源:origin: org.securegraph/securegraph-test

  1. assertEquals(1, count(e.getProperties()));
  2. assertEquals("valueA", e.getPropertyValues("propA").iterator().next());
  3. assertEquals(1, count(v1.getEdges(Direction.OUT, AUTHORIZATIONS_A)));
  4. assertEquals("label1", single(v1.getEdgeLabels(Direction.OUT, AUTHORIZATIONS_A)));
  5. assertEquals(1, count(v2.getEdges(Direction.IN, AUTHORIZATIONS_A)));
  6. assertEquals("label1", single(v2.getEdgeLabels(Direction.IN, AUTHORIZATIONS_A)));
  7. assertEquals("valueA", e.getPropertyValues("propA").iterator().next());
  8. v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
  9. assertEquals(1, count(v1.getEdges(Direction.OUT, AUTHORIZATIONS_A)));
  10. assertEquals("label2", single(v1.getEdgeLabels(Direction.OUT, AUTHORIZATIONS_A)));
  11. v2 = graph.getVertex("v2", AUTHORIZATIONS_A);
  12. assertEquals(1, count(v2.getEdges(Direction.IN, AUTHORIZATIONS_A)));
  13. assertEquals("label2", single(v2.getEdgeLabels(Direction.IN, AUTHORIZATIONS_A)));
  14. assertEquals("valueA", e.getPropertyValues("propA").iterator().next());
  15. v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
  16. assertEquals(1, count(v1.getEdges(Direction.OUT, AUTHORIZATIONS_A)));
  17. assertEquals("label3", single(v1.getEdgeLabels(Direction.OUT, AUTHORIZATIONS_A)));
  18. v2 = graph.getVertex("v2", AUTHORIZATIONS_A);
  19. assertEquals(1, count(v2.getEdges(Direction.IN, AUTHORIZATIONS_A)));
  20. assertEquals("label3", single(v2.getEdgeLabels(Direction.IN, AUTHORIZATIONS_A)));

代码示例来源:origin: org.securegraph/securegraph-test

  1. @Test
  2. public void testElementMutationDoesntChangeObjectUntilSave() {
  3. Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
  4. v.setProperty("prop1", "value1", VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
  5. ElementMutation<Vertex> m = v.prepareMutation()
  6. .setProperty("prop1", "value2", VISIBILITY_A)
  7. .setProperty("prop2", "value2", VISIBILITY_A);
  8. assertEquals(1, count(v.getProperties()));
  9. assertEquals("value1", v.getPropertyValue("prop1"));
  10. m.save(AUTHORIZATIONS_A_AND_B);
  11. assertEquals(2, count(v.getProperties()));
  12. assertEquals("value2", v.getPropertyValue("prop1"));
  13. assertEquals("value2", v.getPropertyValue("prop2"));
  14. }

代码示例来源:origin: lumifyio/securegraph

  1. v.prepareMutation()
  2. .addPropertyValue("propid1a", "prop1", "value1a", VISIBILITY_A)
  3. .addPropertyValue("propid2a", "prop2", "value2a", VISIBILITY_A)
  4. .save(AUTHORIZATIONS_A_AND_B);
  5. v = graph.getVertex("v1", AUTHORIZATIONS_A);
  6. assertEquals("value1a", v.getPropertyValues("prop1").iterator().next());
  7. assertEquals("value2a", v.getPropertyValues("prop2").iterator().next());
  8. assertEquals("value3a", v.getPropertyValues("prop3").iterator().next());
  9. assertEquals(3, count(v.getProperties()));
  10. v.prepareMutation()
  11. .addPropertyValue("propid1a", "prop1", "value1b", VISIBILITY_A)
  12. .addPropertyValue("propid2a", "prop2", "value2b", VISIBILITY_A)
  13. .save(AUTHORIZATIONS_A_AND_B);
  14. v = graph.getVertex("v1", AUTHORIZATIONS_A);
  15. assertEquals(1, count(v.getPropertyValues("prop1")));
  16. assertEquals("value1b", v.getPropertyValues("prop1").iterator().next());
  17. assertEquals(1, count(v.getPropertyValues("prop2")));
  18. assertEquals("value2b", v.getPropertyValues("prop2").iterator().next());
  19. assertEquals(1, count(v.getPropertyValues("prop3")));
  20. assertEquals("value3a", v.getPropertyValues("prop3").iterator().next());
  21. assertEquals(3, count(v.getProperties()));
  22. v.addPropertyValue("propid1b", "prop1", "value1a-new", VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
  23. v = graph.getVertex("v1", AUTHORIZATIONS_A);
  24. assertContains("value1b", v.getPropertyValues("prop1"));
  25. assertContains("value1a-new", v.getPropertyValues("prop1"));
  26. assertEquals(4, count(v.getProperties()));

代码示例来源:origin: org.securegraph/securegraph-test

  1. .setProperty("prop2", "value2", VISIBILITY_B)
  2. .save(AUTHORIZATIONS_A_AND_B);
  3. assertEquals(1, count(vertexAdded.getProperties("prop1")));
  4. assertEquals("value1", vertexAdded.getPropertyValues("prop1").iterator().next());
  5. assertEquals(1, count(vertexAdded.getProperties("prop2")));
  6. assertEquals("value2", vertexAdded.getPropertyValues("prop2").iterator().next());
  7. graph.flush();
  8. assertEquals(1, count(v.getProperties("prop1")));
  9. assertEquals("value1", v.getPropertyValues("prop1").iterator().next());
  10. assertEquals(1, count(v.getProperties("prop2")));
  11. assertEquals("value2", v.getPropertyValues("prop2").iterator().next());
  12. new AddPropertyEvent(graph, vertexAdded, vertexAdded.getProperty("prop1")),
  13. new AddPropertyEvent(graph, vertexAdded, vertexAdded.getProperty("prop2"))
  14. );
  15. graphEvents.clear();
  16. vertexAdded = v.prepareMutation()
  17. .addPropertyValue("key1", "prop1Mutation", "value1Mutation", VISIBILITY_A)
  18. .save(AUTHORIZATIONS_A_AND_B);
  19. graph.flush();
  20. v = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B);
  21. assertEquals(1, count(v.getProperties("prop1Mutation")));
  22. assertEquals("value1Mutation", v.getPropertyValues("prop1Mutation").iterator().next());
  23. assertEvents(
  24. new AddPropertyEvent(graph, vertexAdded, vertexAdded.getProperty("prop1Mutation"))
  25. );

代码示例来源:origin: lumifyio/securegraph

  1. Vertex v = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
  2. v.prepareMutation()
  3. .addPropertyValue("propid1a", "prop1", "value1a", VISIBILITY_A)
  4. .addPropertyValue("propid1b", "prop1", "value1b", VISIBILITY_A)
  5. Property prop1_propid1a = v.getProperty("propid1a", "prop1");
  6. Property prop1_propid1b = v.getProperty("propid1b", "prop1");
  7. v.removeProperty("prop1", AUTHORIZATIONS_A_AND_B);
  8. graph.flush();
  9. assertEquals(1, count(v.getProperties()));
  10. v = graph.getVertex("v1", AUTHORIZATIONS_A);
  11. assertEquals(1, count(v.getProperties()));
  12. this.graphEvents.clear();
  13. Property prop2_propid2a = v.getProperty("propid2a", "prop2");
  14. v.removeProperty("propid2a", "prop2", AUTHORIZATIONS_A_AND_B);
  15. graph.flush();
  16. assertEquals(0, count(v.getProperties()));
  17. v = graph.getVertex("v1", AUTHORIZATIONS_A);
  18. assertEquals(0, count(v.getProperties()));

代码示例来源:origin: org.securegraph/securegraph-test

  1. assertEquals(1, count(v.getProperties("prop1")));
  2. Property prop1 = v.getProperties("prop1").iterator().next();
  3. if (prop1 instanceof HasTimestamp) {
  4. assertTrue("timestamp should be more than 0", ((HasTimestamp) prop1).getTimestamp() > 0);
  5. v.prepareMutation()
  6. .setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A)
  7. .save(AUTHORIZATIONS_A_AND_B);
  8. assertEquals(1, count(v.getProperties("prop1")));
  9. prop1 = v.getProperties("prop1").iterator().next();
  10. prop1Metadata = prop1.getMetadata();
  11. assertEquals(2, prop1Metadata.entrySet().size());
  12. v.setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
  13. assertEquals(1, count(v.getProperties("prop1")));
  14. prop1 = v.getProperties("prop1").iterator().next();
  15. prop1Metadata = prop1.getMetadata();
  16. assertEquals(2, prop1Metadata.entrySet().size());

代码示例来源:origin: org.securegraph/securegraph-test

  1. Property prop1_propid1a = v1.getProperty("propid1a", "prop1");
  2. Property prop1_propid1b = v1.getProperty("propid1b", "prop1");
  3. v1.prepareMutation()
  4. .removeProperties("prop1")
  5. .save(AUTHORIZATIONS_A_AND_B);
  6. graph.flush();
  7. assertEquals(1, count(v1.getProperties()));
  8. v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
  9. assertEquals(1, count(v1.getProperties()));
  10. Property prop2_propid2a = v1.getProperty("propid2a", "prop2");
  11. v1.prepareMutation()
  12. .removeProperties("propid2a", "prop2")
  13. .save(AUTHORIZATIONS_A_AND_B);
  14. graph.flush();
  15. assertEquals(0, count(v1.getProperties()));
  16. v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
  17. assertEquals(0, count(v1.getProperties()));
  18. assertEvents(
  19. new RemovePropertyEvent(graph, v1, prop2_propid2a)

代码示例来源:origin: org.securegraph/securegraph-test

  1. .save(AUTHORIZATIONS_A);
  2. assertEquals(3, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getProperties("prop1")));
  3. v1.markPropertyHidden("key1", "prop1", VISIBILITY_A, VISIBILITY_A_AND_B, AUTHORIZATIONS_A_AND_B);
  4. List<Property> properties = toList(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getProperties("prop1"));
  5. assertEquals(2, count(properties));
  6. boolean foundProp1Key2 = false;
  7. assertTrue("Prop1Key1VisB not found", foundProp1Key1VisB);
  8. List<Property> hiddenProperties = toList(graph.getVertex("v1", FetchHint.ALL_INCLUDING_HIDDEN, AUTHORIZATIONS_A_AND_B).getProperties());
  9. assertEquals(3, hiddenProperties.size());
  10. boolean foundProp1Key1VisA = false;
  11. assertTrue("Prop1Key1VisA not found", foundProp1Key1VisA);
  12. v1.markPropertyVisible("key1", "prop1", VISIBILITY_A, VISIBILITY_A_AND_B, AUTHORIZATIONS_A_AND_B);
  13. assertEquals(3, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getProperties("prop1")));

代码示例来源:origin: org.securegraph/securegraph-test

  1. @Test
  2. public void testConcurrentModificationOfProperties() {
  3. Vertex v = graph.prepareVertex("v1", VISIBILITY_EMPTY)
  4. .setProperty("prop1", "value1", VISIBILITY_A)
  5. .setProperty("prop2", "value2", VISIBILITY_A)
  6. .save(AUTHORIZATIONS_A_AND_B);
  7. int i = 0;
  8. for (Property p : v.getProperties()) {
  9. assertNotNull(p.toString());
  10. if (i == 0) {
  11. v.setProperty("prop3", "value3", VISIBILITY_A, AUTHORIZATIONS_A_AND_B);
  12. }
  13. i++;
  14. }
  15. }

代码示例来源:origin: org.securegraph/securegraph-test

  1. @Test
  2. public void testAddVertexWithPropertiesWithTwoDifferentVisibilities() {
  3. Vertex v = graph.prepareVertex("v1", VISIBILITY_EMPTY)
  4. .setProperty("prop1", "value1a", VISIBILITY_A)
  5. .setProperty("prop1", "value1b", VISIBILITY_B)
  6. .save(AUTHORIZATIONS_A_AND_B);
  7. assertEquals(2, count(v.getProperties("prop1")));
  8. v = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B);
  9. assertEquals(2, count(v.getProperties("prop1")));
  10. v = graph.getVertex("v1", AUTHORIZATIONS_A);
  11. assertEquals(1, count(v.getProperties("prop1")));
  12. assertEquals("value1a", v.getPropertyValue("prop1"));
  13. v = graph.getVertex("v1", AUTHORIZATIONS_B);
  14. assertEquals(1, count(v.getProperties("prop1")));
  15. assertEquals("value1b", v.getPropertyValue("prop1"));
  16. }

代码示例来源:origin: org.securegraph/securegraph-test

  1. @Test
  2. public void testChangeVisibilityOnStreamingProperty() throws IOException {
  3. String expectedLargeValue = IOUtils.toString(new LargeStringInputStream(LARGE_PROPERTY_VALUE_SIZE));
  4. PropertyValue propSmall = new StreamingPropertyValue(new ByteArrayInputStream("value1".getBytes()), String.class);
  5. PropertyValue propLarge = new StreamingPropertyValue(new ByteArrayInputStream(expectedLargeValue.getBytes()), String.class);
  6. String largePropertyName = "propLarge/\\*!@#$%^&*()[]{}|";
  7. graph.prepareVertex("v1", VISIBILITY_A)
  8. .setProperty("propSmall", propSmall, VISIBILITY_A)
  9. .setProperty(largePropertyName, propLarge, VISIBILITY_A)
  10. .save(AUTHORIZATIONS_A_AND_B);
  11. assertEquals(2, count(graph.getVertex("v1", AUTHORIZATIONS_A).getProperties()));
  12. graph.getVertex("v1", AUTHORIZATIONS_A)
  13. .prepareMutation()
  14. .alterPropertyVisibility("propSmall", VISIBILITY_B)
  15. .save(AUTHORIZATIONS_A_AND_B);
  16. assertEquals(1, count(graph.getVertex("v1", AUTHORIZATIONS_A).getProperties()));
  17. graph.getVertex("v1", AUTHORIZATIONS_A)
  18. .prepareMutation()
  19. .alterPropertyVisibility(largePropertyName, VISIBILITY_B)
  20. .save(AUTHORIZATIONS_A_AND_B);
  21. assertEquals(0, count(graph.getVertex("v1", AUTHORIZATIONS_A).getProperties()));
  22. assertEquals(2, count(graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).getProperties()));
  23. }

相关文章