use of org.activiti.bpmn.model.AdhocSubProcess in project Activiti by Activiti.
the class GetEnabledActivitiesForAdhocSubProcessCmd method execute.
public List<FlowNode> execute(CommandContext commandContext) {
ExecutionEntity execution = commandContext.getExecutionEntityManager().findById(executionId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("No execution found for id '" + executionId + "'", ExecutionEntity.class);
}
if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess)) {
throw new ActivitiException("The current flow element of the requested execution is not an ad-hoc sub process");
}
List<FlowNode> enabledFlowNodes = new ArrayList<FlowNode>();
AdhocSubProcess adhocSubProcess = (AdhocSubProcess) execution.getCurrentFlowElement();
// if sequential ordering, only one child execution can be active, so no enabled activities
if (adhocSubProcess.hasSequentialOrdering()) {
if (execution.getExecutions().size() > 0) {
return enabledFlowNodes;
}
}
for (FlowElement flowElement : adhocSubProcess.getFlowElements()) {
if (flowElement instanceof FlowNode) {
FlowNode flowNode = (FlowNode) flowElement;
if (flowNode.getIncomingFlows().size() == 0) {
enabledFlowNodes.add(flowNode);
}
}
}
return enabledFlowNodes;
}
use of org.activiti.bpmn.model.AdhocSubProcess in project Activiti by Activiti.
the class CompleteAdhocSubProcessCmd method execute.
public Void execute(CommandContext commandContext) {
ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
ExecutionEntity execution = executionEntityManager.findById(executionId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("No execution found for id '" + executionId + "'", ExecutionEntity.class);
}
if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess)) {
throw new ActivitiException("The current flow element of the requested execution is not an ad-hoc sub process");
}
List<? extends ExecutionEntity> childExecutions = execution.getExecutions();
if (childExecutions.size() > 0) {
throw new ActivitiException("Ad-hoc sub process has running child executions that need to be completed first");
}
ExecutionEntity outgoingFlowExecution = executionEntityManager.createChildExecution(execution.getParent());
outgoingFlowExecution.setCurrentFlowElement(execution.getCurrentFlowElement());
executionEntityManager.deleteExecutionAndRelatedData(execution, null);
Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(outgoingFlowExecution, true);
return null;
}
Aggregations