protected static String getErrorCodeFromErrorEventDefinition(Event event) { for (EventDefinition eventDefinition : event.getEventDefinitions()) { if (eventDefinition instanceof ErrorEventDefinition) { return ((ErrorEventDefinition) eventDefinition).getErrorCode(); } } return null; }
public void setValues(ErrorEventDefinition otherDefinition) { super.setValues(otherDefinition); setErrorCode(otherDefinition.getErrorCode()); } }
protected void convertJsonToErrorDefinition(JsonNode objectNode, Event event) { String errorRef = getPropertyValueAsString(PROPERTY_ERRORREF, objectNode); ErrorEventDefinition eventDefinition = new ErrorEventDefinition(); eventDefinition.setErrorCode(errorRef); event.getEventDefinitions().add(eventDefinition); }
@Override public ErrorEventDefinition clone() { ErrorEventDefinition clone = new ErrorEventDefinition(); clone.setValues(this); return clone; }
@Override public ErrorEventDefinition clone() { ErrorEventDefinition clone = new ErrorEventDefinition(); clone.setValues(this); return clone; }
@Override public ErrorEndEventActivityBehavior createErrorEndEventActivityBehavior(EndEvent endEvent, ErrorEventDefinition errorEventDefinition) { return new ErrorEndEventActivityBehavior(errorEventDefinition.getErrorCode()); }
public void setValues(ErrorEventDefinition otherDefinition) { super.setValues(otherDefinition); setErrorCode(otherDefinition.getErrorCode()); } }
@Override public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (!(parentElement instanceof Event)) return; ErrorEventDefinition eventDefinition = new ErrorEventDefinition(); BpmnXMLUtil.addXMLLocation(eventDefinition, xtr); eventDefinition.setErrorCode(xtr.getAttributeValue(null, "errorRef")); BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_ERRORDEFINITION, eventDefinition, xtr, model); ((Event) parentElement).getEventDefinitions().add(eventDefinition); } }
@Override public ErrorEndEventActivityBehavior createErrorEndEventActivityBehavior(EndEvent endEvent, ErrorEventDefinition errorEventDefinition) { return new ErrorEndEventActivityBehavior(errorEventDefinition.getErrorCode()); }
@Override protected void executeParse(BpmnParse bpmnParse, ErrorEventDefinition eventDefinition) { ErrorEventDefinition modelErrorEvent = 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(); boolean interrupting = true; // non-interrupting not yet supported activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity)); ActivityImpl parentActivity = scope.findActivity(boundaryEvent.getAttachedToRefId()); createBoundaryErrorEventDefinition(modelErrorEvent, interrupting, parentActivity, activity); } }
protected void writeErrorDefinition(Event parentEvent, ErrorEventDefinition errorDefinition, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(ELEMENT_EVENT_ERRORDEFINITION); writeDefaultAttribute(ATTRIBUTE_ERROR_REF, errorDefinition.getErrorCode(), xtw); boolean didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(errorDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.writeEndElement(); } xtw.writeEndElement(); }
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()); errorDefinition.setErrorCode(errorCode);
protected void createErrorStartEventDefinition(ErrorEventDefinition errorEventDefinition, ActivityImpl startEventActivity, ScopeImpl scope) { org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition definition = new org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition(startEventActivity.getId()); if (StringUtils.isNotEmpty(errorEventDefinition.getErrorCode())) { definition.setErrorCode(errorEventDefinition.getErrorCode()); } definition.setPrecedence(10); addErrorEventDefinition(definition, scope); }
ErrorEventDefinition errorDef = (ErrorEventDefinition) eventDef; eventNode.put("type", "error"); if (StringUtils.isNotEmpty(errorDef.getErrorCode())) { eventNode.put("errorCode", errorDef.getErrorCode());
ErrorEventDefinition errorDef = (ErrorEventDefinition) eventDef; eventNode.put("type", "error"); if (StringUtils.isNotEmpty(errorDef.getErrorCode())) { eventNode.put("errorCode", errorDef.getErrorCode());
if (eventDefinition instanceof ErrorEventDefinition) { ErrorEventDefinition errorDefinition = (ErrorEventDefinition) eventDefinition; if (StringUtils.isNotEmpty(errorDefinition.getErrorCode())) { propertiesNode.put(PROPERTY_ERRORREF, errorDefinition.getErrorCode());
if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions()) && startEvent.getEventDefinitions().get(0) instanceof ErrorEventDefinition) { ErrorEventDefinition errorEventDef = (ErrorEventDefinition) startEvent.getEventDefinitions().get(0); String eventErrorCode = retrieveErrorCode(bpmnModel, errorEventDef.getErrorCode()); String eventErrorCode = retrieveErrorCode(bpmnModel, errorEventDef.getErrorCode());
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); }
@Override protected void executeParse(BpmnParse bpmnParse, EndEvent endEvent) { EventDefinition eventDefinition = null; if (endEvent.getEventDefinitions().size() > 0) { eventDefinition = endEvent.getEventDefinitions().get(0); if (eventDefinition instanceof ErrorEventDefinition) { ErrorEventDefinition errorDefinition = (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()); } } endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition)); } else if (eventDefinition instanceof TerminateEventDefinition) { endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createTerminateEndEventActivityBehavior(endEvent)); } else if (eventDefinition instanceof CancelEventDefinition) { endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createCancelEndEventActivityBehavior(endEvent)); } else { endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent)); } } else { endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent)); } }