Search in sources :

Example 1 with FlowElementsContainer

use of org.eclipse.bpmn2.FlowElementsContainer in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitBoundaryEventsPositions.

protected void revisitBoundaryEventsPositions(Definitions def) {
    for (RootElement root : def.getRootElements()) {
        if (root instanceof Process) {
            Process process = (Process) root;
            List<BoundaryEvent> toRemove = new ArrayList();
            for (FlowElement fe : process.getFlowElements()) {
                if (fe instanceof BoundaryEvent) {
                    BoundaryEvent be = (BoundaryEvent) fe;
                    FlowElementsContainer container = findContainerForBoundaryEvent(process, be);
                    if (container != null && !(container instanceof Process)) {
                        BoundaryEvent beCopy = copyBoundaryEvent(be);
                        container.getFlowElements().add(beCopy);
                        _outgoingFlows.put(beCopy, _outgoingFlows.get(be));
                        toRemove.add(be);
                        _outgoingFlows.remove(be);
                    }
                }
            }
            for (BoundaryEvent be : toRemove) {
                process.getFlowElements().remove(be);
            }
        }
    }
    reconnectFlows();
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) FlowElement(org.eclipse.bpmn2.FlowElement) ArrayList(java.util.ArrayList) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

Example 2 with FlowElementsContainer

use of org.eclipse.bpmn2.FlowElementsContainer in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method setThrowEventsInfoForLanes.

public void setThrowEventsInfoForLanes(Lane lane, Definitions def, List<RootElement> rootElements, List<Signal> toAddSignals, Set<Error> toAddErrors, Set<Escalation> toAddEscalations, Set<Message> toAddMessages, Set<ItemDefinition> toAddItemDefinitions) {
    List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs();
    for (FlowNode fe : laneFlowNodes) {
        if (fe instanceof ThrowEvent) {
            if (((ThrowEvent) fe).getEventDefinitions().size() > 0) {
                EventDefinition ed = ((ThrowEvent) fe).getEventDefinitions().get(0);
                if (ed instanceof SignalEventDefinition) {
                    SignalEventDefinition sed = (SignalEventDefinition) ed;
                    if (sed.getSignalRef() != null && sed.getSignalRef().length() > 0) {
                        String signalRef = sed.getSignalRef();
                        boolean shouldAddSignal = true;
                        for (RootElement re : rootElements) {
                            if (re instanceof Signal) {
                                if (((Signal) re).getName().equals(signalRef)) {
                                    shouldAddSignal = false;
                                    break;
                                }
                            }
                        }
                        if (toAddSignals != null) {
                            for (Signal s : toAddSignals) {
                                if (s.getName().equals(signalRef)) {
                                    shouldAddSignal = false;
                                    break;
                                }
                            }
                        }
                        if (shouldAddSignal) {
                            Signal signal = Bpmn2Factory.eINSTANCE.createSignal();
                            signal.setName(signalRef);
                            toAddSignals.add(signal);
                        }
                    }
                } else if (ed instanceof ErrorEventDefinition) {
                    String errorCode = null;
                    String errorId = null;
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("erefname")) {
                            errorId = (String) entry.getValue();
                            errorCode = (String) entry.getValue();
                        }
                    }
                    Error err = this._errors.get(errorCode);
                    if (err == null) {
                        err = Bpmn2Factory.eINSTANCE.createError();
                        err.setId(errorId);
                        err.setErrorCode(errorCode);
                        this._errors.put(errorCode, err);
                    }
                    toAddErrors.add(err);
                    ((ErrorEventDefinition) ed).setErrorRef(err);
                } else if (ed instanceof EscalationEventDefinition) {
                    String escalationCode = null;
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("esccode")) {
                            escalationCode = (String) entry.getValue();
                            break;
                        }
                    }
                    Escalation escalation = this._escalations.get(escalationCode);
                    if (escalation == null) {
                        escalation = Bpmn2Factory.eINSTANCE.createEscalation();
                        escalation.setEscalationCode(escalationCode);
                        this._escalations.put(escalationCode, escalation);
                    }
                    toAddEscalations.add(escalation);
                    ((EscalationEventDefinition) ed).setEscalationRef(escalation);
                } else if (ed instanceof MessageEventDefinition) {
                    ((MessageEventDefinition) ed).setMessageRef(extractMessage(ed, toAddMessages, toAddItemDefinitions));
                } else if (ed instanceof CompensateEventDefinition) {
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("actrefname")) {
                            String activityNameRef = (String) entry.getValue();
                            // we have to iterate again through all flow
                            // elements
                            // in order to find our activity name
                            List<RootElement> re = def.getRootElements();
                            for (RootElement r : re) {
                                if (r instanceof Process) {
                                    Process p = (Process) r;
                                    List<FlowElement> fes = p.getFlowElements();
                                    for (FlowElement f : fes) {
                                        if (f instanceof Activity && ((Activity) f).getName().equals(activityNameRef)) {
                                            ((CompensateEventDefinition) ed).setActivityRef((Activity) f);
                                            ((Activity) f).setIsForCompensation(true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else if (fe instanceof FlowElementsContainer) {
            setThrowEventsInfo((FlowElementsContainer) fe, def, rootElements, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions);
        }
    }
}
Also used : Escalation(org.eclipse.bpmn2.Escalation) Activity(org.eclipse.bpmn2.Activity) CallActivity(org.eclipse.bpmn2.CallActivity) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) EventDefinition(org.eclipse.bpmn2.EventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) Signal(org.eclipse.bpmn2.Signal) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) Iterator(java.util.Iterator) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) ThrowEvent(org.eclipse.bpmn2.ThrowEvent) Error(org.eclipse.bpmn2.Error) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) RootElement(org.eclipse.bpmn2.RootElement) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) FlowElement(org.eclipse.bpmn2.FlowElement) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 3 with FlowElementsContainer

