private void processFlowElements( Collection<FlowElement> flowElementList, BaseElement parentScope) { for (FlowElement flowElement : flowElementList) { if (flowElement instanceof SequenceFlow) { SequenceFlow sequenceFlow = (SequenceFlow) flowElement; FlowNode sourceNode = getFlowNodeFromScope(sequenceFlow.getSourceRef(), parentScope); if (sourceNode != null) { sourceNode.getOutgoingFlows().add(sequenceFlow); } FlowNode targetNode = getFlowNodeFromScope(sequenceFlow.getTargetRef(), parentScope); if (targetNode != null) { targetNode.getIncomingFlows().add(sequenceFlow); } } else if (flowElement instanceof BoundaryEvent) { BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement; FlowElement attachedToElement = getFlowNodeFromScope(boundaryEvent.getAttachedToRefId(), parentScope); if (attachedToElement != null) { boundaryEvent.setAttachedToRef((Activity) attachedToElement); ((Activity) attachedToElement).getBoundaryEvents().add(boundaryEvent); } } else if (flowElement instanceof SubProcess) { SubProcess subProcess = (SubProcess) flowElement; processFlowElements(subProcess.getFlowElements(), subProcess); } } }
public Object[] create(ICreateContext context) { BoundaryEvent boundaryEvent = new BoundaryEvent(); CompensateEventDefinition compensateEvent = new CompensateEventDefinition(); boundaryEvent.getEventDefinitions().add(compensateEvent); Object parentObject = getBusinessObjectForPictogramElement(context.getTargetContainer()); ((Activity) parentObject).getBoundaryEvents().add(boundaryEvent); boundaryEvent.setAttachedToRef((Activity) parentObject); addObjectToContainer(context, boundaryEvent, "Compensate"); // return newly created business object(s) return new Object[] {boundaryEvent}; }