use of io.automatiko.engine.workflow.base.core.Work in project automatiko-engine by automatiko-io.
the class WorkItemTest method getWorkItemProcess.
private ExecutableProcess getWorkItemProcess(String processId, String workName) {
ExecutableProcess process = new ExecutableProcess();
process.setId(processId);
List<Variable> variables = new ArrayList<Variable>();
Variable variable = new Variable();
variable.setName("UserName");
variable.setType(new StringDataType());
variables.add(variable);
variable = new Variable();
variable.setName("Person");
variable.setType(new ObjectDataType(Person.class));
variables.add(variable);
variable = new Variable();
variable.setName("MyObject");
variable.setType(new ObjectDataType());
variables.add(variable);
variable = new Variable();
variable.setName("Number");
variable.setType(new IntegerDataType());
variables.add(variable);
process.getVariableScope().setVariables(variables);
StartNode startNode = new StartNode();
startNode.setName("Start");
startNode.setId(1);
WorkItemNode workItemNode = new WorkItemNode();
workItemNode.setName("workItemNode");
workItemNode.setId(2);
workItemNode.addInMapping("Comment", "Person.name");
workItemNode.addInMapping("Attachment", "MyObject");
workItemNode.addOutMapping("Result", "MyObject");
workItemNode.addOutMapping("Result.length()", "Number");
Work work = new WorkImpl();
work.setName(workName);
Set<ParameterDefinition> parameterDefinitions = new HashSet<ParameterDefinition>();
ParameterDefinition parameterDefinition = new ParameterDefinitionImpl("ActorId", new StringDataType());
parameterDefinitions.add(parameterDefinition);
parameterDefinition = new ParameterDefinitionImpl("Content", new StringDataType());
parameterDefinitions.add(parameterDefinition);
parameterDefinition = new ParameterDefinitionImpl("Comment", new StringDataType());
parameterDefinitions.add(parameterDefinition);
work.setParameterDefinitions(parameterDefinitions);
work.setParameter("ActorId", "#{UserName}");
work.setParameter("Content", "#{Person.name}");
workItemNode.setWork(work);
EndNode endNode = new EndNode();
endNode.setName("End");
endNode.setId(3);
connect(startNode, workItemNode);
connect(workItemNode, endNode);
process.addNode(startNode);
process.addNode(workItemNode);
process.addNode(endNode);
return process;
}
use of io.automatiko.engine.workflow.base.core.Work in project automatiko-engine by automatiko-io.
the class NodeCreator method createNode.
public T createNode(String name) throws Exception {
T result = this.constructor.newInstance(new Object[0]);
result.setId(idGen++);
result.setName(name);
this.nodeContainer.addNode(result);
if (result instanceof WorkItemNode) {
Work work = new WorkImpl();
((WorkItemNode) result).setWork(work);
}
return result;
}
use of io.automatiko.engine.workflow.base.core.Work in project automatiko-engine by automatiko-io.
the class HumanTaskNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
WorkItemNode workItemNode = (WorkItemNode) node;
writeNode("humanTask", workItemNode, xmlDump, includeMeta);
visitParameters(workItemNode, xmlDump);
xmlDump.append(">" + EOL);
if (includeMeta) {
writeMetaData(workItemNode, xmlDump);
}
Work work = workItemNode.getWork();
visitWork(work, xmlDump, includeMeta);
visitInMappings(workItemNode.getInMappings(), xmlDump);
visitOutMappings(workItemNode.getOutMappings(), xmlDump);
for (String eventType : workItemNode.getActionTypes()) {
writeActions(eventType, workItemNode.getActions(eventType), xmlDump);
}
writeTimers(workItemNode.getTimers(), xmlDump);
endNode("humanTask", xmlDump);
}
use of io.automatiko.engine.workflow.base.core.Work in project automatiko-engine by automatiko-io.
the class ParameterHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
final String name = attrs.getValue("name");
emptyAttributeCheck(localName, "name", name, parser);
Work work = (Work) parser.getParent();
ParameterDefinition parameterDefinition = new ParameterDefinitionImpl();
parameterDefinition.setName(name);
work.addParameterDefinition(parameterDefinition);
return new ParameterWrapper(parameterDefinition, work);
}
use of io.automatiko.engine.workflow.base.core.Work in project automatiko-engine by automatiko-io.
the class TaskHandler method handleNode.
protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
dataTypeInputs.clear();
dataTypeOutputs.clear();
WorkItemNode workItemNode = (WorkItemNode) node;
String name = getTaskName(element);
Work work = new WorkImpl();
work.setName(name);
workItemNode.setWork(work);
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("ioSpecification".equals(nodeName)) {
readIoSpecification(xmlNode, dataInputs, dataOutputs, dataInputTypes);
} else if ("dataInputAssociation".equals(nodeName)) {
readDataInputAssociation(xmlNode, workItemNode, dataInputs);
} else if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, workItemNode, dataOutputs);
}
xmlNode = xmlNode.getNextSibling();
}
workItemNode.setMetaData("DataInputs", new LinkedHashMap<String, String>(dataTypeInputs));
workItemNode.setMetaData("DataOutputs", new LinkedHashMap<String, String>(dataTypeOutputs));
handleScript(workItemNode, element, "onEntry");
handleScript(workItemNode, element, "onExit");
String compensation = element.getAttribute("isForCompensation");
if (compensation != null) {
boolean isForCompensation = Boolean.parseBoolean(compensation);
if (isForCompensation) {
workItemNode.setMetaData("isForCompensation", isForCompensation);
}
}
for (Entry<String, String> entryInputTypes : dataTypeInputs.entrySet()) {
ParameterDefinition parameterDefinition = new ParameterDefinitionImpl();
parameterDefinition.setName(entryInputTypes.getKey());
parameterDefinition.setType(new ObjectDataType(constructClass(entryInputTypes.getValue()), entryInputTypes.getValue()));
work.addParameterDefinition(parameterDefinition);
}
}
Aggregations