+ this.rootNode.sort();
+ }
+
+ public UpdateTree(Session session, GraphChanges changes, UpdateOperations updateOps) throws DatabaseException {
+ this(session, changes, updateOps, new NullProgressMonitor());
+ }
+
+ public UpdateTree(Session session, GraphChanges changes, UpdateOperations updateOps, IProgressMonitor monitor) throws DatabaseException {
+ this.changes = changes;
+ this.nodes = new HashMap<Resource, UpdateNode>();
+ this.rootNode = session.syncRequest(new NodeRequest(UpdateStatus.EXIST, changes.getResource1()));
+ nodes.put(changes.getResource1(), rootNode);
+ nodes.put(changes.getResource2(), rootNode);
+ this.updateOps = updateOps;
+ this.updateOps.populate(session, monitor);
+ populate(session, monitor);
+ if (monitor.isCanceled()) {
+ this.changes = null;
+ this.nodes.clear();
+ this.updateOps = null;
+ this.rootNode = null;
+ } else {
+ this.rootNode.sort();
+ }
+ }
+
+ private class NodeRequest extends ResourceRead<UpdateNode> {
+ UpdateStatus status;
+ public NodeRequest(UpdateStatus status, Resource r) {
+ super(r);
+ this.status = status;
+ }
+ @Override
+ public UpdateNode perform(ReadGraph graph) throws DatabaseException {
+ return createNode(graph, status, resource);
+ }