org.camunda.bpm.engine.task.Task.setName()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(13.0k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.camunda.bpm.engine.task.Task.setName()方法的一些代码示例,展示了Task.setName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.setName()方法的具体详情如下:
包路径:org.camunda.bpm.engine.task.Task
类名称:Task
方法名:setName

Task.setName介绍

[英]Name or title of the task.
[中]任务的名称或标题。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

private List<String> generateDummyTasks(int nrOfTasks) {
 ArrayList<String> taskIds = new ArrayList<String>();
 for (int i = 0; i < nrOfTasks; i++) {
  Task task = taskService.newTask();
  task.setName(((char) ('A' + i)) + "");
  taskService.saveTask(task);
  taskIds.add(task.getId());
 }
 return taskIds;
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected void createTaskForTenant(String tenantId) {
 Task newTask = taskService.newTask();
 newTask.setName("testTask");
 if(tenantId != null) {
  newTask.setTenantId(tenantId);
 }
 taskService.saveTask(newTask);
 taskIds.add(newTask.getId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

.put(SINGLE_TASK_URL);
verify(mockTask).setName((String) json.get("name"));
verify(mockTask).setDescription((String) json.get("description"));
verify(mockTask).setPriority(0);

代码示例来源:origin: camunda/camunda-bpm-platform

public void testMultipleValueChange() {
 // given: a single task
 task = taskService.newTask();
 taskService.saveTask(task);
 // then: change a property twice
 task.setName("a task");
 task.setName("to do");
 taskService.saveTask(task);
 UserOperationLogEntry update = queryOperationDetails(OPERATION_TYPE_UPDATE).singleResult();
 assertNull(update.getOrgValue());
 assertEquals("to do", update.getNewValue());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testResetChange() {
 // given: a single task
 task = taskService.newTask();
 taskService.saveTask(task);
 // then: change the name
 String name = "a task";
 task.setName(name);
 taskService.saveTask(task);
 UserOperationLogEntry update = queryOperationDetails(OPERATION_TYPE_UPDATE).singleResult();
 assertNull(update.getOrgValue());
 assertEquals(name, update.getNewValue());
 // then: change the name some times and set it back to the original value
 task.setName("to do 1");
 task.setName("to do 2");
 task.setName(name);
 taskService.saveTask(task);
 // expect: there is no additional change tracked
 update = queryOperationDetails(OPERATION_TYPE_UPDATE).singleResult();
 assertNull(update.getOrgValue());
 assertEquals(name, update.getNewValue());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testStandaloneTaskTransientVariable() throws IOException {
 Task task = taskService.newTask();
 task.setName("gonzoTask");
 taskService.saveTask(task);
 String taskId = task.getId();
 try{
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  new ObjectOutputStream(baos).writeObject(new String("trumpet"));
  String serializedObject = StringUtil.fromBytes(Base64.encodeBase64(baos.toByteArray()), engineRule.getProcessEngine());
  taskService.setVariable(taskId, "instrument",
   Variables.serializedObjectValue(serializedObject)
    .objectTypeName(String.class.getName())
    .serializationDataFormat(Variables.SerializationDataFormats.JAVA)
    .setTransient(true)
    );
  assertEquals("trumpet", taskService.getVariable(taskId, "instrument"));
 } finally {
  taskService.deleteTask(taskId, true);
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testStandaloneTaskVariables() {
 Task task = taskService.newTask();
 task.setName("gonzoTask");
 taskService.saveTask(task);
 String taskId = task.getId();
 taskService.setVariable(taskId, "instrument", "trumpet");
 assertEquals("trumpet", taskService.getVariable(taskId, "instrument"));
 taskService.deleteTask(taskId, true);
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected void createTasks() {
 Task task = taskService.newTask("task1");
 task.setName("Task 1");
 task.setOwner(testUser.getId());
 task.setDelegationState(DelegationState.PENDING);
 taskService.saveTask(task);
 taskService.addCandidateGroup(task.getId(), "accounting");
 task = taskService.newTask("task2");
 task.setName("Task 2");
 task.setOwner(testUser.getId());
 task.setDelegationState(DelegationState.RESOLVED);
 taskService.saveTask(task);
 taskService.setAssignee(task.getId(), "kermit");
 taskService.addCandidateGroup(task.getId(), "accounting");
 task = taskService.newTask("task3");
 task.setName("Task 3");
 task.setOwner(testUser.getId());
 task.setDelegationState(DelegationState.RESOLVED);
 taskService.saveTask(task);
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void shouldReturnTasksWithTaskNameOrTaskDescription() {
 // given
 Task task1 = taskService.newTask();
 task1.setName("aTaskName");
 taskService.saveTask(task1);
 Task task2 = taskService.newTask();
 task2.setDescription("aTaskDescription");
 taskService.saveTask(task2);
 // when
 List<Task> tasks = taskService.createTaskQuery()
  .or()
   .taskName("aTaskName")
   .taskDescription("aTaskDescription")
  .endOr()
  .list();
 // then
 assertEquals(2, tasks.size());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testCompositeBeanInteraction() {
 // given: a manually created task
 task = taskService.newTask();
 // then: save the task without any property change
 taskService.saveTask(task);
 // expect: no entry
 UserOperationLogQuery query = queryOperationDetails(OPERATION_TYPE_CREATE);
 UserOperationLogEntry create = query.singleResult();
 assertNotNull(create);
 assertEquals(ENTITY_TYPE_TASK, create.getEntityType());
 assertNull(create.getOrgValue());
 assertNull(create.getNewValue());
 assertNull(create.getProperty());
 task.setAssignee("icke");
 task.setName("to do");
 // then: save the task again
 taskService.saveTask(task);
 // expect: two update entries with the same operation id
 List<UserOperationLogEntry> entries = queryOperationDetails(OPERATION_TYPE_UPDATE).list();
 assertEquals(2, entries.size());
 assertEquals(entries.get(0).getOperationId(), entries.get(1).getOperationId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void testCreateToComplete() {
 // Create and save task
 Task task = taskService.newTask();
 task.setName("testTask");
 taskService.saveTask(task);
 String taskId = task.getId();
 // Add user as candidate user
 taskService.addCandidateUser(taskId, "kermit");
 taskService.addCandidateUser(taskId, "gonzo");
 // Retrieve task list for jbarrez
 List<Task> tasks = taskService.createTaskQuery().taskCandidateUser("kermit").list();
 assertEquals(1, tasks.size());
 assertEquals("testTask", tasks.get(0).getName());
 // Retrieve task list for tbaeyens
 tasks = taskService.createTaskQuery().taskCandidateUser("gonzo").list();
 assertEquals(1, tasks.size());
 assertEquals("testTask", tasks.get(0).getName());
 // Claim task
 taskService.claim(taskId, "kermit");
 // Tasks shouldn't appear in the candidate tasklists anymore
 assertTrue(taskService.createTaskQuery().taskCandidateUser("kermit").list().isEmpty());
 assertTrue(taskService.createTaskQuery().taskCandidateUser("gonzo").list().isEmpty());
 // Complete task
 taskService.deleteTask(taskId, true);
 // Task should be removed from runtime data
 // TODO: check for historic data when implemented!
 assertNull(taskService.createTaskQuery().taskId(taskId).singleResult());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void updateTask(Task task) {
 task.setName(getName());
 task.setDescription(getDescription());
 task.setPriority(getPriority());
 task.setAssignee(getAssignee());
 task.setOwner(getOwner());
 DelegationState state = null;
 if (getDelegationState() != null) {
  DelegationStateConverter converter = new DelegationStateConverter();
  state = converter.convertQueryParameterToType(getDelegationState());
 }
 task.setDelegationState(state);
 task.setDueDate(getDue());
 task.setFollowUpDate(getFollowUp());
 task.setParentTaskId(getParentTaskId());
 task.setCaseInstanceId(getCaseInstanceId());
 task.setTenantId(getTenantId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void updateTask(Task task) {
 task.setName(getName());
 task.setDescription(getDescription());
 task.setPriority(getPriority());
 task.setAssignee(getAssignee());
 task.setOwner(getOwner());
 DelegationState state = null;
 if (getDelegationState() != null) {
  DelegationStateConverter converter = new DelegationStateConverter();
  state = converter.convertQueryParameterToType(getDelegationState());
 }
 task.setDelegationState(state);
 task.setDueDate(getDue());
 task.setFollowUpDate(getFollowUp());
 task.setParentTaskId(getParentTaskId());
 task.setCaseInstanceId(getCaseInstanceId());
 task.setTenantId(getTenantId());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testStandaloneTaskTransientVariableSerializedObject() {
 Task task = taskService.newTask();
 task.setName("gonzoTask");
 taskService.saveTask(task);
 String taskId = task.getId();
 try {
  thrown.expect(ProcessEngineException.class);
  thrown.expectMessage("Cannot set variable with name instrument. Java serialization format is prohibited");
  taskService.setVariable(taskId, "instrument",
   Variables.serializedObjectValue("any value")
    .serializationDataFormat(Variables.SerializationDataFormats.JAVA)
    .setTransient(true)
    .create());
 } finally {
  taskService.deleteTask(taskId, true);
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void testDeleteTaskWithDeleteReason() {
 // ACT-900: deleteReason can be manually specified - can only be validated when historyLevel > ACTIVITY
 if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
  Task task = taskService.newTask();
  task.setName("test task");
  taskService.saveTask(task);
  assertNotNull(task.getId());
  taskService.deleteTask(task.getId(), "deleted for testing purposes");
  HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery()
   .taskId(task.getId()).singleResult();
  assertNotNull(historicTaskInstance);
  assertEquals("deleted for testing purposes", historicTaskInstance.getDeleteReason());
  // Delete historic task that is left behind, will not be cleaned up because this is not part of a process
  taskService.deleteTask(task.getId(), true);
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

standaloneTask.setName("A Standalone Task");
taskService.saveTask(standaloneTask);

代码示例来源:origin: camunda/camunda-bpm-platform

public void testQuerySortingByNameShouldBeCaseInsensitive() {
 task.setName("CaseSensitiveTestTask");
 taskService.saveTask(task);

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
public void shouldReturnTasksWithMultipleOrCriteria() {
 // given
 Task task1 = taskService.newTask();
 task1.setName("aTaskName");
 taskService.saveTask(task1);
 Task task2 = taskService.newTask();
 task2.setDescription("aTaskDescription");
 taskService.saveTask(task2);
 Task task3 = taskService.newTask();
 taskService.saveTask(task3);
 Task task4 = taskService.newTask();
 task4.setPriority(5);
 taskService.saveTask(task4);
 Task task5 = taskService.newTask();
 task5.setOwner("aTaskOwner");
 taskService.saveTask(task5);
 // when
 List<Task> tasks = taskService.createTaskQuery()
  .or()
   .taskName("aTaskName")
   .taskDescription("aTaskDescription")
   .taskId(task3.getId())
   .taskPriority(5)
   .taskOwner("aTaskOwner")
  .endOr()
  .list();
 // then
 assertEquals(5, tasks.size());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Test
 @Deployment
 public void testSubTaskData() {
  //given simple process with user task
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subTaskTest");
  Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();

  // when set variable to user task
  taskService.setVariable(task.getId(), "testVariable", "testValue");

  // then variable is set in the scope of execution
  Assert.assertEquals("testValue", runtimeService.getVariable(task.getExecutionId(), "testVariable"));

  // when sub task is created create subtask for user task
  Task subTask = taskService.newTask("123456789");
  subTask.setParentTaskId(task.getId());
  subTask.setName("Test Subtask");
  taskService.saveTask(subTask);

  // and variable is update
  taskService.setVariable(subTask.getId(), "testVariable", "newTestValue");

  //then variable is also updated in the scope execution
  Assert.assertEquals("newTestValue", runtimeService.getVariable(task.getExecutionId(), "testVariable"));
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment
 public void testHistoricTaskInstanceUpdate() {
  runtimeService.startProcessInstanceByKey("HistoricTaskInstanceTest").getId();

  Task task = taskService.createTaskQuery().singleResult();

  // Update and save the task's fields before it is finished
  task.setPriority(12345);
  task.setDescription("Updated description");
  task.setName("Updated name");
  task.setAssignee("gonzo");
  taskService.saveTask(task);

  taskService.complete(task.getId());
  assertEquals(1, historyService.createHistoricTaskInstanceQuery().count());

  HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult();
  assertEquals("Updated name", historicTaskInstance.getName());
  assertEquals("Updated description", historicTaskInstance.getDescription());
  assertEquals("gonzo", historicTaskInstance.getAssignee());
  assertEquals("task", historicTaskInstance.getTaskDefinitionKey());
 }
}

相关文章