Package org.apache.cayenne.graph

Examples of org.apache.cayenne.graph.GraphManager


        Persistent object = (Persistent) obj;

        object.setObjectContext(this);
        object.setPersistenceState(PersistenceState.NEW);

        GraphManager graphManager = getGraphManager();
        synchronized (graphManager) {
            graphManager.registerNode(object.getObjectId(), object);
            graphManager.nodeCreated(object.getObjectId());
        }

        ObjEntity entity;
        try {
            entity = getEntityResolver().lookupObjEntity(object.getClass());
View Full Code Here


        Persistent object = (Persistent) obj;

        object.setObjectContext(this);
        object.setPersistenceState(PersistenceState.NEW);

        GraphManager graphManager = getGraphManager();
        synchronized (graphManager) {
            graphManager.registerNode(object.getObjectId(), object);
            graphManager.nodeCreated(object.getObjectId());
        }

        ObjEntity entity;
        try {
            entity = getEntityResolver().lookupObjEntity(object.getClass());
View Full Code Here

        Persistent object = (Persistent) obj;

        object.setObjectContext(this);
        object.setPersistenceState(PersistenceState.NEW);

        GraphManager graphManager = getGraphManager();
        synchronized (graphManager) {
            graphManager.registerNode(object.getObjectId(), object);
            graphManager.nodeCreated(object.getObjectId());
        }

        ObjEntity entity;
        try {
            entity = getEntityResolver().getObjEntity(object.getClass());
View Full Code Here

        Persistent object = (Persistent) obj;

        object.setObjectContext(this);
        object.setPersistenceState(PersistenceState.NEW);

        GraphManager graphManager = getGraphManager();
        synchronized (graphManager) {
            graphManager.registerNode(object.getObjectId(), object);
            graphManager.nodeCreated(object.getObjectId());
        }

        ObjEntity entity;
        try {
            entity = getEntityResolver().lookupObjEntity(object.getClass());
View Full Code Here

        Persistent object = (Persistent) obj;

        object.setObjectContext(this);
        object.setPersistenceState(PersistenceState.NEW);

        GraphManager graphManager = getGraphManager();
        synchronized (graphManager) {
            graphManager.registerNode(object.getObjectId(), object);
            graphManager.nodeCreated(object.getObjectId());
        }

        ObjEntity entity;
        try {
            entity = getEntityResolver().lookupObjEntity(object.getClass());
View Full Code Here

        ObjectId id = peerInParentContext.getObjectId();

        ClassDescriptor descriptor = context.getEntityResolver().getClassDescriptor(
                id.getEntityName());

        GraphManager graphManager = context.getGraphManager();

        // have to synchronize almost the entire method to prevent multiple threads from
        // messing up dataobjects per CAY-845.
        synchronized (graphManager) {
            T object = (T) graphManager.getNode(id);

            // merge into an existing object
            if (object == null) {
                object = (T) descriptor.createObject();
                object.setObjectContext(context);
                object.setObjectId(id);

                if (peerState == PersistenceState.HOLLOW) {
                    object.setPersistenceState(PersistenceState.HOLLOW);
                }
                else {
                    object.setPersistenceState(PersistenceState.COMMITTED);
                }

                graphManager.registerNode(id, object);
            }

            // TODO: Andrus, 1/24/2006 implement smart merge for modified objects...
            if (peerState != PersistenceState.HOLLOW
                    && object.getPersistenceState() != PersistenceState.MODIFIED
View Full Code Here

*/
public class ContextStateRecorderTest extends TestCase {

    public void testDirtyNodesInState() {

        GraphManager map = new MockGraphManager();
        ObjectContextStateLog recorder = new ObjectContextStateLog(map);

        // check for null collections
        assertNotNull(recorder.dirtyNodes(PersistenceState.MODIFIED));
        assertNotNull(recorder.dirtyNodes(PersistenceState.COMMITTED));
        assertNotNull(recorder.dirtyNodes(PersistenceState.DELETED));
        assertNotNull(recorder.dirtyNodes(PersistenceState.NEW));
        assertNotNull(recorder.dirtyNodes(PersistenceState.TRANSIENT));
        assertNotNull(recorder.dirtyNodes(PersistenceState.HOLLOW));

        assertTrue(recorder.dirtyNodes(PersistenceState.MODIFIED).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.COMMITTED).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.DELETED).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.NEW).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.TRANSIENT).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.HOLLOW).isEmpty());

        MockPersistentObject modified = new MockPersistentObject();
        modified.setObjectId(new ObjectId("MockPersistentObject", "key", "value1"));
        modified.setPersistenceState(PersistenceState.MODIFIED);
        map.registerNode(modified.getObjectId(), modified);
        recorder.nodePropertyChanged(modified.getObjectId(), "a", "b", "c");

        assertTrue(recorder.dirtyNodes(PersistenceState.MODIFIED).contains(modified));
        assertTrue(recorder.dirtyNodes(PersistenceState.COMMITTED).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.DELETED).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.NEW).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.TRANSIENT).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.HOLLOW).isEmpty());

        MockPersistentObject deleted = new MockPersistentObject();
        deleted.setObjectId(new ObjectId("MockPersistentObject", "key", "value2"));
        deleted.setPersistenceState(PersistenceState.DELETED);
        map.registerNode(deleted.getObjectId(), deleted);
        recorder.nodeRemoved(deleted.getObjectId());

        assertTrue(recorder.dirtyNodes(PersistenceState.MODIFIED).contains(modified));
        assertTrue(recorder.dirtyNodes(PersistenceState.COMMITTED).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.DELETED).contains(deleted));
View Full Code Here

        assertTrue(recorder.dirtyNodes(PersistenceState.TRANSIENT).isEmpty());
        assertTrue(recorder.dirtyNodes(PersistenceState.HOLLOW).isEmpty());
    }

    public void testDirtyNodes() {
        GraphManager map = new MockGraphManager();
        ObjectContextStateLog recorder = new ObjectContextStateLog(map);

        assertNotNull(recorder.dirtyNodes());
        assertTrue(recorder.dirtyNodes().isEmpty());

        // introduce a fake dirty object
        MockPersistentObject object = new MockPersistentObject();
        object.setObjectId(new ObjectId("MockPersistentObject", "key", "value"));
        object.setPersistenceState(PersistenceState.MODIFIED);
        map.registerNode(object.getObjectId(), object);
        recorder.nodePropertyChanged(object.getObjectId(), "a", "b", "c");

        assertTrue(recorder.dirtyNodes().contains(object));

        // must go away on clear...
View Full Code Here

        Persistent object = (Persistent) obj;

        object.setObjectContext(this);
        object.setPersistenceState(PersistenceState.NEW);

        GraphManager graphManager = getGraphManager();
        synchronized (graphManager) {
            graphManager.registerNode(object.getObjectId(), object);
            graphManager.nodeCreated(object.getObjectId());
        }

        ObjEntity entity;
        try {
            entity = getEntityResolver().lookupObjEntity(object.getClass());
View Full Code Here

TOP

Related Classes of org.apache.cayenne.graph.GraphManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.