| public void createEdge(final Long from, final Long to, Map<String, Object> properties) { |
| if (settingProperties) { |
| throw new IllegalStateException("Cannot create new edges when already set properties on vertices"); |
| } |
| if (from < 0) { |
| throw new IllegalArgumentException(" Invalid vertex id: " + from); |
| } |
| if (to < 0) { |
| throw new IllegalArgumentException(" Invalid vertex id: " + to); |
| } |
| if (useLightWeigthEdges && (properties == null || properties.size() == 0)) { |
| last = last < from ? from : last; |
| last = last < to ? to : last; |
| putInList(from, out, to); |
| putInList(to, in, from); |
| } else { |
| ODocument edgeDoc = new ODocument(edgeClass); |
|
| edgeDoc.fromMap(properties); |
| edgeDoc.field("out", new ORecordId(getClusterId(from), getClusterPosition(from))); |
| edgeDoc.field("in", new ORecordId(getClusterId(to), getClusterPosition(to))); |
| db.save(edgeDoc); |
| ORecordId rid = (ORecordId) edgeDoc.getIdentity(); |
| putInList(from, out, rid); |
| putInList(to, in, rid); |
| } |
}
|