+ "[" + inst.getId() + "]");
instance.setState(condWorkflowState);
instance.setPriority(inst.getPriority());
WorkflowTask conditionTask = toConditionTask(cond);
instance.setCurrentTaskId(conditionTask.getTaskId());
Graph condGraph = new Graph();
condGraph.setExecutionType("condition");
condGraph.setCond(cond);
condGraph.setTask(conditionTask);
ParentChildWorkflow workflow = new ParentChildWorkflow(condGraph);
workflow.setId("pre-cond-workflow-"
+ inst.getParentChildWorkflow().getId());
workflow.setName("Pre Condition Workflow-" + cond.getConditionName());
workflow.getTasks().add(conditionTask);
instance.setParentChildWorkflow(workflow);
this.addToModelRepo(workflow);
persist(instance);
WorkflowProcessor subProcessor = fromWorkflowInstance(instance);
processor.getSubProcessors().add(subProcessor);
synchronized (processorCache) {
processorCache.put(instance.getId(), subProcessor);
}
}
// handle its tasks
for (WorkflowTask task : inst.getParentChildWorkflow().getTasks()) {
WorkflowInstance instance = new WorkflowInstance();
WorkflowState taskWorkflowState = lifecycle.getDefaultLifecycle()
.createState(
"Null",
"initial",
"Sub Task Workflow created by Workflow Processor Queue for workflow instance: "
+ "[" + inst.getId() + "]");
instance.setState(taskWorkflowState);
instance.setPriority(inst.getPriority());
instance.setCurrentTaskId(task.getTaskId());
Graph taskGraph = new Graph();
taskGraph.setExecutionType("task");
taskGraph.setTask(task);
ParentChildWorkflow workflow = new ParentChildWorkflow(taskGraph);
workflow.setId("task-workflow-"
+ inst.getParentChildWorkflow().getId());
workflow.setName("Task Workflow-" + task.getTaskName());
workflow.getTasks().add(task);
workflow.getGraph().setTask(task);
instance.setParentChildWorkflow(workflow);
this.addToModelRepo(workflow);
persist(instance);
WorkflowProcessor subProcessor = fromWorkflowInstance(instance);
processor.getSubProcessors().add(subProcessor);
synchronized (processorCache) {
processorCache.put(instance.getId(), subProcessor);
}
}
// handle its post conditions
for (WorkflowCondition cond : inst.getParentChildWorkflow()
.getPostConditions()) {
WorkflowInstance instance = new WorkflowInstance();
WorkflowState condWorkflowState = lifecycle
.getDefaultLifecycle()
.createState(
"Null",
"initial",
"Sub Post Condition Workflow created by Workflow Processor Queue for workflow instance: "
+ "[" + inst.getId() + "]");
instance.setState(condWorkflowState);
instance.setPriority(inst.getPriority());
WorkflowTask conditionTask = toConditionTask(cond);
instance.setCurrentTaskId(conditionTask.getTaskId());
Graph condGraph = new Graph();
condGraph.setExecutionType("condition");
condGraph.setCond(cond);
condGraph.setTask(conditionTask);
ParentChildWorkflow workflow = new ParentChildWorkflow(condGraph);
workflow.setId("post-cond-workflow-"
+ inst.getParentChildWorkflow().getId());
workflow
.setName("Post Condition Workflow-" + cond.getConditionName());
workflow.getTasks().add(conditionTask);
instance.setParentChildWorkflow(workflow);
this.addToModelRepo(workflow);
persist(instance);
WorkflowProcessor subProcessor = fromWorkflowInstance(instance);
processor.getSubProcessors().add(subProcessor);
synchronized (processorCache) {
processorCache.put(instance.getId(), subProcessor);
}
}
} else {
// it's not a composite workflow, and it's either just a task processor
// or a condition processor
if (inst.getParentChildWorkflow().getGraph().getExecutionType()
.equals("task")) {
processor = new TaskProcessor(lifecycle, inst);
WorkflowState taskProcessorState = getLifecycle(
inst.getParentChildWorkflow()).createState(
"Loaded",
"initial",
"Task Workflow instance with id: [" + inst.getId()
+ "] loaded by processor queue.");
inst.setState(taskProcessorState);
// handle its pre-conditions
for (WorkflowCondition cond : inst.getParentChildWorkflow()
.getGraph().getTask().getPreConditions()) {
WorkflowInstance instance = new WorkflowInstance();
WorkflowState condWorkflowState = lifecycle
.getDefaultLifecycle()
.createState(
"Null",
"initial",
"Sub Pre Condition Workflow for Task created by Workflow Processor Queue for workflow instance: "
+ "[" + inst.getId() + "]");
instance.setState(condWorkflowState);
instance.setPriority(inst.getPriority());
WorkflowTask conditionTask = toConditionTask(cond);
instance.setCurrentTaskId(conditionTask.getTaskId());
Graph condGraph = new Graph();
condGraph.setExecutionType("condition");
condGraph.setCond(cond);
condGraph.setTask(conditionTask);
ParentChildWorkflow workflow = new ParentChildWorkflow(condGraph);
workflow.setId("pre-cond-workflow-"
+ inst.getParentChildWorkflow().getGraph().getTask()
.getTaskId());
workflow.setName("Task Pre Condition Workflow-"
+ cond.getConditionName());
workflow.getTasks().add(conditionTask);
instance.setParentChildWorkflow(workflow);
this.addToModelRepo(workflow);
persist(instance);
WorkflowProcessor subProcessor = fromWorkflowInstance(instance);
processor.getSubProcessors().add(subProcessor);
synchronized (processorCache) {
processorCache.put(instance.getId(), subProcessor);
}
}
// handle its post-conditions
for (WorkflowCondition cond : inst.getParentChildWorkflow()
.getGraph().getTask().getPostConditions()) {
WorkflowInstance instance = new WorkflowInstance();
WorkflowState condWorkflowState = lifecycle
.getDefaultLifecycle()
.createState(
"Null",
"initial",
"Sub Post Condition Workflow for Task created by Workflow Processor Queue for workflow instance: "
+ "[" + inst.getId() + "]");
instance.setState(condWorkflowState);
instance.setPriority(inst.getPriority());
WorkflowTask conditionTask = toConditionTask(cond);
instance.setCurrentTaskId(conditionTask.getTaskId());
Graph condGraph = new Graph();
condGraph.setExecutionType("condition");
condGraph.setCond(cond);
condGraph.setTask(conditionTask);
ParentChildWorkflow workflow = new ParentChildWorkflow(condGraph);
workflow.setId("post-cond-workflow-"
+ inst.getParentChildWorkflow().getGraph().getTask()
.getTaskId());
workflow.setName("Task Post Condition Workflow-"