use of io.automatiko.engine.api.runtime.process.DataTransformer 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.api.runtime.process.DataTransformer in project automatiko-engine by automatiko-io.
the class IntermediateThrowEventHandler method readDataInputAssociation.
protected void readDataInputAssociation(org.w3c.dom.Node xmlNode, ActionNode actionNode, final ExtensibleXmlParser parser) {
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
if ("sourceRef".equals(subNode.getNodeName())) {
// sourceRef
String eventVariable = subNode.getTextContent();
// targetRef
subNode = subNode.getNextSibling();
String target = subNode.getTextContent();
// transformation
Transformation transformation = null;
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, dataInputs.get(target));
actionNode.setMetaData(TRANSFORMATION_KEY, transformation);
}
if (eventVariable != null && eventVariable.trim().length() > 0) {
if (dataInputs.containsKey(eventVariable)) {
eventVariable = dataInputs.get(eventVariable);
}
actionNode.setMetaData(MAPPING_VARIABLE_KEY, findVariable(eventVariable, parser));
}
} else {
// targetRef
// assignment
subNode = subNode.getNextSibling();
if (subNode != null) {
org.w3c.dom.Node subSubNode = subNode.getFirstChild();
NodeList nl = subSubNode.getChildNodes();
if (nl.getLength() > 1) {
actionNode.setMetaData(MAPPING_VARIABLE_KEY, subSubNode.getTextContent());
return;
} else if (nl.getLength() == 0) {
return;
}
Object result = null;
Object from = nl.item(0);
if (from instanceof Text) {
String text = ((Text) from).getTextContent();
if (text.startsWith("\"") && text.endsWith("\"")) {
result = text.substring(1, text.length() - 1);
} else {
result = text;
}
} else {
result = nl.item(0);
}
actionNode.setMetaData(MAPPING_VARIABLE_KEY, "\"" + findVariable(result.toString(), parser) + "\"");
}
}
}
use of io.automatiko.engine.api.runtime.process.DataTransformer in project automatiko-engine by automatiko-io.
the class CallActivityHandler method readDataInputAssociation.
protected void readDataInputAssociation(org.w3c.dom.Node xmlNode, SubProcessNode subProcessNode, Map<String, String> dataInputs) {
// sourceRef
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
if ("sourceRef".equals(subNode.getNodeName())) {
String from = subNode.getTextContent();
// targetRef
subNode = subNode.getNextSibling();
String to = subNode.getTextContent();
// transformation
Transformation transformation = null;
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);
subNode = subNode.getNextSibling();
}
subProcessNode.addInMapping(dataInputs.get(to), from, transformation);
} else {
// targetRef
String to = subNode.getTextContent();
// assignment
subNode = subNode.getNextSibling();
if (subNode != null) {
org.w3c.dom.Node subSubNode = subNode.getFirstChild();
NodeList nl = subSubNode.getChildNodes();
if (nl.getLength() > 1) {
// not supported ?
subProcessNode.addInMapping(dataInputs.get(to), subSubNode.getTextContent());
return;
} else if (nl.getLength() == 0) {
return;
}
Object result = null;
Object from = nl.item(0);
if (from instanceof Text) {
result = ((Text) from).getTextContent();
} else {
result = nl.item(0);
}
subProcessNode.addInMapping(dataInputs.get(to), result.toString());
}
}
}
use of io.automatiko.engine.api.runtime.process.DataTransformer 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.api.runtime.process.DataTransformer in project automatiko-engine by automatiko-io.
the class ScriptTaskHandler method readDataInputAssociation.
protected void readDataInputAssociation(org.w3c.dom.Node xmlNode, ActionNode actionNode, Map<String, String> dataInputs) {
// sourceRef
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
if ("sourceRef".equals(subNode.getNodeName())) {
List<String> sources = new ArrayList<>();
sources.add(subNode.getTextContent());
subNode = subNode.getNextSibling();
while ("sourceRef".equals(subNode.getNodeName())) {
sources.add(subNode.getTextContent());
subNode = subNode.getNextSibling();
}
// targetRef
String target = subNode.getTextContent();
// transformation
Transformation transformation = null;
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);
subNode = subNode.getNextSibling();
}
// assignments
List<Assignment> assignments = new LinkedList<Assignment>();
while (subNode != null) {
String expressionLang = ((Element) subNode).getAttribute("expressionLanguage");
if (expressionLang == null || expressionLang.trim().isEmpty()) {
expressionLang = "XPath";
}
org.w3c.dom.Node ssubNode = subNode.getFirstChild();
String from = ssubNode.getTextContent();
String to = ssubNode.getNextSibling().getTextContent();
assignments.add(new Assignment(expressionLang, from, to));
subNode = subNode.getNextSibling();
}
actionNode.addInAssociation(new DataAssociation(sources, dataInputs.get(target), assignments, transformation));
}
}
Aggregations