Search in sources :

Example 1 with Error

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

the class ErrorConverterTest method testConversionFromXmlToBPMNModel.

@Test
public void testConversionFromXmlToBPMNModel() throws Exception {
    BpmnModel bpmnModel = readXMLFile();
    assertThat(bpmnModel.getErrors().values()).usingFieldByFieldElementComparator().containsOnlyElementsOf(newArrayList(new Error("Error_0v4rsz5", "ok", "200"), new Error("Error_02htlc0", "conflict", "409")));
}
Also used : Error(org.activiti.bpmn.model.Error) BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.jupiter.api.Test)

Example 2 with Error

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

the class ErrorExport method writeError.

public static void writeError(BpmnModel model, XMLStreamWriter xtw) throws Exception {
    for (Error error : model.getErrors().values()) {
        xtw.writeStartElement(ELEMENT_ERROR);
        xtw.writeAttribute(ATTRIBUTE_ID, error.getId());
        xtw.writeAttribute(ATTRIBUTE_NAME, error.getName());
        xtw.writeAttribute(ATTRIBUTE_ERROR_CODE, error.getErrorCode());
        xtw.writeEndElement();
    }
}
Also used : Error(org.activiti.bpmn.model.Error)

Example 3 with Error

use of org.activiti.bpmn.model.Error 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)

Aggregations

Error (org.activiti.bpmn.model.Error)3 BpmnModel (org.activiti.bpmn.model.BpmnModel)2 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)1 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)1 EventDefinition (org.activiti.bpmn.model.EventDefinition)1 Message (org.activiti.bpmn.model.Message)1 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)1 TerminateEventDefinition (org.activiti.bpmn.model.TerminateEventDefinition)1 Test (org.junit.jupiter.api.Test)1