use of org.jbpm.workflow.core.DroolsAction in project jbpm by kiegroup.
the class XmlWorkflowProcessDumper method visitExceptionHandlers.
public static void visitExceptionHandlers(Map<String, ExceptionHandler> exceptionHandlers, StringBuilder xmlDump) {
if (exceptionHandlers != null && exceptionHandlers.size() > 0) {
xmlDump.append(" <exceptionHandlers>" + EOL);
for (Map.Entry<String, ExceptionHandler> entry : exceptionHandlers.entrySet()) {
ExceptionHandler exceptionHandler = entry.getValue();
if (exceptionHandler instanceof ActionExceptionHandler) {
ActionExceptionHandler actionExceptionHandler = (ActionExceptionHandler) exceptionHandler;
xmlDump.append(" <exceptionHandler faultName=\"" + entry.getKey() + "\" type=\"action\" ");
String faultVariable = actionExceptionHandler.getFaultVariable();
if (faultVariable != null && faultVariable.length() > 0) {
xmlDump.append("faultVariable=\"" + faultVariable + "\" ");
}
xmlDump.append(">" + EOL);
DroolsAction action = actionExceptionHandler.getAction();
if (action != null) {
AbstractNodeHandler.writeAction(action, xmlDump);
}
xmlDump.append(" </exceptionHandler>" + EOL);
} else {
throw new IllegalArgumentException("Unknown exception handler type: " + exceptionHandler);
}
}
xmlDump.append(" </exceptionHandlers>" + EOL);
}
}
use of org.jbpm.workflow.core.DroolsAction in project jbpm by kiegroup.
the class AbstractNodeHandler method handleAction.
protected void handleAction(final ExtendedNodeImpl node, final Element element, String type) {
NodeList nodeList = element.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
org.w3c.dom.Node xmlNode = nodeList.item(i);
String nodeName = xmlNode.getNodeName();
if (nodeName.equals(type)) {
List<DroolsAction> actions = new ArrayList<DroolsAction>();
NodeList subNodeList = xmlNode.getChildNodes();
for (int j = 0; j < subNodeList.getLength(); j++) {
Element subXmlNode = (Element) subNodeList.item(j);
DroolsAction action = extractAction(subXmlNode);
actions.add(action);
}
node.setActions(type, actions);
return;
}
}
}
use of org.jbpm.workflow.core.DroolsAction in project jbpm by kiegroup.
the class AbstractNodeHandler method writeActions.
protected void writeActions(final String type, List<DroolsAction> actions, final StringBuilder xmlDump) {
if (actions != null && actions.size() > 0) {
xmlDump.append(" <" + type + ">" + EOL);
for (DroolsAction action : actions) {
writeAction(action, xmlDump);
}
xmlDump.append(" </" + type + ">" + EOL);
}
}
use of org.jbpm.workflow.core.DroolsAction in project jbpm by kiegroup.
the class ExceptionHandlerHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
ContextContainer contextContainer = (ContextContainer) parser.getParent();
final String type = element.getAttribute("type");
emptyAttributeCheck(localName, "type", type, parser);
final String faultName = element.getAttribute("faultName");
emptyAttributeCheck(localName, "faultName", type, parser);
final String faultVariable = element.getAttribute("faultVariable");
ActionExceptionHandler exceptionHandler = null;
if ("action".equals(type)) {
exceptionHandler = new ActionExceptionHandler();
org.w3c.dom.Node xmlNode = element.getFirstChild();
if (xmlNode instanceof Element) {
Element actionXml = (Element) xmlNode;
DroolsAction action = ActionNodeHandler.extractAction(actionXml);
((ActionExceptionHandler) exceptionHandler).setAction(action);
}
} else {
throw new SAXParseException("Unknown exception handler type " + type, parser.getLocator());
}
if (faultVariable != null && faultVariable.length() > 0) {
exceptionHandler.setFaultVariable(faultVariable);
}
ExceptionScope exceptionScope = (ExceptionScope) contextContainer.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
if (exceptionScope == null) {
exceptionScope = new ExceptionScope();
contextContainer.addContext(exceptionScope);
contextContainer.setDefaultContext(exceptionScope);
}
exceptionScope.setExceptionHandler(faultName, exceptionHandler);
return null;
}
use of org.jbpm.workflow.core.DroolsAction in project jbpm by kiegroup.
the class SubProcessNodeFactory method onExitAction.
public SubProcessNodeFactory onExitAction(String dialect, String action) {
if (getSubProcessNode().getActions(dialect) != null) {
getSubProcessNode().getActions(dialect).add(new DroolsConsequenceAction(dialect, action));
} else {
List<DroolsAction> actions = new ArrayList<DroolsAction>();
actions.add(new DroolsConsequenceAction(dialect, action));
getSubProcessNode().setActions(MilestoneNode.EVENT_NODE_EXIT, actions);
}
return this;
}
Aggregations