* @param scope
* The {@link ScopeImpl} to which the end events must be added.
*/
public void parseEndEvents(Element parentElement, ScopeImpl scope) {
for (Element endEventElement : parentElement.elements("endEvent")) {
ActivityImpl activity = createActivityOnScope(endEventElement, scope);
Element errorEventDefinition = endEventElement.element("errorEventDefinition");
Element cancelEventDefinition = endEventElement.element("cancelEventDefinition");
Element terminateEventDefinition = endEventElement.element("terminateEventDefinition");
Element messageEventDefinitionElement = endEventElement.element("messageEventDefinition");
Element signalEventDefinition = endEventElement.element("signalEventDefinition");
if (errorEventDefinition != null) { // error end event
String errorRef = errorEventDefinition.attribute("errorRef");
if (errorRef == null || "".equals(errorRef)) {
addError("'errorRef' attribute is mandatory on error end event", errorEventDefinition);
} else {
Error error = errors.get(errorRef);
if (error != null && (error.getErrorCode() == null || "".equals(error.getErrorCode()))) {
addError("'errorCode' is mandatory on errors referenced by throwing error event definitions, but the error '" + error.getId() + "' does not define one.", errorEventDefinition);
}
activity.setProperty("type", "errorEndEvent");
activity.setActivityBehavior(new ErrorEndEventActivityBehavior(error != null ? error.getErrorCode() : errorRef));
}
} else if (cancelEventDefinition != null) {
if (scope.getProperty("type")==null || !scope.getProperty("type").equals("transaction")) {
addError("end event with cancelEventDefinition only supported inside transaction subprocess", cancelEventDefinition);
} else {
activity.setProperty("type", "cancelEndEvent");
activity.setActivityBehavior(new CancelEndEventActivityBehavior());
}
} else if (terminateEventDefinition != null) {
activity.setProperty("type", "terminateEndEvent");
activity.setActivityBehavior(new TerminateEndEventActivityBehavior());
activity.setCancelScope(true);
} else if (messageEventDefinitionElement != null) {
if (isServiceTaskLike(messageEventDefinitionElement)) {
// CAM-436 same behaviour as service task
activity.setProperty("type", "messageEndEvent");
activity.setActivityBehavior(parseServiceTaskLike("messageEndEvent", messageEventDefinitionElement, scope).getActivityBehavior());
} else {
// default to non behavior if no service task
// properties have been specified
activity.setActivityBehavior(new IntermediateThrowNoneEventActivityBehavior());
}
} else if (signalEventDefinition != null) {
activity.setProperty("type", "signalEndEvent");
EventSubscriptionDeclaration signalDefinition = parseSignalEventDefinition(signalEventDefinition);
activity.setActivityBehavior(new SignalEndEventActivityBehavior(signalDefinition));
} else { // default: none end event
activity.setProperty("type", "noneEndEvent");
activity.setActivityBehavior(new NoneEndEventActivityBehavior());
}
if(activity != null) {
parseActivityInputOutput(endEventElement, activity);
}