protected void autoStartTransaction() { setCurrentGraphInThreadLocal(); }
@Override public <T> T getProperty(final String key) { graph.setCurrentGraphInThreadLocal(); if (rawElement == null) // LIGHTWEIGHT EDGE return null; return super.getProperty(key); }
protected OrientBaseGraph setCurrentGraphInThreadLocal() { final OrientBaseGraph graph = getGraph(); if (graph != null) graph.setCurrentGraphInThreadLocal(); return graph; }
@Override public OrientVertexQuery query() { graph.setCurrentGraphInThreadLocal(); return new OrientVertexQuery(this); }
@Override public <T> T removeProperty(String key) { graph.setCurrentGraphInThreadLocal(); if (rawElement != null) // NON LIGHTWEIGHT EDGE return super.removeProperty(key); return null; }
@Override public Set<String> getPropertyKeys() { graph.setCurrentGraphInThreadLocal(); final ODocument doc = getRecord(); final Set<String> result = new HashSet<String>(); for (String field : doc.fieldNames()) if (graph.isUseVertexFieldsForEdgeLabels()) { if (!field.startsWith(CONNECTION_OUT_PREFIX) && !field.startsWith(CONNECTION_IN_PREFIX)) result.add(field); } else if (!field.equals(OrientBaseGraph.CONNECTION_OUT) && !field.equals(OrientBaseGraph.CONNECTION_IN)) result.add(field); return result; }
@Override public Set<String> getPropertyKeys() { if (rawElement == null) // LIGHTWEIGHT EDGE return Collections.emptySet(); graph.setCurrentGraphInThreadLocal(); final Set<String> result = new HashSet<String>(); for (String field : getRecord().fieldNames()) if (!field.equals(OrientBaseGraph.CONNECTION_OUT) && !field.equals(OrientBaseGraph.CONNECTION_IN) && (graph.isUseClassForEdgeLabel() || !field .equals(OrientElement.LABEL_FIELD_NAME))) result.add(field); return result; }
@Override public void setProperty(final String key, final Object value) { graph.setCurrentGraphInThreadLocal(); if (rawElement == null) // LIGHTWEIGHT EDGE convertToDocument(); super.setProperty(key, value); }
@Override public Object getId() { if (rawElement == null) // CREATE A TEMPORARY ID return vOut.getIdentity() + "->" + vIn.getIdentity(); graph.setCurrentGraphInThreadLocal(); return super.getId(); }
/** * Returns a OTraverse object to start traversing from the current vertex. */ public OTraverse traverse() { graph.setCurrentGraphInThreadLocal(); return new OTraverse().target(getRecord()); }
public String toString() { graph.setCurrentGraphInThreadLocal(); final String clsName = getRecord().getClassName(); if (clsName.equals(CLASS_NAME)) return StringFactory.vertexString(this); return StringFactory.V + "(" + clsName + ")" + StringFactory.L_BRACKET + getId() + StringFactory.R_BRACKET; }
/** * (Blueprints Extension) Saves current element to a particular cluster. You don't need to call save() unless you're working * against Temporary Vertices. * * @param iClusterName Cluster name or null to use the default "E" */ public void save(final String iClusterName) { final OrientBaseGraph graph = checkIfAttached(); graph.setCurrentGraphInThreadLocal(); if (rawElement instanceof ODocument) if (iClusterName != null) rawElement = ((ODocument) rawElement).save(iClusterName); else rawElement = ((ODocument) rawElement).save(); }
public void remove(final String key, final Object value, final T element) { final String keyTemp = key + SEPARATOR + value; graph.setCurrentGraphInThreadLocal(); graph.autoStartTransaction(); try { underlying.remove(keyTemp, element.getRecord()); recordKeyValueIndex.remove(new OCompositeKey(element.getIdentity(), keyTemp), element.getIdentity()); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
public String getLabel() { graph.setCurrentGraphInThreadLocal(); if (graph.isUseClassForVertexLabel()) { final String clsName = getRecord().getClassName(); if (!CLASS_NAME.equals(clsName)) // RETURN THE CLASS NAME return clsName; } return getRecord().field(OrientElement.LABEL_FIELD_NAME); }
public OIdentifiable getOutVertex() { if (vOut != null) // LIGHTWEIGHT EDGE return vOut; graph.setCurrentGraphInThreadLocal(); final ODocument doc = getRecord(); if (doc == null) return null; if (graph.isKeepInMemoryReferences()) // AVOID LAZY RESOLVING+SETTING OF RECORD return doc.rawField(OrientBaseGraph.CONNECTION_OUT); else return doc.field(OrientBaseGraph.CONNECTION_OUT); }
public OIdentifiable getInVertex() { if (vIn != null) // LIGHTWEIGHT EDGE return vIn; graph.setCurrentGraphInThreadLocal(); final ODocument doc = getRecord(); if (doc == null) return null; if (graph.isKeepInMemoryReferences()) // AVOID LAZY RESOLVING+SETTING OF RECORD return doc.rawField(OrientBaseGraph.CONNECTION_IN); else return doc.field(OrientBaseGraph.CONNECTION_IN); }
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); }
protected void removeElement(final T element) { graph.setCurrentGraphInThreadLocal(); graph.autoStartTransaction(); final OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("select from index:" + recordKeyValueIndex.getName() + " where key between [" + element.getIdentity() + "] and [" + element.getIdentity() + "]"); final Collection<ODocument> entries = (Collection<ODocument>) graph.getRawGraph().query(query); for (ODocument entry : entries) { final OCompositeKey key = entry.field("key"); final List<Object> keys = key.getKeys(); underlying.remove(keys.get(1).toString(), element.getIdentity()); recordKeyValueIndex.remove(key, element.getIdentity()); } }
@Override public OrientVertex getVertex(final Direction direction) { graph.setCurrentGraphInThreadLocal(); if (direction.equals(Direction.OUT)) return new OrientVertex(graph, getOutVertex()); else if (direction.equals(Direction.IN)) return new OrientVertex(graph, getInVertex()); else throw ExceptionFactory.bothIsNotSupported(); }
public void put(final String key, final Object value, final T element) { final String keyTemp = key + SEPARATOR + value; final ODocument doc = element.getRecord(); if (!doc.getIdentity().isValid()) doc.save(); graph.setCurrentGraphInThreadLocal(); graph.autoStartTransaction(); underlying.put(keyTemp, doc); recordKeyValueIndex.put(new OCompositeKey(doc.getIdentity(), keyTemp), doc.getIdentity()); }