@Override public T get() throws InterruptedException, ExecutionException { if (element == null) { element = this.elementUpdateContext.getMutation().save(authorizations); } return element; }
public Vertex saveVertex(ElementMutation<Vertex> m) { return m.save(getAuthorizations()); }
public Element save(Authorizations authorizations) { return getElementMutation().save(authorizations); }
public Edge saveEdge(ElementMutation<Edge> m) { return m.save(getAuthorizations()); }
@Override public Iterable<Element> saveElementMutations(Iterable<ElementMutation> mutations, Authorizations authorizations) { List<Element> elements = new ArrayList<>(); for (ElementMutation m : mutations) { if (m instanceof ExistingElementMutation && !m.hasChanges()) { elements.add(((ExistingElementMutation) m).getElement()); continue; } Element element = m.save(authorizations); elements.add(element); } return elements; }
@Override public Iterable<Element> saveElementMutations(Iterable<ElementMutation> mutations, Authorizations authorizations) { List<Element> elements = new ArrayList<>(); for (ElementMutation m : mutations) { if (m instanceof ExistingElementMutation && !m.hasChanges()) { elements.add(((ExistingElementMutation) m).getElement()); continue; } Element element = m.save(authorizations); elements.add(element); } return elements; }
/** * Adds or updates a property. * * @param key The unique key given to the property allowing for multi-valued properties. * @param name The name of the property. * @param value The value of the property. * @param visibility The visibility to give this property. */ default void addPropertyValue(String key, String name, Object value, Visibility visibility, Authorizations authorizations) { prepareMutation().addPropertyValue(key, name, value, visibility).save(authorizations); }
/** * Adds or updates a property. * * @param key The unique key given to the property allowing for multi-valued properties. * @param name The name of the property. * @param value The value of the property. * @param metadata The metadata to assign to this property. * @param visibility The visibility to give this property. */ default void addPropertyValue(String key, String name, Object value, Metadata metadata, Visibility visibility, Authorizations authorizations) { prepareMutation().addPropertyValue(key, name, value, metadata, visibility).save(authorizations); }
/** * Adds or updates a property. * * @param key The unique key given to the property allowing for multi-valued properties. * @param name The name of the property. * @param value The value of the property. * @param visibility The visibility to give this property. */ default void addPropertyValue(String key, String name, Object value, Visibility visibility, Authorizations authorizations) { prepareMutation().addPropertyValue(key, name, value, visibility).save(authorizations); }
/** * Sets or updates a property value. The property key will be set to a constant. This is a convenience method * which allows treating the multi-valued nature of properties as only containing a single value. Care must be * taken when using this method because properties are not only uniquely identified by just key and name but also * visibility so adding properties with the same name and different visibility strings is still permitted. * * @param name The name of the property. * @param value The value of the property. * @param visibility The visibility to give this property. */ default void setProperty(String name, Object value, Visibility visibility, Authorizations authorizations) { prepareMutation().setProperty(name, value, visibility).save(authorizations); }
/** * Adds or updates a property. * * @param key The unique key given to the property allowing for multi-valued properties. * @param name The name of the property. * @param value The value of the property. * @param metadata The metadata to assign to this property. * @param visibility The visibility to give this property. */ default void addPropertyValue(String key, String name, Object value, Metadata metadata, Visibility visibility, Authorizations authorizations) { prepareMutation().addPropertyValue(key, name, value, metadata, visibility).save(authorizations); }
/** * Sets or updates a property value. The property key will be set to a constant. This is a convenience method * which allows treating the multi-valued nature of properties as only containing a single value. Care must be * taken when using this method because properties are not only uniquely identified by just key and name but also * visibility so adding properties with the same name and different visibility strings is still permitted. * * @param name The name of the property. * @param value The value of the property. * @param metadata The metadata to assign to this property. * @param visibility The visibility to give this property. */ default void setProperty(String name, Object value, Metadata metadata, Visibility visibility, Authorizations authorizations) { prepareMutation().setProperty(name, value, metadata, visibility).save(authorizations); }
/** * Sets or updates a property value. The property key will be set to a constant. This is a convenience method * which allows treating the multi-valued nature of properties as only containing a single value. Care must be * taken when using this method because properties are not only uniquely identified by just key and name but also * visibility so adding properties with the same name and different visibility strings is still permitted. * * @param name The name of the property. * @param value The value of the property. * @param visibility The visibility to give this property. */ default void setProperty(String name, Object value, Visibility visibility, Authorizations authorizations) { prepareMutation().setProperty(name, value, visibility).save(authorizations); }
/** * Sets or updates a property value. The property key will be set to a constant. This is a convenience method * which allows treating the multi-valued nature of properties as only containing a single value. Care must be * taken when using this method because properties are not only uniquely identified by just key and name but also * visibility so adding properties with the same name and different visibility strings is still permitted. * * @param name The name of the property. * @param value The value of the property. * @param metadata The metadata to assign to this property. * @param visibility The visibility to give this property. */ default void setProperty(String name, Object value, Metadata metadata, Visibility visibility, Authorizations authorizations) { prepareMutation().setProperty(name, value, metadata, visibility).save(authorizations); }
public void lrpUpdate(Vertex vertex, Graph graph, Authorizations authorizations) { Date updateDate = new Date(); Long waitTimeMs = updateDate.getTime() - PingOntology.CREATE_DATE.getPropertyValueRequired(vertex).getTime(); ElementMutation<Vertex> mutation = vertex.prepareMutation(); PingOntology.LONG_RUNNING_PROCESS_DATE.setProperty(mutation, updateDate, VISIBILITY); PingOntology.LONG_RUNNING_PROCESS_HOSTNAME.setProperty(mutation, getHostname(), VISIBILITY); PingOntology.LONG_RUNNING_PROCESS_HOST_ADDRESS.setProperty(mutation, getHostAddress(), VISIBILITY); PingOntology.LONG_RUNNING_PROCESS_WAIT_TIME_MS.setProperty(mutation, waitTimeMs, VISIBILITY); mutation.save(authorizations); graph.flush(); }
public void gpwUpdate(Vertex vertex, Graph graph, Authorizations authorizations) { Date updateDate = new Date(); Long waitTimeMs = updateDate.getTime() - PingOntology.CREATE_DATE.getPropertyValueRequired(vertex).getTime(); ElementMutation<Vertex> mutation = vertex.prepareMutation(); PingOntology.GRAPH_PROPERTY_WORKER_DATE.setProperty(mutation, updateDate, VISIBILITY); PingOntology.GRAPH_PROPERTY_WORKER_HOSTNAME.setProperty(mutation, getHostname(), VISIBILITY); PingOntology.GRAPH_PROPERTY_WORKER_HOST_ADDRESS.setProperty(mutation, getHostAddress(), VISIBILITY); PingOntology.GRAPH_PROPERTY_WORKER_WAIT_TIME_MS.setProperty(mutation, waitTimeMs, VISIBILITY); mutation.save(authorizations); graph.flush(); }
public Vertex createVertex(String remoteAddr, long searchTime, long retrievalTime, Graph graph, Authorizations authorizations) { Date createDate = new Date(); String vertexId = PingOntology.getVertexId(createDate); ElementMutation<Vertex> mutation = graph.prepareVertex(vertexId, VISIBILITY); VisalloProperties.CONCEPT_TYPE.setProperty(mutation, PingOntology.IRI_CONCEPT_PING, visibilityTranslator.getDefaultVisibility()); PingOntology.CREATE_DATE.setProperty(mutation, createDate, VISIBILITY); PingOntology.CREATE_REMOTE_ADDR.setProperty(mutation, remoteAddr, VISIBILITY); PingOntology.SEARCH_TIME_MS.setProperty(mutation, searchTime, VISIBILITY); PingOntology.RETRIEVAL_TIME_MS.setProperty(mutation, retrievalTime, VISIBILITY); Vertex vertex = mutation.save(authorizations); graph.flush(); return vertex; }
@Test public void testAddVertexWithoutIndexing() { assumeTrue("add vertex without indexing not supported", !isDefaultSearchIndex()); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_A) .setIndexHint(IndexHint.DO_NOT_INDEX) .save(AUTHORIZATIONS_A); graph.flush(); Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A_AND_B) .has("prop1", "value1") .vertices(); assertVertexIds(vertices); }
@Test public void testAddVertexWithoutIndexing() { assumeTrue("add vertex without indexing not supported", !isDefaultSearchIndex()); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_A) .setIndexHint(IndexHint.DO_NOT_INDEX) .save(AUTHORIZATIONS_A); graph.flush(); Iterable<Vertex> vertices = graph.query(AUTHORIZATIONS_A_AND_B) .has("prop1", "value1") .vertices(); assertVertexIds(vertices); }
@Test public void testElementMutationDoesntChangeObjectUntilSave() { Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL); v.setProperty("prop1", "value1-1", VISIBILITY_A, AUTHORIZATIONS_ALL); graph.flush(); ElementMutation<Vertex> m = v.prepareMutation() .setProperty("prop1", "value1-2", VISIBILITY_A) .setProperty("prop2", "value2-2", VISIBILITY_A); Assert.assertEquals(1, count(v.getProperties())); assertEquals("value1-1", v.getPropertyValue("prop1")); v = m.save(AUTHORIZATIONS_A_AND_B); Assert.assertEquals(2, count(v.getProperties())); assertEquals("value1-2", v.getPropertyValue("prop1")); assertEquals("value2-2", v.getPropertyValue("prop2")); }