Search in sources :

Example 1 with Event

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

the class IntermediateCatchEventConverter method convertIntermediateCatchEvent.

public BpmnNode convertIntermediateCatchEvent(IntermediateCatchEvent event) {
    CatchEventPropertyReader p = propertyReaderFactory.of(event);
    List<EventDefinition> eventDefinitions = p.getEventDefinitions();
    switch(eventDefinitions.size()) {
        case 0:
            throw new UnsupportedOperationException("An intermediate catch event should contain exactly one definition");
        case 1:
            return Match.of(EventDefinition.class, BpmnNode.class).when(TimerEventDefinition.class, e -> timerEvent(event, e)).when(SignalEventDefinition.class, e -> signalEvent(event, e)).when(MessageEventDefinition.class, e -> messageEvent(event, e)).when(ErrorEventDefinition.class, e -> errorEvent(event, e)).missing(EscalationEventDefinition.class).missing(CompensateEventDefinition.class).missing(ConditionalEventDefinition.class).apply(eventDefinitions.get(0)).value();
        default:
            throw new UnsupportedOperationException("Multiple definitions not supported for intermediate catch event");
    }
}
Also used : EventDefinition(org.eclipse.bpmn2.EventDefinition) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) CancellingErrorEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.CancellingErrorEventExecutionSet) IntermediateErrorEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateErrorEventCatching) CancellingMessageEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.CancellingMessageEventExecutionSet) Edge(org.kie.workbench.common.stunner.core.graph.Edge) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) TimerSettings(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettings) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) ErrorRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.ErrorRef) IntermediateCatchEvent(org.eclipse.bpmn2.IntermediateCatchEvent) CancelActivity(org.kie.workbench.common.stunner.bpmn.definition.property.event.CancelActivity) 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) IntermediateSignalEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventCatching) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) CancellingSignalEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.CancellingSignalEventExecutionSet) CancellingTimerEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.CancellingTimerEventExecutionSet) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) EventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) PropertyReaderFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.PropertyReaderFactory) 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) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) CatchEvent(org.eclipse.bpmn2.CatchEvent) CatchEventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.CatchEventPropertyReader) IntermediateMessageEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventCatching) Node(org.kie.workbench.common.stunner.core.graph.Node) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) CatchEventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.CatchEventPropertyReader) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) 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) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition)

Example 2 with Event

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

the class Bpmn2JsonMarshaller method setCatchEventProperties.

private void setCatchEventProperties(CatchEvent event, Map<String, Object> properties, Definitions def) {
    if (event.getOutputSet() != null) {
        List<DataOutput> dataOutputs = event.getOutputSet().getDataOutputRefs();
        StringBuffer doutbuff = new StringBuffer();
        for (DataOutput dout : dataOutputs) {
            doutbuff.append(dout.getName());
            String dtype = getAnyAttributeValue(dout, "dtype");
            if (dtype != null && !dtype.isEmpty()) {
                doutbuff.append(":").append(dtype);
            }
            doutbuff.append(",");
        }
        if (doutbuff.length() > 0) {
            doutbuff.setLength(doutbuff.length() - 1);
        }
        String dataoutput = doutbuff.toString();
        properties.put(DATAOUTPUT, dataoutput);
        List<DataOutputAssociation> outputAssociations = event.getDataOutputAssociation();
        StringBuffer doutassociationbuff = new StringBuffer();
        for (DataOutputAssociation doa : outputAssociations) {
            String doaName = ((DataOutput) doa.getSourceRef().get(0)).getName();
            if (doaName != null && doaName.length() > 0) {
                doutassociationbuff.append("[dout]" + ((DataOutput) doa.getSourceRef().get(0)).getName());
                doutassociationbuff.append("->");
                doutassociationbuff.append(doa.getTargetRef().getId());
                doutassociationbuff.append(",");
            }
        }
        if (doutassociationbuff.length() > 0) {
            doutassociationbuff.setLength(doutassociationbuff.length() - 1);
        }
        String assignments = doutassociationbuff.toString();
        properties.put(DATAOUTPUTASSOCIATIONS, assignments);
        setAssignmentsInfoProperty(null, null, dataoutput, null, assignments, properties);
    }
    // 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 : DataOutput(org.eclipse.bpmn2.DataOutput) 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) 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) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) 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)

Example 3 with Event

use of org.eclipse.bpmn2.Event 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 4 with Event

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

the class Bpmn2JsonUnmarshaller method applyEventProperties.

protected void applyEventProperties(Event event, Map<String, String> properties) {
    if (properties.get("name") != null) {
        event.setName(StringEscapeUtils.escapeXml(properties.get("name")).replaceAll("\\r\\n|\\r|\\n", " "));
        // add unescaped and untouched name value as extension element as well
        Utils.setMetaDataExtensionValue(event, "elementname", wrapInCDATABlock(properties.get("name").replaceAll("\\\\n", "\n")));
    } else {
        event.setName("");
    }
    if (properties.get("auditing") != null && !"".equals(properties.get("auditing"))) {
        Auditing audit = Bpmn2Factory.eINSTANCE.createAuditing();
        audit.getDocumentation().add(createDocumentation(properties.get("auditing")));
        event.setAuditing(audit);
    }
    if (properties.get("monitoring") != null && !"".equals(properties.get("monitoring"))) {
        Monitoring monitoring = Bpmn2Factory.eINSTANCE.createMonitoring();
        monitoring.getDocumentation().add(createDocumentation(properties.get("monitoring")));
        event.setMonitoring(monitoring);
    }
}
Also used : Monitoring(org.eclipse.bpmn2.Monitoring) Auditing(org.eclipse.bpmn2.Auditing)

Example 5 with Event

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

the class Bpmn2JsonUnmarshaller method revisitSignalRef.

/**
 * Updates the signal ref on catch and throw event definitions (including boundary)
 * @param def Definitions
 */
public void revisitSignalRef(Definitions def) {
    revisitSignalIds(def);
    List<RootElement> rootElements = def.getRootElements();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            setSignalRefForCatchEvents((Process) root, def);
            setSignalRefForThrowEvents((Process) root, def);
            setSignalRefForBoundaryEvents((Process) root, def);
        }
    }
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

Aggregations

BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)28 Test (org.junit.Test)18 EventDefinition (org.eclipse.bpmn2.EventDefinition)15 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)14 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)14 ArrayList (java.util.ArrayList)13 List (java.util.List)13 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)13 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)13 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)13 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)13 ThrowEventPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ThrowEventPropertyWriter)13 TimerEventDefinition (org.eclipse.bpmn2.TimerEventDefinition)12 Event (io.requery.test.model3.Event)9 UUID (java.util.UUID)9 EndEvent (org.eclipse.bpmn2.EndEvent)9 CatchEventPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CatchEventPropertyWriter)9 CatchEvent (org.eclipse.bpmn2.CatchEvent)8 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)8 MessageRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef)8