use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class DefinitionsHandler method postProcessNodes.
protected void postProcessNodes(NodeContainer nodeContainer, List<Variable> parentVariables, ExtensibleXmlParser parser) throws SAXException {
for (Node node : nodeContainer.getNodes()) {
List<Variable> variables = new LinkedList<>(parentVariables);
VariableScope variableScope = (VariableScope) ((ContextContainer) nodeContainer).getDefaultContext(VariableScope.VARIABLE_SCOPE);
if (variableScope != null) {
variables.addAll(variableScope.getVariables());
}
if (node instanceof NodeContainer) {
postProcessNodes((NodeContainer) node, variables, parser);
} else {
if (node instanceof ActionNode) {
ActionNode actionNode = (ActionNode) node;
ProcessAction action = actionNode.getAction();
if (action instanceof ConsequenceAction) {
ConsequenceAction consequenceAction = (ConsequenceAction) action;
switch(consequenceAction.getDialect()) {
case "java":
if (actionNode.getAction().getMetaData("Action") == null) {
actionNode.getAction().setMetaData("Action", new MvelAction(actionNode));
}
break;
case "mvel":
if (actionNode.getAction().getMetaData("Action") == null) {
actionNode.getAction().setMetaData("Action", new MvelAction(actionNode));
}
break;
default:
}
}
}
}
}
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class ServerlessWorkflowFactory method compensationEventNode.
public ActionNode compensationEventNode(long id, String name, NodeContainer nodeContainer, ExecutableProcess process) {
ActionNode compensationEventNode = new ActionNode();
compensationEventNode.setId(id);
compensationEventNode.setName(name);
compensationEventNode.setMetaData(UNIQUE_ID_PARAM, Long.toString(id));
ProcessInstanceCompensationAction pic = new ProcessInstanceCompensationAction("implicit:" + process.getId());
ProcessAction processAction = new ProcessAction();
processAction.setMetaData(ACTION, pic);
compensationEventNode.setAction(processAction);
compensationEventNode.setMetaData(Metadata.TRIGGER_TYPE, "Compensation");
compensationEventNode.setMetaData("NodeType", "IntermediateThrowEvent-None");
compensationEventNode.setMetaData("CompensationEvent", "implicit:" + process.getId());
nodeContainer.addNode(compensationEventNode);
return compensationEventNode;
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
the class ServerlessWorkflowFactory method stateDataFilterActionNode.
public ActionNode stateDataFilterActionNode(long id, String name, NodeContainer nodeContainer, String outputFilterString) {
ActionNode actionNode = new ActionNode();
actionNode.setId(id);
actionNode.setName(name);
String outputFilter = unwrapExpression(outputFilterString);
ConsequenceAction processAction = new ConsequenceAction(null, "new io.automatiko.engine.workflow.base.instance.impl.jq.OutputJqAssignmentAction(" + escapeExpression(outputFilter) + ").execute(null, context);");
io.automatiko.engine.workflow.base.instance.impl.Action injectAction = context -> {
new OutputJqAssignmentAction(outputFilter).execute(null, context);
};
processAction.setMetaData(ACTION, injectAction);
actionNode.setAction(processAction);
nodeContainer.addNode(actionNode);
return actionNode;
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
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<ProcessAction> actions = new ArrayList<ProcessAction>();
NodeList subNodeList = xmlNode.getChildNodes();
for (int j = 0; j < subNodeList.getLength(); j++) {
Element subXmlNode = (Element) subNodeList.item(j);
ProcessAction action = extractAction(subXmlNode);
actions.add(action);
}
node.setActions(type, actions);
return;
}
}
}
use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.
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;
ProcessAction 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);
}
for (String error : faultName.split(",")) {
exceptionScope.setExceptionHandler(error, exceptionHandler);
}
return null;
}
Aggregations