/** * Returns a string representation of the edge. */ public String toString() { if (setCurrentGraphInThreadLocal() != null) { if (getLabel() == null) return StringFactory.E + StringFactory.L_BRACKET + getId() + StringFactory.R_BRACKET + StringFactory.L_BRACKET + getVertex( Direction.OUT).getId() + StringFactory.ARROW + getVertex(Direction.IN).getId() + StringFactory.R_BRACKET; return StringFactory.edgeString(this); } else return StringFactory.E + StringFactory.L_BRACKET + getId(); }
@Override public <T> T createEdge(final Class<T> edgeClass, final Object from, final Object to, final ODocument edge) { final OrientEdge edgeImpl = createEdgeImpl(edgeClass, from, to); for (String key : edge.fieldNames()) { final Object val = edge.field(key); if (key.charAt(0) != '@' && val != null) { edgeImpl.setProperty(key, val); } } edgeImpl.save(); return objectDb.get().load(edgeImpl.getIdentity()); }
protected OrientEdge getEdgeInstance(final OIdentifiable from, final OIdentifiable to, final String label) { return new OrientEdge(this, from, to, label); }
protected OrientEdge(final OrientBaseGraph rawGraph, final String iLabel, final Object... fields) { super(rawGraph, null); rawElement = createDocument(iLabel); setPropertiesInternal(fields); }
public OrientEdge(final OrientBaseGraph rawGraph, final String iLabel, final Object... fields) { super(rawGraph, null); rawElement = createDocument(iLabel); setProperties(fields); }
final String edgeClassName = OrientBaseGraph.encodeClassName(edge.getLabel()); final OIdentifiable outVertex = edge.getOutVertex(); ODocument outVertexRecord = null; boolean outVertexChanged = false; if (outVertexRecord != null) { final String outFieldName = OrientVertex.getConnectionFieldName(Direction.OUT, edgeClassName, useVertexFieldsForEdgeLabels); outVertexChanged = edge.dropEdgeFromVertex(inVertexEdge, outVertexRecord, outFieldName, outVertexRecord.field(outFieldName)); final OIdentifiable inVertex = edge.getInVertex(); ODocument inVertexRecord = null; boolean inVertexChanged = false; if (inVertexRecord != null) { final String inFieldName = OrientVertex.getConnectionFieldName(Direction.IN, edgeClassName, useVertexFieldsForEdgeLabels); inVertexChanged = edge.dropEdgeFromVertex(outVertexEdge, inVertexRecord, inFieldName, inVertexRecord.field(inFieldName)); edge.removeRecord();
@Override public OIdentifiable getGraphElementRecord(final Object iObject) { final ORecord rec = ((OIdentifiable) iObject).getRecord(); if (rec == null || !(rec instanceof ODocument)) return null; final ODocument value = (ODocument) rec; final OIdentifiable v; OImmutableClass immutableClass = ODocumentInternal.getImmutableSchemaClass(value); if (immutableClass.isVertexType()) { // DIRECT VERTEX v = value; } else if (immutableClass.isEdgeType()) { // EDGE if (vertex.settings.isUseVertexFieldsForEdgeLabels() || OrientEdge.isLabeled(OrientEdge.getRecordLabel(value), iLabels)) v = OrientEdge.getConnection(value, connection.getKey().opposite()); else v = null; } else throw new IllegalStateException("Invalid content found between connections: " + value); return v; }
@Override public void remove() { checkClass(); final ODocument outVertex = getOutVertex().getRecord(); .encodeClassName(getLabel()); dropEdgeFromVertex(inVertexEdge, outVertex, outFieldName, outVertex.field(outFieldName)); final ODocument inVertex = getInVertex().getRecord(); dropEdgeFromVertex(outVertexEdge, inVertex, inFieldName, inVertex.field(inFieldName));
if (oe.isLightweight()) { final OrientVertex inV = oe.getVertex(Direction.IN); .getConnectionFieldName(Direction.IN, oe.getLabel(), graph.isUseVertexFieldsForEdgeLabels()); oe.getRecord().field(OrientBaseGraph.CONNECTION_OUT, newIdentity); oe.save(); if (oe.isLightweight()) { final OrientVertex outV = oe.getVertex(Direction.OUT); .getConnectionFieldName(Direction.OUT, oe.getLabel(), graph.isUseVertexFieldsForEdgeLabels()); oe.getRecord().field(OrientBaseGraph.CONNECTION_IN, newIdentity); oe.save();
public String toString() { graph.setCurrentGraphInThreadLocal(); if (getLabel() == null) return StringFactory.E + StringFactory.L_BRACKET + getId() + StringFactory.R_BRACKET + StringFactory.L_BRACKET + getVertex(Direction.OUT).getId() + StringFactory.ARROW + getVertex(Direction.IN).getId() + StringFactory.R_BRACKET; return StringFactory.edgeString(this); }
edge = new OrientEdge(graph, from, to, label); } else { edge = new OrientEdge(graph, label, fields); edge.getRecord().fields(OrientBaseGraph.CONNECTION_OUT, rawElement.getIdentity(), OrientBaseGraph.CONNECTION_IN, inDocument.getIdentity()); else edge.getRecord().fields(OrientBaseGraph.CONNECTION_OUT, rawElement, OrientBaseGraph.CONNECTION_IN, inDocument); from = (OIdentifiable) edge.getRecord(); to = (OIdentifiable) edge.getRecord(); edge.save(iClusterName); inDocument.save(); outDocument.save();
json.beginObject(); json.beginObject(1, false, "ae"); json.beginObject(2, false, edge.getId()); json.writeAttribute(3, false, "directed", false); json.writeAttribute(3, false, "source", edge.getVertex(Direction.IN).getId()); json.writeAttribute(3, false, "target", edge.getVertex(Direction.OUT).getId()); for (String field : edge.getPropertyKeys()) { final Object v = edge.getProperty(field); if (v != null) json.writeAttribute(3, false, field, v);
toAdd = new OrientEdge(graph, doc, fieldRecord, connection.getValue()); else toAdd = new OrientEdge(graph, fieldRecord, doc, connection.getValue()); OrientEdge.CLASS_NAME)) { toAdd = new OrientEdge(graph, fieldRecord); } else throw new IllegalStateException("Invalid content found in " + fieldName + " field: " + fieldRecord); if (graph.isUseVertexFieldsForEdgeLabels() || toAdd.isLabeled(iLabels))
edge.getRecord().fields(OrientBaseGraph.CONNECTION_OUT, currentVertex.rawElement.getIdentity(), OrientBaseGraph.CONNECTION_IN, inDocument.getIdentity()); else edge.getRecord().fields(OrientBaseGraph.CONNECTION_OUT, currentVertex.rawElement, OrientBaseGraph.CONNECTION_IN, inDocument); from = edge.getRecord(); to = edge.getRecord(); if (!edge.isLightweight()) edge.save(iClusterName); else outDocument.save();
if (iVertexToRemove.equals(OrientEdge.getConnection(curr, direction.opposite()))) { it.remove(); if (iAlsoInverse) if (iVertexToRemove.equals(OrientEdge.getConnection(curr, direction.opposite()))) { it.remove(); if (iAlsoInverse)
/** * Removes the Edge from the Graph. Connected vertices aren't removed. */ @Override public void remove() { final OrientBaseGraph graph = getGraph(); if (!isLightweight()) checkClass(); graph.setCurrentGraphInThreadLocal(); graph.autoStartTransaction(); for (final Index<? extends Element> index : graph.getIndices()) { if (Edge.class.isAssignableFrom(index.getIndexClass())) { OrientIndex<OrientEdge> idx = (OrientIndex<OrientEdge>) index; idx.removeElement(this); } } if (graph != null) graph.removeEdgeInternal(this); else // IN MEMORY CHANGES ONLY: USE NOTX CLASS OrientGraphNoTx.removeEdgeInternal(null, this); }
new OrientEdge(graph, iFromVertex, iToVertex, label) .convertToDocument(); return false; new OrientEdge(graph, iFromVertex, iToVertex, label) .convertToDocument(); return false; new OrientEdge(graph, iFromVertex, iToVertex, label) .convertToDocument(); return false; new OrientEdge(graph, iFromVertex, iToVertex, label) .convertToDocument(); return false;
final OrientBaseGraph graph = checkIfAttached(); if (rawElement != null) final ODocument vInRecord = vIn.getRecord(); final ODocument doc = createDocument(label); removeLightweightConnection(vOutRecord, outFieldName, vInRecord); removeLightweightConnection(vInRecord, inFieldName, vOutRecord);
protected ODocument createDocument(final String iLabel) { final String className = getClassName(iLabel); final ODocument doc = new ODocument(className); if (iLabel != null && !settings.isUseClassForEdgeLabel()) // SET THE LABEL AS FIELD doc.field(OrientElement.LABEL_FIELD_NAME, iLabel); return doc; }