Search in sources :

Example 6 with MessageEventDefinition

use of org.activiti.bpmn.model.MessageEventDefinition in project Activiti by Activiti.

the class BaseBpmnJsonConverter method addEventProperties.

protected void addEventProperties(Event event, ObjectNode propertiesNode) {
    List<EventDefinition> eventDefinitions = event.getEventDefinitions();
    if (eventDefinitions.size() == 1) {
        EventDefinition eventDefinition = eventDefinitions.get(0);
        if (eventDefinition instanceof ErrorEventDefinition) {
            ErrorEventDefinition errorDefinition = (ErrorEventDefinition) eventDefinition;
            if (StringUtils.isNotEmpty(errorDefinition.getErrorCode())) {
                propertiesNode.put(PROPERTY_ERRORREF, errorDefinition.getErrorCode());
            }
        } else if (eventDefinition instanceof SignalEventDefinition) {
            SignalEventDefinition signalDefinition = (SignalEventDefinition) eventDefinition;
            if (StringUtils.isNotEmpty(signalDefinition.getSignalRef())) {
                propertiesNode.put(PROPERTY_SIGNALREF, signalDefinition.getSignalRef());
            }
        } else if (eventDefinition instanceof MessageEventDefinition) {
            MessageEventDefinition messageDefinition = (MessageEventDefinition) eventDefinition;
            if (StringUtils.isNotEmpty(messageDefinition.getMessageRef())) {
                propertiesNode.put(PROPERTY_MESSAGEREF, messageDefinition.getMessageRef());
            }
        } else if (eventDefinition instanceof TimerEventDefinition) {
            TimerEventDefinition timerDefinition = (TimerEventDefinition) eventDefinition;
            if (StringUtils.isNotEmpty(timerDefinition.getTimeDuration())) {
                propertiesNode.put(PROPERTY_TIMER_DURATON, timerDefinition.getTimeDuration());
            }
            if (StringUtils.isNotEmpty(timerDefinition.getTimeCycle())) {
                propertiesNode.put(PROPERTY_TIMER_CYCLE, timerDefinition.getTimeCycle());
            }
            if (StringUtils.isNotEmpty(timerDefinition.getTimeDate())) {
                propertiesNode.put(PROPERTY_TIMER_DATE, timerDefinition.getTimeDate());
            }
            if (StringUtils.isNotEmpty(timerDefinition.getEndDate())) {
                propertiesNode.put(PROPERTY_TIMER_CYCLE_END_DATE, timerDefinition.getEndDate());
            }
        } else if (eventDefinition instanceof TerminateEventDefinition) {
            TerminateEventDefinition terminateEventDefinition = (TerminateEventDefinition) eventDefinition;
            propertiesNode.put(PROPERTY_TERMINATE_ALL, terminateEventDefinition.isTerminateAll());
        }
    }
}
Also used : ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 7 with MessageEventDefinition

use of org.activiti.bpmn.model.MessageEventDefinition in project Activiti by Activiti.

the class BoundaryEventJsonConverter method getStencilId.

protected String getStencilId(BaseElement baseElement) {
    BoundaryEvent boundaryEvent = (BoundaryEvent) baseElement;
    List<EventDefinition> eventDefinitions = boundaryEvent.getEventDefinitions();
    if (eventDefinitions.size() != 1) {
        // return timer event as default;
        return STENCIL_EVENT_BOUNDARY_TIMER;
    }
    EventDefinition eventDefinition = eventDefinitions.get(0);
    if (eventDefinition instanceof ErrorEventDefinition) {
        return STENCIL_EVENT_BOUNDARY_ERROR;
    } else if (eventDefinition instanceof SignalEventDefinition) {
        return STENCIL_EVENT_BOUNDARY_SIGNAL;
    } else if (eventDefinition instanceof MessageEventDefinition) {
        return STENCIL_EVENT_BOUNDARY_MESSAGE;
    } else if (eventDefinition instanceof CancelEventDefinition) {
        return STENCIL_EVENT_BOUNDARY_CANCEL;
    } else if (eventDefinition instanceof CompensateEventDefinition) {
        return STENCIL_EVENT_BOUNDARY_COMPENSATION;
    } else {
        return STENCIL_EVENT_BOUNDARY_TIMER;
    }
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) CompensateEventDefinition(org.activiti.bpmn.model.CompensateEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) CompensateEventDefinition(org.activiti.bpmn.model.CompensateEventDefinition)

