Package com.impetus.kundera.graph

Examples of com.impetus.kundera.graph.ObjectGraph


            throw new IllegalArgumentException(
                    "Entity object is invalid, operation failed. Please check previous log message for details");
        }

        // Create an object graph of the entity object.
        ObjectGraph graph = new GraphGenerator().generateGraph(e, this);
        // Call persist on each node in object graph.
        Node node = graph.getHeadNode();
        try
        {
            // Get write lock before writing object required for transaction.
            lock.writeLock().lock();

            node.setPersistenceDelegator(this);
            node.persist();

            // build flush stack.
            flushManager.buildFlushStack(node, com.impetus.kundera.persistence.context.EventLog.EventType.INSERT);

            // Flushing data.
            flush();

            // Add node to persistence context after successful flush.
            getPersistenceCache().getMainCache().addHeadNode(node);
        }
        finally
        {
            lock.writeLock().unlock();
        }

        // Unlocking object.
        graph.clear();
        graph = null;
        if (log.isDebugEnabled())
        {
            log.debug("Data persisted successfully for entity {}.", e.getClass());
        }
View Full Code Here


        }

        EntityMetadata metadata = getMetadata(e.getClass());

        // Create an object graph of the entity object
        ObjectGraph graph = new GraphGenerator().generateGraph(e, this, new ManagedState());

        Node node = graph.getHeadNode();

        try
        {
            lock.writeLock().lock();

            // TODO : push into action queue, get original end-point from
            // persistenceContext first!

            // Action/ExecutionQueue/ActivityQueue :-> id, name, EndPoint,
            // changed
            // state

            // Change state of node, after successful flush processing.
            node.setPersistenceDelegator(this);
            node.remove();

            // build flush stack.

            flushManager.buildFlushStack(node, EventType.DELETE);

            // Flush node.
            flush();
        }
        finally
        {
            lock.writeLock().unlock();
        }
        // clear out graph
        graph.clear();
        graph = null;

        if (log.isDebugEnabled())
        {
            log.debug("Data removed successfully for entity : " + e.getClass());
View Full Code Here

        }

        EntityMetadata m = getMetadata(e.getClass());

        // Create an object graph of the entity object to be merged
        ObjectGraph graph = new GraphGenerator().generateGraph(e, this);

        // Call merge on each node in object graph
        Node node = graph.getHeadNode();

        try
        {
            lock.writeLock().lock();
            // Change node's state after successful flush.
            node.setPersistenceDelegator(this);
            node.merge();

            // build flush stack.
            flushManager.buildFlushStack(node, EventType.UPDATE);

            flush();
        }
        finally
        {
            lock.writeLock().unlock();
        }
        graph.clear();
        graph = null;

        return (E) node.getData();
    }
View Full Code Here

        Store store = new Store(1, "Food Bazaar, Noida");
        store.addCounter(new BillingCounter(1, "A"));
        store.addCounter(new BillingCounter(2, "B"));
        store.addCounter(new BillingCounter(3, "C"));

        ObjectGraph graph = graphBuilder.getObjectGraph(store, null);

        Assert.assertNotNull(graph);
        Node headNode = graph.getHeadNode();
        Map<String, Node> nodeMappings = graph.getNodeMapping();

        Assert.assertNotNull(headNode);
        Assert.assertNotNull(nodeMappings);
        Assert.assertFalse(nodeMappings.isEmpty());
        Assert.assertEquals(4, nodeMappings.size());
View Full Code Here

        Store store = new Store(1, "Food Bazaar, Noida");
        store.addCounter(new BillingCounter(1, "A"));
        store.addCounter(new BillingCounter(2, "B"));
        store.addCounter(new BillingCounter(3, "C"));

        ObjectGraph graph = graphBuilder.getObjectGraph(store, null);

        pc.getMainCache().addGraphToCache(graph, pc);

        Assert.assertNotNull(pc.getMainCache());
        Assert.assertEquals(1, pc.getMainCache().getHeadNodes().size());
