P_YIdentifier pid = runner.get_standin_caseIDForNet();
if (runner.getContainingTaskID() == null) {
// This is a root net runner
YIdentifier id = restoreYID(pmgr, runnermap, idtoid, pid, null, runner.getYNetID(), net);
runner.set_caseIDForNet(id);
addRunner(runner);
}
YIdentifier yid = new YIdentifier(runner.get_caseID());
YWorkItemRepository.getInstance().setNetRunnerToCaseIDBinding(runner, yid);
Set busytasks = runner.getBusyTaskNames();
for (Iterator busyit = busytasks.iterator(); busyit.hasNext();) {
String name = (String) busyit.next();
YExternalNetElement element = net.getNetElement(name);
runner.addBusyTask(element);
}
Set enabledtasks = runner.getEnabledTaskNames();
for (Iterator enabit = enabledtasks.iterator(); enabit.hasNext();) {
String name = (String) enabit.next();
YExternalNetElement element = net.getNetElement(name);
if (element instanceof YTask) {
YTask externalTask = (YTask) element;
runner.addEnabledTask(externalTask);
}
}
}
// restore case & exception observers (where they exist)
for (int i = 0; i < runners.size(); i++) {
YNetRunner runner = (YNetRunner) runners.get(i);
runner.restoreObservers();
}
logger.info("Restoring process instances - Ends");
logger.info("Restoring work items - Starts");
query = pmgr.createQuery("from au.edu.qut.yawl.engine.YWorkItem");
for (Iterator it = query.iterate(); it.hasNext();) {
YWorkItem witem = (YWorkItem) it.next();
if (witem.getStatus().equals(YWorkItem.statusEnabled)) {
witem.setStatus(YWorkItem.statusEnabled);
}
if (witem.getStatus().equals(YWorkItem.statusFired)) {
witem.setStatus(YWorkItem.statusFired);
}
if (witem.getStatus().equals(YWorkItem.statusExecuting)) {
witem.setStatus(YWorkItem.statusExecuting);
}
if (witem.getStatus().equals(YWorkItem.statusComplete)) {
witem.setStatus(YWorkItem.statusComplete);
}
if (witem.getStatus().equals(YWorkItem.statusIsParent)) {
witem.setStatus(YWorkItem.statusIsParent);
}
if (witem.getStatus().equals(YWorkItem.statusDeadlocked)) {
witem.setStatus(YWorkItem.statusDeadlocked);
}
if (witem.getStatus().equals(YWorkItem.statusDeleted)) {
witem.setStatus(YWorkItem.statusDeleted);
}
if (witem.getStatus().equals(YWorkItem.statusForcedComplete)) {
witem.setStatus(YWorkItem.statusForcedComplete);
}
if (witem.getStatus().equals(YWorkItem.statusFailed)) {
witem.setStatus(YWorkItem.statusFailed);
}
if (witem.getStatus().equals(YWorkItem.statusSuspended)) {
witem.setStatus(YWorkItem.statusSuspended);
}
if (witem.getData_string() != null) {
StringReader reader = new StringReader(witem.getData_string());
SAXBuilder builder = new SAXBuilder();
Document data = builder.build(reader);
witem.setInitData(data.getRootElement());
}
java.util.StringTokenizer st = new java.util.StringTokenizer(witem.getThisId(), ":");
String caseandid = st.nextToken();
java.util.StringTokenizer st2 = new java.util.StringTokenizer(caseandid, ".");
//String caseid =
st2.nextToken();
String taskid = st.nextToken();
// AJH: Strip off unique ID to obtain our taskID
{
java.util.StringTokenizer st3 = new java.util.StringTokenizer(taskid, "!");
taskid = st3.nextToken();
}
YIdentifier workitemid = (YIdentifier) idtoid.get(caseandid);
if (workitemid != null) {
witem.setWorkItemID(new YWorkItemID(workitemid, taskid));
witem.addToRepository();
} else {
pmgr.deleteObject(witem);