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")));
}
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();
}
}
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));
}
}
Aggregations