@Override protected boolean include(final ORecord record) { return record instanceof ODocument && targetClass .isSuperClassOf(ODocumentInternal.getImmutableSchemaClass(((ODocument) record))); }
public byte[] writeClassOnly(ORecord iSource) { final ODocument record = (ODocument) iSource; StringBuilder iOutput = new StringBuilder(); if (ODocumentInternal.getImmutableSchemaClass(record) != null) { iOutput.append(ODocumentInternal.getImmutableSchemaClass(record).getStreamableName()); iOutput.append(OStringSerializerHelper.CLASS_SEPARATOR); } try { return iOutput.toString().getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw OException.wrapException(new OSerializationException("error writing class name"), e); } }
protected OType getLinkedType(ODocument document, OType type, String key) { if (type != OType.EMBEDDEDLIST && type != OType.EMBEDDEDSET && type != OType.EMBEDDEDMAP) return null; OClass immutableClass = ODocumentInternal.getImmutableSchemaClass(document); if (immutableClass != null) { OProperty prop = immutableClass.getProperty(key); if (prop != null) { return prop.getLinkedType(); } } return null; }
public static void processIndexOnCreate(ODatabaseDocumentInternal database, ODocument document, List<IndexChange> ops) { final OImmutableClass cls = ODocumentInternal.getImmutableSchemaClass(database, document); if (cls != null) { final Collection<OIndex<?>> indexes = cls.getRawIndexes(); addIndexesEntries(database, document, indexes, ops); } }
private OType determineType(ODocument doc, String fieldName) { OType type = null; final OClass cls = ODocumentInternal.getImmutableSchemaClass(doc); if (cls != null) { final OProperty prop = cls.getProperty(fieldName); if (prop != null) type = prop.getType(); } return type; }
private OType getLinkedType(ODocument document, OType type, String key) { if (type != OType.EMBEDDEDLIST && type != OType.EMBEDDEDSET && type != OType.EMBEDDEDMAP) return null; OClass immutableClass = ODocumentInternal.getImmutableSchemaClass(document); if (immutableClass != null) { OProperty prop = immutableClass.getProperty(key); if (prop != null) { return prop.getLinkedType(); } } return null; }
private OType getLinkedType(ODocument document, OType type, String key) { if (type != OType.EMBEDDEDLIST && type != OType.EMBEDDEDSET && type != OType.EMBEDDEDMAP) return null; OClass immutableClass = ODocumentInternal.getImmutableSchemaClass(document); if (immutableClass != null) { OProperty prop = immutableClass.getProperty(key); if (prop != null) { return prop.getLinkedType(); } } return null; }
protected OElement getRawDocument(ORecord record) { if (record == null) throw new NoSuchElementException(); if (record instanceof OIdentifiable) record = record.getRecord(); ODocument currentDocument = (ODocument) record; if (currentDocument.getInternalStatus() == ODocument.STATUS.NOT_LOADED) currentDocument.load(); if (ODocumentInternal.getImmutableSchemaClass(currentDocument) == null) throw new IllegalArgumentException( "Cannot determine the graph element type because the document class is null. Probably this is a projection, use the EXPAND() function"); return currentDocument; }
public static void processIndexOnUpdate(ODatabaseDocumentInternal database, ODocument iDocument, List<IndexChange> changes) { final OImmutableClass cls = ODocumentInternal.getImmutableSchemaClass(database, iDocument); if (cls == null) { return; } final Collection<OIndex<?>> indexes = cls.getRawIndexes(); if (!indexes.isEmpty()) { final Set<String> dirtyFields = new HashSet<>(Arrays.asList(iDocument.getDirtyFields())); if (!dirtyFields.isEmpty()) for (final OIndex<?> index : indexes) { processIndexUpdate(iDocument, dirtyFields, getTransactionalIndex(database, index), changes); } } }
protected OClass serializeClass(final ODocument document, final BytesContainer bytes) { final OClass clazz = ODocumentInternal.getImmutableSchemaClass(document); if (clazz != null) writeString(bytes, clazz.getName()); else writeEmptyString(bytes); return clazz; }
@Override public void afterReadOperations(OIdentifiable identifiable) { if (identifiable instanceof ODocument) { ODocument doc = (ODocument) identifiable; OImmutableClass clazz = ODocumentInternal.getImmutableSchemaClass(this, doc); if (clazz != null) { if (clazz.isTriggered()) { OClassTrigger.onRecordAfterRead(doc, this); } } } callbackHooks(ORecordHook.TYPE.AFTER_READ, identifiable); }
/** * (Internal only) */ protected static void deleteEdgeIfAny(final OIdentifiable iRecord, boolean forceReload) { if (iRecord != null) { final ODocument doc = getDocument(iRecord, forceReload); if (doc != null) { final OImmutableClass clazz = ODocumentInternal.getImmutableSchemaClass(doc); if (clazz != null && clazz.isEdgeType()) // DELETE THE EDGE RECORD TOO doc.delete(); } } }
protected void checkClass() { // FORCE EARLY UNMARSHALLING final ODocument doc = getRecord(); doc.deserializeFields(); final OClass cls = ODocumentInternal.getImmutableSchemaClass(doc); if (cls == null || !cls.isSubClassOf(getBaseClassName())) throw new IllegalArgumentException("The document received is not a " + getElementType() + ". Found class '" + cls + "'"); }
protected OClass serializeClass(final ODocument document, final BytesContainer bytes) { final OClass clazz = ODocumentInternal.getImmutableSchemaClass(document); String name = null; if (clazz != null) name = clazz.getName(); if (name == null) name = document.getClassName(); if (name != null) writeString(bytes, name); else writeEmptyString(bytes); return clazz; }
protected OClass serializeClass(final ODocument document, final BytesContainer bytes, boolean serializeClassName) { final OClass clazz = ODocumentInternal.getImmutableSchemaClass(document); if (serializeClassName) { if (clazz != null && document.isEmbedded()) writeString(bytes, clazz.getName()); else writeEmptyString(bytes); } return clazz; }
protected Object v2v(final OrientBaseGraph graph, final OIdentifiable iRecord, final Direction iDirection, final String[] iLabels) { final ODocument rec = iRecord.getRecord(); OImmutableClass immutableClass = ODocumentInternal.getImmutableSchemaClass(rec); if (immutableClass != null && immutableClass.isVertexType()) { // VERTEX final OrientVertex vertex = graph.getVertex(rec); if (vertex != null) return vertex.getVertices(iDirection, iLabels); } return null; }
protected Object v2e(final OrientBaseGraph graph, final OIdentifiable iRecord, final Direction iDirection, final String[] iLabels) { final ODocument rec = iRecord.getRecord(); OImmutableClass immutableClass = ODocumentInternal.getImmutableSchemaClass(rec); if (immutableClass != null && immutableClass.isVertexType()) { // VERTEX final OrientVertex vertex = graph.getVertex(rec); if (vertex != null) return vertex.getEdges(iDirection, iLabels); } return null; }
protected OClass serializeClass(final ODocument document, final BytesContainer bytes) { final OClass clazz = ODocumentInternal.getImmutableSchemaClass(document); String name = null; if (clazz != null) name = clazz.getName(); if (name == null) name = document.getClassName(); if (name != null) writeString(bytes, name); else writeEmptyString(bytes); return clazz; }
@Override public void beforeDeleteOperations(OIdentifiable id, String iClusterName) { checkClusterSecurity(ORole.PERMISSION_DELETE, id, iClusterName); if (id instanceof ODocument) { ODocument doc = (ODocument) id; OImmutableClass clazz = ODocumentInternal.getImmutableSchemaClass(this, doc); if (clazz != null) { if (clazz.isTriggered()) { OClassTrigger.onRecordBeforeDelete(doc, this); } if (clazz.isRestricted()) { if (!ORestrictedAccessHook.isAllowed(this, doc, ORestrictedOperation.ALLOW_DELETE, true)) throw new OSecurityException("Cannot delete record " + doc.getIdentity() + ": the resource has restricted access"); } } } callbackHooks(ORecordHook.TYPE.BEFORE_DELETE, id); }
private Object getLabel(final OrientBaseGraph graph, final OIdentifiable iCurrentRecord) { final ODocument rec = iCurrentRecord.getRecord(); OClass klass = ODocumentInternal.getImmutableSchemaClass(rec); if (klass == null && ODatabaseRecordThreadLocal.instance().getIfDefined() != null) { ODatabaseRecordThreadLocal.instance().getIfDefined().getMetadata().reload(); klass = rec.getSchemaClass(); } if (klass.isVertexType()) { // VERTEX final OrientVertex vertex = graph.getVertex(iCurrentRecord); return vertex.getLabel(); } else if (klass.isEdgeType()) { // EDGE final OrientEdge edge = graph.getEdge(iCurrentRecord); return edge.getLabel(); } else throw new OCommandExecutionException("Invalid record: is neither a vertex nor an edge. Found class: " + klass); }