final ODocument document = entries.next().getRecord();
@Override public ODocument getRecord() { if (rawElement instanceof ODocument) return (ODocument) rawElement; final ODocument doc = rawElement.getRecord(); if (doc == null) return null; // CHANGE THE RID -> DOCUMENT rawElement = doc; return doc; }
@Override public Optional<ORecord> getRecord() { if (this.element == null) { return Optional.empty(); } return Optional.ofNullable(this.element.getRecord()); }
public Optional<OElement> getElement() { if (element == null || element instanceof OElement) { return Optional.ofNullable((OElement) element); } ORecord rec = element.getRecord(); if (rec instanceof OElement) { return Optional.ofNullable((OElement) rec); } return Optional.empty(); }
public Set<String> getPropertyNames() { Set<String> result = new LinkedHashSet<>(); if (element != null) { result.addAll(((ODocument) element.getRecord()).getPropertyNames()); } result.addAll(content.keySet()); return result; }
@Override public Object getValue(final OIdentifiable iRecord, Object iCurrentResult, OCommandContext iContext) { final ODocument current = iRecord != null ? (ODocument) iRecord.getRecord() : null; return execute(current, current, null, iContext); }
@SuppressWarnings("unchecked") @Override public REC previous() { final OIdentifiable rec = super.previous(); if (rec == null) return null; return (REC) rec.getRecord(); }
public boolean clearDeletedRecords() { boolean removed = false; Iterator<OIdentifiable> it = super.iterator(); while (it.hasNext()) { OIdentifiable rec = it.next(); if (!(rec instanceof ORecord) && rec.getRecord() == null) { it.remove(); removed = true; } } return removed; }
@Override public Object getValue(final OIdentifiable iRecord, Object iCurrentResult, OCommandContext iContext) { final ODocument current = iRecord != null ? (ODocument) iRecord.getRecord() : null; return execute(current, current, null, iContext); }
/** * Load record and cast it to {@link ODocument} from first ite in identifiables * @param identifiables {@link List <OIdentifiable>} identifiables * @return {@link Optional<ODocument>} get first document or {@link Optional#empty()} */ public static Optional<ODocument> getDocument(List<OIdentifiable> identifiables) { return isNotEmpty(identifiables) ? ofNullable(identifiables.get(0).getRecord()) : empty(); }
private String serializeODocuments(Collection<? extends OIdentifiable> collection) { StringBuilder sb = new StringBuilder(); for(OIdentifiable id : collection) { sb.append(id.getRecord().toJSON()).append('\n'); } return sb.toString(); }
@Override public boolean equals(Object obj) { if (!(obj instanceof OIdentifiable)) { return false; } if (!(obj instanceof OElement)) { obj = ((OIdentifiable) obj).getRecord(); } return element.equals(((OElement) obj).getRecord()); }
@Override public Object call(Integer iArgument) { final ODocument doc = rec.getRecord(); doc.field("updated", true); doc.save(); return doc; } }, 10);
protected ODocument toODocument(Object object) { if(object instanceof ODocument) return (ODocument) object; else if(object instanceof OIdentifiable) return ((OIdentifiable)object).getRecord(); else if(object instanceof ODocumentWrapper) return ((ODocumentWrapper)object).getDocument(); else throw new WicketRuntimeException("Object is not castable to ODocument: "+object); }
@Override public Document buildDocument(Object key, OIdentifiable value) { ODocument location = ((OIdentifiable) key).getRecord(); return newGeoDocument(value, factory.fromDoc(location)); }
private boolean matchesFilters(OIdentifiable value) { if (this.compiledFilter == null || this.compiledFilter.getRootCondition() == null) { return true; } if (!(value instanceof ODocument)) { value = value.getRecord(); } return !(Boolean.FALSE.equals(compiledFilter.evaluate((ODocument) value, (ODocument) value, getContext()))); }
protected Object v2v(final ODatabase graph, final OIdentifiable iRecord, final ODirection iDirection, final String[] iLabels) { OElement rec = iRecord.getRecord(); if (rec.isVertex()) { return rec.asVertex().get().getVertices(iDirection, iLabels); } else { return null; } }
@Override public boolean result(Object iRecord) { final ODocument record = ((OIdentifiable) iRecord).getRecord(); record.field(propertyName, record.field(propertyName), type); database.save(record); return true; }
public <T> T getProperty(String name) { T result = null; if (content.containsKey(name)) { result = (T) wrap(content.get(name)); } else if (element != null) { result = (T) wrap(((ODocument) element.getRecord()).getProperty(name)); } if (result instanceof OIdentifiable && ((OIdentifiable) result).getIdentity().isPersistent()) { result = (T) ((OIdentifiable) result).getIdentity(); } return result; }
private static void deleteEdgeIfAny(final OIdentifiable iRecord) { if (iRecord != null) { final ODocument doc = iRecord.getRecord(); if (doc != null && doc.getSchemaClass() != null && doc.getSchemaClass().isSubClassOf(OrientEdge.CLASS_NAME)) // DELETE THE EDGE RECORD TOO doc.delete(); } }