use of org.eclipse.bpmn2.FlowElementsContainer in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitCatchEVentsConvertToBoundaryExecute.

private void revisitCatchEVentsConvertToBoundaryExecute(Process process, FlowElementsContainer subContainer, List<CatchEvent> catchEventsToRemove, Map<BoundaryEvent, List<String>> boundaryEventsToAdd) {
    FlowElementsContainer container = subContainer != null ? subContainer : process;
    List<FlowElement> flowElements = container.getFlowElements();
    for (FlowElement fe : flowElements) {
        if (fe instanceof CatchEvent) {
            // check if we have an outgoing connection to this catch event from an activity
            for (Entry<Object, List<String>> entry : _outgoingFlows.entrySet()) {
                for (String flowId : entry.getValue()) {
                    if (entry.getKey() instanceof Activity && flowId.equals(fe.getId())) {
                        CatchEvent ce = (CatchEvent) fe;
                        EventDefinition ed = null;
                        if (ce.getEventDefinitions() != null && ce.getEventDefinitions().size() > 0) {
                            ed = ce.getEventDefinitions().get(0);
                        }
                        BoundaryEvent be = Bpmn2Factory.eINSTANCE.createBoundaryEvent();
                        if (ed != null && ed instanceof ErrorEventDefinition) {
                            be.setCancelActivity(true);
                        } else {
                            Iterator<FeatureMap.Entry> iter = ce.getAnyAttribute().iterator();
                            while (iter.hasNext()) {
                                FeatureMap.Entry entry2 = iter.next();
                                if (entry2.getEStructuralFeature().getName().equals("boundaryca")) {
                                    String boundaryceVal = (String) entry2.getValue();
                                    be.setCancelActivity(Boolean.parseBoolean(boundaryceVal));
                                }
                            }
                        }
                        if (ce.getDataOutputs() != null) {
                            be.getDataOutputs().addAll(ce.getDataOutputs());
                        }
                        if (ce.getDataOutputAssociation() != null) {
                            be.getDataOutputAssociation().addAll(ce.getDataOutputAssociation());
                        }
                        if (ce.getOutputSet() != null) {
                            be.setOutputSet(ce.getOutputSet());
                        }
                        if (ce.getEventDefinitions() != null) {
                            be.getEventDefinitions().addAll(ce.getEventDefinitions());
                        }
                        if (ce.getEventDefinitionRefs() != null) {
                            be.getEventDefinitionRefs().addAll(ce.getEventDefinitionRefs());
                        }
                        if (ce.getProperties() != null) {
                            be.getProperties().addAll(ce.getProperties());
                        }
                        if (ce.getAnyAttribute() != null) {
                            be.getAnyAttribute().addAll(ce.getAnyAttribute());
                        }
                        if (ce.getOutgoing() != null) {
                            be.getOutgoing().addAll(ce.getOutgoing());
                        }
                        if (ce.getIncoming() != null) {
                            be.getIncoming().addAll(ce.getIncoming());
                        }
                        if (ce.getProperties() != null) {
                            be.getProperties().addAll(ce.getProperties());
                        }
                        be.getDocumentation().addAll(ce.getDocumentation());
                        be.setName(ce.getName());
                        String ceElementName = Utils.getMetaDataValue(ce.getExtensionValues(), "elementname");
                        if (ceElementName != null) {
                            Utils.setMetaDataExtensionValue(be, "elementname", ceElementName);
                        }
                        be.setId(ce.getId());
                        be.setAttachedToRef(((Activity) entry.getKey()));
                        ((Activity) entry.getKey()).getBoundaryEventRefs().add(be);
                        catchEventsToRemove.add(ce);
                        boundaryEventsToAdd.put(be, _outgoingFlows.get(ce));
                    }
                }
            }
        } else if (fe instanceof FlowElementsContainer) {
            revisitCatchEVentsConvertToBoundaryExecute(process, (FlowElementsContainer) fe, catchEventsToRemove, boundaryEventsToAdd);
        }
    }
    if (catchEventsToRemove.size() > 0) {
        for (CatchEvent ce : catchEventsToRemove) {
            boolean removed = container.getFlowElements().remove(ce);
            _outgoingFlows.remove(ce);
        }
    }
    if (boundaryEventsToAdd.size() > 0) {
        Iterator<BoundaryEvent> boundaryToAddIterator = boundaryEventsToAdd.keySet().iterator();
        while (boundaryToAddIterator.hasNext()) {
            BoundaryEvent bToAdd = boundaryToAddIterator.next();
            container.getFlowElements().add(bToAdd);
            _outgoingFlows.put(bToAdd, boundaryEventsToAdd.get(bToAdd));
        }
    }
}
Also used : BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) Activity(org.eclipse.bpmn2.Activity) CallActivity(org.eclipse.bpmn2.CallActivity) CatchEvent(org.eclipse.bpmn2.CatchEvent) EventDefinition(org.eclipse.bpmn2.EventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) FlowElement(org.eclipse.bpmn2.FlowElement) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) EObject(org.eclipse.emf.ecore.EObject) DataObject(org.eclipse.bpmn2.DataObject) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with FlowElementsContainer

