use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.
the class BoundaryEventActivityBehavior method execute.
@SuppressWarnings("unchecked")
public void execute(ActivityExecution execution) throws Exception {
ExecutionEntity executionEntity = (ExecutionEntity) execution;
ActivityImpl boundaryActivity = executionEntity.getProcessDefinition().findActivity(activityId);
ActivityImpl interruptedActivity = executionEntity.getActivity();
List<PvmTransition> outgoingTransitions = boundaryActivity.getOutgoingTransitions();
List<ExecutionEntity> interruptedExecutions = null;
if (interrupting) {
// Call activity
if (executionEntity.getSubProcessInstance() != null) {
executionEntity.getSubProcessInstance().deleteCascade(executionEntity.getDeleteReason());
} else {
Context.getCommandContext().getHistoryManager().recordActivityEnd(executionEntity);
}
executionEntity.setActivity(boundaryActivity);
interruptedExecutions = new ArrayList<ExecutionEntity>(executionEntity.getExecutions());
for (ExecutionEntity interruptedExecution : interruptedExecutions) {
interruptedExecution.deleteCascade("interrupting boundary event '" + execution.getActivity().getId() + "' fired");
}
execution.takeAll(outgoingTransitions, (List) interruptedExecutions);
} else {
// non interrupting event, introduced with BPMN 2.0, we need to create a new execution in this case
// create a new execution and move it out from the timer activity
ExecutionEntity concurrentRoot = executionEntity.getParent().isConcurrent() ? executionEntity.getParent() : executionEntity;
ExecutionEntity outgoingExecution = concurrentRoot.createExecution();
outgoingExecution.setActive(true);
outgoingExecution.setScope(false);
outgoingExecution.setConcurrent(true);
outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST);
outgoingExecution.remove();
// now we have to move the execution back to the real activity
// since the execution stays there (non interrupting) and it was
// set to the boundary event before
executionEntity.setActivity(interruptedActivity);
}
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.
the class ExecutionQueryImpl method executeList.
@SuppressWarnings({ "unchecked" })
public List<Execution> executeList(CommandContext commandContext, Page page) {
checkQueryOk();
ensureVariablesInitialized();
List<?> executions = commandContext.getExecutionEntityManager().findExecutionsByQueryCriteria(this, page);
for (ExecutionEntity execution : (List<ExecutionEntity>) executions) {
String activityId = null;
if (execution.getId().equals(execution.getProcessInstanceId())) {
if (execution.getProcessDefinitionId() != null) {
ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(execution.getProcessDefinitionId());
activityId = processDefinition.getKey();
}
} else {
activityId = execution.getActivityId();
}
if (activityId != null) {
localize(execution, activityId);
}
}
return (List<Execution>) executions;
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.
the class StartToEndTest method testStartProcessInstanceWithServiceTask.
@Deployment(resources = { "org/activiti/engine/test/bpmn/StartToEndTest.testStartWithServiceTask.bpmn20.xml" })
public void testStartProcessInstanceWithServiceTask() {
Map<String, Object> varMap = new HashMap<String, Object>();
varMap.put("test", "hello");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startToEnd", varMap);
assertProcessEnded(processInstance.getId());
Map<String, Object> returnVarMap = ((ExecutionEntity) processInstance).getVariableValues();
assertEquals("hello", returnVarMap.get("test"));
assertEquals("string", returnVarMap.get("string"));
assertEquals(true, returnVarMap.get("boolean"));
assertEquals(25.5, returnVarMap.get("double"));
assertEquals(10L, returnVarMap.get("long"));
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.
the class StartToEndTest method testStartProcessInstanceWithVariables.
@Deployment(resources = { "org/activiti/engine/test/bpmn/StartToEndTest.testStartToEnd.bpmn20.xml" })
public void testStartProcessInstanceWithVariables() {
Map<String, Object> varMap = new HashMap<String, Object>();
varMap.put("test", "hello");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startToEnd", varMap);
assertProcessEnded(processInstance.getId());
Map<String, Object> returnVarMap = ((ExecutionEntity) processInstance).getVariableValues();
assertEquals("hello", returnVarMap.get("test"));
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project midpoint by Evolveum.
the class DumpVariables method dumpExecutionVariables.
private void dumpExecutionVariables(String executionId, DelegateExecution delegateExecution, Execution execution, Set<String> variablesSeen, RuntimeService runtimeService) {
Map<String, Object> variablesLocal = runtimeService.getVariablesLocal(executionId);
LOGGER.trace("Execution id={} ({} variables); class={}/{}", executionId, variablesLocal.size(), delegateExecution != null ? delegateExecution.getClass().getName() : null, execution != null ? execution.getClass().getName() : null);
TreeSet<String> names = new TreeSet<>(variablesLocal.keySet());
names.forEach(n -> LOGGER.trace(" - {} = {} {}", n, variablesLocal.get(n), variablesSeen.contains(n) ? "(dup)" : ""));
variablesSeen.addAll(variablesLocal.keySet());
if (delegateExecution instanceof ExecutionEntity) {
ExecutionEntity executionEntity = (ExecutionEntity) delegateExecution;
if (executionEntity.getParent() != null) {
dumpExecutionVariables(executionEntity.getParentId(), executionEntity.getParent(), null, variablesSeen, runtimeService);
}
} else if (delegateExecution instanceof ExecutionImpl) {
ExecutionImpl executionImpl = (ExecutionImpl) delegateExecution;
if (executionImpl.getParent() != null) {
dumpExecutionVariables(executionImpl.getParentId(), executionImpl.getParent(), null, variablesSeen, runtimeService);
}
} else {
Execution execution1 = runtimeService.createExecutionQuery().executionId(executionId).singleResult();
if (execution1 == null) {
LOGGER.trace("Execution with id {} was not found.", executionId);
} else if (execution1.getParentId() != null) {
Execution execution2 = runtimeService.createExecutionQuery().executionId(execution1.getParentId()).singleResult();
dumpExecutionVariables(execution.getParentId(), null, execution2, variablesSeen, runtimeService);
}
}
}
Aggregations