use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class CompensationEventHandler method handleEvent.
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {
String configuration = eventSubscription.getConfiguration();
if (configuration == null) {
throw new ActivitiException("Compensating execution not set for compensate event subscription with id " + eventSubscription.getId());
}
ExecutionEntity compensatingExecution = commandContext.getExecutionEntityManager().findExecutionById(configuration);
ActivityImpl compensationHandler = eventSubscription.getActivity();
if ((compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION) == null || !(Boolean) compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION)) && compensationHandler.isScope()) {
// descend into scope:
List<CompensateEventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions();
ScopeUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);
} else {
try {
if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createActivityEvent(ActivitiEventType.ACTIVITY_COMPENSATE, compensationHandler.getId(), (String) compensationHandler.getProperty("name"), compensatingExecution.getId(), compensatingExecution.getProcessInstanceId(), compensatingExecution.getProcessDefinitionId(), (String) compensatingExecution.getActivity().getProperties().get("type"), compensatingExecution.getActivity().getActivityBehavior().getClass().getCanonicalName()));
}
compensatingExecution.setActivity(compensationHandler);
// executing the atomic operation makes sure activity start events are fired
compensatingExecution.performOperation(AtomicOperation.ACTIVITY_START);
} catch (Exception e) {
throw new ActivitiException("Error while handling compensation event " + eventSubscription, e);
}
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class FlowNodeHistoryParseHandler method parse.
public void parse(BpmnParse bpmnParse, BaseElement element) {
ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(element.getId());
if (element instanceof BoundaryEvent) {
// A boundary-event never receives an activity start-event
activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, ACTIVITY_INSTANCE_START_LISTENER, 0);
activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, ACTIVITI_INSTANCE_END_LISTENER, 1);
} else {
activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, ACTIVITY_INSTANCE_START_LISTENER, 0);
activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, ACTIVITI_INSTANCE_END_LISTENER);
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class TimerStartEventJobHandler method startProcessInstanceWithInitialActivity.
protected void startProcessInstanceWithInitialActivity(JobEntity job, String configuration, DeploymentManager deploymentManager, CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = deploymentManager.findDeployedProcessDefinitionById(job.getProcessDefinitionId());
String activityId = getActivityIdFromConfiguration(configuration);
ActivityImpl startActivity = processDefinition.findActivity(activityId);
if (!deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) {
dispatchTimerFiredEvent(job, commandContext);
ExecutionEntity processInstance = processDefinition.createProcessInstance(null, startActivity);
processInstance.start();
} else {
log.debug("Ignoring timer of suspended process definition {}", processDefinition.getId());
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class CustomSequenceFlowBpmnParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, SequenceFlow flow) {
// Do the regular stuff
super.executeParse(bpmnParse, flow);
// Add extension element conditions
Map<String, List<ExtensionElement>> extensionElements = flow.getExtensionElements();
if (extensionElements.containsKey("activiti_custom_condition")) {
List<ExtensionElement> conditionsElements = extensionElements.get("activiti_custom_condition");
CustomSetConditionsExecutionListener customFlowListener = new CustomSetConditionsExecutionListener();
customFlowListener.setFlowId(flow.getId());
for (ExtensionElement conditionElement : conditionsElements) {
customFlowListener.addCondition(conditionElement.getElementText());
}
ActivityImpl activity = findActivity(bpmnParse, flow.getSourceRef());
activity.addExecutionListener("start", customFlowListener);
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class TerminateEndEventActivityBehavior method execute.
public void execute(ActivityExecution execution) throws Exception {
ActivityImpl terminateEndEventActivity = (ActivityImpl) execution.getActivity();
if (terminateAll) {
ActivityExecution processInstanceExecution = findRootProcessInstanceExecution((ExecutionEntity) execution);
terminateProcessInstanceExecution(execution, terminateEndEventActivity, processInstanceExecution);
} else {
ActivityExecution scopeExecution = ScopeUtil.findScopeExecution(execution);
if (scopeExecution != null) {
terminateExecution(execution, terminateEndEventActivity, scopeExecution);
}
}
}
Aggregations