use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class SubProcessActivityBehavior method execute.
public void execute(ActivityExecution execution) throws Exception {
PvmActivity activity = execution.getActivity();
ActivityImpl initialActivity = (ActivityImpl) activity.getProperty(BpmnParse.PROPERTYNAME_INITIAL);
if (initialActivity == null) {
throw new ActivitiException("No initial activity found for subprocess " + execution.getActivity().getId());
}
// initialize the template-defined data objects as variables
initializeDataObjects(execution, activity);
if (initialActivity.getActivityBehavior() != null && initialActivity.getActivityBehavior() instanceof NoneStartEventActivityBehavior) {
// embedded subprocess: only none start allowed
((ExecutionEntity) execution).setActivity(initialActivity);
Context.getCommandContext().getHistoryManager().recordActivityStart((ExecutionEntity) execution);
}
execution.executeActivity(initialActivity);
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class AbstractBpmnActivityBehavior method createCompensateEventSubscription.
protected void createCompensateEventSubscription(ActivityExecution execution) {
String compensationHandlerId = (String) execution.getActivity().getProperty(BpmnParse.PROPERTYNAME_COMPENSATION_HANDLER_ID);
ExecutionEntity executionEntity = (ExecutionEntity) execution;
ActivityImpl compensationHandlder = executionEntity.getProcessDefinition().findActivity(compensationHandlerId);
PvmScope scopeActivitiy = compensationHandlder.getParent();
ExecutionEntity scopeExecution = ScopeUtil.findScopeExecutionForScope(executionEntity, scopeActivitiy);
CompensateEventSubscriptionEntity compensateEventSubscriptionEntity = CompensateEventSubscriptionEntity.createAndInsert(scopeExecution);
compensateEventSubscriptionEntity.setActivity(compensationHandlder);
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl 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.pvm.process.ActivityImpl in project Activiti by Activiti.
the class CancelEndEventActivityBehavior method execute.
@Override
public void execute(ActivityExecution execution) throws Exception {
// find cancel boundary event:
ActivityImpl cancelBoundaryEvent = ScopeUtil.findInParentScopesByBehaviorType((ActivityImpl) execution.getActivity(), CancelBoundaryEventActivityBehavior.class);
if (cancelBoundaryEvent == null) {
throw new ActivitiException("Could not find cancel boundary event for cancel end event " + execution.getActivity());
}
ActivityExecution scopeExecution = ScopeUtil.findScopeExecutionForScope((ExecutionEntity) execution, cancelBoundaryEvent.getParentActivity());
// end all executions and process instances in the scope of the transaction
scopeExecution.destroyScope("cancel end event fired");
// the scope execution executes the boundary event
InterpretableExecution outgoingExecution = (InterpretableExecution) scopeExecution;
outgoingExecution.setActivity(cancelBoundaryEvent);
outgoingExecution.setActive(true);
// execute the boundary
cancelBoundaryEvent.getActivityBehavior().execute(outgoingExecution);
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class TerminateEndEventTest method testParseTerminateEndEventDefinitionWithExtensions.
public void testParseTerminateEndEventDefinitionWithExtensions() {
org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/bpmn/event/end/TerminateEndEventTest.parseExtensionElements.bpmn20.xml").deploy();
ProcessDefinition processDefinitionQuery = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
ProcessDefinitionEntity processDefinition = this.processEngineConfiguration.getProcessDefinitionCache().get(processDefinitionQuery.getId());
assertThat(processDefinition.getActivities().size(), is(2));
ActivityImpl endEvent = processDefinition.getActivities().get(1);
assertThat(endEvent.getId(), is("terminateEnd"));
assertThat(endEvent.getActivityBehavior(), instanceOf(TerminateEndEventActivityBehavior.class));
TerminateEndEventActivityBehavior terminateEndEventBehavior = (TerminateEndEventActivityBehavior) endEvent.getActivityBehavior();
Map<String, List<ExtensionElement>> extensionElements = terminateEndEventBehavior.getEndEvent().getExtensionElements();
assertThat(extensionElements.size(), is(1));
List<ExtensionElement> strangeProperties = extensionElements.get("strangeProperty");
assertThat(strangeProperties.size(), is(1));
ExtensionElement strangeProperty = strangeProperties.get(0);
assertThat(strangeProperty.getNamespace(), is("http://activiti.org/bpmn"));
assertThat(strangeProperty.getElementText(), is("value"));
assertThat(strangeProperty.getAttributes().size(), is(1));
ExtensionAttribute id = strangeProperty.getAttributes().get("id").get(0);
assertThat(id.getName(), is("id"));
assertThat(id.getValue(), is("strangeId"));
repositoryService.deleteDeployment(deployment.getId());
}
Aggregations