@Override public ExistingEdgeMutation prepareMutation() { return getEdge().prepareMutation(); }
@Override public ExistingEdgeMutation prepareMutation() { return getEdge().prepareMutation(); }
ExistingEdgeMutation m = edge.prepareMutation(); m.setIndexHint(IndexHint.DO_NOT_INDEX); m.save(authorizations);
@Test public void testGraphQueryEdgeWithTermsAggregationAlterElementVisibility() { graph.prepareVertex("v1", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.prepareVertex("v2", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e1", "v1", "v2", LABEL_LABEL1, VISIBILITY_A) .addPropertyValue("k1", "age", 25, VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Edge e1 = graph.getEdge("e1", AUTHORIZATIONS_A_AND_B); e1.prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Map<Object, Long> propertyCountByValue = queryGraphQueryWithTermsAggregation("age", ElementType.EDGE, AUTHORIZATIONS_A_AND_B); assumeTrue("terms aggregation not supported", propertyCountByValue != null); assertEquals(1, propertyCountByValue.size()); propertyCountByValue = queryGraphQueryWithTermsAggregation("age", ElementType.EDGE, AUTHORIZATIONS_A); assumeTrue("terms aggregation not supported", propertyCountByValue != null); assertEquals(0, propertyCountByValue.size()); propertyCountByValue = queryGraphQueryWithTermsAggregation("age", ElementType.EDGE, AUTHORIZATIONS_B); assumeTrue("terms aggregation not supported", propertyCountByValue != null); assertEquals(1, propertyCountByValue.size()); }
@Test public void testGraphQueryEdgeWithTermsAggregationAlterElementVisibility() { graph.prepareVertex("v1", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.prepareVertex("v2", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.prepareEdge("e1", "v1", "v2", LABEL_LABEL1, VISIBILITY_A) .addPropertyValue("k1", "age", 25, VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Edge e1 = graph.getEdge("e1", AUTHORIZATIONS_A_AND_B); e1.prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Map<Object, Long> propertyCountByValue = queryGraphQueryWithTermsAggregation("age", ElementType.EDGE, AUTHORIZATIONS_A_AND_B); assumeTrue("terms aggregation not supported", propertyCountByValue != null); assertEquals(1, propertyCountByValue.size()); propertyCountByValue = queryGraphQueryWithTermsAggregation("age", ElementType.EDGE, AUTHORIZATIONS_A); assumeTrue("terms aggregation not supported", propertyCountByValue != null); assertEquals(0, propertyCountByValue.size()); propertyCountByValue = queryGraphQueryWithTermsAggregation("age", ElementType.EDGE, AUTHORIZATIONS_B); assumeTrue("terms aggregation not supported", propertyCountByValue != null); assertEquals(1, propertyCountByValue.size()); }
@Test public void testMetadataMutationsOnEdge() { Metadata metadataPropB = Metadata.create(); metadataPropB.add("meta1", "meta1", VISIBILITY_A); Edge edge = graph.prepareEdge("v1", "v2", LABEL_LABEL1, VISIBILITY_A) .setProperty("propBmeta", "propBmeta", metadataPropB, VISIBILITY_A) .save(AUTHORIZATIONS_ALL); graph.flush(); ExistingElementMutation<Edge> m = edge.prepareMutation(); m.setPropertyMetadata("propBmeta", "meta1", "meta2", VISIBILITY_A); edge = m.save(AUTHORIZATIONS_ALL); assertEquals("meta2", edge.getProperty("propBmeta").getMetadata().getEntry("meta1").getValue()); }
@Test public void testMetadataMutationsOnEdge() { Metadata metadataPropB = Metadata.create(); metadataPropB.add("meta1", "meta1", VISIBILITY_A); Edge edge = graph.prepareEdge("v1", "v2", LABEL_LABEL1, VISIBILITY_A) .setProperty("propBmeta", "propBmeta", metadataPropB, VISIBILITY_A) .save(AUTHORIZATIONS_ALL); graph.flush(); ExistingElementMutation<Edge> m = edge.prepareMutation(); m.setPropertyMetadata("propBmeta", "meta1", "meta2", VISIBILITY_A); edge = m.save(AUTHORIZATIONS_ALL); assertEquals("meta2", edge.getProperty("propBmeta").getMetadata().getEntry("meta1").getValue()); }
@Test public void testSoftDeletePropertyOnEdgeNotIndexed() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.addVertex("v2", VISIBILITY_B, AUTHORIZATIONS_A_AND_B); ElementBuilder<Edge> elementBuilder = graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_B) .setProperty("prop1", "value1", VISIBILITY_B); elementBuilder.setIndexHint(IndexHint.DO_NOT_INDEX); Edge e1 = elementBuilder.save(AUTHORIZATIONS_A_AND_B); graph.flush(); ExistingElementMutation<Edge> m = e1.prepareMutation(); m.softDeleteProperty("prop1", VISIBILITY_B); m.setIndexHint(IndexHint.DO_NOT_INDEX); m.save(AUTHORIZATIONS_A_AND_B); graph.flush(); e1 = graph.getEdge("e1", AUTHORIZATIONS_A_AND_B); assertEquals(0, IterableUtils.count(e1.getProperties())); }
@Test public void testSoftDeletePropertyOnEdgeNotIndexed() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A_AND_B); Vertex v2 = graph.addVertex("v2", VISIBILITY_B, AUTHORIZATIONS_A_AND_B); ElementBuilder<Edge> elementBuilder = graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_B) .setProperty("prop1", "value1", VISIBILITY_B); elementBuilder.setIndexHint(IndexHint.DO_NOT_INDEX); Edge e1 = elementBuilder.save(AUTHORIZATIONS_A_AND_B); graph.flush(); ExistingElementMutation<Edge> m = e1.prepareMutation(); m.softDeleteProperty("prop1", VISIBILITY_B); m.setIndexHint(IndexHint.DO_NOT_INDEX); m.save(AUTHORIZATIONS_A_AND_B); graph.flush(); e1 = graph.getEdge("e1", AUTHORIZATIONS_A_AND_B); assertEquals(0, IterableUtils.count(e1.getProperties())); }
public void updateVisibility(Vertex termMention, Visibility newVisibility, Authorizations authorizations) { Authorizations authorizationsWithTermMention = getAuthorizations(authorizations); Visibility newVisibilityWithTermMention = VisalloVisibility.and(newVisibility, VISIBILITY_STRING); ExistingElementMutation<Vertex> m = termMention.prepareMutation(); m.alterElementVisibility(newVisibilityWithTermMention); for (Property property : termMention.getProperties()) { m.alterPropertyVisibility(property, newVisibilityWithTermMention); } Property refPropertyVisibility = VisalloProperties.TERM_MENTION_REF_PROPERTY_VISIBILITY.getProperty(termMention); if (refPropertyVisibility != null) { VisalloProperties.TERM_MENTION_REF_PROPERTY_VISIBILITY.setProperty( m, newVisibility.getVisibilityString(), refPropertyVisibility.getMetadata(), newVisibilityWithTermMention ); } m.save(authorizationsWithTermMention); for (Edge edge : termMention.getEdges(Direction.BOTH, authorizationsWithTermMention)) { ExistingElementMutation<Edge> edgeMutation = edge.prepareMutation(); edgeMutation.alterElementVisibility(newVisibilityWithTermMention); for (Property property : edge.getProperties()) { edgeMutation.alterPropertyVisibility(property, newVisibilityWithTermMention); } edgeMutation.save(authorizationsWithTermMention); } }
ElementMutation<Edge> m = productEdge.prepareMutation(); GraphProductOntology.NODE_TITLE.setProperty(m, title, GraphWorkProductService.VISIBILITY.getVisibility()); m.save(authorizations);
e1.prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); e1.prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B);
e1.prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); e1.prepareMutation() .alterElementVisibility(VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B);
Assert.assertEquals(LABEL_LABEL1, IterableUtils.single(v2.getEdgesSummary(AUTHORIZATIONS_A).getInEdgeLabels())); e.prepareMutation() .alterEdgeLabel(LABEL_LABEL2) .save(AUTHORIZATIONS_A);
.prepareMutation() .alterElementVisibility(VISIBILITY_A) .save(AUTHORIZATIONS_A);
Assert.assertEquals(LABEL_LABEL1, IterableUtils.single(v2.getEdgesSummary(AUTHORIZATIONS_A).getInEdgeLabels())); e.prepareMutation() .alterEdgeLabel(LABEL_LABEL2) .save(AUTHORIZATIONS_A);
.prepareMutation() .alterElementVisibility(VISIBILITY_A) .save(AUTHORIZATIONS_A);
e1.prepareMutation() .alterPropertyVisibility("k2", "prop2", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B);
e1.prepareMutation() .alterPropertyVisibility("k2", "prop2", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B);
e1.prepareMutation() .deleteProperties("key1", "prop1") .save(AUTHORIZATIONS_A_AND_B);