View Full Code Here

        Store store = new Store(1, "Food Bazaar, Noida");
        store.addCounter(new BillingCounter(1, "A"));
        store.addCounter(new BillingCounter(2, "B"));
        store.addCounter(new BillingCounter(3, "C"));

        ObjectGraph graph = graphBuilder.getObjectGraph(store, null);

        pc.getMainCache().addGraphToCache(graph, pc);

        Assert.assertNotNull(pc.getMainCache());
        Assert.assertEquals(1, pc.getMainCache().getHeadNodes().size());
View Full Code Here

        PhotoUni_1_1_1_1 c = new PhotoUni_1_1_1_1();
        c.setPhotoId("c1");
        a.setAlbum(b);
        b.setPhoto(c);

        ObjectGraph graph = graphBuilder.getObjectGraph(a, null);
        pc.getMainCache().addGraphToCache(graph, pc);

        PersistenceDelegator pd = new PersistenceDelegator(emfImpl.getKunderaMetadataInstance(), pc);

        Node headNode = pc.getMainCache()
                .getNodeFromCache(ObjectGraphUtils.getNodeId("c1", PhotoUni_1_1_1_1.class), pd);

        markAllNodeAsDirty();
        flushManager.buildFlushStack(graph.getHeadNode(), EventType.INSERT);

        Deque<Node> fs = flushManager.getFlushStack();
        Assert.assertEquals(3, fs.size());
    }
View Full Code Here

        c.setPhotoId("c1");

        b.setPhotographer(a);
        b.setPhoto(c);

        ObjectGraph graph = graphBuilder.getObjectGraph(b, null);
        pc.getMainCache().addGraphToCache(graph, pc);

        markAllNodeAsDirty();
        flushManager.buildFlushStack(graph.getHeadNode(), EventType.INSERT);

        Deque<Node> fs = flushManager.getFlushStack();
        Assert.assertEquals(2, fs.size());
    }
View Full Code Here

        a.setAlbum(b);
        b.addPhoto(c1);
        b.addPhoto(c2);
        b.addPhoto(c3);

        ObjectGraph graph = graphBuilder.getObjectGraph(a, null);
        pc.getMainCache().addGraphToCache(graph, pc);

        markAllNodeAsDirty();
        flushManager.buildFlushStack(graph.getHeadNode(), EventType.INSERT);
        Deque<Node> fs = flushManager.getFlushStack();
        Assert.assertEquals(5, fs.size());
    }
View Full Code Here

        a.setAlbum(b1);
        b1.setPhoto(c);
        b2.setPhoto(c);
        b3.setPhoto(c);

        ObjectGraph graph = graphBuilder.getObjectGraph(a, null);
        ObjectGraph graphb2 = graphBuilder.getObjectGraph(b2, null);
        ObjectGraph graphb3 = graphBuilder.getObjectGraph(b3, null);

        pc.getMainCache().addGraphToCache(graph, pc);
        pc.getMainCache().addGraphToCache(graphb2, pc);
        pc.getMainCache().addGraphToCache(graphb3, pc);

        markAllNodeAsDirty();
        flushManager.buildFlushStack(graph.getHeadNode(), EventType.INSERT);
        Deque<Node> fs = flushManager.getFlushStack();
        Assert.assertEquals(3, fs.size());
        flushManager.clearFlushStack();
        flushManager = new FlushManager();
        flushManager.buildFlushStack(graphb2.getHeadNode(), EventType.INSERT);
        fs = flushManager.getFlushStack();
        Assert.assertEquals(2, fs.size());
        flushManager.clearFlushStack();
        flushManager = new FlushManager();
        flushManager.buildFlushStack(graphb3.getHeadNode(), EventType.INSERT);
        fs = flushManager.getFlushStack();
        Assert.assertEquals(2, fs.size());
        flushManager.clearFlushStack();
    }
View Full Code Here

TOP

Related Classes of com.impetus.kundera.graph.ObjectGraph

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.