use of io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType in project automatiko-engine by automatiko-io.
the class AbstractNodeHandler method getDataType.
protected DataType getDataType(String itemSubjectRef, Map<String, ItemDefinition> itemDefinitions, ClassLoader cl) {
DataType dataType = new ObjectDataType();
if (itemDefinitions == null) {
return dataType;
}
ItemDefinition itemDefinition = itemDefinitions.get(itemSubjectRef);
if (itemDefinition != null) {
String structureRef = itemDefinition.getStructureRef();
if ("java.lang.Boolean".equals(structureRef) || "Boolean".equals(structureRef)) {
dataType = new BooleanDataType();
} else if ("java.lang.Integer".equals(structureRef) || "Integer".equals(structureRef)) {
dataType = new IntegerDataType();
} else if ("java.lang.Float".equals(structureRef) || "Float".equals(structureRef)) {
dataType = new FloatDataType();
} else if ("java.lang.String".equals(structureRef) || "String".equals(structureRef)) {
dataType = new StringDataType();
} else if ("java.lang.Object".equals(structureRef) || "Object".equals(structureRef)) {
dataType = new ObjectDataType(constructClass(structureRef), structureRef);
} else {
dataType = new ObjectDataType(constructClass(structureRef, cl), structureRef);
}
}
return dataType;
}
use of io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType in project automatiko-engine by automatiko-io.
the class ServerlessWorkflowFactory method processVar.
public void processVar(String varName, Class<?> varType, ExecutableProcess process) {
Variable variable = new Variable();
variable.setName(varName);
variable.setType(new ObjectDataType(varType));
process.getVariableScope().getVariables().add(variable);
}
use of io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType in project automatiko-engine by automatiko-io.
the class CompensationTest method createNestedCompensationBoundaryEventProcess.
private ExecutableProcess createNestedCompensationBoundaryEventProcess(String processId, String[] workItemNames, final List<String> eventList) throws Exception {
ExecutableProcess process = new ExecutableProcess();
process.setAutoComplete(true);
process.setId(processId);
process.setName("CESP Process");
process.setMetaData("Compensation", true);
List<Variable> variables = new ArrayList<Variable>();
Variable variable = new Variable();
variable.setName("event");
ObjectDataType personDataType = new ObjectDataType(java.lang.String.class);
variable.setType(personDataType);
variables.add(variable);
process.getVariableScope().setVariables(variables);
NodeCreator<StartNode> startNodeCreator = new NodeCreator<StartNode>(process, StartNode.class);
NodeCreator<EndNode> endNodeCreator = new NodeCreator<EndNode>(process, EndNode.class);
NodeCreator<CompositeContextNode> compNodeCreator = new NodeCreator<CompositeContextNode>(process, CompositeContextNode.class);
// process level
CompositeContextNode compositeNode = compNodeCreator.createNode("sub0");
{
StartNode startNode = startNodeCreator.createNode("start0");
connect(startNode, compositeNode);
EndNode endNode = endNodeCreator.createNode("end0");
connect(compositeNode, endNode);
}
// 1rst level nested subprocess (contains compensation visibility scope)
{
startNodeCreator.setNodeContainer(compositeNode);
compNodeCreator.setNodeContainer(compositeNode);
endNodeCreator.setNodeContainer(compositeNode);
StartNode startNode = startNodeCreator.createNode("start1");
CompositeContextNode subCompNode = compNodeCreator.createNode("sub1");
connect(startNode, subCompNode);
EndNode endNode = endNodeCreator.createNode("end1");
connect(subCompNode, endNode);
compositeNode = subCompNode;
}
// 2nd level nested subprocess (contains compensation visibility scope)
NodeCreator<WorkItemNode> workItemNodeCreator = new NodeCreator<WorkItemNode>(compositeNode, WorkItemNode.class);
{
startNodeCreator.setNodeContainer(compositeNode);
compNodeCreator.setNodeContainer(compositeNode);
endNodeCreator.setNodeContainer(compositeNode);
StartNode startNode = startNodeCreator.createNode("start2");
CompositeContextNode subCompNode = compNodeCreator.createNode("sub2");
connect(startNode, subCompNode);
WorkItemNode workItemNode = workItemNodeCreator.createNode("work2");
workItemNode.getWork().setName(workItemNames[2]);
connect(subCompNode, workItemNode);
EndNode endNode = endNodeCreator.createNode("end2");
connect(workItemNode, endNode);
createBoundaryEventCompensationHandler(compositeNode, workItemNode, eventList, "2");
compositeNode = subCompNode;
}
// Fill 3rd level with process with compensation
{
startNodeCreator.setNodeContainer(compositeNode);
workItemNodeCreator.setNodeContainer(compositeNode);
endNodeCreator.setNodeContainer(compositeNode);
StartNode startNode = startNodeCreator.createNode("start");
Node lastNode = startNode;
WorkItemNode[] workItemNodes = new WorkItemNode[3];
for (int i = 0; i < 2; ++i) {
workItemNodes[i] = workItemNodeCreator.createNode("work-comp-" + (i + 1));
workItemNodes[i].getWork().setName(workItemNames[i]);
connect(lastNode, workItemNodes[i]);
lastNode = workItemNodes[i];
}
EndNode endNode = endNodeCreator.createNode("end");
connect(workItemNodes[1], endNode);
// Compensation (boundary event) handlers
for (int i = 0; i < 2; ++i) {
createBoundaryEventCompensationHandler(compositeNode, workItemNodes[i], eventList, "" + i + 1);
}
}
return process;
}
use of io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType in project automatiko-engine by automatiko-io.
the class FactoryTest method test.
@Test
public void test() {
ExecutableProcessFactory factory = ExecutableProcessFactory.createProcess("ExampleProcess");
factory.variable("x", new ObjectDataType(java.lang.String.class));
factory.variable("y", new ObjectDataType(java.lang.String.class));
factory.variable("list", new ObjectDataType(java.util.List.class, "java.util.List<String>"));
factory.variable("listOut", new ObjectDataType(java.util.List.class, "java.util.List<String>"));
factory.name("Example Process");
factory.packageName("org.company.bpmn2");
factory.dynamic(false);
factory.version("1.0");
factory.visibility("Private");
factory.metaData("TargetNamespace", "http://www.example.org/MinimalExample");
factory.startNode(1).name("StartProcess").done();
factory.dynamicNode(2).metaData("UniqueId", "_2").metaData("MICollectionOutput", "_2_listOutOutput").metaData("x", 96).metaData("y", 16).activationExpression(kcontext -> Objects.equals(kcontext.getVariable("x"), kcontext.getVariable("oldValue"))).variable("x", new ObjectDataType(java.lang.String.class)).exceptionHandler(RuntimeException.class.getName(), "java", "System.out.println(\"Error\");").autoComplete(true).language("java").done();
factory.humanTaskNode(3).name("Task").taskName("Task Name").actorId("Actor").comment("Hey").content("Some content").workParameter("x", "Parameter").inMapping("x", "y").outMapping("y", "x").waitForCompletion(true).timer("1s", null, "java", "").onEntryAction("java", "").onExitAction("java", "").done();
factory.faultNode(4).name("Fault").faultName("Fault Name").faultVariable("x").done();
factory.connection(1, 2, "_1-_2").connection(2, 3, "_2-_3").connection(3, 4, "_3-_4");
factory.validate();
List<String> list = new ArrayList<String>();
list.add("first");
list.add("second");
List<String> listOut = new ArrayList<String>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("x", "oldValue");
parameters.put("list", list);
InternalProcessRuntime ksession = createProcessRuntime(factory.getProcess());
ksession.startProcess("ExampleProcess", parameters);
}
use of io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType in project automatiko-engine by automatiko-io.
the class ForEachTest method test.
@Test
public void test() {
ExecutableProcessFactory factory = ExecutableProcessFactory.createProcess("ParentProcess");
factory.variable("x", new ObjectDataType(java.lang.String.class));
factory.variable("y", new ObjectDataType(java.lang.String.class));
factory.variable("list", new ObjectDataType(java.util.List.class, "java.util.List<String>"));
factory.variable("listOut", new ObjectDataType(java.util.List.class, "java.util.List<String>"));
factory.name("Parent Process");
factory.packageName("org.company.bpmn2");
factory.dynamic(false);
factory.version("1.0");
factory.visibility("Private");
factory.metaData("TargetNamespace", "http://www.example.org/MinimalExample");
io.automatiko.engine.workflow.process.executable.core.factory.StartNodeFactory startNode1 = factory.startNode(1);
startNode1.name("StartProcess");
startNode1.done();
io.automatiko.engine.workflow.process.executable.core.factory.ForEachNodeFactory forEachNode2 = factory.forEachNode(2);
forEachNode2.metaData("UniqueId", "_2");
forEachNode2.metaData("MICollectionOutput", "_2_listOutOutput");
forEachNode2.metaData("x", 96);
forEachNode2.metaData("width", 110);
forEachNode2.metaData("y", 16);
forEachNode2.metaData("MICollectionInput", "_2_input");
forEachNode2.metaData("height", 48);
forEachNode2.collectionExpression("list");
forEachNode2.variable("x", new ObjectDataType(java.lang.String.class));
forEachNode2.outputCollectionExpression("listOut");
forEachNode2.outputVariable("y", new ObjectDataType(java.lang.String.class));
forEachNode2.actionNode(5).action((kcontext) -> System.out.println(kcontext.getVariable("x"))).done();
forEachNode2.linkIncomingConnections(5);
forEachNode2.linkOutgoingConnections(5);
forEachNode2.done();
io.automatiko.engine.workflow.process.executable.core.factory.EndNodeFactory endNode3 = factory.endNode(3);
endNode3.name("EndProcess");
endNode3.terminate(true);
endNode3.done();
factory.connection(1, 2, "_1-_2");
factory.connection(2, 3, "_2-_3");
factory.validate();
List<String> list = new ArrayList<String>();
list.add("first");
list.add("second");
List<String> listOut = new ArrayList<String>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("x", "oldValue");
parameters.put("list", list);
parameters.put("listOut", listOut);
InternalProcessRuntime ksession = createProcessRuntime(factory.getProcess());
ksession.startProcess("ParentProcess", parameters);
}
Aggregations