use of io.automatiko.engine.workflow.base.core.event.EventTransformerImpl in project automatiko-engine by automatiko-io.
the class HandleEscalationAction method execute.
public void execute(ProcessContext context) throws Exception {
ExceptionScopeInstance scopeInstance = (ExceptionScopeInstance) ((NodeInstance) context.getNodeInstance()).resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, faultName);
if (scopeInstance != null) {
Object tVariable = variableName == null ? null : context.getVariable(variableName);
io.automatiko.engine.workflow.process.core.node.Transformation transformation = (io.automatiko.engine.workflow.process.core.node.Transformation) context.getNodeInstance().getNode().getMetaData().get("Transformation");
if (transformation != null) {
tVariable = new EventTransformerImpl(transformation).transformEvent(context.getProcessInstance().getVariables());
}
scopeInstance.handleException(context.getNodeInstance(), faultName, tVariable);
} else {
((ProcessInstance) context.getProcessInstance()).setState(STATE_ABORTED);
}
}
use of io.automatiko.engine.workflow.base.core.event.EventTransformerImpl in project automatiko-engine by automatiko-io.
the class StartEventHandler method readDataOutputAssociation.
protected void readDataOutputAssociation(org.w3c.dom.Node xmlNode, StartNode startNode) {
// sourceRef
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
if (!"sourceRef".equals(subNode.getNodeName())) {
throw new IllegalArgumentException("No sourceRef found in dataOutputAssociation in startEvent");
}
String source = subNode.getTextContent();
if (dataOutputs.get(source) == null) {
throw new IllegalArgumentException("No dataOutput could be found for the dataOutputAssociation.");
}
String target = null;
Transformation transformation = null;
// targetRef
subNode = subNode.getNextSibling();
if (subNode != null && "targetRef".equals(subNode.getNodeName())) {
target = subNode.getTextContent();
if (target != null) {
startNode.setMetaData("TriggerMapping", target);
}
// transformation
subNode = subNode.getNextSibling();
}
if (subNode != null && "transformation".equals(subNode.getNodeName())) {
String lang = subNode.getAttributes().getNamedItem("language").getNodeValue();
String expression = subNode.getTextContent();
DataTransformer transformer = transformerRegistry.find(lang);
if (transformer == null) {
throw new IllegalArgumentException("No transformer registered for language " + lang);
}
transformation = new Transformation(lang, expression, dataOutputs.get(source));
startNode.setMetaData("Transformation", transformation);
startNode.setEventTransformer(new EventTransformerImpl(transformation));
subNode = subNode.getNextSibling();
startNode.addOutMapping(target, dataOutputs.get(source));
} else if (subNode != null && "assignment".equals(subNode.getNodeName())) {
// assignments
while (subNode != null) {
org.w3c.dom.Node ssubNode = subNode.getFirstChild();
target = ssubNode.getNextSibling().getTextContent();
subNode = subNode.getNextSibling();
}
startNode.setMetaData("TriggerMapping", target);
startNode.addOutMapping(dataOutputs.get(source), target);
} else {
startNode.addOutMapping(dataOutputs.get(source), target);
}
}
use of io.automatiko.engine.workflow.base.core.event.EventTransformerImpl in project automatiko-engine by automatiko-io.
the class IntermediateCatchEventHandler method readDataOutputAssociation.
protected void readDataOutputAssociation(org.w3c.dom.Node xmlNode, EventNode eventNode) {
// sourceRef
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
String from = subNode.getTextContent();
String to = null;
Transformation transformation = null;
// targetRef
subNode = subNode.getNextSibling();
if (subNode != null && "targetRef".equals(subNode.getNodeName())) {
to = subNode.getTextContent();
eventNode.setVariableName(to);
subNode = subNode.getNextSibling();
}
if (subNode != null && "transformation".equals(subNode.getNodeName())) {
String lang = subNode.getAttributes().getNamedItem("language").getNodeValue();
String expression = subNode.getTextContent();
DataTransformer transformer = transformerRegistry.find(lang);
if (transformer == null) {
throw new IllegalArgumentException("No transformer registered for language " + lang);
}
transformation = new Transformation(lang, expression, dataOutputs.get(from));
eventNode.setMetaData("Transformation", transformation);
eventNode.setEventTransformer(new EventTransformerImpl(transformation));
} else if (subNode != null && "assignment".equals(subNode.getNodeName())) {
// assignments
while (subNode != null) {
org.w3c.dom.Node ssubNode = subNode.getFirstChild();
to = ssubNode.getNextSibling().getTextContent();
subNode = subNode.getNextSibling();
eventNode.setVariableName(to);
}
}
}
use of io.automatiko.engine.workflow.base.core.event.EventTransformerImpl in project automatiko-engine by automatiko-io.
the class BoundaryEventHandler method readDataOutputAssociation.
protected void readDataOutputAssociation(org.w3c.dom.Node xmlNode, EventNode eventNode, final ExtensibleXmlParser parser) {
// sourceRef
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
String from = subNode.getTextContent();
String to = null;
Transformation transformation = null;
// targetRef
subNode = subNode.getNextSibling();
if (subNode != null && "targetRef".equals(subNode.getNodeName())) {
to = subNode.getTextContent();
eventNode.setVariableName(to);
subNode = subNode.getNextSibling();
} else if (subNode != null && "transformation".equals(subNode.getNodeName())) {
String lang = subNode.getAttributes().getNamedItem("language").getNodeValue();
String expression = subNode.getTextContent();
DataTransformer transformer = transformerRegistry.find(lang);
if (transformer == null) {
throw new IllegalArgumentException("No transformer registered for language " + lang);
}
transformation = new Transformation(lang, expression, dataOutputs.get(from));
eventNode.setMetaData("Transformation", transformation);
eventNode.setEventTransformer(new EventTransformerImpl(transformation));
} else if (subNode != null && "assignment".equals(subNode.getNodeName())) {
// assignments
while (subNode != null) {
org.w3c.dom.Node ssubNode = subNode.getFirstChild();
to = ssubNode.getNextSibling().getTextContent();
subNode = subNode.getNextSibling();
eventNode.setVariableName(to);
}
}
eventNode.setVariableName(findVariable(to, parser));
}
use of io.automatiko.engine.workflow.base.core.event.EventTransformerImpl in project automatiko-engine by automatiko-io.
the class HandleMessageAction method execute.
public void execute(ProcessContext context) throws Exception {
Object variable = VariableUtil.resolveVariable(variableName, context.getNodeInstance());
if (transformation != null) {
variable = new EventTransformerImpl(transformation).transformEvent(variable);
}
WorkItemImpl workItem = new WorkItemImpl();
workItem.setName("Send Task");
workItem.setNodeInstanceId(context.getNodeInstance().getId());
workItem.setProcessInstanceId(context.getProcessInstance().getId());
workItem.setProcessInstanceId(context.getProcessInstance().getParentProcessInstanceId());
workItem.setNodeId(context.getNodeInstance().getNodeId());
workItem.setParameter("MessageType", messageType);
if (variable != null) {
workItem.setParameter("Message", variable);
}
((DefaultWorkItemManager) context.getProcessRuntime().getWorkItemManager()).internalExecuteWorkItem(workItem);
}
Aggregations