Search in sources :

Example 1 with BoundaryEvent

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

the class Bpmn2JsonMarshaller method marshallBoundaryEvent.

protected void marshallBoundaryEvent(BoundaryEvent boundaryEvent, BPMNPlane plane, JsonGenerator generator, float xOffset, float yOffset, Map<String, Object> catchEventProperties) throws JsonGenerationException, IOException {
    List<EventDefinition> eventDefinitions = boundaryEvent.getEventDefinitions();
    if (boundaryEvent.isCancelActivity()) {
        catchEventProperties.put(BOUNDARYCANCELACTIVITY, "true");
    } else {
        catchEventProperties.put(BOUNDARYCANCELACTIVITY, "false");
    }
    // simulation properties
    setSimulationProperties(boundaryEvent.getId(), catchEventProperties);
    if (eventDefinitions.size() == 1) {
        EventDefinition eventDefinition = eventDefinitions.get(0);
        if (eventDefinition instanceof SignalEventDefinition) {
            marshallNode(boundaryEvent, catchEventProperties, "IntermediateSignalEventCatching", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof EscalationEventDefinition) {
            marshallNode(boundaryEvent, catchEventProperties, "IntermediateEscalationEvent", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof ErrorEventDefinition) {
            marshallNode(boundaryEvent, catchEventProperties, "IntermediateErrorEvent", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof TimerEventDefinition) {
            marshallNode(boundaryEvent, catchEventProperties, "IntermediateTimerEvent", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof CompensateEventDefinition) {
            marshallNode(boundaryEvent, catchEventProperties, "IntermediateCompensationEventCatching", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof ConditionalEventDefinition) {
            marshallNode(boundaryEvent, catchEventProperties, "IntermediateConditionalEvent", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof MessageEventDefinition) {
            marshallNode(boundaryEvent, catchEventProperties, "IntermediateMessageEventCatching", plane, generator, xOffset, yOffset);
        } else {
            throw new UnsupportedOperationException("Event definition not supported: " + eventDefinition);
        }
    } else {
        throw new UnsupportedOperationException("None or multiple event definitions not supported for boundary event");
    }
}
Also used : EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) EventDefinition(org.eclipse.bpmn2.EventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) TerminateEventDefinition(org.eclipse.bpmn2.TerminateEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) CancelEventDefinition(org.eclipse.bpmn2.CancelEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition)

Example 2 with BoundaryEvent

use of org.eclipse.bpmn2.BoundaryEvent 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 3 with BoundaryEvent

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

the class Bpmn2JsonUnmarshaller method copyBoundaryEvent.

private BoundaryEvent copyBoundaryEvent(BoundaryEvent beEntry) {
    EventDefinition ed = null;
    if (beEntry.getEventDefinitions() != null && beEntry.getEventDefinitions().size() > 0) {
        ed = beEntry.getEventDefinitions().get(0);
    }
    BoundaryEvent be = Bpmn2Factory.eINSTANCE.createBoundaryEvent();
    if (ed instanceof ErrorEventDefinition) {
        be.setCancelActivity(true);
    } else {
        Iterator<FeatureMap.Entry> iter = beEntry.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 (beEntry.getDataOutputs() != null) {
        be.getDataOutputs().addAll(beEntry.getDataOutputs());
    }
    if (beEntry.getDataOutputAssociation() != null) {
        be.getDataOutputAssociation().addAll(beEntry.getDataOutputAssociation());
    }
    if (beEntry.getOutputSet() != null) {
        be.setOutputSet(beEntry.getOutputSet());
    }
    if (beEntry.getEventDefinitions() != null) {
        be.getEventDefinitions().addAll(beEntry.getEventDefinitions());
    }
    if (beEntry.getEventDefinitionRefs() != null) {
        be.getEventDefinitionRefs().addAll(beEntry.getEventDefinitionRefs());
    }
    if (beEntry.getProperties() != null) {
        be.getProperties().addAll(beEntry.getProperties());
    }
    if (beEntry.getAnyAttribute() != null) {
        be.getAnyAttribute().addAll(beEntry.getAnyAttribute());
    }
    if (beEntry.getOutgoing() != null) {
        be.getOutgoing().addAll(beEntry.getOutgoing());
    }
    if (beEntry.getIncoming() != null) {
        be.getIncoming().addAll(beEntry.getIncoming());
    }
    if (beEntry.getExtensionValues() != null) {
        be.getExtensionValues().addAll(beEntry.getExtensionValues());
    }
    be.getDocumentation().addAll(beEntry.getDocumentation());
    be.setName(beEntry.getName());
    be.setId(beEntry.getId());
    be.setAttachedToRef(beEntry.getAttachedToRef());
    return be;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) 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)

Example 4 with BoundaryEvent

use of org.eclipse.bpmn2.BoundaryEvent 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 5 with BoundaryEvent

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

the class Bpmn2JsonUnmarshaller method createSubProcessDiagram.

private void createSubProcessDiagram(BPMNPlane plane, FlowElement flowElement, BpmnDiFactory factory) {
    SubProcess sp = (SubProcess) flowElement;
    for (FlowElement subProcessFlowElement : sp.getFlowElements()) {
        if (subProcessFlowElement instanceof SubProcess) {
            createBpmnShapeForElement(factory, plane, subProcessFlowElement);
            createSubProcessDiagram(plane, subProcessFlowElement, factory);
        } else if (subProcessFlowElement instanceof FlowNode) {
            createBpmnShapeForElement(factory, plane, subProcessFlowElement);
            if (subProcessFlowElement instanceof BoundaryEvent) {
                createDockersForBoundaryEvent((BoundaryEvent) subProcessFlowElement);
            }
        } else if (subProcessFlowElement instanceof SequenceFlow) {
            createBpmnEdgeForSequenceFlow(factory, plane, (SequenceFlow) subProcessFlowElement);
        }
    }
    if (sp.getArtifacts() != null) {
        List<Association> incompleteAssociations = new ArrayList<Association>();
        for (Artifact artifact : sp.getArtifacts()) {
            // if (artifact instanceof TextAnnotation || artifact instanceof Group) {
            if (artifact instanceof Group) {
                createBpmnShapeForElement(factory, plane, artifact);
            }
            if (artifact instanceof Association) {
                Association association = (Association) artifact;
                if (association.getSourceRef() != null && association.getTargetRef() != null) {
                    createBpmnEdgeForAssociation(factory, plane, association);
                } else {
                    incompleteAssociations.add(association);
                }
            }
        }
        if (!incompleteAssociations.isEmpty()) {
            for (Association incompleteAssociation : incompleteAssociations) {
                sp.getArtifacts().remove(incompleteAssociation);
            }
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Group(org.eclipse.bpmn2.Group) Association(org.eclipse.bpmn2.Association) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) FlowElement(org.eclipse.bpmn2.FlowElement) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) ArrayList(java.util.ArrayList) Artifact(org.eclipse.bpmn2.Artifact) FlowNode(org.eclipse.bpmn2.FlowNode)

Aggregations

BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)9 ArrayList (java.util.ArrayList)7 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)6 SubProcess (org.eclipse.bpmn2.SubProcess)6 FlowElement (org.eclipse.bpmn2.FlowElement)5 Process (org.eclipse.bpmn2.Process)5 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)4 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)4 DataObject (org.eclipse.bpmn2.DataObject)4 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)4 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)4 EventDefinition (org.eclipse.bpmn2.EventDefinition)4 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)4 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)4 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)4 List (java.util.List)3 Entry (java.util.Map.Entry)3 Artifact (org.eclipse.bpmn2.Artifact)3 CatchEvent (org.eclipse.bpmn2.CatchEvent)3 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)3