Example 8 with MessageEventDefinition

use of org.activiti.bpmn.model.MessageEventDefinition in project Activiti by Activiti.

the class BoundaryEventConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    BoundaryEvent errorElement = (BoundaryEvent) model.getMainProcess().getFlowElement("errorEvent");
    ErrorEventDefinition errorEvent = (ErrorEventDefinition) extractEventDefinition(errorElement);
    //always true
    assertTrue(errorElement.isCancelActivity());
    assertEquals("errorRef", errorEvent.getErrorCode());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
    BoundaryEvent signalElement = (BoundaryEvent) model.getMainProcess().getFlowElement("signalEvent");
    SignalEventDefinition signalEvent = (SignalEventDefinition) extractEventDefinition(signalElement);
    assertFalse(signalElement.isCancelActivity());
    assertEquals("signalRef", signalEvent.getSignalRef());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
    BoundaryEvent messageElement = (BoundaryEvent) model.getMainProcess().getFlowElement("messageEvent");
    MessageEventDefinition messageEvent = (MessageEventDefinition) extractEventDefinition(messageElement);
    assertFalse(messageElement.isCancelActivity());
    assertEquals("messageRef", messageEvent.getMessageRef());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
    BoundaryEvent timerElement = (BoundaryEvent) model.getMainProcess().getFlowElement("timerEvent");
    TimerEventDefinition timerEvent = (TimerEventDefinition) extractEventDefinition(timerElement);
    assertFalse(timerElement.isCancelActivity());
    assertEquals("PT5M", timerEvent.getTimeDuration());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 9 with MessageEventDefinition

use of org.activiti.bpmn.model.MessageEventDefinition in project Activiti by Activiti.

the class CatchEventConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement timerElement = model.getMainProcess().getFlowElement("timer_evt");
    EventDefinition timerEvent = extractEventDefinition(timerElement);
    assertTrue(timerEvent instanceof TimerEventDefinition);
    TimerEventDefinition ted = (TimerEventDefinition) timerEvent;
    assertEquals("PT5M", ted.getTimeDuration());
    FlowElement signalElement = model.getMainProcess().getFlowElement("signal_evt");
    EventDefinition signalEvent = extractEventDefinition(signalElement);
    assertTrue(signalEvent instanceof SignalEventDefinition);
    SignalEventDefinition sed = (SignalEventDefinition) signalEvent;
    assertEquals("signal_ref", sed.getSignalRef());
    FlowElement messageElement = model.getMainProcess().getFlowElement("message_evt");
    EventDefinition messageEvent = extractEventDefinition(messageElement);
    assertTrue(messageEvent instanceof MessageEventDefinition);
    MessageEventDefinition med = (MessageEventDefinition) messageEvent;
    assertEquals("message_ref", med.getMessageRef());
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 10 with MessageEventDefinition

use of org.activiti.bpmn.model.MessageEventDefinition in project Activiti by Activiti.

the class CatchEventJsonConverter method getStencilId.

protected String getStencilId(BaseElement baseElement) {
    IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) baseElement;
    List<EventDefinition> eventDefinitions = catchEvent.getEventDefinitions();
    if (eventDefinitions.size() != 1) {
        // return timer event as default;
        return STENCIL_EVENT_CATCH_TIMER;
    }
    EventDefinition eventDefinition = eventDefinitions.get(0);
    if (eventDefinition instanceof MessageEventDefinition) {
        return STENCIL_EVENT_CATCH_MESSAGE;
    } else if (eventDefinition instanceof SignalEventDefinition) {
        return STENCIL_EVENT_CATCH_SIGNAL;
    } else {
        return STENCIL_EVENT_CATCH_TIMER;
    }
}
Also used : IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition)

Aggregations

MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)14 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)11 EventDefinition (org.activiti.bpmn.model.EventDefinition)10 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)7 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)4 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)4 FlowElement (org.activiti.bpmn.model.FlowElement)4 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)3 Event (org.activiti.bpmn.model.Event)3 Message (org.activiti.bpmn.model.Message)3 CompensateEventDefinition (org.activiti.bpmn.model.CompensateEventDefinition)2 Signal (org.activiti.bpmn.model.Signal)2 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)2 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Activity (org.activiti.bpmn.model.Activity)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 FlowNode (org.activiti.bpmn.model.FlowNode)1