Search in sources :

Example 1 with NodeCreateOperation

use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.

the class ObjectStore method nodeCreated.

/**
 * @since 1.2
 */
@Override
public void nodeCreated(Object nodeId) {
    NodeDiff diff = new NodeCreateOperation(nodeId);
    if (lifecycleEventInducedChanges != null) {
        registerLifecycleEventInducedChange(diff);
    }
    registerDiff(nodeId, diff);
}
Also used : NodeCreateOperation(org.apache.cayenne.graph.NodeCreateOperation) NodeDiff(org.apache.cayenne.graph.NodeDiff)

Example 2 with NodeCreateOperation

use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.

the class CayenneContextGraphManager method nodeCreated.

@Override
public synchronized void nodeCreated(Object nodeId) {
    stateLog.nodeCreated(nodeId);
    processChange(new NodeCreateOperation(nodeId));
}
Also used : NodeCreateOperation(org.apache.cayenne.graph.NodeCreateOperation)

Example 3 with NodeCreateOperation

use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.

the class ObjectContextChangeLogTest method testGetDiffsSerializable.

@Test
public void testGetDiffsSerializable() throws Exception {
    ObjectContextChangeLog recorder = new ObjectContextChangeLog();
    recorder.addOperation(new NodeCreateOperation(new ObjectId("test")));
    CompoundDiff diff = (CompoundDiff) recorder.getDiffs();
    Object clone = Util.cloneViaSerialization(diff);
    assertNotNull(clone);
    assertTrue(clone instanceof CompoundDiff);
    CompoundDiff d1 = (CompoundDiff) clone;
    assertEquals(1, d1.getDiffs().size());
}
Also used : NodeCreateOperation(org.apache.cayenne.graph.NodeCreateOperation) CompoundDiff(org.apache.cayenne.graph.CompoundDiff) Test(org.junit.Test)

Example 4 with NodeCreateOperation

use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.

the class ObjectContextChangeLogTest method testReset.

@Test
public void testReset() {
    ObjectContextChangeLog recorder = new ObjectContextChangeLog();
    assertNotNull(recorder.getDiffs());
    assertTrue(recorder.getDiffs().isNoop());
    recorder.addOperation(new NodeCreateOperation(new Object()));
    assertNotNull(recorder.getDiffs());
    assertFalse(recorder.getDiffs().isNoop());
    recorder.reset();
    assertNotNull(recorder.getDiffs());
    assertTrue(recorder.getDiffs().isNoop());
    // now test that a diff stored before "clear" is not affected by 'clear'
    recorder.addOperation(new NodeCreateOperation(new Object()));
    GraphDiff diff = recorder.getDiffs();
    assertFalse(diff.isNoop());
    recorder.reset();
    assertFalse(diff.isNoop());
}
Also used : NodeCreateOperation(org.apache.cayenne.graph.NodeCreateOperation) GraphDiff(org.apache.cayenne.graph.GraphDiff) Test(org.junit.Test)

Example 5 with NodeCreateOperation

use of org.apache.cayenne.graph.NodeCreateOperation in project cayenne by apache.

the class ObjectContextChangeLogTest method testGetDiffs.

@Test
public void testGetDiffs() {
    // assert that after returning, the diffs array won't get modified by
    // operation
    // recorder
    ObjectContextChangeLog recorder = new ObjectContextChangeLog();
    recorder.addOperation(new NodeCreateOperation(new Object()));
    CompoundDiff diff = (CompoundDiff) recorder.getDiffs();
    assertEquals(1, diff.getDiffs().size());
    recorder.addOperation(new NodeCreateOperation(new Object()));
    assertEquals(1, diff.getDiffs().size());
    CompoundDiff diff2 = (CompoundDiff) recorder.getDiffs();
    assertEquals(2, diff2.getDiffs().size());
}
Also used : NodeCreateOperation(org.apache.cayenne.graph.NodeCreateOperation) CompoundDiff(org.apache.cayenne.graph.CompoundDiff) Test(org.junit.Test)

Aggregations

NodeCreateOperation (org.apache.cayenne.graph.NodeCreateOperation)9 Test (org.junit.Test)7 CompoundDiff (org.apache.cayenne.graph.CompoundDiff)4 GraphDiff (org.apache.cayenne.graph.GraphDiff)3 EntityResolver (org.apache.cayenne.map.EntityResolver)2 ObjectContext (org.apache.cayenne.ObjectContext)1 ObjectId (org.apache.cayenne.ObjectId)1 NodeDiff (org.apache.cayenne.graph.NodeDiff)1 SelectQuery (org.apache.cayenne.query.SelectQuery)1