Search in sources :

Example 1 with ExecutableProcessFactory

use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory in project automatiko-engine by automatiko-io.

the class ProcessToExecModelGeneratorTest method testScriptAndWorkItemModelGeneration.

@Test
public void testScriptAndWorkItemModelGeneration() {
    ExecutableProcessFactory factory = ExecutableProcessFactory.createProcess("demo.orders");
    factory.variable("order", new ObjectDataType(Integer.class)).variable("order", new ObjectDataType(List.class, "java.util.List<String>")).variable("approver", new ObjectDataType(String.class)).name("orders").packageName("com.myspace.demo").dynamic(false).version("1.0").workItemNode(1).name("Log").workName("Log").done().actionNode(2).name("Dump order").action("java", "System.out.println(\"Order has been created \" + order);").done().endNode(3).name("end").terminate(false).done().startNode(4).name("start").done().connection(2, 1).connection(4, 2).connection(1, 3);
    Process process = factory.validate().getProcess();
    ModelMetaData modelMetadata = ProcessToExecModelGenerator.INSTANCE.generateModel((WorkflowProcess) process);
    assertNotNull(modelMetadata, "Dumper should return non null class for process");
    logger.debug(modelMetadata.generate());
    assertEquals("com.myspace.demo.Orders_1_0Model", modelMetadata.getModelClassName());
}
Also used : ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) WorkflowProcess(io.automatiko.engine.api.definition.process.WorkflowProcess) Process(io.automatiko.engine.api.definition.process.Process) ExecutableProcessFactory(io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory) ModelMetaData(io.automatiko.engine.workflow.compiler.canonical.ModelMetaData) Test(org.junit.jupiter.api.Test)

Example 2 with ExecutableProcessFactory

use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory 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);
}
Also used : Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) AbstractBaseTest(io.automatiko.engine.workflow.test.util.AbstractBaseTest) List(java.util.List) ExecutableProcessFactory(io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory) Map(java.util.Map) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) List(java.util.List) ArrayList(java.util.ArrayList) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) ExecutableProcessFactory(io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory) Test(org.junit.jupiter.api.Test) AbstractBaseTest(io.automatiko.engine.workflow.test.util.AbstractBaseTest)

Example 3 with ExecutableProcessFactory

use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory 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);
}
Also used : Test(org.junit.jupiter.api.Test) AbstractBaseTest(io.automatiko.engine.workflow.test.util.AbstractBaseTest) List(java.util.List) ExecutableProcessFactory(io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory) Map(java.util.Map) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) ExecutableProcessFactory(io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory) List(java.util.List) ArrayList(java.util.ArrayList) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) Test(org.junit.jupiter.api.Test) AbstractBaseTest(io.automatiko.engine.workflow.test.util.AbstractBaseTest)

Example 4 with ExecutableProcessFactory

use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory in project automatiko-engine by automatiko-io.

the class ProcessFactoryTest method testProcessFactory.

@Test
public void testProcessFactory() throws Exception {
    ExecutableProcessFactory factory = ExecutableProcessFactory.createProcess("org.company.core.process");
    factory.name("My process").packageName("org.company").startNode(1).name("Start").done().actionNode(2).name("Action").action("java", "System.out.println(\"Action\");").done().endNode(3).name("End").done().connection(1, 2).connection(2, 3);
    factory.validate().getProcess();
}
Also used : ExecutableProcessFactory(io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory) Test(org.junit.jupiter.api.Test) AbstractBaseTest(io.automatiko.engine.workflow.test.util.AbstractBaseTest)

Example 5 with ExecutableProcessFactory

use of io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory in project automatiko-engine by automatiko-io.

the class ProcessToExecModelGeneratorTest method testScriptAndWorkItemGeneration.

@Test
public void testScriptAndWorkItemGeneration() {
    ExecutableProcessFactory factory = ExecutableProcessFactory.createProcess("demo.orders");
    factory.variable("order", new ObjectDataType(Integer.class)).variable("approver", new ObjectDataType(String.class)).name("orders").packageName("com.myspace.demo").dynamic(false).version("1.0").workItemNode(1).name("Log").workName("Log").done().actionNode(2).name("Dump order").action("java", "System.out.println(\"Order has been created \" + order);").done().endNode(3).name("end").terminate(false).done().startNode(4).name("start").done().connection(2, 1).connection(4, 2).connection(1, 3);
    WorkflowProcess process = factory.validate().getProcess();
    ProcessMetaData processMetadata = ProcessToExecModelGenerator.INSTANCE.generate(process);
    assertNotNull(processMetadata, "Dumper should return non null class for process");
    logger.debug(processMetadata.getGeneratedClassModel().toString());
    assertEquals("orders_1_0", processMetadata.getExtractedProcessId());
    assertEquals("demo.orders", processMetadata.getProcessId());
    assertEquals("orders", processMetadata.getProcessName());
    assertEquals("_1_0", processMetadata.getProcessVersion());
    assertEquals("com.myspace.demo.Orders_1_0Process", processMetadata.getProcessClassName());
    assertNotNull(processMetadata.getGeneratedClassModel());
    assertEquals(1, processMetadata.getWorkItems().size());
}
Also used : ProcessMetaData(io.automatiko.engine.workflow.compiler.canonical.ProcessMetaData) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) WorkflowProcess(io.automatiko.engine.api.definition.process.WorkflowProcess) ExecutableProcessFactory(io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory) Test(org.junit.jupiter.api.Test)

Aggregations

ExecutableProcessFactory (io.automatiko.engine.workflow.process.executable.core.ExecutableProcessFactory)5 Test (org.junit.jupiter.api.Test)5 ObjectDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType)4 AbstractBaseTest (io.automatiko.engine.workflow.test.util.AbstractBaseTest)3 WorkflowProcess (io.automatiko.engine.api.definition.process.WorkflowProcess)2 InternalProcessRuntime (io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 LoggerFactory (org.slf4j.LoggerFactory)2 Process (io.automatiko.engine.api.definition.process.Process)1 ModelMetaData (io.automatiko.engine.workflow.compiler.canonical.ModelMetaData)1 ProcessMetaData (io.automatiko.engine.workflow.compiler.canonical.ProcessMetaData)1 Objects (java.util.Objects)1