Search in sources :

Example 16 with EventDefinition

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

the class StartEventConverter method convert.

public BpmnNode convert(StartEvent event) {
    CatchEventPropertyReader p = propertyReaderFactory.of(event);
    List<EventDefinition> eventDefinitions = p.getEventDefinitions();
    switch(eventDefinitions.size()) {
        case 0:
            return noneEvent(event);
        case 1:
            return Match.of(EventDefinition.class, BpmnNode.class).when(SignalEventDefinition.class, e -> signalEvent(event, e)).when(MessageEventDefinition.class, e -> messageEvent(event, e)).when(TimerEventDefinition.class, e -> timerEvent(event, e)).when(ErrorEventDefinition.class, e -> errorEvent(event, e)).missing(ConditionalEventDefinition.class).missing(EscalationEventDefinition.class).missing(CompensateEventDefinition.class).apply(eventDefinitions.get(0)).value();
        default:
            throw new UnsupportedOperationException("Multiple event definitions not supported for start event");
    }
}
Also used : StartEvent(org.eclipse.bpmn2.StartEvent) EventDefinition(org.eclipse.bpmn2.EventDefinition) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) Edge(org.kie.workbench.common.stunner.core.graph.Edge) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) StartSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) TimerSettings(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettings) StartTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) ErrorRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.ErrorRef) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) InterruptingSignalEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.InterruptingSignalEventExecutionSet) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) EventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader) StartErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) InterruptingTimerEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.InterruptingTimerEventExecutionSet) PropertyReaderFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.PropertyReaderFactory) InterruptingErrorEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.InterruptingErrorEventExecutionSet) List(java.util.List) SignalRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) Match(org.kie.workbench.common.stunner.bpmn.backend.converters.Match) Optional(java.util.Optional) StartMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.StartMessageEvent) IsInterrupting(org.kie.workbench.common.stunner.bpmn.definition.property.event.IsInterrupting) CatchEventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.CatchEventPropertyReader) Node(org.kie.workbench.common.stunner.core.graph.Node) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) InterruptingMessageEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.InterruptingMessageEventExecutionSet) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) CatchEventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.CatchEventPropertyReader) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) EventDefinition(org.eclipse.bpmn2.EventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition)

Example 17 with EventDefinition

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

the class Bpmn2JsonMarshaller method marshallIntermediateCatchEvent.

