Search in sources :

Example 1 with ObjectStoreGraphDiff

use of org.apache.cayenne.access.ObjectStoreGraphDiff in project cayenne by apache.

the class DefaultDataDomainFlushAction method flush.

@Override
public GraphDiff flush(DataContext context, GraphDiff changes) {
    CompoundDiff afterCommitDiff = new CompoundDiff();
    if (changes == null) {
        return afterCommitDiff;
    }
    if (!(changes instanceof ObjectStoreGraphDiff)) {
        throw new CayenneRuntimeException("Instance of ObjectStoreGraphDiff expected, got %s", changes.getClass());
    }
    ObjectStore objectStore = context.getObjectStore();
    ObjectStoreGraphDiff objectStoreGraphDiff = (ObjectStoreGraphDiff) changes;
    List<DbRowOp> dbRowOps = createDbRowOps(objectStore, objectStoreGraphDiff);
    updateObjectIds(dbRowOps);
    List<DbRowOp> deduplicatedOps = mergeSameObjectIds(dbRowOps);
    List<DbRowOp> filteredOps = filterOps(deduplicatedOps);
    List<DbRowOp> sortedOps = sort(filteredOps);
    List<? extends Query> queries = createQueries(sortedOps);
    executeQueries(queries);
    createReplacementIds(objectStore, afterCommitDiff, sortedOps);
    postprocess(context, objectStoreGraphDiff, afterCommitDiff, sortedOps);
    return afterCommitDiff;
}
Also used : ObjectStoreGraphDiff(org.apache.cayenne.access.ObjectStoreGraphDiff) ObjectStore(org.apache.cayenne.access.ObjectStore) DbRowOp(org.apache.cayenne.access.flush.operation.DbRowOp) UpdateDbRowOp(org.apache.cayenne.access.flush.operation.UpdateDbRowOp) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) CompoundDiff(org.apache.cayenne.graph.CompoundDiff)

Aggregations

CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)1 ObjectStore (org.apache.cayenne.access.ObjectStore)1 ObjectStoreGraphDiff (org.apache.cayenne.access.ObjectStoreGraphDiff)1 DbRowOp (org.apache.cayenne.access.flush.operation.DbRowOp)1 UpdateDbRowOp (org.apache.cayenne.access.flush.operation.UpdateDbRowOp)1 CompoundDiff (org.apache.cayenne.graph.CompoundDiff)1