@Override public ODocument get(final ORID id) { return dbProvider.get().load(id); }
@Override public ODocument get(final String id) { return dbProvider.get().load(new ORecordId(id)); }
@Override protected ODocument load() { if(orid!=null && orid.isValid()) { try { ODatabaseDocument db = OrientDbWebSession.get().getDatabase(); return db.load(orid); } catch (ORecordNotFoundException e) { return null; } } else { return savedDocument; } }
@Override protected ODocument load() { if(orid!=null && orid.isValid()) { try { ODatabaseDocument db = OrientDbWebSession.get().getDatabase(); return db.load(orid); } catch (ORecordNotFoundException e) { return null; } } else { return savedDocument; } }
@SuppressWarnings("unchecked") public <T extends ORecord> T getRecord() { if (!isValid()) return null; final ODatabaseDocument db = ODatabaseRecordThreadLocal.instance().get(); if (db == null) throw new ODatabaseException( "No database found in current thread local space. If you manually control databases over threads assure to set the current database before to use it by calling: ODatabaseRecordThreadLocal.instance().set(db);"); return (T) db.load(this); }
public Blob getBlob(String columnLabel) throws SQLException { try { Object value = result.getProperty(columnLabel); if (value instanceof ORID) { value = ((ORID) value).getRecord(); } if (value instanceof OBlob) { lastReadWasNull = false; return new OrientBlob((OBlob) value); } else if (value instanceof ORecordLazyList) { ORecordLazyList list = (ORecordLazyList) value; // check if all the list items are instances of ORecordBytes ListIterator<OIdentifiable> iterator = list.listIterator(); List<OBlob> binaryRecordList = new ArrayList<>(list.size()); while (iterator.hasNext()) { OIdentifiable listElement = iterator.next(); OBlob ob = statement.database.load(listElement.getIdentity()); binaryRecordList.add(ob); } lastReadWasNull = false; return new OrientBlob(binaryRecordList); } lastReadWasNull = true; return null; } catch (Exception e) { throw new SQLException("An error occurred during the retrieval of the BLOB at column '" + columnLabel + "'", e); } }
public void setVertexProperties(Long id, Map<String, Object> properties) { if (properties == null || properties.size() == 0) { return; } settingProperties = true; final int cluster = (int) (id % parallel); if (nextVerticesToCreate[cluster] <= id) { if (oVertexClass == null) { oVertexClass = db.getMetadata().getSchema().getClass(vertexClass); } if (nextVerticesToCreate[cluster] < id) { new BatchImporterJob(cluster, oVertexClass, id - 1).run(db); } new BatchImporterJob(cluster, oVertexClass, id).createVertex(db, id, properties); } else { final ODocument doc = db.load(new ORecordId(getClusterId(id), getClusterPosition(id))); if (doc == null) { throw new RuntimeException("trying to insert properties on non existing document"); } doc.fromMap(properties); db.save(doc); } }
private Object getValueAsRecord(ODocument iRecord, String iFieldValue, OType iType, String iOptions, String[] fields) { ORID rid = new ORecordId(OIOUtils.getStringContent(getFieldValue("@rid", fields))); boolean shouldReload = rid.isTemporary(); final ODocument recordInternal = (ODocument) fromString(iFieldValue, new ODocument(), null, iOptions, shouldReload); if (shouldBeDeserializedAsEmbedded(recordInternal, iType)) ODocumentInternal.addOwner(recordInternal, iRecord); else { ODatabaseDocument database = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (rid.isPersistent() && database != null) { ODocument documentToMerge = database.load(rid); documentToMerge.merge(recordInternal, false, false); return documentToMerge; } } return recordInternal; }