Search in sources :

Example 1 with ArcOperation

use of org.apache.cayenne.access.ObjectDiff.ArcOperation in project cayenne by apache.

the class ObjectStore method arcCreated.

/**
 * @since 1.2
 */
@Override
public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) {
    NodeDiff diff = new ArcOperation(nodeId, targetNodeId, arcId.toString(), false);
    if (lifecycleEventInducedChanges != null) {
        registerLifecycleEventInducedChange(diff);
    }
    registerDiff(nodeId, diff);
}
Also used : ArcOperation(org.apache.cayenne.access.ObjectDiff.ArcOperation) NodeDiff(org.apache.cayenne.graph.NodeDiff)

Example 2 with ArcOperation

use of org.apache.cayenne.access.ObjectDiff.ArcOperation in project cayenne by apache.

the class DeleteRulesIT method assertJoinDeleted.

private void assertJoinDeleted(DeleteRuleFlatA a, DeleteRuleFlatB b) {
    ObjectDiff changes = context.getObjectStore().changes.get(a.getObjectId());
    assertNotNull(changes);
    Collection<NodeDiff> diffs = new ArrayList<NodeDiff>();
    changes.appendDiffs(diffs);
    Iterator<?> it = diffs.iterator();
    while (it.hasNext()) {
        Object diff = it.next();
        if (diff instanceof ArcOperation) {
            ArcOperation arcDelete = (ArcOperation) diff;
            if (arcDelete.getNodeId().equals(a.getObjectId()) && arcDelete.getTargetNodeId().equals(b.getObjectId()) && arcDelete.getArcId().equals(DeleteRuleFlatA.FLAT_B.getName()) && arcDelete.isDelete()) {
                return;
            }
        }
    }
    fail("Join was not deleted for flattened relationship");
}
Also used : ArcOperation(org.apache.cayenne.access.ObjectDiff.ArcOperation) NodeDiff(org.apache.cayenne.graph.NodeDiff) ArrayList(java.util.ArrayList)

Example 3 with ArcOperation

use of org.apache.cayenne.access.ObjectDiff.ArcOperation in project cayenne by apache.

the class DeleteRulesIT method assertJoinNotDeleted.

private void assertJoinNotDeleted(DeleteRuleFlatA a, DeleteRuleFlatB b) {
    ObjectDiff changes = context.getObjectStore().changes.get(a.getObjectId());
    if (changes != null) {
        Collection<NodeDiff> diffs = new ArrayList<NodeDiff>();
        changes.appendDiffs(diffs);
        Iterator<?> it = diffs.iterator();
        while (it.hasNext()) {
            Object diff = it.next();
            if (diff instanceof ArcOperation) {
                ArcOperation arcDelete = (ArcOperation) diff;
                if (arcDelete.getNodeId().equals(a.getObjectId()) && arcDelete.getTargetNodeId().equals(b.getObjectId()) && arcDelete.getArcId().equals(DeleteRuleFlatA.FLAT_B.getName()) && !arcDelete.isDelete()) {
                    fail("Join was  deleted for flattened relationship");
                }
            }
        }
    }
}
Also used : ArcOperation(org.apache.cayenne.access.ObjectDiff.ArcOperation) NodeDiff(org.apache.cayenne.graph.NodeDiff) ArrayList(java.util.ArrayList)

Example 4 with ArcOperation

use of org.apache.cayenne.access.ObjectDiff.ArcOperation in project cayenne by apache.

the class ObjectStore method arcDeleted.

/**
 * @since 1.2
 */
@Override
public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) {
    NodeDiff diff = new ArcOperation(nodeId, targetNodeId, arcId.toString(), true);
    if (lifecycleEventInducedChanges != null) {
        registerLifecycleEventInducedChange(diff);
    }
    registerDiff((ObjectId) nodeId, diff);
}
Also used : ArcOperation(org.apache.cayenne.access.ObjectDiff.ArcOperation) NodeDiff(org.apache.cayenne.graph.NodeDiff)

Aggregations

ArcOperation (org.apache.cayenne.access.ObjectDiff.ArcOperation)4 NodeDiff (org.apache.cayenne.graph.NodeDiff)4 ArrayList (java.util.ArrayList)2