protected String getStencilId(BaseElement baseElement) { BoundaryEvent boundaryEvent = (BoundaryEvent) baseElement; List<EventDefinition> eventDefinitions = boundaryEvent.getEventDefinitions(); if (eventDefinitions.size() != 1) { // return timer event as default; return STENCIL_EVENT_BOUNDARY_TIMER; } EventDefinition eventDefinition = eventDefinitions.get(0); if (eventDefinition instanceof ErrorEventDefinition) { return STENCIL_EVENT_BOUNDARY_ERROR; } else if (eventDefinition instanceof SignalEventDefinition) { return STENCIL_EVENT_BOUNDARY_SIGNAL; } else if (eventDefinition instanceof MessageEventDefinition) { return STENCIL_EVENT_BOUNDARY_MESSAGE; } else if (eventDefinition instanceof CancelEventDefinition) { return STENCIL_EVENT_BOUNDARY_CANCEL; } else if (eventDefinition instanceof CompensateEventDefinition) { return STENCIL_EVENT_BOUNDARY_COMPENSATION; } else { return STENCIL_EVENT_BOUNDARY_TIMER; } }
@Override protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { BoundaryEvent boundaryEvent = (BoundaryEvent) element; writeEventDefinitions(boundaryEvent, boundaryEvent.getEventDefinitions(), model, xtw); } }
@Override protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { BoundaryEvent boundaryEvent = (BoundaryEvent) element; if (boundaryEvent.getAttachedToRef() != null) { writeDefaultAttribute(ATTRIBUTE_BOUNDARY_ATTACHEDTOREF, boundaryEvent.getAttachedToRef().getId(), xtw); } if (boundaryEvent.getEventDefinitions().size() == 1) { EventDefinition eventDef = boundaryEvent.getEventDefinitions().get(0); if (eventDef instanceof ErrorEventDefinition == false) { writeDefaultAttribute(ATTRIBUTE_BOUNDARY_CANCELACTIVITY, String.valueOf(boundaryEvent.isCancelActivity()).toLowerCase(), xtw); } } }
protected void executeParse(BpmnParse bpmnParse, BoundaryEvent boundaryEvent) { if (boundaryEvent.getAttachedToRef() == null) { logger.warn("Invalid reference in boundary event. Make sure that the referenced activity " + "is defined in the same scope as the boundary event " + boundaryEvent.getId()); return; } EventDefinition eventDefinition = null; if (boundaryEvent.getEventDefinitions().size() > 0) { eventDefinition = boundaryEvent.getEventDefinitions().get(0); } if (eventDefinition instanceof TimerEventDefinition || eventDefinition instanceof ErrorEventDefinition || eventDefinition instanceof SignalEventDefinition || eventDefinition instanceof CancelEventDefinition || eventDefinition instanceof MessageEventDefinition || eventDefinition instanceof CompensateEventDefinition) { bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition); } else { // Should already be picked up by process validator on deploy, so this is just to be sure logger.warn("Unsupported boundary event type for boundary event " + boundaryEvent.getId()); } }
@Override protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception { BoundaryEvent boundaryEvent = new BoundaryEvent(); BpmnXMLUtil.addXMLLocation(boundaryEvent, xtr); if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_BOUNDARY_CANCELACTIVITY))) { String cancelActivity = xtr.getAttributeValue(null, ATTRIBUTE_BOUNDARY_CANCELACTIVITY); if (ATTRIBUTE_VALUE_FALSE.equalsIgnoreCase(cancelActivity)) { boundaryEvent.setCancelActivity(false); } } boundaryEvent.setAttachedToRefId(xtr.getAttributeValue(null, ATTRIBUTE_BOUNDARY_ATTACHEDTOREF)); parseChildElements(getXMLElementName(), boundaryEvent, model, xtr); // Explicitly set cancel activity to false for error boundary events if (boundaryEvent.getEventDefinitions().size() == 1) { EventDefinition eventDef = boundaryEvent.getEventDefinitions().get(0); if (eventDef instanceof ErrorEventDefinition) { boundaryEvent.setCancelActivity(false); } } return boundaryEvent; }
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(flowNode.getId()); BoundaryEvent boundaryEvent = (BoundaryEvent) flowNode; if (boundaryEvent.getEventDefinitions() != null && !boundaryEvent.getEventDefinitions().isEmpty()) { if (boundaryEvent.getEventDefinitions().get(0) instanceof TimerEventDefinition) { graphicInfo, boundaryEvent.isCancelActivity()); } else if (boundaryEvent.getEventDefinitions().get(0) instanceof ErrorEventDefinition) { } else if (boundaryEvent.getEventDefinitions().get(0) instanceof SignalEventDefinition) { processDiagramCanvas.drawCatchingSignalEvent(flowNode.getId(), flowNode.getName(), graphicInfo, boundaryEvent.isCancelActivity()); } else if (boundaryEvent.getEventDefinitions().get(0) instanceof MessageEventDefinition) { processDiagramCanvas.drawCatchingMessageEvent(flowNode.getId(), flowNode.getName(), graphicInfo, boundaryEvent.isCancelActivity()); } else if (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition) { processDiagramCanvas.drawCatchingCompensateEvent(flowNode.getId(), graphicInfo,
if (boundaryEvent.getEventDefinitions() != null && !boundaryEvent.getEventDefinitions().isEmpty()) { EventDefinition eventDefinition = boundaryEvent.getEventDefinitions().get(0); if (!(eventDefinition instanceof TimerEventDefinition) && !(eventDefinition instanceof ErrorEventDefinition) && !(eventDefinition instanceof SignalEventDefinition) && !(eventDefinition instanceof CancelEventDefinition) && !(eventDefinition instanceof MessageEventDefinition) && !(eventDefinition instanceof CompensateEventDefinition)) { BoundaryEvent otherBoundaryEvent = boundaryEvents.get(j); if (otherBoundaryEvent.getAttachedToRefId() != null && otherBoundaryEvent.getAttachedToRefId().equals(boundaryEvent.getAttachedToRefId())) { if (otherBoundaryEvent.getEventDefinitions() != null && !otherBoundaryEvent.getEventDefinitions().isEmpty()) { EventDefinition otherEventDefinition = otherBoundaryEvent.getEventDefinitions().get(0); if (otherEventDefinition instanceof MessageEventDefinition) { MessageEventDefinition currentMessageEventDefinition = (MessageEventDefinition) eventDefinition;
protected void executeBoundaryEvents(Collection<BoundaryEvent> boundaryEvents, ExecutionEntity execution) { // The parent execution becomes a scope, and a child execution is created for each of the boundary events for (BoundaryEvent boundaryEvent : boundaryEvents) { if (CollectionUtil.isEmpty(boundaryEvent.getEventDefinitions()) || (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition)) { continue; } // A Child execution of the current execution is created to represent the boundary event being active ExecutionEntity childExecutionEntity = commandContext.getExecutionEntityManager().createChildExecution((ExecutionEntity) execution); childExecutionEntity.setParentId(execution.getId()); childExecutionEntity.setCurrentFlowElement(boundaryEvent); childExecutionEntity.setScope(false); ActivityBehavior boundaryEventBehavior = ((ActivityBehavior) boundaryEvent.getBehavior()); logger.debug("Executing boundary event activityBehavior {} with execution {}", boundaryEventBehavior.getClass(), childExecutionEntity.getId()); boundaryEventBehavior.execute(childExecutionEntity); } } }
if (boundaryEvent.getAttachedToRefId() != null && CollectionUtil.isNotEmpty(boundaryEvent.getEventDefinitions()) && boundaryEvent.getEventDefinitions().get(0) instanceof ErrorEventDefinition) { ErrorEventDefinition errorEventDef = (ErrorEventDefinition) boundaryEvent.getEventDefinitions().get(0); String eventErrorCode = retrieveErrorCode(bpmnModel, errorEventDef.getErrorCode());
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) { BoundaryEvent boundaryEvent = new BoundaryEvent(); String stencilId = BpmnJsonConverterUtil.getStencilId(elementNode); if (STENCIL_EVENT_BOUNDARY_TIMER.equals(stencilId)) { convertJsonToTimerDefinition(elementNode, boundaryEvent); boundaryEvent.setCancelActivity(getPropertyValueAsBoolean(PROPERTY_CANCEL_ACTIVITY, elementNode)); } else if (STENCIL_EVENT_BOUNDARY_ERROR.equals(stencilId)) { convertJsonToErrorDefinition(elementNode, boundaryEvent); } else if (STENCIL_EVENT_BOUNDARY_SIGNAL.equals(stencilId)) { convertJsonToSignalDefinition(elementNode, boundaryEvent); boundaryEvent.setCancelActivity(getPropertyValueAsBoolean(PROPERTY_CANCEL_ACTIVITY, elementNode)); } else if (STENCIL_EVENT_BOUNDARY_MESSAGE.equals(stencilId)) { convertJsonToMessageDefinition(elementNode, boundaryEvent); boundaryEvent.setCancelActivity(getPropertyValueAsBoolean(PROPERTY_CANCEL_ACTIVITY, elementNode)); } else if (STENCIL_EVENT_BOUNDARY_CANCEL.equals(stencilId)) { CancelEventDefinition cancelEventDefinition = new CancelEventDefinition(); boundaryEvent.getEventDefinitions().add(cancelEventDefinition); boundaryEvent.setCancelActivity(getPropertyValueAsBoolean(PROPERTY_CANCEL_ACTIVITY, elementNode)); } else if (STENCIL_EVENT_BOUNDARY_COMPENSATION.equals(stencilId)) { CompensateEventDefinition compensateEventDefinition = new CompensateEventDefinition(); boundaryEvent.getEventDefinitions().add(compensateEventDefinition); boundaryEvent.setCancelActivity(getPropertyValueAsBoolean(PROPERTY_CANCEL_ACTIVITY, elementNode)); } boundaryEvent.setAttachedToRefId(lookForAttachedRef(elementNode.get(EDITOR_SHAPE_ID).asText(), modelNode.get(EDITOR_CHILD_SHAPES))); return boundaryEvent; }
protected void executeCompensateBoundaryEvents(Collection<BoundaryEvent> boundaryEvents, DelegateExecution execution) { // The parent execution becomes a scope, and a child execution is created for each of the boundary events for (BoundaryEvent boundaryEvent : boundaryEvents) { if (CollectionUtil.isEmpty(boundaryEvent.getEventDefinitions())) { continue; } if (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition == false) { continue; } ExecutionEntity childExecutionEntity = Context.getCommandContext().getExecutionEntityManager().createChildExecution((ExecutionEntity) execution); childExecutionEntity.setParentId(execution.getId()); childExecutionEntity.setCurrentFlowElement(boundaryEvent); childExecutionEntity.setScope(false); ActivityBehavior boundaryEventBehavior = ((ActivityBehavior) boundaryEvent.getBehavior()); boundaryEventBehavior.execute(childExecutionEntity); } }
protected void executeCompensationBoundaryEvents(FlowElement flowElement, DelegateExecution execution) { //Execute compensation boundary events Collection<BoundaryEvent> boundaryEvents = findBoundaryEventsForFlowNode(execution.getProcessDefinitionId(), flowElement); if (CollectionUtil.isNotEmpty(boundaryEvents)) { // The parent execution becomes a scope, and a child execution is created for each of the boundary events for (BoundaryEvent boundaryEvent : boundaryEvents) { if (CollectionUtil.isEmpty(boundaryEvent.getEventDefinitions())) { continue; } if (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition) { ExecutionEntity childExecutionEntity = Context.getCommandContext().getExecutionEntityManager() .createChildExecution((ExecutionEntity) execution); childExecutionEntity.setParentId(execution.getId()); childExecutionEntity.setCurrentFlowElement(boundaryEvent); childExecutionEntity.setScope(false); ActivityBehavior boundaryEventBehavior = ((ActivityBehavior) boundaryEvent.getBehavior()); boundaryEventBehavior.execute(childExecutionEntity); } } } }
protected void cleanupExecutions(FlowElement currentFlowElement) { if (execution.getParentId() != null && execution.isScope()) { // If the execution is a scope (and not a process instance), the scope must first be // destroyed before we can continue and follow the sequence flow Context.getAgenda().planDestroyScopeOperation(execution); } else if (currentFlowElement instanceof Activity) { // If the current activity is an activity, we need to remove any currently active boundary events Activity activity = (Activity) currentFlowElement; if (CollectionUtil.isNotEmpty(activity.getBoundaryEvents())) { // Cancel events are not removed List<String> notToDeleteEvents = new ArrayList<String>(); for (BoundaryEvent event : activity.getBoundaryEvents()) { if (CollectionUtil.isNotEmpty(event.getEventDefinitions()) && event.getEventDefinitions().get(0) instanceof CancelEventDefinition) { notToDeleteEvents.add(event.getId()); } } // Delete all child executions Collection<ExecutionEntity> childExecutions = commandContext.getExecutionEntityManager().findChildExecutionsByParentExecutionId(execution.getId()); for (ExecutionEntity childExecution : childExecutions) { if (childExecution.getCurrentFlowElement() == null || !notToDeleteEvents.contains(childExecution.getCurrentFlowElement().getId())) { commandContext.getExecutionEntityManager().deleteExecutionAndRelatedData(childExecution, null, false); } } } } }
if (CollectionUtil.isNotEmpty(subActivity.getBoundaryEvents())) { for (BoundaryEvent boundaryEvent : subActivity.getBoundaryEvents()) { if (CollectionUtil.isNotEmpty(boundaryEvent.getEventDefinitions()) && boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition) { hasCompensation = true; break;
if (CollectionUtil.isNotEmpty(subProcess.getBoundaryEvents())) { for (BoundaryEvent boundaryEvent : subProcess.getBoundaryEvents()) { if (CollectionUtil.isNotEmpty(boundaryEvent.getEventDefinitions()) && boundaryEvent.getEventDefinitions().get(0) instanceof CancelEventDefinition) {
if (CollectionUtil.isNotEmpty(subActivity.getBoundaryEvents())) { for (BoundaryEvent boundaryEvent : subActivity.getBoundaryEvents()) { if (CollectionUtil.isNotEmpty(boundaryEvent.getEventDefinitions()) && boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition) {
@Override protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { BoundaryEvent boundaryEvent = (BoundaryEvent) element; writeEventDefinitions(boundaryEvent, boundaryEvent.getEventDefinitions(), model, xtw); } }
@Override protected void writeAdditionalChildElements(BaseElement element, XMLStreamWriter xtw) throws Exception { BoundaryEvent boundaryEvent = (BoundaryEvent) element; writeEventDefinitions(boundaryEvent.getEventDefinitions(), xtw); } }
@Override protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { BoundaryEvent boundaryEvent = (BoundaryEvent) element; if (boundaryEvent.getAttachedToRef() != null) { writeDefaultAttribute(ATTRIBUTE_BOUNDARY_ATTACHEDTOREF, boundaryEvent.getAttachedToRef().getId(), xtw); } if (boundaryEvent.getEventDefinitions().size() == 1) { EventDefinition eventDef = boundaryEvent.getEventDefinitions().get(0); if (eventDef instanceof ErrorEventDefinition == false) { writeDefaultAttribute(ATTRIBUTE_BOUNDARY_CANCELACTIVITY, String.valueOf(boundaryEvent.isCancelActivity()).toLowerCase(), xtw); } } }
@Override protected void writeAdditionalAttributes(BaseElement element, XMLStreamWriter xtw) throws Exception { BoundaryEvent boundaryEvent = (BoundaryEvent) element; if (boundaryEvent.getAttachedToRef() != null) { writeDefaultAttribute(ATTRIBUTE_BOUNDARY_ATTACHEDTOREF, boundaryEvent.getAttachedToRef().getId(), xtw); } if (boundaryEvent.getEventDefinitions().size() == 1) { EventDefinition eventDef = boundaryEvent.getEventDefinitions().get(0); if (eventDef instanceof ErrorEventDefinition == false) { writeDefaultAttribute(ATTRIBUTE_BOUNDARY_CANCELACTIVITY, String.valueOf(boundaryEvent.isCancelActivity()).toLowerCase(), xtw); } } }