@Override public OEdge copy() { if (element != null) { return new OEdgeDelegate(element.copy()); } else { return new OEdgeDelegate(vOut, vIn, lightweightEdgeType, lightwightEdgeLabel); } }
public OEdgeDocument delete() { OEdgeDelegate.deleteLinks(this); super.delete(); return this; }
private void promoteToRegularEdge() { ODatabaseDocument db = getDatabase(); OVertex from = getFrom(); OVertex to = getTo(); OVertexDelegate.detachOutgointEdge(from, this); OVertexDelegate.detachIncomingEdge(to, this); this.element = ((ODatabaseDocumentInternal) db) .newRegularEdge(lightweightEdgeType == null ? "E" : lightweightEdgeType.getName(), from, to).getRecord(); this.lightweightEdgeType = null; this.vOut = null; this.vIn = null; }
@Override public <RET extends ORecord> RET fromJSON(String iJson) { if (element == null) { promoteToRegularEdge(); } element.fromJSON(iJson); return (RET) this; }
@Override public OVertex getTo() { if (vIn != null) // LIGHTWEIGHT EDGE return vIn; final ODocument doc = getRecord(); if (doc == null) return null; Object result = doc.getProperty(DIRECTION_IN); if (!(result instanceof OElement)) { return null; } OElement v = (OElement) result; if (!v.isVertex()) { return null;//TODO optional...? } return v.asVertex().get(); }
public boolean isLabeled(String[] labels) { if (labels == null) { return true; } if (labels.length == 0) { return true; } Set<String> types = new HashSet<>(); Optional<OClass> typeClass = getSchemaType(); if (typeClass.isPresent()) { types.add(typeClass.get().getName()); typeClass.get().getAllSuperClasses().stream().map(x -> x.getName()).forEach(name -> types.add(name)); } else { if (lightwightEdgeLabel != null) types.add(lightwightEdgeLabel); else types.add("E"); } for (String s : labels) { for (String type : types) { if (type.equalsIgnoreCase(s)) { return true; } } } return false; }
@Override public void setProperty(String name, Object value) { if (element == null) { promoteToRegularEdge(); } element.setProperty(name, value); }
@Override public OVertex getFrom() { if (vOut != null) // LIGHTWEIGHT EDGE return vOut; final ODocument doc = getRecord(); if (doc == null) return null; Object result = doc.getProperty(DIRECTION_OUT); if (!(result instanceof OElement)) { return null; } OElement v = (OElement) result; if (!v.isVertex()) { return null;//TODO optional...? } return v.asVertex().get(); }
@Override public Optional<OEdge> asEdge() { if (this instanceof OEdge) return Optional.of((OEdge) this); OClass type = this.getSchemaClass(); if (type == null) { return Optional.empty(); } if (type.isEdgeType()) { return Optional.of(new OEdgeDelegate(this)); } return Optional.empty(); }
@Override public void setProperty(String name, Object value, OType... fieldType) { if (element == null) { promoteToRegularEdge(); } element.setProperty(name, value, fieldType); }
public OEdge delete() { deleteLinks(this); if (element != null) { element.delete(); } return this; }
public OEdge newLightweightEdge(String iClassName, OVertex from, OVertex to) { OClass clazz = getMetadata().getSchema().getClass(iClassName); OEdgeDelegate result = new OEdgeDelegate(from, to, clazz, iClassName); return result; }
OVertexDelegate.deleteLinks((OVertex) record); } else if (record instanceof OEdge) { OEdgeDelegate.deleteLinks((OEdge) record);
protected static OEdge createRawElement(OGraph graph, String label) { String className = graph.createEdgeClass(label); OEdgeDelegate delegate = new OEdgeDelegate(new ODocument(className)); return delegate; }
edge = new OEdgeDelegate(this.sourceVertex, value.asVertex().get(), clazz, connection.getValue()); } else { edge = new OEdgeDelegate(value.asVertex().get(), this.sourceVertex, clazz, connection.getValue());