Java Code Examples for org.activiti.engine.task.Task#setParentTaskId()
The following examples show how to use
org.activiti.engine.task.Task#setParentTaskId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskBaseResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Populate the task based on the values that are present in the given {@link TaskRequest}. */ protected void populateTaskFromRequest(Task task, TaskRequest taskRequest) { if (taskRequest.isNameSet()) { task.setName(taskRequest.getName()); } if (taskRequest.isAssigneeSet()) { task.setAssignee(taskRequest.getAssignee()); } if (taskRequest.isDescriptionSet()) { task.setDescription(taskRequest.getDescription()); } if (taskRequest.isDuedateSet()) { task.setDueDate(taskRequest.getDueDate()); } if (taskRequest.isOwnerSet()) { task.setOwner(taskRequest.getOwner()); } if (taskRequest.isParentTaskIdSet()) { task.setParentTaskId(taskRequest.getParentTaskId()); } if (taskRequest.isPrioritySet()) { task.setPriority(taskRequest.getPriority()); } if (taskRequest.isCategorySet()) { task.setCategory(taskRequest.getCategory()); } if (taskRequest.isTenantIdSet()) { task.setTenantId(taskRequest.getTenantId()); } if (taskRequest.isFormKeySet()) { task.setFormKey(taskRequest.getFormKey()); } if (taskRequest.isDelegationStateSet()) { DelegationState delegationState = getDelegationState(taskRequest.getDelegationState()); task.setDelegationState(delegationState); } }
Example 2
Source File: TaskController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 添加子任务 */ @RequestMapping("task/subtask/add/{taskId}") public String addSubTask(@PathVariable("taskId") String parentTaskId, @RequestParam("taskName") String taskName, @RequestParam(value = "description", required = false) String description, HttpSession session) { Task newTask = taskService.newTask(); newTask.setParentTaskId(parentTaskId); String userId = UserUtil.getUserFromSession(session).getId(); newTask.setOwner(userId); newTask.setAssignee(userId); newTask.setName(taskName); newTask.setDescription(description); taskService.saveTask(newTask); return "redirect:/chapter6/task/getform/" + parentTaskId; }
Example 3
Source File: TaskController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 添加子任务 */ @RequestMapping("task/subtask/add/{taskId}") public String addSubTask(@PathVariable("taskId") String parentTaskId, @RequestParam("taskName") String taskName, @RequestParam(value = "description", required = false) String description, HttpSession session) { Task newTask = taskService.newTask(); newTask.setParentTaskId(parentTaskId); String userId = UserUtil.getUserFromSession(session).getId(); newTask.setOwner(userId); newTask.setAssignee(userId); newTask.setName(taskName); newTask.setDescription(description); taskService.saveTask(newTask); return "redirect:/chapter6/task/getform/" + parentTaskId; }
Example 4
Source File: TaskController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 添加子任务 */ @RequestMapping("task/subtask/add/{taskId}") public String addSubTask(@PathVariable("taskId") String parentTaskId, @RequestParam("taskName") String taskName, @RequestParam(value = "description", required = false) String description, HttpSession session) { Task newTask = taskService.newTask(); newTask.setParentTaskId(parentTaskId); String userId = UserUtil.getUserFromSession(session).getId(); newTask.setOwner(userId); newTask.setAssignee(userId); newTask.setName(taskName); newTask.setDescription(description); taskService.saveTask(newTask); return "redirect:/chapter6/task/getform/" + parentTaskId; }
Example 5
Source File: SubTaskTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testSubTask() { Task gonzoTask = taskService.newTask(); gonzoTask.setName("gonzoTask"); taskService.saveTask(gonzoTask); Task subTaskOne = taskService.newTask(); subTaskOne.setName("subtask one"); String gonzoTaskId = gonzoTask.getId(); subTaskOne.setParentTaskId(gonzoTaskId); taskService.saveTask(subTaskOne); Task subTaskTwo = taskService.newTask(); subTaskTwo.setName("subtask two"); subTaskTwo.setParentTaskId(gonzoTaskId); taskService.saveTask(subTaskTwo); String subTaskId = subTaskOne.getId(); assertTrue(taskService.getSubTasks(subTaskId).isEmpty()); assertTrue(historyService.createHistoricTaskInstanceQuery().taskParentTaskId(subTaskId).list().isEmpty()); List<Task> subTasks = taskService.getSubTasks(gonzoTaskId); Set<String> subTaskNames = new HashSet<String>(); for (Task subTask : subTasks) { subTaskNames.add(subTask.getName()); } if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { Set<String> expectedSubTaskNames = new HashSet<String>(); expectedSubTaskNames.add("subtask one"); expectedSubTaskNames.add("subtask two"); assertEquals(expectedSubTaskNames, subTaskNames); List<HistoricTaskInstance> historicSubTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(gonzoTaskId).list(); subTaskNames = new HashSet<String>(); for (HistoricTaskInstance historicSubTask : historicSubTasks) { subTaskNames.add(historicSubTask.getName()); } assertEquals(expectedSubTaskNames, subTaskNames); } taskService.deleteTask(gonzoTaskId, true); }
Example 6
Source File: SubTaskTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testSubTaskDeleteOnProcessInstanceDelete() { Deployment deployment = repositoryService.createDeployment() .addClasspathResource("org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml") .deploy(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); taskService.setAssignee(task.getId(), "test"); Task subTask1 = taskService.newTask(); subTask1.setName("Sub task 1"); subTask1.setParentTaskId(task.getId()); subTask1.setAssignee("test"); taskService.saveTask(subTask1); Task subTask2 = taskService.newTask(); subTask2.setName("Sub task 2"); subTask2.setParentTaskId(task.getId()); subTask2.setAssignee("test"); taskService.saveTask(subTask2); List<Task> tasks = taskService.createTaskQuery().taskAssignee("test").list(); assertEquals(3, tasks.size()); runtimeService.deleteProcessInstance(processInstance.getId(), "none"); tasks = taskService.createTaskQuery().taskAssignee("test").list(); assertEquals(0, tasks.size()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list(); assertEquals(3, historicTasks.size()); historyService.deleteHistoricProcessInstance(processInstance.getId()); historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list(); assertEquals(0, historicTasks.size()); } repositoryService.deleteDeployment(deployment.getId(), true); }
Example 7
Source File: TaskSubTaskCollectionResourceTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
/** * Test getting all sub tasks. GET runtime/tasks/{taskId}/subtasks */ public void testGetSubTasks() throws Exception { Task parentTask = taskService.newTask(); parentTask.setName("parent task"); taskService.saveTask(parentTask); Task subTask = taskService.newTask(); subTask.setName("sub task 1"); subTask.setParentTaskId(parentTask.getId()); taskService.saveTask(subTask); Task subTask2 = taskService.newTask(); subTask2.setName("sub task 2"); subTask2.setParentTaskId(parentTask.getId()); taskService.saveTask(subTask2); // Request all sub tasks CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_SUBTASKS_COLLECTION, parentTask.getId())), HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertNotNull(responseNode); assertTrue(responseNode.isArray()); assertEquals(2, responseNode.size()); boolean foundSubtask1 = false; boolean foundSubtask2 = false; for (int i = 0; i < responseNode.size(); i++) { JsonNode var = responseNode.get(i); if ("sub task 1".equals(var.get("name").asText())) { foundSubtask1 = true; assertEquals(subTask.getId(), var.get("id").asText()); } else if ("sub task 2".equals(var.get("name").asText())) { foundSubtask2 = true; assertEquals(subTask2.getId(), var.get("id").asText()); } } assertTrue(foundSubtask1); assertTrue(foundSubtask2); taskService.deleteTask(parentTask.getId()); taskService.deleteTask(subTask.getId()); taskService.deleteTask(subTask2.getId()); historyService.deleteHistoricTaskInstance(parentTask.getId()); historyService.deleteHistoricTaskInstance(subTask.getId()); historyService.deleteHistoricTaskInstance(subTask2.getId()); }
Example 8
Source File: SubTaskTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testSubTask() { Task gonzoTask = taskService.newTask(); gonzoTask.setName("gonzoTask"); taskService.saveTask(gonzoTask); Task subTaskOne = taskService.newTask(); subTaskOne.setName("subtask one"); String gonzoTaskId = gonzoTask.getId(); subTaskOne.setParentTaskId(gonzoTaskId); taskService.saveTask(subTaskOne); Task subTaskTwo = taskService.newTask(); subTaskTwo.setName("subtask two"); subTaskTwo.setParentTaskId(gonzoTaskId); taskService.saveTask(subTaskTwo); String subTaskId = subTaskOne.getId(); assertTrue(taskService.getSubTasks(subTaskId).isEmpty()); assertTrue(historyService .createHistoricTaskInstanceQuery() .taskParentTaskId(subTaskId) .list() .isEmpty()); List<Task> subTasks = taskService.getSubTasks(gonzoTaskId); Set<String> subTaskNames = new HashSet<String>(); for (Task subTask: subTasks) { subTaskNames.add(subTask.getName()); } if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { Set<String> expectedSubTaskNames = new HashSet<String>(); expectedSubTaskNames.add("subtask one"); expectedSubTaskNames.add("subtask two"); assertEquals(expectedSubTaskNames, subTaskNames); List<HistoricTaskInstance> historicSubTasks = historyService .createHistoricTaskInstanceQuery() .taskParentTaskId(gonzoTaskId) .list(); subTaskNames = new HashSet<String>(); for (HistoricTaskInstance historicSubTask: historicSubTasks) { subTaskNames.add(historicSubTask.getName()); } assertEquals(expectedSubTaskNames, subTaskNames); } taskService.deleteTask(gonzoTaskId, true); }
Example 9
Source File: SubTaskTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testSubTaskDeleteOnProcessInstanceDelete() { Deployment deployment = repositoryService.createDeployment() .addClasspathResource("org/activiti5/engine/test/api/runtime/oneTaskProcess.bpmn20.xml") .deploy(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); taskService.setAssignee(task.getId(), "test"); Task subTask1 = taskService.newTask(); subTask1.setName("Sub task 1"); subTask1.setParentTaskId(task.getId()); subTask1.setAssignee("test"); taskService.saveTask(subTask1); Task subTask2 = taskService.newTask(); subTask2.setName("Sub task 2"); subTask2.setParentTaskId(task.getId()); subTask2.setAssignee("test"); taskService.saveTask(subTask2); List<Task> tasks = taskService.createTaskQuery().taskAssignee("test").list(); assertEquals(3, tasks.size()); runtimeService.deleteProcessInstance(processInstance.getId(), "none"); tasks = taskService.createTaskQuery().taskAssignee("test").list(); assertEquals(0, tasks.size()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list(); assertEquals(3, historicTasks.size()); historyService.deleteHistoricProcessInstance(processInstance.getId()); historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list(); assertEquals(0, historicTasks.size()); } repositoryService.deleteDeployment(deployment.getId(), true); }