public Deployment deploy(ExecutableWorkflow workflow) { Deployment deployment = workflowEngine.deployWorkflow(workflow); deployment.checkNoErrors(); workflow.setId(deployment.getWorkflowId()); return deployment; }
@Test public void testUnlockListener() { // Create a workflow ExecutableWorkflow workflow = new ExecutableWorkflow() .activity("a", new ListeningActivity()); // Deploy the workflow to the engine WorkflowId workflowId = workflowEngine .deployWorkflow(workflow) .checkNoErrorsAndNoWarnings() .getWorkflowId(); // Start a new workflow instance workflowEngine .start(new TriggerInstance() .workflowId(workflowId)); assertEquals("Activity a is started and it's workflow instance unlocked", notificationsReceived.get(0)); } }
@Override public Deployment deployWorkflow(ExecutableWorkflow workflow) { if (log.isDebugEnabled()) { log.debug("Deploying workflow"); } WorkflowParser parser = new WorkflowParser(configuration); parser.parse(workflow); if (!parser.hasErrors()) { WorkflowImpl workflowImpl = parser.getWorkflow(); WorkflowId workflowId; if (workflow.getId()==null) { workflowId = workflowStore.generateWorkflowId(); workflow.setId(workflowId); } workflow.setCreateTime(Time.now()); workflowImpl.id = workflow.getId(); workflowStore.insertWorkflow(workflow); if (workflowImpl.trigger!=null) { workflowImpl.trigger.published(workflowImpl); } workflowCache.put(workflowImpl); } return new Deployment(workflow.getId(), parser.getIssues()); }
@Test public void testApiExample() { // Create the default (in-memory) workflow engine Configuration configuration = new MemoryConfiguration(); configuration.start(); WorkflowEngine workflowEngine = configuration.getWorkflowEngine(); // Create a workflow ExecutableWorkflow workflow = new ExecutableWorkflow() .sourceWorkflowId("Release") .activity("Move open issues", new ReceiveTask() .transitionToNext()) .activity("Check continuous integration", new ReceiveTask()); // Deploy the workflow to the engine WorkflowId workflowId = workflowEngine .deployWorkflow(workflow) .checkNoErrorsAndNoWarnings() .getWorkflowId(); // Start a new workflow instance WorkflowInstance workflowInstance = workflowEngine .start(new TriggerInstance() .workflowId(workflowId)); System.err.println(configuration.get(JsonStreamMapper.class).write(workflow)); } }