use of org.activiti.engine.impl.pvm.PvmTransition in project Activiti by Activiti.
the class ExecutionImpl method takeAll.
@SuppressWarnings("unchecked")
public void takeAll(List<PvmTransition> transitions, List<ActivityExecution> recyclableExecutions) {
transitions = new ArrayList<PvmTransition>(transitions);
recyclableExecutions = (recyclableExecutions != null ? new ArrayList<ActivityExecution>(recyclableExecutions) : new ArrayList<ActivityExecution>());
if (recyclableExecutions.size() > 1) {
for (ActivityExecution recyclableExecution : recyclableExecutions) {
if (((ExecutionImpl) recyclableExecution).isScope()) {
throw new PvmException("joining scope executions is not allowed");
}
}
}
ExecutionImpl concurrentRoot = ((isConcurrent && !isScope) ? getParent() : this);
List<ExecutionImpl> concurrentActiveExecutions = new ArrayList<ExecutionImpl>();
for (ExecutionImpl execution : concurrentRoot.getExecutions()) {
if (execution.isActive()) {
concurrentActiveExecutions.add(execution);
}
}
if (log.isDebugEnabled()) {
log.debug("transitions to take concurrent: {}", transitions);
log.debug("active concurrent executions: {}", concurrentActiveExecutions);
}
if ((transitions.size() == 1) && (concurrentActiveExecutions.isEmpty())) {
@SuppressWarnings("rawtypes") List<ExecutionImpl> recyclableExecutionImpls = (List) recyclableExecutions;
for (ExecutionImpl prunedExecution : recyclableExecutionImpls) {
// Others are already ended (end activities)
if (!prunedExecution.isEnded()) {
log.debug("pruning execution {}", prunedExecution);
prunedExecution.remove();
}
}
log.debug("activating the concurrent root {} as the single path of execution going forward", concurrentRoot);
concurrentRoot.setActive(true);
concurrentRoot.setActivity(activity);
concurrentRoot.setConcurrent(false);
concurrentRoot.take(transitions.get(0));
} else {
List<OutgoingExecution> outgoingExecutions = new ArrayList<OutgoingExecution>();
recyclableExecutions.remove(concurrentRoot);
log.debug("recyclable executions for reused: {}", recyclableExecutions);
// first create the concurrent executions
while (!transitions.isEmpty()) {
PvmTransition outgoingTransition = transitions.remove(0);
ExecutionImpl outgoingExecution = null;
if (recyclableExecutions.isEmpty()) {
outgoingExecution = concurrentRoot.createExecution();
log.debug("new {} created to take transition {}", outgoingExecution, outgoingTransition);
} else {
outgoingExecution = (ExecutionImpl) recyclableExecutions.remove(0);
log.debug("recycled {} to take transition {}", outgoingExecution, outgoingTransition);
}
outgoingExecution.setActive(true);
outgoingExecution.setScope(false);
outgoingExecution.setConcurrent(true);
outgoingExecutions.add(new OutgoingExecution(outgoingExecution, outgoingTransition, true));
}
// prune the executions that are not recycled
for (ActivityExecution prunedExecution : recyclableExecutions) {
log.debug("pruning execution {}", prunedExecution);
prunedExecution.end();
}
// then launch all the concurrent executions
for (OutgoingExecution outgoingExecution : outgoingExecutions) {
outgoingExecution.take();
}
}
}
use of org.activiti.engine.impl.pvm.PvmTransition in project Activiti by Activiti.
the class WaitState method signal.
public void signal(ActivityExecution execution, String signalName, Object event) {
PvmTransition transition = findTransition(execution, signalName);
execution.take(transition);
}
use of org.activiti.engine.impl.pvm.PvmTransition in project Activiti by Activiti.
the class Automatic method execute.
public void execute(ActivityExecution activityContext) throws Exception {
PvmTransition defaultOutgoingTransition = activityContext.getActivity().getOutgoingTransitions().get(0);
activityContext.take(defaultOutgoingTransition);
}
use of org.activiti.engine.impl.pvm.PvmTransition in project Activiti by Activiti.
the class Decision method execute.
public void execute(ActivityExecution execution) throws Exception {
PvmTransition transition;
String creditRating = (String) execution.getVariable("creditRating");
if (creditRating.equals("AAA+")) {
transition = execution.getActivity().findOutgoingTransition("wow");
} else if (creditRating.equals("Aaa-")) {
transition = execution.getActivity().findOutgoingTransition("nice");
} else {
transition = execution.getActivity().findOutgoingTransition("default");
}
execution.take(transition);
}
use of org.activiti.engine.impl.pvm.PvmTransition in project Activiti by Activiti.
the class BpmnParseTest method testParseNamespaceInConditionExpressionType.
@Deployment
public void testParseNamespaceInConditionExpressionType() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
public ProcessDefinitionEntity execute(CommandContext commandContext) {
return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedLatestProcessDefinitionByKey("resolvableNamespacesProcess");
}
});
// Test that the process definition has been deployed
assertNotNull(processDefinitionEntity);
ActivityImpl activity = processDefinitionEntity.findActivity("ExclusiveGateway_1");
assertNotNull(activity);
// Test that the conditions has been resolved
for (PvmTransition transition : activity.getOutgoingTransitions()) {
if (transition.getDestination().getId().equals("Task_2")) {
assertTrue(transition.getProperty("conditionText").equals("#{approved}"));
} else if (transition.getDestination().getId().equals("Task_3")) {
assertTrue(transition.getProperty("conditionText").equals("#{!approved}"));
} else {
fail("Something went wrong");
}
}
}
Aggregations