protected void marshallIntermediateCatchEvent(IntermediateCatchEvent catchEvent, BPMNPlane plane, JsonGenerator generator, float xOffset, float yOffset, Map<String, Object> properties) throws JsonGenerationException, IOException {
    List<EventDefinition> eventDefinitions = catchEvent.getEventDefinitions();
    // simulation properties
    setSimulationProperties(catchEvent.getId(), properties);
    if (eventDefinitions.size() == 1) {
        EventDefinition eventDefinition = eventDefinitions.get(0);
        if (eventDefinition instanceof SignalEventDefinition) {
            marshallNode(catchEvent, properties, "IntermediateSignalEventCatching", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof MessageEventDefinition) {
            marshallNode(catchEvent, properties, "IntermediateMessageEventCatching", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof TimerEventDefinition) {
            marshallNode(catchEvent, properties, "IntermediateTimerEvent", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof ConditionalEventDefinition) {
            marshallNode(catchEvent, properties, "IntermediateConditionalEvent", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof ErrorEventDefinition) {
            marshallNode(catchEvent, properties, "IntermediateErrorEvent", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof EscalationEventDefinition) {
            marshallNode(catchEvent, properties, "IntermediateEscalationEvent", plane, generator, xOffset, yOffset);
        } else if (eventDefinition instanceof CompensateEventDefinition) {
            marshallNode(catchEvent, properties, "IntermediateCompensationEventCatching", plane, generator, xOffset, yOffset);
        } else {
            throw new UnsupportedOperationException("Event definition not supported: " + eventDefinition);
        }
    } else {
        throw new UnsupportedOperationException("Intermediate catch event does not have event definition.");
    }
}
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 18 with EventDefinition

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

the class Bpmn2JsonMarshaller method setThrowEventProperties.

private void setThrowEventProperties(ThrowEvent event, Map<String, Object> properties, Definitions def) {
    if (event.getInputSet() != null) {
        List<DataInput> dataInputs = event.getInputSet().getDataInputRefs();
        StringBuffer dinbuff = new StringBuffer();
        for (DataInput din : dataInputs) {
            dinbuff.append(din.getName());
            String dtype = getAnyAttributeValue(din, "dtype");
            if (dtype != null && !dtype.isEmpty()) {
                dinbuff.append(":").append(dtype);
            }
            dinbuff.append(",");
        }
        if (dinbuff.length() > 0) {
            dinbuff.setLength(dinbuff.length() - 1);
        }
        String datainput = dinbuff.toString();
        properties.put(DATAINPUT, datainput);
        StringBuilder associationBuff = new StringBuilder();
        marshallDataInputAssociations(associationBuff, event.getDataInputAssociation());
        String assignmentString = associationBuff.toString();
        if (assignmentString.endsWith(",")) {
            assignmentString = assignmentString.substring(0, assignmentString.length() - 1);
        }
        properties.put(DATAINPUTASSOCIATIONS, assignmentString);
        setAssignmentsInfoProperty(datainput, null, null, null, assignmentString, properties);
    }
    // signal scope
    String signalScope = Utils.getMetaDataValue(event.getExtensionValues(), "customScope");
    if (signalScope != null) {
        properties.put(SIGNALSCOPE, signalScope);
    }
    // event definitions
    List<EventDefinition> eventdefs = event.getEventDefinitions();
    for (EventDefinition ed : eventdefs) {
        if (ed instanceof TimerEventDefinition) {
            setTimerEventProperties((TimerEventDefinition) ed, properties);
        } else if (ed instanceof SignalEventDefinition) {
            if (((SignalEventDefinition) ed).getSignalRef() != null) {
                // find signal with the corresponding id
                boolean foundSignalRef = false;
                List<RootElement> rootElements = def.getRootElements();
                for (RootElement re : rootElements) {
                    if (re instanceof Signal) {
                        if (re.getId().equals(((SignalEventDefinition) ed).getSignalRef())) {
                            properties.put(SIGNALREF, ((Signal) re).getName());
                            foundSignalRef = true;
                        }
                    }
                }
                if (!foundSignalRef) {
                    properties.put(SIGNALREF, "");
                }
            } else {
                properties.put(SIGNALREF, "");
            }
        } else if (ed instanceof ErrorEventDefinition) {
            if (((ErrorEventDefinition) ed).getErrorRef() != null && ((ErrorEventDefinition) ed).getErrorRef().getErrorCode() != null) {
                properties.put(ERRORREF, ((ErrorEventDefinition) ed).getErrorRef().getErrorCode());
            } else {
                properties.put(ERRORREF, "");
            }
        } else if (ed instanceof ConditionalEventDefinition) {
            FormalExpression conditionalExp = (FormalExpression) ((ConditionalEventDefinition) ed).getCondition();
            if (conditionalExp != null) {
                setConditionExpressionProperties(conditionalExp, properties, "drools");
            }
        } else if (ed instanceof EscalationEventDefinition) {
            if (((EscalationEventDefinition) ed).getEscalationRef() != null) {
                Escalation esc = ((EscalationEventDefinition) ed).getEscalationRef();
                if (esc.getEscalationCode() != null && esc.getEscalationCode().length() > 0) {
                    properties.put(ESCALATIONCODE, esc.getEscalationCode());
                } else {
                    properties.put(ESCALATIONCODE, "");
                }
            }
        } else if (ed instanceof MessageEventDefinition) {
            if (((MessageEventDefinition) ed).getMessageRef() != null) {
                Message msg = ((MessageEventDefinition) ed).getMessageRef();
                properties.put(MESSAGEREF, msg.getName());
            }
        } else if (ed instanceof CompensateEventDefinition) {
            if (((CompensateEventDefinition) ed).getActivityRef() != null) {
                Activity act = ((CompensateEventDefinition) ed).getActivityRef();
                properties.put(ACTIVITYREF, act.getName());
            }
        }
    }
}
Also used : Message(org.eclipse.bpmn2.Message) Escalation(org.eclipse.bpmn2.Escalation) Activity(org.eclipse.bpmn2.Activity) CallActivity(org.eclipse.bpmn2.CallActivity) 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) FormalExpression(org.eclipse.bpmn2.FormalExpression) DataInput(org.eclipse.bpmn2.DataInput) Signal(org.eclipse.bpmn2.Signal) RootElement(org.eclipse.bpmn2.RootElement) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition)

Aggregations

CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)17 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)17 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)17 EventDefinition (org.eclipse.bpmn2.EventDefinition)17 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)17 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)17 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)16 TimerEventDefinition (org.eclipse.bpmn2.TimerEventDefinition)16 List (java.util.List)9 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)8 Activity (org.eclipse.bpmn2.Activity)7 CallActivity (org.eclipse.bpmn2.CallActivity)7 Escalation (org.eclipse.bpmn2.Escalation)6 RootElement (org.eclipse.bpmn2.RootElement)6 Signal (org.eclipse.bpmn2.Signal)6 ArrayList (java.util.ArrayList)5 Entry (java.util.Map.Entry)5 CancelEventDefinition (org.eclipse.bpmn2.CancelEventDefinition)5 TerminateEventDefinition (org.eclipse.bpmn2.TerminateEventDefinition)5 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)5