if (o == null)
continue;
OIdentifiable id = null;
ODocument doc = null;
final OClass linkedClass;
if (!(o instanceof OIdentifiable)) {
final String fieldBound = OObjectSerializerHelper.getDocumentBoundField(o.getClass());
if (fieldBound != null) {
OObjectSerializerHelper.invokeCallback(o, null, OBeforeSerialization.class);
doc = (ODocument) OObjectSerializerHelper.getFieldValue(o, fieldBound);
OObjectSerializerHelper.invokeCallback(o, doc, OAfterSerialization.class);
id = doc;
}
linkedClass = iLinkedClass;
} else {
id = (OIdentifiable) o;
if (iLinkedType == null)
// AUTO-DETERMINE LINKED TYPE
if (id.getIdentity().isValid())
iLinkedType = OType.LINK;
else
iLinkedType = OType.EMBEDDED;
if (id instanceof ODocument) {
doc = (ODocument) id;
if (id.getIdentity().isTemporary())
doc.save();
linkedClass = doc.getSchemaClass();
} else
linkedClass = null;
}
if (id != null && iLinkedType != OType.LINK)
iOutput.append(OStringSerializerHelper.PARENTHESIS_BEGIN);
if (iLinkedType != OType.LINK && (linkedClass != null || doc != null)) {
if (id == null)
// EMBEDDED OBJECTS
id = OObjectSerializerHelper.toStream(o, new ODocument((ODatabaseRecord) iDatabase, o.getClass().getSimpleName()),
iDatabase instanceof ODatabaseObjectTx ? ((ODatabaseObjectTx) iDatabase).getEntityManager()
: OEntityManagerInternal.INSTANCE, iLinkedClass, iObjHandler != null ? iObjHandler
: new OUserObject2RecordHandler() {
public Object getUserObjectByRecord(ORecordInternal<?> iRecord, final String iFetchPlan) {
return iRecord;
}
public ORecordInternal<?> getRecordByUserObject(Object iPojo, boolean iCreateIfNotAvailable) {
return new ODocument(linkedClass);
}
public boolean existsUserObjectByRID(ORID iRID) {
return false;
}