Package org.activiti.engine

Examples of org.activiti.engine.HistoryService


 
  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()
            .size());

    assertEquals(expectedHistoryTaskInstances+1,
            historyService.createHistoricTaskInstanceQuery()
              .processInstanceId(processInstanceId)
              .orderByTaskName().asc()
              .count());
  }
View Full Code Here


  }
 
  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

    protected void printDetails(String pid) {
        ProcessEngine pe = this.getProcessEngine();
        RepositoryService repo = pe.getRepositoryService();
        RuntimeService rt = pe.getRuntimeService();
        HistoryService hs = pe.getHistoryService();

        ProcessInstance pi = rt.createProcessInstanceQuery().processInstanceId(pid).singleResult();
        HistoricProcessInstance hpi = hs.createHistoricProcessInstanceQuery().processInstanceId(pid)
            .singleResult();
        if (pi == null && hpi == null) {
            // both null means. no process with that id.
            out().printf("No process details found with process id %s \n", pid);
            return;
        }

        String pdId = null;
        if (pi != null) {
            pdId = pi.getProcessDefinitionId();
        } else if (hpi != null) {
            pdId = hpi.getProcessDefinitionId();
        }

        ProcessDefinition pd = repo.createProcessDefinitionQuery().processDefinitionId(pdId).singleResult();
        Deployment depInfo = repo.createDeploymentQuery().deploymentId(pd.getDeploymentId()).singleResult();
        // print
        if (isVerbose()) {
            out().println("======== Deployment Details");
            printDeploymentInfo(depInfo);

            out().println("======== Process Definition Details");
            printProcessDefinitionInfo(pd);
        }

        out().println("======== Process Instance Details");
        printProcessInstanceInfo(hpi);

        List<HistoricActivityInstance> actInstList = hs.createHistoricActivityInstanceQuery()
            .processInstanceId(hpi.getId()).orderByHistoricActivityInstanceStartTime().asc().list();
        if (actInstList != null && actInstList.size() > 0) {
            out().println("======== Activity Execution Details");
            for (HistoricActivityInstance actInst : actInstList) {
                printActivityInstanceInfo(actInst);
View Full Code Here

            RepositoryService repo = pe.getRepositoryService();
            printProcessDefinitions(out(), repo);
        }

        if (this.history) {
            HistoryService his = pe.getHistoryService();
            boolean printActive = !this.active; // if we show active process, dont print then in history
            printHistoricProcessInstances(out(), his, printActive);
        }

        if (this.active) {
View Full Code Here

        ProcessEngine engine = this.getProcessEngine();
        if (engine == null) {
            out().println("Process Engine NOT Found!");
            return null;
        }
        HistoryService historyService = engine.getHistoryService();

        // order of priority if instnaceIDs or definitionIDs and all on the list
        // process instnaceID and exist or process definitionIDs and exit or process all
        // TODO figure out how to add mutually exclusive options - instanceIDs | definitions | all
View Full Code Here

TOP

Related Classes of org.activiti.engine.HistoryService

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.