use of org.eclipse.bpmn2.FlowElementsContainer in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method setCatchEventsInfo.

public void setCatchEventsInfo(FlowElementsContainer container, Definitions def, List<Signal> toAddSignals, Set<Error> toAddErrors, Set<Escalation> toAddEscalations, Set<Message> toAddMessages, Set<ItemDefinition> toAddItemDefinitions) {
    List<FlowElement> flowElements = container.getFlowElements();
    for (FlowElement fe : flowElements) {
        if (fe instanceof CatchEvent) {
            if (((CatchEvent) fe).getEventDefinitions().size() > 0) {
                EventDefinition ed = ((CatchEvent) fe).getEventDefinitions().get(0);
                if (ed instanceof SignalEventDefinition) {
                    SignalEventDefinition sed = (SignalEventDefinition) ed;
                    if (sed.getSignalRef() != null && sed.getSignalRef().length() > 0) {
                        String signalRef = sed.getSignalRef();
                        boolean shouldAddSignal = true;
                        List<RootElement> rootElements = def.getRootElements();
                        for (RootElement re : rootElements) {
                            if (re instanceof Signal) {
                                if (((Signal) re).getName().equals(signalRef)) {
                                    shouldAddSignal = false;
                                    break;
                                }
                            }
                        }
                        if (toAddSignals != null) {
                            for (Signal s : toAddSignals) {
                                if (s.getName().equals(signalRef)) {
                                    shouldAddSignal = false;
                                    break;
                                }
                            }
                        }
                        if (shouldAddSignal) {
                            Signal signal = Bpmn2Factory.eINSTANCE.createSignal();
                            signal.setName(signalRef);
                            toAddSignals.add(signal);
                        }
                    }
                } else if (ed instanceof ErrorEventDefinition) {
                    String errorCode = null;
                    String errorId = null;
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("erefname")) {
                            errorId = (String) entry.getValue();
                            errorCode = (String) entry.getValue();
                        }
                    }
                    Error err = this._errors.get(errorCode);
                    if (err == null) {
                        err = Bpmn2Factory.eINSTANCE.createError();
                        err.setId(errorId);
                        err.setErrorCode(errorCode);
                        this._errors.put(errorCode, err);
                    }
                    toAddErrors.add(err);
                    ((ErrorEventDefinition) ed).setErrorRef(err);
                } else if (ed instanceof EscalationEventDefinition) {
                    String escalationCode = null;
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("esccode")) {
                            escalationCode = (String) entry.getValue();
                            break;
                        }
                    }
                    Escalation escalation = this._escalations.get(escalationCode);
                    if (escalation == null) {
                        escalation = Bpmn2Factory.eINSTANCE.createEscalation();
                        escalation.setEscalationCode(escalationCode);
                        this._escalations.put(escalationCode, escalation);
                    }
                    toAddEscalations.add(escalation);
                    ((EscalationEventDefinition) ed).setEscalationRef(escalation);
                } else if (ed instanceof MessageEventDefinition) {
                    ((MessageEventDefinition) ed).setMessageRef(extractMessage(ed, toAddMessages, toAddItemDefinitions));
                } else if (ed instanceof CompensateEventDefinition) {
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("actrefname")) {
                            String activityNameRef = (String) entry.getValue();
                            // we have to iterate again through all flow elements
                            // in order to find our activity name
                            List<RootElement> re = def.getRootElements();
                            for (RootElement r : re) {
                                if (r instanceof Process) {
                                    Process p = (Process) r;
                                    List<FlowElement> fes = p.getFlowElements();
                                    for (FlowElement f : fes) {
                                        if (f instanceof Activity && ((Activity) f).getName().equals(activityNameRef)) {
                                            ((CompensateEventDefinition) ed).setActivityRef((Activity) f);
                                            ((Activity) f).setIsForCompensation(true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else if (fe instanceof FlowElementsContainer) {
            setCatchEventsInfo((FlowElementsContainer) fe, def, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions);
        }
    }
}
Also used : Escalation(org.eclipse.bpmn2.Escalation) Error(org.eclipse.bpmn2.Error) Activity(org.eclipse.bpmn2.Activity) CallActivity(org.eclipse.bpmn2.CallActivity) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) CatchEvent(org.eclipse.bpmn2.CatchEvent) EventDefinition(org.eclipse.bpmn2.EventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Signal(org.eclipse.bpmn2.Signal) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) RootElement(org.eclipse.bpmn2.RootElement) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) FlowElement(org.eclipse.bpmn2.FlowElement) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) Iterator(java.util.Iterator) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition)

