Package org.activiti.engine

Examples of org.activiti.engine.RuntimeService


  @Override
  public void notify(DelegateExecution execution) throws Exception {
    // TODO Auto-generated method stub
    EngineServices engineServices = execution.getEngineServices();
    RuntimeService runtimeService = engineServices.getRuntimeService();
    runtimeService.signal(execution.getId());
  }
View Full Code Here


        responseJSON.put("success", false);
        responseJSON.put("failureReason", "Request is missing activity id");
        return responseJSON;
      }
       
      RuntimeService runtimeService = ActivitiUtil.getRuntimeService();
      Execution execution = runtimeService.createExecutionQuery()
            .processInstanceId(processInstanceId)
            .activityId(activityId)
            .singleResult();
     
      // signal receive task and attach variables if available
      if (variables.size() > 0) {
        runtimeService.signal(execution.getId(), variables);
      } else {
        runtimeService.signal(execution.getId());
      }

      // set up and return response message
      responseJSON.put("success", true);
      return responseJSON;
View Full Code Here

        }
       
        LOGGER.finer("WfUtil.launchWf: workflowName="+wfName);
       
        ClassLoader previous = Thread.currentThread().getContextClassLoader();
        RuntimeService rtSvc = JenkowEngine.getEngine().getRuntimeService();
       
        try {
            ProcessDefinition pDef = getDeployedWf(wfName);
            if (pDef == null) throw new RuntimeException("no deployed process definition for "+wfName);

            Map<String,Object> varMap = new HashMap<String,Object>();
            // TODO 9: move jenkow variables into JenkowProcessData
            varMap.put("jenkow_build_parent",parentName);
            varMap.put("jenkow_build_number",buildNo);
            varMap.put("console",new ConsoleLogger(parentName,buildNo));
            JobMD.setJobs(varMap,JobMD.newJobs());
           
            log.println(Consts.UI_PREFIX+": \""+wfName+"\" started");
long t = System.currentTimeMillis();           
System.out.println("starting process "+pDef.getId());
// TODO 9: why is this blocking????
            ProcessInstance proc = rtSvc.startProcessInstanceById(pDef.getId(),varMap);
//            String procId = startProcess(pDef.getId(),varMap);
            String procId = proc.getId();
System.out.println("process started procId="+procId+" ("+(System.currentTimeMillis()-t)+")");           
            return procId;
        } finally {
View Full Code Here

   
    static void deployToEngine(File wff) throws FileNotFoundException{
        LOGGER.info("deploying "+wff+" to workflow engine");
       
        ProcessEngine eng = JenkowEngine.getEngine();
        RuntimeService rtSvc = eng.getRuntimeService();
        RepositoryService repoSvc = eng.getRepositoryService();

        String wfn = wff+"20.xml"; // TODO 9: workaround for http://forums.activiti.org/en/viewtopic.php?f=8&t=3745&start=10
        DeploymentBuilder db = repoSvc.createDeployment().addInputStream(wfn,new FileInputStream(wff));
View Full Code Here

  @Test
  public void testProcessInstanceStartEvents() throws Exception {
    ProcessEngineImpl processEngine = initProcessEngine();

    TaskService taskService = processEngine.getTaskService();
    RuntimeService runtimeService = processEngine.getRuntimeService();
    ManagementService managementService = processEngine.getManagementService();
    HistoryService historyService = processEngine.getHistoryService();

    // record events
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(TEST_VARIABLE, TEST_VALUE);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(USERTASK_PROCESS, BUSINESS_KEY, variables);

    Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
    TimeUnit.MILLISECONDS.sleep(50);
    variables = new HashMap<String, Object>();
    variables.put(TASK_TEST_VARIABLE, TASK_TEST_VALUE);
    taskService.complete(task.getId(), variables);

    // transform log events
    List<EventLogEntry> eventLogEntries = managementService.getEventLogEntries(null, null);

    EventLogTransformer transformer = new EventLogTransformer(getTransformers());

    List<SimulationEvent> simulationEvents = transformer.transform(eventLogEntries);

    SimpleEventCalendar eventCalendar = new SimpleEventCalendar(processEngine.getProcessEngineConfiguration().getClock(), new SimulationEventComparator());
    eventCalendar.addEvents(simulationEvents);

    // replay process instance run
    final SimulationDebugger simRun = new ReplaySimulationRun(processEngine, eventCalendar, getReplayHandlers(processInstance.getId()));

    simRun.init(new NoExecutionVariableScope());

    // original process is finished - there should not be any running process instance/task
    assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
    assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());

    simRun.step();

    // replay process was started
    ProcessInstance replayProcessInstance = runtimeService.createProcessInstanceQuery()
        .processDefinitionKey(USERTASK_PROCESS)
        .singleResult();
    assertNotNull(replayProcessInstance);
    assertTrue(replayProcessInstance.getId().equals(processInstance.getId()) == false);
    assertEquals(TEST_VALUE, runtimeService.getVariable(replayProcessInstance.getId(), TEST_VARIABLE));
    // there should be one task
    assertEquals(1, taskService.createTaskQuery().taskDefinitionKey("userTask").count());

    simRun.step();

    // userTask was completed - replay process was finished
    assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
    assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
    HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery()
        .processInstanceId(replayProcessInstance.getId())
        .variableName(TASK_TEST_VARIABLE)
        .singleResult();
View Full Code Here

  @Test
  public void testProcessInstanceStartEvents() throws Exception {
    ProcessEngineImpl processEngine = initProcessEngine();

    TaskService taskService = processEngine.getTaskService();
    RuntimeService runtimeService = processEngine.getRuntimeService();

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(TEST_VARIABLE, TEST_VALUE);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(USERTASK_PROCESS, BUSINESS_KEY, variables);

    Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
    TimeUnit.MILLISECONDS.sleep(50);
    taskService.complete(task.getId());

    final SimulationDebugger simRun = new ReplaySimulationRun(processEngine, getReplayHandlers(processInstance.getId()));

    simRun.init(new NoExecutionVariableScope());

    // original process is finished - there should not be any running process instance/task
    assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
    assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());

    simRun.step();

    // replay process was started
    assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
    // there should be one task
    assertEquals(1, taskService.createTaskQuery().taskDefinitionKey("userTask").count());

    simRun.step();

    // userTask was completed - replay process was finished
    assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
    assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());

    simRun.close();
    processEngine.close();
    ProcessEngines.destroy();
View Full Code Here

    @Test
    public void testLaunchingGatewayProcessDefinition() throws Exception {
        AnnotationConfigApplicationContext applicationContext = this.context(InboundGatewayConfiguration.class);

        RepositoryService repositoryService = applicationContext.getBean(RepositoryService.class);
        RuntimeService runtimeService = applicationContext.getBean(RuntimeService.class);
        ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);

        Assert.assertNotNull("the process engine should not be null", processEngine);
        Assert.assertNotNull("we should have a default repositoryService included", repositoryService);
        String integrationGatewayProcess = "integrationGatewayProcess";
        List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery()
                .processDefinitionKey(integrationGatewayProcess)
                .list();
        ProcessDefinition processDefinition = processDefinitionList.iterator().next();
        Assert.assertEquals(processDefinition.getKey(), integrationGatewayProcess);
        Map<String, Object> vars = new HashMap<String, Object>();
        vars.put("customerId", 232);
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(integrationGatewayProcess, vars);
        Assert.assertNotNull("the processInstance should not be null", processInstance);
        org.junit.Assert.assertTrue(
                applicationContext.getBean(InboundGatewayConfiguration.AnalysingService.class)
                        .getStringAtomicReference().get().equals(projectId));
    }
