@Override protected boolean include(final ORecord record) { return record instanceof ODocument && targetClass .isSuperClassOf(ODocumentInternal.getImmutableSchemaClass(((ODocument) record))); }
@Override public Object execute(Object iThis, OIdentifiable iCurrentRecord, OCommandContext iContext, Object ioResult, Object[] iParams) { if (iThis instanceof String) { if (iParams.length > 0) { final ODocument doc = new ODocument().fromJSON(iThis.toString(), iParams[0].toString()); if (iParams[0].toString().contains("embedded")) ODocumentInternal.addOwner(doc, iCurrentRecord.getRecord()); return doc; } return new ODocument().fromJSON(iThis.toString().toString()); } return null; } }
protected void clearDocumentTracking(final ORecord record) { if (record instanceof ODocument && ((ODocument) record).isTrackingChanges()) { ODocumentInternal.clearTrackData((ODocument) record); } }
public void deserializePartial(final ODocument document, final BytesContainer bytes, final String[] iFields) { final String className = readString(bytes); if (className.length() != 0) ODocumentInternal.fillClassNameIfNeeded(document, className); value = deserializeValue(bytes, type, document); if (ODocumentInternal.rawContainsField(document, fieldName)) { continue; ODocumentInternal.rawField(document, fieldName, value, type);
if (pos > -1 && (pos < posFirstValue || posFirstValue == -1)) { if ((record.getIdentity().getClusterId() < 0 || database == null)) ODocumentInternal.fillClassNameIfNeeded(((ODocument) iRecord), iContent.substring(0, pos)); iContent = iContent.substring(pos + 1); } else prop = ODocumentInternal.getImmutableSchemaClass(record) != null ? ODocumentInternal.getImmutableSchemaClass(record).getProperty(fieldName) : null; if (prop != null && prop.getType() != OType.ANY) { ODocumentInternal.fillClassNameIfNeeded(((ODocument) iRecord), value.toString()); } else { record.field(fieldName, value, type);
ODocument doc = new ODocument(); objectToAdd = fromString(item, doc, null); ODocumentInternal.fillClassNameIfNeeded(doc, iLinkedClass.getName()); } else ODocumentInternal.addOwner((ODocument) objectToAdd, (ORecordElement) coll);
OImmutableClass immutableClass = ODocumentInternal.getImmutableSchemaClass(iDocument); if (immutableClass != null) { final OProperty prop = immutableClass.getProperty(fieldName); ODocumentInternal.addOwner(doc, iDocument); ODocumentInternal.addOwner(doc, iDocument); tempColl.add(doc);
final String className = readString(bytes); if (className.length() != 0) ODocumentInternal.fillClassNameIfNeeded(document, className); if (ODocumentInternal.rawContainsField(document, fieldName)) { continue;
if (ODocumentInternal.rawContainsField(document, fieldName)) { cumulativeSize += fieldLength; continue; last = bytes.offset; bytes.offset = headerCursor; ODocumentInternal.rawField(document, fieldName, value, type); } else ODocumentInternal.rawField(document, fieldName, null, null);
final String className = readString(bytes); if (className.length() != 0) ODocumentInternal.fillClassNameIfNeeded(document, className); final Object value = deserializeValue(bytes, type, document); bytes.offset = headerCursor; ODocumentInternal.rawField(document, fieldName, value, type); } else ODocumentInternal.rawField(document, fieldName, null, null);
if (OType.EMBEDDED.equals(fieldType)) { final ODocument embeddedDocument = (ODocument) iPropertyValue; ODocumentInternal.addOwner(embeddedDocument, this); } else if (OType.LINK.equals(fieldType)) { final ODocument embeddedDocument = (ODocument) iPropertyValue; ODocumentInternal.removeOwner(embeddedDocument, this);
private <RET extends ORecord> RET saveInternal(ORecord iRecord, String iClusterName, OPERATION_MODE iMode, boolean iForceCreate, ORecordCallback<? extends Number> iRecordCreatedCallback, ORecordCallback<Integer> iRecordUpdatedCallback) { if (!(iRecord instanceof ODocument)) { assignAndCheckCluster(iRecord, iClusterName); return (RET) currentTx.saveRecord(iRecord, iClusterName, iMode, iForceCreate, iRecordCreatedCallback, iRecordUpdatedCallback); } ODocument doc = (ODocument) iRecord; ODocumentInternal.checkClass(doc, this); // IN TX THE VALIDATION MAY BE RUN TWICE BUT IS CORRECT BECAUSE OF DIFFERENT RECORD STATUS try { doc.validate(); } catch (OValidationException e) { doc.undo(); throw e; } ODocumentInternal.convertAllMultiValuesToTrackedVersions(doc); if (iForceCreate || !doc.getIdentity().isValid()) { if (doc.getClassName() != null) checkSecurity(ORule.ResourceGeneric.CLASS, ORole.PERMISSION_CREATE, doc.getClassName()); assignAndCheckCluster(doc, iClusterName); } else { // UPDATE: CHECK ACCESS ON SCHEMA CLASS NAME (IF ANY) if (doc.getClassName() != null) checkSecurity(ORule.ResourceGeneric.CLASS, ORole.PERMISSION_UPDATE, doc.getClassName()); } doc = (ODocument) currentTx .saveRecord(iRecord, iClusterName, iMode, iForceCreate, iRecordCreatedCallback, iRecordUpdatedCallback); return (RET) doc; }
@Override public void deserializeWithClassName(final ODocument document, final BytesContainer bytes) { final String className = readString(bytes); if (className.length() != 0) ODocumentInternal.fillClassNameIfNeeded(document, className); deserialize(document, bytes); }
protected OGlobalProperty getGlobalProperty(final ODocument document, final int len) { final int id = (len * -1) - 1; return ODocumentInternal.getGlobalPropertyById(document, id); }
ODocumentInternal.checkClass((ODocument) record, this); ORecordSerializationContext.pushContext(); try {
depthLevel = iFieldDepthLevel; fieldValue = ODocumentInternal.getRawProperty(record, fieldName); if (fieldValue == null || !(fieldValue instanceof OIdentifiable) && (!(fieldValue instanceof ORecordLazyMultiValue) || !((ORecordLazyMultiValue) fieldValue).rawIterator().hasNext() || !(((ORecordLazyMultiValue) fieldValue).rawIterator()
for (ORecord rec : newRecord) { if (rec instanceof ODocument) ODocumentInternal.convertAllMultiValuesToTrackedVersions((ODocument) rec); if (rec == iRecord) { recordOperation = addRecord(rec, ORecordOperation.CREATED, iClusterName); for (ORecord rec : updatedRecord) { if (rec instanceof ODocument) ODocumentInternal.convertAllMultiValuesToTrackedVersions((ODocument) rec); if (rec == iRecord) { final byte operation = iForceCreate ?
public void deserialize(final ODocument document, final BytesContainer bytes) { final String className = readString(bytes); if (className.length() != 0) ODocumentInternal.fillClassNameIfNeeded(document, className); String fieldName; OType type; Object value; int size = OVarIntSerializer.readAsInteger(bytes); while ((size--) > 0) { // PARSE FIELD NAME fieldName = readString(bytes); type = readOType(bytes); if (type == null) { value = null; } else { value = deserializeValue(bytes, type, document); } if (ODocumentInternal.rawContainsField(document, fieldName)) { continue; } ODocumentInternal.rawField(document, fieldName, value, type); } ORecordInternal.clearSource(document); }
@Override public void deserializePartialWithClassName(final ODocument document, final BytesContainer bytes, final String[] iFields) { final String className = readString(bytes); if (className.length() != 0) ODocumentInternal.fillClassNameIfNeeded(document, className); deserializePartial(document, bytes, iFields); }
@Override public String[] getFieldNames(ODocument reference, final BytesContainer bytes, boolean deserializeClassName) { // SKIP CLASS NAME final int classNameLen = OVarIntSerializer.readAsInteger(bytes); bytes.skip(classNameLen); final List<String> result = new ArrayList<String>(); String fieldName; while (true) { OGlobalProperty prop = null; final int len = OVarIntSerializer.readAsInteger(bytes); if (len == 0) { // SCAN COMPLETED break; } else if (len > 0) { // PARSE FIELD NAME fieldName = stringFromBytes(bytes.bytes, bytes.offset, len).intern(); result.add(fieldName); // SKIP THE REST bytes.skip(len + OIntegerSerializer.INT_SIZE + 1); } else { // LOAD GLOBAL PROPERTY BY ID final int id = (len * -1) - 1; prop = ODocumentInternal.getGlobalPropertyById(reference, id); result.add(prop.getName()); // SKIP THE REST bytes.skip(OIntegerSerializer.INT_SIZE + (prop.getType() != OType.ANY ? 0 : 1)); } } return result.toArray(new String[result.size()]); }