protected String getErrorIdForErrorCode(String errorCode, Node node) { org.kie.api.definition.process.NodeContainer parent = node.getNodeContainer(); while( ! (parent instanceof RuleFlowProcess) && parent instanceof Node ) { parent = ((Node) parent).getNodeContainer(); } 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 IllegalArgumentException("Could not find error with errorCode " + errorCode); } return error.getId(); }
@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; }
protected void visitErrors(Definitions definitions, StringBuilder xmlDump) { if( definitions == null ) { return; } List<Error> errors = definitions.getErrors(); if( errors == null || errors.isEmpty() ) { return; } for( org.jbpm.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 ); } }
@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; }
protected String getErrorIdForErrorCode(String errorCode, Node node) { org.kie.api.definition.process.NodeContainer parent = node.getNodeContainer(); while( ! (parent instanceof RuleFlowProcess) && parent instanceof Node ) { parent = ((Node) parent).getNodeContainer(); } 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 IllegalArgumentException("Could not find error with errorCode " + errorCode); } return error.getId(); }
protected void visitErrors(Definitions definitions, StringBuilder xmlDump) { if( definitions == null ) { return; } List<Error> errors = definitions.getErrors(); if( errors == null || errors.isEmpty() ) { return; } for( org.jbpm.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 ); } }