use of io.automatiko.engine.workflow.bpmn2.core.Error in project kogito-runtimes by kiegroup.
the class AbstractNodeHandler method getErrorIdForErrorCode.
protected String getErrorIdForErrorCode(String errorCode, Node node) {
org.kie.api.definition.process.NodeContainer parent = node.getParentContainer();
while (!(parent instanceof RuleFlowProcess) && parent instanceof Node) {
parent = ((Node) parent).getParentContainer();
}
if (!(parent instanceof RuleFlowProcess)) {
throw new RuntimeException("This should never happen: !(parent instanceof RuleFlowProcess): parent is " + parent.getClass().getSimpleName());
}
List<Error> errors = ((Definitions) ((RuleFlowProcess) parent).getMetaData("Definitions")).getErrors();
Error error = null;
for (Error listError : errors) {
if (errorCode.equals(listError.getErrorCode())) {
error = listError;
break;
} else if (errorCode.equals(listError.getId())) {
error = listError;
break;
}
}
if (error == null) {
throw new ProcessParsingValidationException("Could not find error with errorCode " + errorCode);
}
return error.getId();
}
use of io.automatiko.engine.workflow.bpmn2.core.Error in project kogito-runtimes by kiegroup.
the class BoundaryEventHandler method handleErrorNode.
@SuppressWarnings("unchecked")
protected void handleErrorNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
BoundaryEventNode eventNode = (BoundaryEventNode) node;
eventNode.setMetaData("AttachedTo", attachedTo);
eventNode.setAttachedToNodeId(attachedTo);
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("errorEventDefinition".equals(nodeName)) {
String errorRef = ((Element) xmlNode).getAttribute("errorRef");
if (errorRef != null && errorRef.trim().length() > 0) {
List<Error> errors = (List<Error>) ((ProcessBuildData) parser.getData()).getMetaData("Errors");
if (errors == null) {
throw new ProcessParsingValidationException("No errors found");
}
Error error = null;
for (Error listError : errors) {
if (errorRef.equals(listError.getId())) {
error = listError;
}
}
if (error == null) {
throw new ProcessParsingValidationException("Could not find error " + errorRef);
}
String type = error.getErrorCode();
boolean hasErrorCode = true;
if (type == null) {
type = error.getId();
hasErrorCode = false;
}
String structureRef = error.getStructureRef();
if (structureRef != null) {
Map<String, ItemDefinition> itemDefs = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
if (itemDefs.containsKey(structureRef)) {
structureRef = itemDefs.get(structureRef).getStructureRef();
}
}
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventTypeFilter eventFilter = new EventTypeFilter();
eventFilter.setType("Error-" + attachedTo + "-" + type);
eventFilters.add(eventFilter);
eventNode.setEventFilters(eventFilters);
eventNode.setMetaData("ErrorEvent", type);
eventNode.setMetaData("HasErrorEvent", hasErrorCode);
eventNode.setMetaData("ErrorStructureRef", structureRef);
}
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.bpmn2.core.Error in project automatiko-engine by automatiko-io.
the class BoundaryEventHandler method handleErrorNode.
@SuppressWarnings("unchecked")
protected void handleErrorNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
BoundaryEventNode eventNode = (BoundaryEventNode) node;
eventNode.setMetaData("AttachedTo", attachedTo);
eventNode.setAttachedToNodeId(attachedTo);
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataOutput".equals(nodeName)) {
String id = ((Element) xmlNode).getAttribute("id");
String outputName = ((Element) xmlNode).getAttribute("name");
dataOutputs.put(id, outputName);
populateDataOutputs(xmlNode, outputName, parser);
} else if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, eventNode, parser);
} else if ("errorEventDefinition".equals(nodeName)) {
String errorRef = ((Element) xmlNode).getAttribute("errorRef");
if (errorRef != null && errorRef.trim().length() > 0) {
List<Error> errors = (List<Error>) ((ProcessBuildData) parser.getData()).getMetaData("Errors");
if (errors == null) {
throw new IllegalArgumentException("No errors found");
}
Error error = null;
for (Error listError : errors) {
if (errorRef.equals(listError.getId())) {
error = listError;
}
}
if (error == null) {
throw new IllegalArgumentException("Could not find error " + errorRef);
}
String type = error.getErrorCode();
boolean hasErrorCode = true;
if (type == null) {
type = error.getId();
hasErrorCode = false;
}
String structureRef = error.getStructureRef();
if (structureRef != null) {
Map<String, ItemDefinition> itemDefs = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
if (itemDefs.containsKey(structureRef)) {
structureRef = itemDefs.get(structureRef).getStructureRef();
}
}
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventTypeFilter eventFilter = new EventTypeFilter();
eventFilter.setType("Error-" + attachedTo + "-" + type);
eventFilters.add(eventFilter);
eventNode.setEventFilters(eventFilters);
eventNode.setMetaData("ErrorEvent", type);
eventNode.setMetaData("HasErrorEvent", hasErrorCode);
eventNode.setMetaData("ErrorStructureRef", structureRef);
if (error.getMetaData().get("retry") != null) {
eventNode.setMetaData("ErrorRetry", ((Long) DateTimeUtils.parseDuration((String) error.getMetaData().get("retry"))).intValue());
if (error.getMetaData().get("retryLimit") != null) {
eventNode.setMetaData("ErrorRetryLimit", Integer.parseInt((String) error.getMetaData().get("retryLimit")));
}
if (error.getMetaData().get("retryIncrement") != null) {
eventNode.setMetaData("ErrorRetryIncrement", ((Long) DateTimeUtils.parseDuration((String) error.getMetaData().get("retryIncrement"))).intValue());
}
if (error.getMetaData().get("retryMultiplier") != null) {
eventNode.setMetaData("ErrorRetryIncrementMultiplier", Float.parseFloat((String) error.getMetaData().get("retryMultiplier")));
}
}
}
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.bpmn2.core.Error in project automatiko-engine by automatiko-io.
the class ErrorHandler method start.
@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
String id = attrs.getValue("id");
String errorCode = attrs.getValue("errorCode");
String structureRef = attrs.getValue("structureRef");
Definitions definitions = (Definitions) parser.getParent();
List<Error> errors = definitions.getErrors();
if (errors == null) {
errors = new ArrayList<Error>();
definitions.setErrors(errors);
((ProcessBuildData) parser.getData()).setMetaData("Errors", errors);
}
Error e = new Error(id, errorCode, structureRef);
errors.add(e);
return e;
}
use of io.automatiko.engine.workflow.bpmn2.core.Error in project automatiko-engine by automatiko-io.
the class XmlBPMNProcessDumper method visitErrors.
protected void visitErrors(Definitions definitions, StringBuilder xmlDump) {
if (definitions == null) {
return;
}
List<Error> errors = definitions.getErrors();
if (errors == null || errors.isEmpty()) {
return;
}
for (io.automatiko.engine.workflow.bpmn2.core.Error error : errors) {
String id = XmlBPMNProcessDumper.replaceIllegalCharsAttribute(error.getId());
String code = error.getErrorCode();
xmlDump.append(" <error id=\"" + id + "\"");
if (error.getErrorCode() != null) {
code = XmlBPMNProcessDumper.replaceIllegalCharsAttribute(code);
xmlDump.append(" errorCode=\"" + code + "\"");
}
String structureRef = error.getStructureRef();
if (structureRef != null) {
structureRef = XmlBPMNProcessDumper.replaceIllegalCharsAttribute(structureRef);
xmlDump.append(" structureRef=\"" + structureRef + "\"");
}
xmlDump.append("/>" + EOL);
}
}
Aggregations