Search in sources :

Example 11 with SignalEventDefinition

use of org.eclipse.bpmn2.SignalEventDefinition 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)

Example 12 with SignalEventDefinition

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

the class EventPropertyWriter method addSignal.

public void addSignal(SignalRef signalRef) {
    SignalEventDefinition signalEventDefinition = bpmn2.createSignalEventDefinition();
    Signal signal = bpmn2.createSignal();
    String name = signalRef.getValue();
    signal.setName(name);
    signal.setId(Ids.fromString(name));
    signalEventDefinition.setSignalRef(signal.getId());
    addEventDefinition(signalEventDefinition);
    addRootElement(signal);
}
Also used : Signal(org.eclipse.bpmn2.Signal) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition)

Aggregations

SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)12 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)11 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)11 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)11 EventDefinition (org.eclipse.bpmn2.EventDefinition)11 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)11 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)10 TimerEventDefinition (org.eclipse.bpmn2.TimerEventDefinition)10 Signal (org.eclipse.bpmn2.Signal)7 Activity (org.eclipse.bpmn2.Activity)6 CallActivity (org.eclipse.bpmn2.CallActivity)6 Escalation (org.eclipse.bpmn2.Escalation)6 RootElement (org.eclipse.bpmn2.RootElement)6 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)6 CancelEventDefinition (org.eclipse.bpmn2.CancelEventDefinition)5 TerminateEventDefinition (org.eclipse.bpmn2.TerminateEventDefinition)5 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 List (java.util.List)4 Entry (java.util.Map.Entry)4