View Full Code Here

* @author Joram Barrez
*/
public class StartProcessInstanceTestDelegate implements JavaDelegate {

    public void execute(DelegateExecution execution) throws Exception {
        RuntimeService runtimeService = execution.getEngineServices().getRuntimeService();
        runtimeService.startProcessInstanceByKey("oneTaskProcess");
    }
View Full Code Here

    RepositoryService repositoryService = processEngine.getRepositoryService();
    Deployment deployment = repositoryService.createDeployment()
        .addClasspathResource("org/activiti/mule/testVM.bpmn20.xml")
        .deploy();
   
    RuntimeService runtimeService = processEngine.getRuntimeService();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
    Assert.assertFalse(processInstance.isEnded());
    Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
    Assert.assertEquals(30, result);
    runtimeService.deleteProcessInstance(processInstance.getId(), "test");
   
    processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
    repositoryService.deleteDeployment(deployment.getId());
    assertAndEnsureCleanDb(processEngine);
    ProcessEngines.destroy();
View Full Code Here

   
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    Deployment deployment = processEngine.getRepositoryService().createDeployment()
        .addClasspathResource("org/activiti/mule/testHttp.bpmn20.xml")
        .deploy();
    RuntimeService runtimeService = processEngine.getRuntimeService();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
    Assert.assertFalse(processInstance.isEnded());
    Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
    Assert.assertEquals(20, result);
    runtimeService.deleteProcessInstance(processInstance.getId(), "test");
    processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
    processEngine.getRepositoryService().deleteDeployment(deployment.getId());
    assertAndEnsureCleanDb(processEngine);
    ProcessEngines.destroy();
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.RuntimeService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.