public void remove(final String key, final Object value, final T element) { final String keyTemp = key + SEPARATOR + value; graph.autoStartTransaction(); try { underlying.remove(keyTemp, element.getRecord()); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
@Override public void remove() { graph.autoStartTransaction(); getRecord().delete(); }
protected void removeElement(final T vertex) { graph.autoStartTransaction(); final ORecord<?> vertexDoc = vertex.getRecord(); underlying.remove(vertexDoc); }
public <T extends OrientElement> T setProperties(final Object... fields) { if (fields != null && fields.length > 0 && fields[0] != null) { graph.autoStartTransaction(); if (fields.length == 1) { Object f = fields[0]; if (f instanceof Map<?, ?>) { for (Map.Entry<Object, Object> entry : ((Map<Object, Object>) f).entrySet()) setPropertyInternal(this, (ODocument) rawElement.getRecord(), entry.getKey().toString(), entry.getValue()); } else throw new IllegalArgumentException( "Invalid fields: expecting a pairs of fields as String,Object or a single Map<String,Object>, but found: " + f); } else // SET THE FIELDS for (int i = 0; i < fields.length; i += 2) setPropertyInternal(this, (ODocument) rawElement.getRecord(), fields[i].toString(), fields[i + 1]); } return (T) this; }
/** * Creates a temporary vertex. The vertex is not saved and the transaction * is not started. * * @param iClassName * Vertex's class name * @param prop * Varargs of properties to set * @return */ public OrientVertex addTemporaryVertex(final String iClassName, final Object... prop) { this.autoStartTransaction(); final OrientVertex vertex = new OrientVertex(this, iClassName); vertex.setProperties(prop); return vertex; }
public OrientVertex addVertex(final String iClassName, final String iClusterName) { this.autoStartTransaction(); final OrientVertex vertex = new OrientVertex(this, iClassName); // SAVE IT if (iClusterName != null) vertex.save(iClusterName); else vertex.save(); return vertex; }
public <T> T removeProperty(final String key) { graph.autoStartTransaction(); final Object oldValue = getRecord().removeField(key); save(); return (T) oldValue; }
@Override public ORID getIdentity() { if (rawElement == null) return ORecordId.EMPTY_RECORD_ID; final ORID rid = rawElement.getIdentity(); if (!rid.isValid()) { // SAVE THE RECORD TO OBTAIN A VALID RID graph.autoStartTransaction(); save(); } return rid; }
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 void setProperty(final String key, final Object value) { ElementHelper.validateProperty(this, key, value); graph.autoStartTransaction(); getRecord().field(key, value); save(); }
/** * (Blueprints Extension) Creates a temporary vertex setting the initial field values. The vertex is not saved and the transaction * is not started. * * @param iClassName Vertex's class name * @param prop Fields must be a odd pairs of key/value or a single object as Map containing entries as key/value pairs * * @return added vertex */ public OrientVertex addTemporaryVertex(final String iClassName, final Object... prop) { makeActive(); setCurrentGraphInThreadLocal(); autoStartTransaction(); final OrientVertex vertex = getVertexInstance(iClassName); vertex.setPropertiesInternal(prop); return vertex; }
@Override protected void autoStartTransaction() { super.autoStartTransaction(); if (!autoStartTx) return; final OrientGraphContext context = getContext(true); if (context.rawGraph.getTransaction() instanceof OTransactionNoTx && context.rawGraph.getTransaction().getStatus() != TXSTATUS.BEGUN) { context.rawGraph.begin(); } }
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.autoStartTransaction(); underlying.put(keyTemp, doc); }
/** * Removes a Property. * * @param key Property name * @return Old value if any */ @Override public <T> T removeProperty(final String key) { if (checkDeletedInTx()) throw new IllegalStateException("The vertex " + getIdentity() + " has been deleted"); final OrientBaseGraph graph = getGraph(); if (graph != null) graph.autoStartTransaction(); final Object oldValue = getRecord().removeField(key); if (graph != null) save(); return (T) oldValue; }
/** * (Blueprints Extension) Returns the record's identity. */ @Override public ORID getIdentity() { if (rawElement == null) return ORecordId.EMPTY_RECORD_ID; final ORID rid = rawElement.getIdentity(); if (!rid.isValid()) { final OrientBaseGraph graph = getGraph(); if (graph != null) { // SAVE THE RECORD TO OBTAIN A VALID RID graph.setCurrentGraphInThreadLocal(); graph.autoStartTransaction(); save(); } } return rid; }
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()); } }
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()); }
/** * Sets a Property value. * * @param key Property name * @param value Property value */ @Override public void setProperty(final String key, final Object value) { if (checkDeletedInTx()) graph.throwRecordNotFoundException(getIdentity(), "The graph element " + getIdentity() + " has been deleted"); validateProperty(this, key, value); final OrientBaseGraph graph = getGraph(); if (graph != null) graph.autoStartTransaction(); getRecord().field(key, value); if (graph != null) save(); }
/** * Sets a Property value specifying a type. This is useful when you don't have a schema on this property but you want to force the * type. * * @param key Property name * @param value Property value * @param iType Type to set */ public void setProperty(final String key, final Object value, final OType iType) { if (checkDeletedInTx()) graph.throwRecordNotFoundException(getIdentity(), "The graph element " + getIdentity() + " has been deleted"); validateProperty(this, key, value); final OrientBaseGraph graph = getGraph(); if (graph != null) graph.autoStartTransaction(); getRecord().field(key, value, iType); if (graph != null) save(); }
/** * Removes the Element from the Graph. In case the element is a Vertex, all the incoming and outgoing edges are automatically * removed too. */ void removeRecord() { checkIfAttached(); final OrientBaseGraph graph = getGraph(); graph.setCurrentGraphInThreadLocal(); graph.autoStartTransaction(); if (checkDeletedInTx()) graph.throwRecordNotFoundException(getIdentity(), "The graph element with id " + getIdentity() + " not found"); try { getRecord().load(); } catch (ORecordNotFoundException e) { graph.throwRecordNotFoundException(getIdentity(), e.getMessage()); } getRecord().delete(); }