use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class EndEventParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, EndEvent endEvent) {
ActivityImpl endEventActivity = createActivityOnCurrentScope(bpmnParse, endEvent, BpmnXMLConstants.ELEMENT_EVENT_END);
EventDefinition eventDefinition = null;
if (!endEvent.getEventDefinitions().isEmpty()) {
eventDefinition = endEvent.getEventDefinitions().get(0);
}
// Error end event
if (eventDefinition instanceof org.activiti.bpmn.model.ErrorEventDefinition) {
org.activiti.bpmn.model.ErrorEventDefinition errorDefinition = (org.activiti.bpmn.model.ErrorEventDefinition) eventDefinition;
if (bpmnParse.getBpmnModel().containsErrorRef(errorDefinition.getErrorCode())) {
String errorCode = bpmnParse.getBpmnModel().getErrors().get(errorDefinition.getErrorCode());
if (StringUtils.isEmpty(errorCode)) {
logger.warn("errorCode is required for an error event " + endEvent.getId());
}
endEventActivity.setProperty("type", "errorEndEvent");
errorDefinition.setErrorCode(errorCode);
}
endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition));
// Cancel end event
} else if (eventDefinition instanceof CancelEventDefinition) {
ScopeImpl scope = bpmnParse.getCurrentScope();
if (scope.getProperty("type") == null || !scope.getProperty("type").equals("transaction")) {
logger.warn("end event with cancelEventDefinition only supported inside transaction subprocess (id=" + endEvent.getId() + ")");
} else {
endEventActivity.setProperty("type", "cancelEndEvent");
endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCancelEndEventActivityBehavior(endEvent));
}
// Terminate end event
} else if (eventDefinition instanceof TerminateEventDefinition) {
endEventActivity.setAsync(endEvent.isAsynchronous());
endEventActivity.setExclusive(!endEvent.isNotExclusive());
endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createTerminateEndEventActivityBehavior(endEvent));
// None end event
} else if (eventDefinition == null) {
endEventActivity.setAsync(endEvent.isAsynchronous());
endEventActivity.setExclusive(!endEvent.isNotExclusive());
endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent));
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class ErrorEventDefinitionParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, ErrorEventDefinition eventDefinition) {
ErrorEventDefinition modelErrorEvent = (ErrorEventDefinition) eventDefinition;
if (bpmnParse.getBpmnModel().containsErrorRef(modelErrorEvent.getErrorCode())) {
String errorCode = bpmnParse.getBpmnModel().getErrors().get(modelErrorEvent.getErrorCode());
modelErrorEvent.setErrorCode(errorCode);
}
ScopeImpl scope = bpmnParse.getCurrentScope();
ActivityImpl activity = bpmnParse.getCurrentActivity();
if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
if (scope.getProperty(PROPERTYNAME_INITIAL) == null) {
scope.setProperty(PROPERTYNAME_INITIAL, activity);
// the scope of the event subscription is the parent of the event
// subprocess (subscription must be created when parent is initialized)
ScopeImpl catchingScope = ((ActivityImpl) scope).getParent();
createErrorStartEventDefinition(modelErrorEvent, activity, catchingScope);
}
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
// non-interrupting not yet supported
boolean interrupting = true;
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
ActivityImpl parentActivity = scope.findActivity(boundaryEvent.getAttachedToRefId());
createBoundaryErrorEventDefinition(modelErrorEvent, interrupting, parentActivity, activity);
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class ErrorEventDefinitionParseHandler method createBoundaryErrorEventDefinition.
public void createBoundaryErrorEventDefinition(ErrorEventDefinition errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity) {
nestedErrorEventActivity.setProperty("type", "boundaryError");
ScopeImpl catchingScope = nestedErrorEventActivity.getParent();
((ActivityImpl) catchingScope).setScope(true);
org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition definition = new org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition(nestedErrorEventActivity.getId());
definition.setErrorCode(errorEventDefinition.getErrorCode());
addErrorEventDefinition(definition, catchingScope);
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class TimerExecuteNestedActivityJobHandler method execute.
public void execute(JobEntity job, String configuration, ExecutionEntity execution, CommandContext commandContext) {
String nestedActivityId = TimerEventHandler.getActivityIdFromConfiguration(configuration);
ActivityImpl borderEventActivity = execution.getProcessDefinition().findActivity(nestedActivityId);
if (borderEventActivity == null) {
throw new ActivitiException("Error while firing timer: border event activity " + nestedActivityId + " not found");
}
try {
if (commandContext.getEventDispatcher().isEnabled()) {
commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.TIMER_FIRED, job));
dispatchActivityTimeoutIfNeeded(job, execution, commandContext);
}
borderEventActivity.getActivityBehavior().execute(execution);
} catch (RuntimeException e) {
log.error("exception during timer execution", e);
throw e;
} catch (Exception e) {
log.error("exception during timer execution", e);
throw new ActivitiException("exception during timer execution: " + e.getMessage(), e);
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class TimerExecuteNestedActivityJobHandler method dispatchExecutionTimeOut.
protected void dispatchExecutionTimeOut(JobEntity timerEntity, ExecutionEntity execution, CommandContext commandContext) {
// subprocesses
for (ExecutionEntity subExecution : execution.getExecutions()) {
dispatchExecutionTimeOut(timerEntity, subExecution, commandContext);
}
// call activities
ExecutionEntity subProcessInstance = commandContext.getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId());
if (subProcessInstance != null) {
dispatchExecutionTimeOut(timerEntity, subProcessInstance, commandContext);
}
// activity with timer boundary event
ActivityImpl activity = execution.getActivity();
if (activity != null && activity.getActivityBehavior() != null) {
dispatchActivityTimeOut(timerEntity, activity, execution, commandContext);
}
}
Aggregations