Collection toTrans = null;
try {
toTrans = toActivity.getRelated("ToWorkflowTransition");
} catch (GenericEntityException e) {
throw new WfException(e.getMessage(), e);
}
// get a list of followed transition to this activity
Collection followed = null;
try {
Map fields = new HashMap();
fields.put("processWorkEffortId", dataObject.getString("workEffortId"));
fields.put("toActivityId", toActivity.getString("activityId"));
followed = getDelegator().findByAnd("WorkEffortTransBox", fields);
} catch (GenericEntityException e) {
throw new WfException(e.getMessage(), e);
}
if (Debug.verboseOn()) Debug.logVerbose("[WfProcess.joinTransition] : toTrans (" + toTrans.size() + ") followed (" +
(followed.size() + 1) + ")", module);
// check to see if all transition requirements are met
if (toTrans.size() == (followed.size() + 1)) {
Debug.logVerbose("[WfProcess.joinTransition] : All transitions have followed.", module);
startActivity(toActivity);
try {
Map fields = new HashMap();
fields.put("processWorkEffortId", dataObject.getString("workEffortId"));
fields.put("toActivityId", toActivity.getString("activityId"));
getDelegator().removeByAnd("WorkEffortTransBox", fields);
} catch (GenericEntityException e) {
throw new WfException(e.getMessage(), e);
}
} else {
Debug.logVerbose("[WfProcess.joinTransition] : Waiting for transitions to finish.", module);
try {
Map fields = new HashMap();
fields.put("processWorkEffortId", dataObject.getString("workEffortId"));
fields.put("toActivityId", toActivity.getString("activityId"));
fields.put("transitionId", transition.getString("transitionId"));
GenericValue obj = getDelegator().makeValue("WorkEffortTransBox", fields);
getDelegator().create(obj);
} catch (GenericEntityException e) {
throw new WfException(e.getMessage(), e);
}
}
}