Search in sources :

Example 1 with TerminateEventDefinition

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

the class DefaultActivityBehaviorFactory method createTerminateEndEventActivityBehavior.

public TerminateEndEventActivityBehavior createTerminateEndEventActivityBehavior(EndEvent endEvent) {
    boolean terminateAll = false;
    boolean terminateMultiInstance = false;
    if (endEvent.getEventDefinitions() != null && endEvent.getEventDefinitions().size() > 0 && endEvent.getEventDefinitions().get(0) instanceof TerminateEventDefinition) {
        terminateAll = ((TerminateEventDefinition) endEvent.getEventDefinitions().get(0)).isTerminateAll();
        terminateMultiInstance = ((TerminateEventDefinition) endEvent.getEventDefinitions().get(0)).isTerminateMultiInstance();
    }
    TerminateEndEventActivityBehavior terminateEndEventActivityBehavior = new TerminateEndEventActivityBehavior();
    terminateEndEventActivityBehavior.setTerminateAll(terminateAll);
    terminateEndEventActivityBehavior.setTerminateMultiInstance(terminateMultiInstance);
    return terminateEndEventActivityBehavior;
}
Also used : TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) TerminateEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior)

Example 2 with TerminateEventDefinition

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

the class TerminateEventDefinitionParser method parseChildElement.

public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
    if (!(parentElement instanceof EndEvent)) {
        return;
    }
    TerminateEventDefinition eventDefinition = new TerminateEventDefinition();
    parseTerminateAllAttribute(xtr, eventDefinition);
    parseTerminateMultiInstanceAttribute(xtr, eventDefinition);
    BpmnXMLUtil.addXMLLocation(eventDefinition, xtr);
    BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_TERMINATEDEFINITION, eventDefinition, xtr, model);
    ((Event) parentElement).getEventDefinitions().add(eventDefinition);
}
Also used : EndEvent(org.activiti.bpmn.model.EndEvent) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition)

Example 3 with TerminateEventDefinition

use of org.activiti.bpmn.model.TerminateEventDefinition 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.getErrorRef())) {
                propertiesNode.put(PROPERTY_ERRORREF, errorDefinition.getErrorRef());
            }
        } 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());
            propertiesNode.put(PROPERTY_TERMINATE_MULTI_INSTANCE, terminateEventDefinition.isTerminateMultiInstance());
        }
    }
}
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 4 with TerminateEventDefinition

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

the class EndEventParseHandler method executeParse.

@Override
protected void executeParse(BpmnParse bpmnParse, EndEvent endEvent) {
    EventDefinition eventDefinition = null;
    if (endEvent.getEventDefinitions().size() > 0) {
        eventDefinition = endEvent.getEventDefinitions().get(0);
        if (eventDefinition instanceof ErrorEventDefinition) {
            ErrorEventDefinition errorDefinition = (ErrorEventDefinition) eventDefinition;
            if (bpmnParse.getBpmnModel().containsErrorRef(errorDefinition.getErrorRef())) {
                for (Error error : bpmnParse.getBpmnModel().getErrors().values()) {
                    String errorCode = null;
                    if (error.getId().equals(errorDefinition.getErrorRef())) {
                        errorCode = error.getErrorCode();
                    }
                    if (StringUtils.isEmpty(errorCode)) {
                        logger.warn("errorCode is required for an error event " + endEvent.getId());
                    }
                }
            }
            endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition));
        } else if (eventDefinition instanceof TerminateEventDefinition) {
            endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createTerminateEndEventActivityBehavior(endEvent));
        } else if (eventDefinition instanceof CancelEventDefinition) {
            endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createCancelEndEventActivityBehavior(endEvent));
        } else if (eventDefinition instanceof MessageEventDefinition) {
            MessageEventDefinition messageEventDefinition = MessageEventDefinition.class.cast(eventDefinition);
            Message message = bpmnParse.getBpmnModel().getMessage(messageEventDefinition.getMessageRef());
            BpmnModel bpmnModel = bpmnParse.getBpmnModel();
            if (bpmnModel.containsMessageId(messageEventDefinition.getMessageRef())) {
                messageEventDefinition.setMessageRef(message.getName());
                messageEventDefinition.setExtensionElements(message.getExtensionElements());
            }
            endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createThrowMessageEndEventActivityBehavior(endEvent, messageEventDefinition, message));
        } else {
            endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent));
        }
    } else {
        endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent));
    }
}
Also used : Message(org.activiti.bpmn.model.Message) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) Error(org.activiti.bpmn.model.Error) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 5 with TerminateEventDefinition

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

the class EndEventJsonConverter method getStencilId.

protected String getStencilId(BaseElement baseElement) {
    EndEvent endEvent = (EndEvent) baseElement;
    List<EventDefinition> eventDefinitions = endEvent.getEventDefinitions();
    if (eventDefinitions.size() != 1) {
        return STENCIL_EVENT_END_NONE;
    }
    EventDefinition eventDefinition = eventDefinitions.get(0);
    if (eventDefinition instanceof ErrorEventDefinition) {
        return STENCIL_EVENT_END_ERROR;
    } else if (eventDefinition instanceof CancelEventDefinition) {
        return STENCIL_EVENT_END_CANCEL;
    } else if (eventDefinition instanceof TerminateEventDefinition) {
        return STENCIL_EVENT_END_TERMINATE;
    } else {
        return STENCIL_EVENT_END_NONE;
    }
}
Also used : ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) EndEvent(org.activiti.bpmn.model.EndEvent) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) CancelEventDefinition(org.activiti.bpmn.model.CancelEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition)

Aggregations

TerminateEventDefinition (org.activiti.bpmn.model.TerminateEventDefinition)6 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)3 EndEvent (org.activiti.bpmn.model.EndEvent)3 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)3 EventDefinition (org.activiti.bpmn.model.EventDefinition)3 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)2 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 Error (org.activiti.bpmn.model.Error)1 Message (org.activiti.bpmn.model.Message)1 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)1 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)1 TerminateEndEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior)1