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;
}
Aggregations