@Override public boolean equals(final Object object) { return ElementHelper.areEqual(this, object); } }
public void setProperty(final String key, final Object value) { ElementHelper.validateProperty(this, key, value); if (key.equals(Tokens._COUNT)) throw new IllegalArgumentException("_count is a reserved property"); if (null == this.properties) this.properties = new HashMap<String, Object>(); this.properties.put(TYPE_MAP.get(key), value); }
@Override public void run(TitanTransaction tx) { TitanVertex v1 = tx.addVertex(); ElementHelper.setProperties(v1,"time",2,"text","hello"); } });
/** * Edges are relabeled by creating new edges with the same properties, but new label. * Note that for each edge is deleted and an edge is added. * * @param graph the graph to add the new edge to * @param oldEdges the existing edges to "relabel" * @param newLabel the label of the new edge */ public static void relabelEdges(final Graph graph, final Iterable<Edge> oldEdges, final String newLabel) { for (final Edge oldEdge : oldEdges) { final Vertex outVertex = oldEdge.getVertex(Direction.OUT); final Vertex inVertex = oldEdge.getVertex(Direction.IN); final Edge newEdge = graph.addEdge(null, outVertex, inVertex, newLabel); ElementHelper.copyProperties(oldEdge, newEdge); graph.removeEdge(oldEdge); } }
/** * An edge is relabeled by creating a new edge with the same properties, but new label. * Note that an edge is deleted and an edge is added. * * @param graph the graph to add the new edge to * @param oldEdge the existing edge to "relabel" * @param newId the id of the new edge * @param newLabel the label of the new edge * @return the newly created edge */ public static Edge relabelEdge(final Graph graph, final Edge oldEdge, final Object newId, final String newLabel) { final Vertex outVertex = oldEdge.getVertex(Direction.OUT); final Vertex inVertex = oldEdge.getVertex(Direction.IN); final Edge newEdge = graph.addEdge(newId, outVertex, inVertex, newLabel); ElementHelper.copyProperties(oldEdge, newEdge); graph.removeEdge(oldEdge); return newEdge; }
public boolean equals(final Object object) { return ElementHelper.areEqual(this, object); } }
protected static void setPropertyInternal(final Element element, final ODocument doc, final String key, final Object value) { ElementHelper.validateProperty(element, key, value); doc.field(key, value); }
@Override public void run(TitanTransaction tx) { TitanVertex v0 = tx.addVertex(); ElementHelper.setProperties(v0,"time",2,"text","hello"); TitanVertex v1 = tx.addVertex(); ElementHelper.setProperties(v1,"time",2,"text","hello"); } });
/** * Copy the vertex/edges of one graph over to another graph. * The id of the elements in the from graph are attempted to be used in the to graph. * This method only works for graphs where the user can control the element ids. * * @param from the graph to copy from * @param to the graph to copy to */ public static void copyGraph(final Graph from, final Graph to) { for (final Vertex fromVertex : from.getVertices()) { final Vertex toVertex = to.addVertex(fromVertex.getId()); ElementHelper.copyProperties(fromVertex, toVertex); } for (final Edge fromEdge : from.getEdges()) { final Vertex outVertex = to.getVertex(fromEdge.getVertex(Direction.OUT).getId()); final Vertex inVertex = to.getVertex(fromEdge.getVertex(Direction.IN).getId()); final Edge toEdge = to.addEdge(fromEdge.getId(), outVertex, inVertex, fromEdge.getLabel()); ElementHelper.copyProperties(fromEdge, toEdge); } } }
public boolean equals(final Object object) { return ElementHelper.areEqual(this, object); }
public void setProperty(final String key, final Object value) { ElementHelper.validateProperty(this, key, value); Object oldValue = this.properties.put(key, value); if (this instanceof TinkerVertex) this.graph.vertexKeyIndex.autoUpdate(key, value, oldValue, (TinkerVertex) this); else this.graph.edgeKeyIndex.autoUpdate(key, value, oldValue, (TinkerEdge) this); }
@Test public void testStaleVertex() { PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make(); PropertyKey age = mgmt.makePropertyKey("age").dataType(Integer.class).make(); mgmt.buildIndex("byName", Vertex.class).addKey(name).unique().buildCompositeIndex(); finishSchema(); TitanVertex cartman = graph.addVertex(null); ElementHelper.setProperties(cartman,"name","cartman", "age", 10); TitanVertex stan = graph.addVertex(null); ElementHelper.setProperties(stan,"name","stan","age",8); graph.commit(); cartman = (TitanVertex)graph.getVertices("name", "cartman").iterator().next(); graph.commit(); //TitanProperty p = (TitanProperty) ((Iterable)graph.multiQuery(cartman).properties().values().iterator().next()).iterator().next(); TitanProperty p = cartman.getProperties().iterator().next(); System.out.println(p.getLongId()); graph.commit(); }
public boolean equals(final Object object) { return ElementHelper.areEqual(this, object); } }
public void setProperty(final String key, final Object value) { ElementHelper.validateProperty(this, key, value); this.graph.autoStartTransaction(true); // attempts to take a collection and convert it to an array so that Neo4j can consume it this.rawElement.setProperty(key, tryConvertCollectionToArray(value)); }
TitanVertex v = tx.addVertex(null); verifyMetrics(STORE_NAMES.get(3), SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 2l, M_GET_SLICE, 4l)); ElementHelper.setProperties(v, "age", 25, "name", "john"); TitanVertex u = tx.addVertex(null); ElementHelper.setProperties(u, "age", 35, "name", "mary"); v.addEdge("knows", u); tx.commit();
public boolean equals(final Object object) { return ElementHelper.areEqual(this, object); } }
public void setProperty(final String key, final Object value) { ElementHelper.validateProperty(this, key, value); graph.autoStartTransaction(); getRecord().field(key, value); save(); }
TitanVertex v = tx.addVertex(); verifyStoreMetrics(STORE_NAMES.get(3), SYSTEM_METRICS, ImmutableMap.of(M_MUTATE, 2l, M_GET_SLICE, 4l)); ElementHelper.setProperties(v, "age", 25, "name", "john"); TitanVertex u = tx.addVertex(); ElementHelper.setProperties(u, "age", 35, "name", "mary"); v.addEdge("knows", u); tx.commit();
public boolean equals(final Object object) { return ElementHelper.areEqual(this, object); }
public void setProperty(final String key, final Object value) { ElementHelper.validateProperty(this, key, value); if (key.startsWith(RexsterTokens.UNDERSCORE)) throw new RuntimeException("RexsterGraph does not support property keys that start with underscore"); final Map<String, Object> data = new HashMap<String, Object>(); data.put(key, RestHelper.uriCast(value)); final JSONObject json = new JSONObject(data); if (this instanceof Vertex) { RestHelper.postResultObject(this.graph.getGraphURI() + RexsterTokens.SLASH_VERTICES_SLASH + RestHelper.encode(this.getId()), json); } else { RestHelper.postResultObject(this.graph.getGraphURI() + RexsterTokens.SLASH_EDGES_SLASH + RestHelper.encode(this.getId()), json); } }