Package org.activiti.engine

Examples of org.activiti.engine.TaskService


      .setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000")
      .setJobExecutorActivate(false)
      .buildProcessEngine();
    RepositoryService repositoryService2 = processEngine2.getRepositoryService();
    RuntimeService runtimeService2 = processEngine2.getRuntimeService();
    TaskService taskService2 = processEngine2.getTaskService();
   
    // Deploy first version of process: start->originalTask->end on first process engine
    String deploymentId = repositoryService1.createDeployment()
      .addClasspathResource("org/activiti/engine/test/cache/originalProcess.bpmn20.xml")
      .deploy()
      .getId();
   
    // Start process instance on second engine
    String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId();
    runtimeService2.startProcessInstanceById(processDefinitionId);
    Task task = taskService2.createTaskQuery().singleResult();
    assertEquals("original task", task.getName());
   
    // Delete the deployment on second process engine
    repositoryService2.deleteDeployment(deploymentId, true);
    assertEquals(0, repositoryService2.createDeploymentQuery().count());
    assertEquals(0, runtimeService2.createProcessInstanceQuery().count());
   
    // deploy a revised version of the process: start->revisedTask->end on first process engine
    //
    // Before the bugfix, this would set the cache on the first process engine,
    // but the second process engine still has the original process definition in his cache.
    // Since there is a deployment delete in between, the new generated process definition id is the same
    // as in the original deployment, making the second process engine using the old cached process definition.
    deploymentId = repositoryService1.createDeployment()
      .addClasspathResource("org/activiti/engine/test/cache/revisedProcess.bpmn20.xml")
      .deploy()
      .getId();
   
    // Start process instance on second process engine -> must use revised process definition
    processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId();
    runtimeService2.startProcessInstanceByKey("oneTaskProcess");
    task = taskService2.createTaskQuery().singleResult();
    assertEquals("revised task", task.getName());
   
    // cleanup
    repositoryService1.deleteDeployment(deploymentId, true);
    processEngine1.close();
View Full Code Here


  @Deployment
  public void ruleUsageExample() {
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    runtimeService.startProcessInstanceByKey("ruleUsage");
   
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("My Task", task.getName());
   
    taskService.complete(task.getId());
    assertEquals(0, runtimeService.createProcessInstanceQuery().count());
  }
View Full Code Here

public class UpgradeTaskOneTest extends UpgradeTestCase {
 
  public void testSimplestTask() {
    RuntimeService runtimeService = processEngine.getRuntimeService();
    TaskService taskService = processEngine.getTaskService();
    ManagementService managementService = processEngine.getManagementService();
    HistoryService historyService = processEngine.getHistoryService();

    Task task = taskService
      .createTaskQuery()
      .taskName("simpleTask2")
      .singleResult();
   
    String processInstanceId = task.getProcessInstanceId();
   
    long expectedHistoryTaskInstances = -1;
    String schemaHistory = managementService.getProperties().get("schema.history");
    if (schemaHistory.startsWith("create(5.0)")) {
      expectedHistoryTaskInstances = 0;
    } else {
      expectedHistoryTaskInstances = 2;
    }
   
    assertEquals(expectedHistoryTaskInstances,
      historyService.createHistoricTaskInstanceQuery()
        .processInstanceId(processInstanceId)
        .orderByTaskName().asc()
        .count());
     
    taskService.complete(task.getId());
   
    assertEquals(1, runtimeService
            .createExecutionQuery()
            .processInstanceId(processInstanceId)
            .list()
            .size());

    assertEquals(expectedHistoryTaskInstances+1,
            historyService.createHistoricTaskInstanceQuery()
              .processInstanceId(processInstanceId)
              .orderByTaskName().asc()
              .count());
           
    task = taskService
      .createTaskQuery()
      .taskName("simpleTask3")
      .singleResult();

    taskService.complete(task.getId());

    assertEquals(0, runtimeService
            .createExecutionQuery()
            .processInstanceId(processInstanceId)
            .list()
View Full Code Here

    return types.get(type) == null ? type: types.get(type);
  }
 
  public static WorkflowEntity getWorkflowEntity(String processInstanceId) {
    RuntimeService runtimeService= SpringContextHolder.getBean(RuntimeService.class);
    TaskService taskService= SpringContextHolder.getBean(TaskService.class);
    HistoryService historyService= SpringContextHolder.getBean(HistoryService.class);
    RepositoryService repositoryService= SpringContextHolder.getBean(RepositoryService.class);
   
    WorkflowEntity workflowEntity = new WorkflowEntity();
    List<Task> tasks= taskService.createTaskQuery().processInstanceId(processInstanceId).active().list();
    workflowEntity.setTasks(tasks);
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
    if(historicProcessInstance!=null) {
      workflowEntity.setHistoricProcessInstance(historicProcessInstance);
      workflowEntity.setProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionId(historicProcessInstance.getProcessDefinitionId()).singleResult());
    } else {
      ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).active().singleResult();
      workflowEntity.setProcessInstance(processInstance);
      workflowEntity.setProcessDefinition(repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult());
    }
    workflowEntity.setHistoricTaskInstances(historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).orderByHistoricTaskInstanceEndTime().asc().list());
    workflowEntity.setHistoricVariableInstances(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list());
    workflowEntity.setComments(taskService.getProcessInstanceComments(processInstanceId));
    return workflowEntity;
  }
View Full Code Here

    workflowEntity.setComments(taskService.getProcessInstanceComments(processInstanceId));
    return workflowEntity;
  }
 
  public static void claim(String processInstanceId) {
    TaskService taskService= SpringContextHolder.getBean(TaskService.class);
    //如果没有签收,签收
    Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
    if(task != null && StringUtils.isEmpty(task.getAssignee())){
      taskService.claim(task.getId(), ObjectUtils.toString(UserUtils.getUser().getId()));
    }
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.TaskService

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.