Example 5 with FlowElementsContainer

use of org.eclipse.bpmn2.FlowElementsContainer in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method setCatchEventsInfoForLanes.

public void setCatchEventsInfoForLanes(Lane lane, Definitions def, List<Signal> toAddSignals, Set<Error> toAddErrors, Set<Escalation> toAddEscalations, Set<Message> toAddMessages, Set<ItemDefinition> toAddItemDefinitions) {
    List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs();
    for (FlowElement fe : laneFlowNodes) {
        if (fe instanceof CatchEvent) {
            if (((CatchEvent) fe).getEventDefinitions().size() > 0) {
                EventDefinition ed = ((CatchEvent) fe).getEventDefinitions().get(0);
                if (ed instanceof SignalEventDefinition) {
                    SignalEventDefinition sed = (SignalEventDefinition) ed;
                    if (sed.getSignalRef() != null && sed.getSignalRef().length() > 0) {
                        String signalRef = sed.getSignalRef();
                        boolean shouldAddSignal = true;
                        List<RootElement> rootElements = def.getRootElements();
                        for (RootElement re : rootElements) {
                            if (re instanceof Signal) {
                                if (((Signal) re).getName().equals(signalRef)) {
                                    shouldAddSignal = false;
                                    break;
                                }
                            }
                        }
                        if (toAddSignals != null) {
                            for (Signal s : toAddSignals) {
                                if (s.getName().equals(signalRef)) {
                                    shouldAddSignal = false;
                                    break;
                                }
                            }
                        }
                        if (shouldAddSignal) {
                            Signal signal = Bpmn2Factory.eINSTANCE.createSignal();
                            signal.setName(signalRef);
                            toAddSignals.add(signal);
                        }
                    }
                } else if (ed instanceof ErrorEventDefinition) {
                    String errorCode = null;
                    String errorId = null;
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("erefname")) {
                            errorId = (String) entry.getValue();
                            errorCode = (String) entry.getValue();
                        }
                    }
                    Error err = this._errors.get(errorCode);
                    if (err == null) {
                        err = Bpmn2Factory.eINSTANCE.createError();
                        err.setId(errorId);
                        err.setErrorCode(errorCode);
                        this._errors.put(errorCode, err);
                    }
                    toAddErrors.add(err);
                    ((ErrorEventDefinition) ed).setErrorRef(err);
                } else if (ed instanceof EscalationEventDefinition) {
                    String escalationCode = null;
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("esccode")) {
                            escalationCode = (String) entry.getValue();
                            break;
                        }
                    }
                    Escalation escalation = this._escalations.get(escalationCode);
                    if (escalation == null) {
                        escalation = Bpmn2Factory.eINSTANCE.createEscalation();
                        escalation.setEscalationCode(escalationCode);
                        this._escalations.put(escalationCode, escalation);
                    }
                    toAddEscalations.add(escalation);
                    ((EscalationEventDefinition) ed).setEscalationRef(escalation);
                } else if (ed instanceof MessageEventDefinition) {
                    ((MessageEventDefinition) ed).setMessageRef(extractMessage(ed, toAddMessages, toAddItemDefinitions));
                } else if (ed instanceof CompensateEventDefinition) {
                    Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
                    while (iter.hasNext()) {
                        FeatureMap.Entry entry = iter.next();
                        if (entry.getEStructuralFeature().getName().equals("actrefname")) {
                            String activityNameRef = (String) entry.getValue();
                            // we have to iterate again through all flow elements
                            // in order to find our activity name
                            List<RootElement> re = def.getRootElements();
                            for (RootElement r : re) {
                                if (r instanceof Process) {
                                    Process p = (Process) r;
                                    List<FlowElement> fes = p.getFlowElements();
                                    for (FlowElement f : fes) {
                                        if (f instanceof Activity && ((Activity) f).getName().equals(activityNameRef)) {
                                            ((CompensateEventDefinition) ed).setActivityRef((Activity) f);
                                            ((Activity) f).setIsForCompensation(true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } else if (fe instanceof FlowElementsContainer) {
            setCatchEventsInfo((FlowElementsContainer) fe, def, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions);
        }
    }
}
Also used : Escalation(org.eclipse.bpmn2.Escalation) Activity(org.eclipse.bpmn2.Activity) CallActivity(org.eclipse.bpmn2.CallActivity) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) CatchEvent(org.eclipse.bpmn2.CatchEvent) EventDefinition(org.eclipse.bpmn2.EventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) Signal(org.eclipse.bpmn2.Signal) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) Iterator(java.util.Iterator) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) Error(org.eclipse.bpmn2.Error) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) RootElement(org.eclipse.bpmn2.RootElement) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) FlowElement(org.eclipse.bpmn2.FlowElement) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) FlowNode(org.eclipse.bpmn2.FlowNode)

Aggregations

FlowElement (org.eclipse.bpmn2.FlowElement)14 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)14 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)9 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)9 Entry (java.util.Map.Entry)8 RootElement (org.eclipse.bpmn2.RootElement)8 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)7 CallActivity (org.eclipse.bpmn2.CallActivity)7 Process (org.eclipse.bpmn2.Process)7 SubProcess (org.eclipse.bpmn2.SubProcess)7 ArrayList (java.util.ArrayList)6 Activity (org.eclipse.bpmn2.Activity)6 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)5 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)5 Iterator (java.util.Iterator)4 List (java.util.List)4 CatchEvent (org.eclipse.bpmn2.CatchEvent)4 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)4 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)4 EventDefinition (org.eclipse.bpmn2.EventDefinition)4