ParentChildWorkflow model, boolean isCondition,
Map<String, Class<? extends WorkflowProcessor>> modelToProcessorMap)
throws Exception {
WorkflowProcessor wp = modelToProcessorMap.get(
model.getGraph().getExecutionType()).newInstance();
WorkflowLifecycle wLifecycle = lifecycle.getLifecycleForWorkflow(model) != null ? lifecycle
.getLifecycleForWorkflow(model) : lifecycle.getDefaultLifecycle();
// FIXME: I'm not sure what these excused processor Ids are. I didn't seem
// need them in the PackagedWorkflowRepository, so not sure what they do.
// wp.setExcusedSubProcessorIds(model.getGraph().getExcusedSubProcessorIds());
wp.getWorkflowInstance().setId(instanceId);
wp.setConditionProcessor(isCondition);
wp.setExecutionType(model.getGraph().getExecutionType());
if (model.getPreConditions() != null)
wp.setPreConditions(buildProcessor(instanceId, model,
modelToProcessorMap, true));
if (model.getPostConditions() != null)
wp.setPostConditions(buildProcessor(instanceId, model,
modelToProcessorMap, false));
wp.setPriority(Priority.getDefault());
wp.setMinReqSuccessfulSubProcessors(Integer.parseInt(model.getGraph()
.getMinReqSuccessfulSubProcessors()));
wp.setStaticMetadata(new Metadata());
wp.setState(wLifecycle.createState("Loaded", wLifecycle
.getStageForWorkflow("Loaded").getName(), ""));
if (wp instanceof TaskProcessor)
((TaskProcessor) wp)
.setInstanceClass((Class<? extends WorkflowTaskInstance>) Class
.forName(model.getGraph().getTask().getTaskInstanceClassName()));