public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { if (label == null) throw ExceptionFactory.edgeLabelCanNotBeNull(); Value outVertexValue = ((SailVertex) outVertex).getRawVertex(); Value inVertexValue = ((SailVertex) inVertex).getRawVertex(); if (!(outVertexValue instanceof Resource)) { throw new IllegalArgumentException(outVertex.toString() + " is not a legal URI or blank node"); } try { URI labelURI = new URIImpl(this.expandPrefix(label)); Statement statement = new StatementImpl((Resource) outVertexValue, labelURI, inVertexValue); SailHelper.addStatement(statement, this.sailConnection.get()); return new SailEdge(statement, this); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { if (label == null) throw ExceptionFactory.edgeLabelCanNotBeNull(); final Map<String, Object> data = new HashMap<String, Object>(); data.put(RexsterTokens._OUTV, outVertex.getId()); data.put(RexsterTokens._INV, inVertex.getId()); data.put(RexsterTokens._LABEL, label); final JSONObject json = new JSONObject(data); if (null == id) return new RexsterEdge(RestHelper.postResultObject(this.graphURI + RexsterTokens.SLASH_EDGES, json), this); else return new RexsterEdge(RestHelper.postResultObject(this.graphURI + RexsterTokens.SLASH_EDGES_SLASH + RestHelper.encode(id), json), this); }
public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { if (label == null) throw ExceptionFactory.edgeLabelCanNotBeNull(); String idString = null; Edge edge; if (null != id) { idString = id.toString(); edge = this.edges.get(idString); if (null != edge) { throw ExceptionFactory.edgeWithIdAlreadyExist(id); } } else { boolean done = false; while (!done) { idString = this.getNextId(); edge = this.edges.get(idString); if (null == edge) done = true; } } edge = new TinkerEdge(idString, outVertex, inVertex, label, this); this.edges.put(edge.getId().toString(), edge); final TinkerVertex out = (TinkerVertex) outVertex; final TinkerVertex in = (TinkerVertex) inVertex; out.addOutEdge(label, edge); in.addInEdge(label, edge); return edge; }
public Neo4j2Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { if (label == null) throw ExceptionFactory.edgeLabelCanNotBeNull(); this.autoStartTransaction(true); return new Neo4j2Edge(((Neo4j2Vertex) outVertex).getRawVertex().createRelationshipTo(((Neo4j2Vertex) inVertex).getRawVertex(), DynamicRelationshipType.withName(label)), this); }
/** * {@inheritDoc} * <p/> * The object id must be a Map<String,Object> or null. * The id is the properties written when the vertex is created. * While it is possible to Edge.setProperty(), this method is faster. * * @param id a id of properties which can be null * @return the newly created vertex */ public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { if (label == null) throw ExceptionFactory.edgeLabelCanNotBeNull(); final Map<String, Object> finalProperties; if (id == null || !(id instanceof Map)) finalProperties = new HashMap<String, Object>(); else finalProperties = makePropertyMap((Map<String, Object>) id); final Long finalId = this.rawGraph.createRelationship((Long) outVertex.getId(), (Long) inVertex.getId(), DynamicRelationshipType.withName(label), finalProperties); return new Neo4j2BatchEdge(this, finalId, label); }
/** * Add an edge as with {@link #addEdge(String, Vertex)}, * but with a specified edge id. * @param id * @param label * @param inVertex * @return */ public Edge addEdge(Object id, String label, Vertex inVertex) { if (label == null) { throw ExceptionFactory.edgeLabelCanNotBeNull(); } if (id == null) { id = AccumuloGraphUtils.generateId(); } String myID = id.toString(); AccumuloEdge edge = new AccumuloEdge(globals, myID, inVertex, this, label); // TODO we arent suppose to make sure the given edge ID doesn't already // exist? globals.getEdgeWrapper().writeEdge(edge); globals.getVertexWrapper().writeEdgeEndpoints(edge); globals.checkedFlush(); globals.getCaches().cache(edge, Edge.class); return edge; }
@Override public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { if (label == null) { throw ExceptionFactory.edgeLabelCanNotBeNull(); } autoStartTransaction(true); com.sparsity.sparksee.gdb.Graph rawGraph = getRawGraph(); int type = rawGraph.findType(label); if (type == com.sparsity.sparksee.gdb.Type.InvalidType) { // First instance of this type, let's create it type = rawGraph.newEdgeType(label, true, true); } assert type != com.sparsity.sparksee.gdb.Type.InvalidType; assert outVertex instanceof SparkseeVertex && inVertex instanceof SparkseeVertex; long oid = rawGraph.newEdge(type, (Long) outVertex.getId(), (Long) inVertex.getId()); return new SparkseeEdge(this, oid); }
/** * Add an edge as with {@link #addEdge(String, Vertex)}, * but with a specified edge id. * @param id * @param label * @param inVertex * @return */ public Edge addEdge(Object id, String label, Vertex inVertex) { if (label == null) { throw ExceptionFactory.edgeLabelCanNotBeNull(); } if (id == null) { id = AccumuloGraphUtils.generateId(); } String myID = id.toString(); AccumuloEdge edge = new AccumuloEdge(globals, myID, inVertex, this, label); // TODO we arent suppose to make sure the given edge ID doesn't already // exist? globals.getEdgeWrapper().writeEdge(edge); globals.getVertexWrapper().writeEdgeEndpoints(edge); globals.checkedFlush(); globals.getCaches().cache(edge, Edge.class); return edge; }
throw ExceptionFactory.edgeLabelCanNotBeNull();
throw ExceptionFactory.edgeLabelCanNotBeNull();
throw ExceptionFactory.edgeLabelCanNotBeNull();