Package org.activiti.engine

Examples of org.activiti.engine.TaskService


    variableMap.put("type", "2");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("DefaultFlow", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("usertask2", task.getTaskDefinitionKey());
  }
View Full Code Here


  public ActivitiRule activitiRule = new ActivitiRule();

  @Test
  @Deployment(resources = { "diagrams/Attachment.bpmn" })
  public void startProcess() throws Exception {
    TaskService taskService = activitiRule.getTaskService();
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    Task singleResult = taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult();
    String url = "http://labs.mop.com/apache-mirror//ant/binaries/apache-ant-1.8.3-bin.zip";
    String attachmentDescription = "ant bin package";
    taskService.createAttachment("zip", singleResult.getId(), processInstance.getId(), "apache-ant-1.8.3-bin.zip", attachmentDescription, url);
    taskService.complete(singleResult.getId());

    List<Attachment> taskAttachments = taskService.getTaskAttachments(singleResult.getId());
    assertEquals(1, taskAttachments.size());

    HistoryService historyService = activitiRule.getHistoryService();
    List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().finished().list();
    assertEquals(false, list.isEmpty());
View Full Code Here

  }

  @Test
  @Deployment(resources = { "diagrams/Attachment.bpmn" })
  public void testCandidateUsers() throws Exception {
    TaskService taskService = activitiRule.getTaskService();
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    assertNotNull(taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult());
    assertNotNull(taskService.createTaskQuery().taskCandidateUser("kafeitu").singleResult());

    Task singleResult = taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult();
    taskService.complete(singleResult.getId());

    assertNull(taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult());
    assertNull(taskService.createTaskQuery().taskCandidateUser("kafeitu").singleResult());
  }
View Full Code Here

  }

  @Test
  @Deployment(resources = { "diagrams/Attachment.bpmn" })
  public void testCandidateUsersAddUserRuntime() throws Exception {
    TaskService taskService = activitiRule.getTaskService();
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    assertNotNull(taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult());
    assertNotNull(taskService.createTaskQuery().taskCandidateUser("kafeitu").singleResult());

    String taskId = taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult().getId();
    taskService.addCandidateUser(taskId, "runtimeUser");

    assertNotNull(taskService.createTaskQuery().taskCandidateUser("runtimeUser").singleResult());

    Task singleResult = taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult();
    taskService.complete(singleResult.getId());

    assertNull(taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult());
    assertNull(taskService.createTaskQuery().taskCandidateUser("kafeitu").singleResult());
  }
View Full Code Here

  public ActivitiRule activitiRule = new ActivitiRule();

  @Test
  public void startProcess() throws Exception {
    RepositoryService repositoryService = activitiRule.getRepositoryService();
    TaskService taskService = activitiRule.getTaskService();
    repositoryService.createDeployment().addInputStream("process1.bpmn20.xml", new FileInputStream(filename)).deploy();
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("MyProcess", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    assertNotNull(taskService.createTaskQuery().taskAssignee("fg").singleResult());
  }
View Full Code Here

    String user = getQuery().getValues("user");
    if(user == null) {
      throw new ActivitiException("No user provided");
    }
   
    TaskService ts = ActivitiUtil.getTaskService();
   
    GroupQuery query = ActivitiUtil.getIdentityService()
      .createGroupQuery()
      .groupMember(user)
      .groupType("assignment");
   
    List<Group> groups = query.list();
    ObjectNode groupsJSON = new ObjectMapper().createObjectNode();
    for (Group group : groups) {
      long tasksInGroup = ts.createTaskQuery().taskCandidateGroup(group.getId()).count();
      groupsJSON.put(group.getName(), tasksInGroup);
    }
   
    ObjectNode summaryResponseJSON = new ObjectMapper().createObjectNode();
   
    ObjectNode totalAssignedJSON = new ObjectMapper().createObjectNode();
    totalAssignedJSON.put("total", ts.createTaskQuery().taskAssignee(user).count());
    summaryResponseJSON.put("assigned", totalAssignedJSON);
   
    ObjectNode totalUnassignedJSON = new ObjectMapper().createObjectNode();
    totalUnassignedJSON.put("total", ts.createTaskQuery().taskCandidateUser(user).count());
    totalUnassignedJSON.put("groups", groupsJSON);
    summaryResponseJSON.put("unassigned", totalUnassignedJSON);
   
    return summaryResponseJSON;
  }
View Full Code Here

  public ActivitiRule activitiRule = new ActivitiRule();

  @Test
  public void startProcess() throws Exception {
    RepositoryService repositoryService = activitiRule.getRepositoryService();
    TaskService taskService = activitiRule.getTaskService();
    repositoryService.createDeployment().addInputStream("process1.bpmn20.xml", new FileInputStream(filename)).deploy();
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    ProcessInstance processInstance = null;
    try {
      processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
    } catch (RuntimeException e) {
      System.err.println("cache runtimeexception");
      return;
    }
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    TaskQuery taskAssignee = taskService.createTaskQuery().taskAssignee("henryyan");
    System.out.println(ToStringBuilder.reflectionToString(taskAssignee));
  }
View Full Code Here

    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("assigneeList", Arrays.asList("user1", "user2", "user3"));
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("MultiInstanceActivitiAttrs", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
    TaskService taskService = activitiRule.getTaskService();
    long count = taskService.createTaskQuery().count();
    assertEquals(count, 3);
  }
View Full Code Here

    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("shopping-only-subprocess", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().taskAssignee("henryyan").singleResult();
   
    variableMap = new HashMap<String, Object>();
    variableMap.put("amount", 328d);
    taskService.complete(task.getId(), variableMap);
   
    task = taskService.createTaskQuery().taskAssignee("henryyan").singleResult();
    assertEquals("银行付款", task.getName());
    Object variable = taskService.getVariable(task.getId(), "amount");
    assertNotNull(variable);
    assertEquals(variable, 328d);
  }
View Full Code Here

    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("DymaticTaskName", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " "
        + processInstance.getProcessDefinitionId());
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("User TaskActiviti", task.getName());
  }
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.