Search in sources :

Example 16 with OObjectProxyMethodHandler

use of com.orientechnologies.orient.object.enhancement.OObjectProxyMethodHandler in project orientdb by orientechnologies.

the class OObjectLazyList method set.

public TYPE set(int index, TYPE element) {
    OIdentifiable record;
    if (element instanceof OIdentifiable) {
        record = (OIdentifiable) element;
        if (converted)
            converted = false;
        if (orphanRemoval && record != null && sourceRecord != null)
            ((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
        recordList.set(index, record);
    } else if (element instanceof Proxy) {
        record = (OIdentifiable) OObjectEntitySerializer.getDocument((Proxy) element);
        if (orphanRemoval && record != null && sourceRecord != null)
            ((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
        recordList.set(index, record);
    } else {
        element = (TYPE) OObjectEntitySerializer.serializeObject(element, getDatabase());
        record = getDatabase().getRecordByUserObject(element, false);
        if (orphanRemoval && record != null && sourceRecord != null)
            ((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
        recordList.add(index, record);
    }
    setDirty();
    return (TYPE) super.set(index, element);
}
Also used : Proxy(javassist.util.proxy.Proxy) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) OObjectProxyMethodHandler(com.orientechnologies.orient.object.enhancement.OObjectProxyMethodHandler)

Example 17 with OObjectProxyMethodHandler

use of com.orientechnologies.orient.object.enhancement.OObjectProxyMethodHandler in project orientdb by orientechnologies.

the class OObjectLazyList method add.

public boolean add(TYPE element) {
    boolean dirty = false;
    OIdentifiable record;
    if (element instanceof OIdentifiable) {
        record = (OIdentifiable) element;
        if (converted)
            converted = false;
        if (recordList.add(record)) {
            setDirty();
            if (orphanRemoval && record != null && sourceRecord != null)
                ((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
            return true;
        }
    } else if (element instanceof Proxy) {
        record = (OIdentifiable) OObjectEntitySerializer.getDocument((Proxy) element);
        if (orphanRemoval && record != null && sourceRecord != null)
            ((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
        dirty = recordList.add(record);
    } else {
        element = (TYPE) OObjectEntitySerializer.serializeObject(element, getDatabase());
        record = (OIdentifiable) OObjectEntitySerializer.getDocument((Proxy) element);
        if (orphanRemoval && record != null && sourceRecord != null)
            ((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
        dirty = recordList.add(record);
    }
    if (dirty)
        setDirty();
    return super.add(element);
}
Also used : Proxy(javassist.util.proxy.Proxy) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) OObjectProxyMethodHandler(com.orientechnologies.orient.object.enhancement.OObjectProxyMethodHandler)

Aggregations

OObjectProxyMethodHandler (com.orientechnologies.orient.object.enhancement.OObjectProxyMethodHandler)17 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)12 ProxyObject (javassist.util.proxy.ProxyObject)6 ORID (com.orientechnologies.orient.core.id.ORID)5 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)4 Proxy (javassist.util.proxy.Proxy)4 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)3 ORecord (com.orientechnologies.orient.core.record.ORecord)2 ConcurrentModificationException (java.util.ConcurrentModificationException)1 HashSet (java.util.HashSet)1