org.kie.api.task.model.Task类的使用及代码示例

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

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

Task介绍

暂无

代码示例

代码示例来源:origin: kiegroup/jbpm

@Override
public void afterTaskDelegatedEvent(TaskEvent event) {
  String userId = event.getTaskContext().getUserId();
  Task ti = event.getTask();
  TaskEventImpl taskEvent = new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.DELEGATED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId);
  AuditTaskImpl auditTaskImpl = createAuditTask(ti, event.getEventDate());
  auditTaskImpl.setDescription(ti.getDescription());
  auditTaskImpl.setName(ti.getName());
  auditTaskImpl.setActivationTime(ti.getTaskData().getActivationTime());
  auditTaskImpl.setPriority(ti.getPriority());
  auditTaskImpl.setDueDate(ti.getTaskData().getExpirationTime());
  auditTaskImpl.setStatus(ti.getTaskData().getStatus().name());
  auditTaskImpl.setActualOwner(getActualOwner(ti));
  auditTaskImpl.setLastModificationDate(event.getEventDate());
  sendMessage(new AuditTaskData(auditTaskImpl, taskEvent), 4);
}

代码示例来源:origin: kiegroup/jbpm

public void initialize(Task task) { 
  if( task == null ) { 
    return;
  }
  this.id = task.getId();
  this.priority = task.getPriority();
  this.version = task.getVersion();
  this.archived = task.isArchived();
  this.subTasksStrategy = ((InternalTask) task).getSubTaskStrategy();
  this.peopleAssignments = new JaxbPeopleAssignments(task.getPeopleAssignments());
  this.names = convertListFromInterfaceToJaxbImpl(task.getNames(), I18NText.class, JaxbI18NText.class);
  this.name = ((InternalTask)task).getName();
  this.subjects = convertListFromInterfaceToJaxbImpl(task.getSubjects(), I18NText.class, JaxbI18NText.class);
  this.subject = ((InternalTask)task).getSubject();
  this.descriptions = convertListFromInterfaceToJaxbImpl(task.getDescriptions(), I18NText.class, JaxbI18NText.class);
  this.description = ((InternalTask)task).getDescription();
  
  this.taskType = task.getTaskType();
  this.formName = ((InternalTask)task).getFormName();
  this.taskData = new JaxbTaskData(task.getTaskData());
}

代码示例来源:origin: kiegroup/jbpm

/**
 * Generates a queue name that is based on data retrieved from the task. The form of the generated queue name is:
 * Process ID + "_" + Deployment ID + " " + Task Name
 * @param task Source of the data used to generate the queue name
 * @return The generated queue name
 */
protected String getQueueName(Task task) {
  return task.getTaskData().getProcessId() + "_" + task.getTaskData().getDeploymentId() + "_" + task.getName();
}

代码示例来源:origin: kiegroup/jbpm

protected AuditTaskImpl createAuditTask(Task ti, Date date) {
  AuditTaskImpl auditTaskImpl = new AuditTaskImpl(
      ti.getId(),
      ti.getName(),
      ti.getTaskData().getStatus().name(),
      ti.getTaskData().getActivationTime(),
      (ti.getTaskData().getActualOwner() != null) ? ti.getTaskData().getActualOwner().getId() : "",
      ti.getDescription(),
      ti.getPriority(),
      (ti.getTaskData().getCreatedBy() != null) ? ti.getTaskData().getCreatedBy().getId() : "",
      ti.getTaskData().getCreatedOn(),
      ti.getTaskData().getExpirationTime(),
      ti.getTaskData().getProcessInstanceId(),
      ti.getTaskData().getProcessId(),
      ti.getTaskData().getProcessSessionId(),
      ti.getTaskData().getDeploymentId(),
      ti.getTaskData().getParentId(),
      ti.getTaskData().getWorkItemId(),
      date
    );
  
  return auditTaskImpl;
}

代码示例来源:origin: kiegroup/jbpm

private String buildDefafultEmailBody(TaskData taskData,Task task){
  Map<String, Object> vars = new HashMap<String, Object>();
  vars.put("taskName", task.getName());
  vars.put("taskId", task.getId());
  vars.put("deploymentId", taskData.getDeploymentId());
  vars.put("processId", taskData.getProcessId());
  vars.put("processInstanceId", taskData.getProcessInstanceId());
  String body = (String) TemplateRuntime.eval(defaultEmailBody, vars);
  return body;
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testClaimWithGroupAssignee() throws Exception {
  
  // One potential owner, should go straight to state Reserved
  String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
  str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new Group('Knights Templer' )], businessAdministrators = [ new User('Administrator') ], }),";
  str += "name = 'This is my task name' })";
  Task task = TaskFactory.evalTask(new StringReader(str));
  taskService.addTask(task, new HashMap<String, Object>());
  long taskId = task.getId();
  // A Task with multiple potential owners moves to "Ready" state until someone claims it.
  Task task1 = taskService.getTaskById(taskId);
  assertEquals(Status.Ready, task1.getTaskData().getStatus());
  taskService.claim(taskId, "Darth Vader");
  Task task2 = taskService.getTaskById(taskId);
  assertEquals(Status.Reserved, task2.getTaskData().getStatus());
  assertEquals("Darth Vader", task2.getTaskData().getActualOwner().getId());
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testExitFromReserved() {
  
  String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { skipable = false} ), ";
  str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet') ], businessAdministrators = [ new User('Administrator')] }),";
  str += "name = 'This is my task name' })";
  Task task = TaskFactory.evalTask(new StringReader(str));
  taskService.addTask(task, new HashMap<String, Object>());
  long taskId = task.getId();
  task = taskService.getTaskById(taskId);
  assertEquals(Status.Reserved, task.getTaskData().getStatus());
  taskService.exit(taskId, "Administrator");
  Task task1 = taskService.getTaskById(taskId);
  assertEquals(Status.Exited, task1.getTaskData().getStatus());
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testDelegateFromReady() throws Exception {
  
  // One potential owner, should go straight to state Reserved
  String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
  str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new User('Darth Vader') ],businessAdministrators = [ new User('Administrator') ], }),";
  str += "name = 'This is my task name' })";
  Task task = TaskFactory.evalTask(new StringReader(str));
  taskService.addTask(task, new HashMap<String, Object>());
  long taskId = task.getId();
  // Check is Delegated
  taskService.delegate(taskId, "Darth Vader", "Tony Stark");
  Task task2 = taskService.getTaskById(taskId);
  User user = createUser("Darth Vader");
  assertTrue(task2.getPeopleAssignments().getPotentialOwners().contains(user));
  user = createUser("Tony Stark");
  assertTrue(task2.getPeopleAssignments().getPotentialOwners().contains(user));
  assertEquals("Tony Stark", task2.getTaskData().getActualOwner().getId());
  // this was checking for ready, but it should be reserved.. it was an old bug
  assertEquals(Status.Reserved, task2.getTaskData().getStatus());
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testNominateToGroup() {
  
  String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
  str += "peopleAssignments = (with ( new PeopleAssignments() ) { businessAdministrators = [ new User('Darth Vader'), new User('Bobba Fet') ] } ),";
  str += "name = 'This is my task name'})";
  Task task = TaskFactory.evalTask(new StringReader(str));
  taskService.addTask(task, new HashMap<String, Object>());
  long taskId = task.getId();
  List<OrganizationalEntity> potentialGroups = new ArrayList<OrganizationalEntity>();
  Group group = TaskModelProvider.getFactory().newGroup();
  ((InternalOrganizationalEntity) group).setId("Knights Templer");
  potentialGroups.add(group);
  taskService.nominate(taskId, "Darth Vader", potentialGroups);
  //shouldn't affect the assignments
  Task task1 = taskService.getTaskById(taskId);
  assertTrue(task1.getPeopleAssignments().getPotentialOwners().contains(group));
  assertEquals(task1.getTaskData().getStatus(), Status.Ready);
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testAssignmentsWhenNoRuleWasFired() throws Exception {
  String str = "(with (new Task()) { priority = 51, taskData = (with( new TaskData()) { } ), ";
  str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Ben Dover') ],businessAdministrators = [ new User('Administrator') ],}),";
  str += "name =  'Not Bobbas tasks' })";
  Task task = TaskFactory.evalTask(new StringReader(str));
  assertPotentialOwners(task, 1);
  long taskId = taskService.addTask(task, Collections.emptyMap());
  task = taskService.getTaskById(taskId);
  assertPotentialOwners(task, 0);
  User actualOwner = task.getTaskData().getActualOwner();
  Assertions.assertThat(actualOwner).isNull();
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testLongDescription() {
  // BZ-1107473
  String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
  str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new User('Darth Vader') ],businessAdministrators = [ new User('Administrator') ], }),";
  str += "name = 'This is my task name' })";
  Task task = TaskFactory.evalTask(new StringReader(str));
  StringBuilder sb = new StringBuilder();
  for (int i = 0; i < 1000; i++) {
    sb.append("a");
  }
  String comment = sb.toString();
  // NOTE: AbstractHTWorkItemHandler stores "Comment" parameter as 'Description'
  List<I18NText> descriptions = new ArrayList<I18NText>();
  I18NText descText = TaskModelProvider.getFactory().newI18NText();
  ((InternalI18NText) descText).setLanguage("en-UK");
  ((InternalI18NText) descText).setText(comment);
  descriptions.add(descText);
  ((InternalTask)task).setDescriptions(descriptions);
  taskService.addTask(task, new HashMap<String, Object>()); // Fails if shortText is longer than 255
  long taskId = task.getId();
  Task resultTask = taskService.getTaskById(taskId);
  List<I18NText> resultDescriptions = resultTask.getDescriptions();
  InternalI18NText resultDescription = (InternalI18NText)resultDescriptions.get(0);
  assertEquals(1000, resultDescription.getText().length()); // This is text
  // 6.1.x no longer uses shortText in API and Taskorm.xml so no assert.
}

代码示例来源:origin: kiegroup/jbpm

str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')  ],businessAdministrators = [ new User('Administrator') ], }),";
str += "name = '"+taskName+"' })";
Task task = TaskFactory.evalTask(new StringReader(str));
List<I18NText> names = new ArrayList<I18NText>();
  I18NText text = TaskModelProvider.getFactory().newI18NText();
  names.add(text);
  ((InternalTask)task).setNames(names);
taskService.addTask(task, new HashMap<String, Object>());
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", "en-UK");
assertEquals(1, tasks.size());
assertEquals(taskName, tasks.get(0).getName());
Task newTask = taskService.getTaskById(tasks.get(0).getId());
List<I18NText> updatedNames = new ArrayList<I18NText>();
I18NText updatedName = TaskModelProvider.getFactory().newI18NText();
((InternalI18NText) updatedName).setLanguage(newTask.getNames().get(0).getLanguage());
((InternalI18NText) updatedName).setText("New task name");
updatedNames.add(updatedName);
taskService.setTaskNames(newTask.getId(), updatedNames);
List<TaskSummary> newTasks = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", "en-UK");
newTask = taskService.getTaskById(newTasks.get(0).getId());
assertEquals("New task name", newTask.getNames().get(0).getText());

代码示例来源:origin: kiegroup/jbpm

str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')  ],businessAdministrators = [ new User('Administrator') ], }),";
str += "name = '"+taskName+"' })";
Task task = TaskFactory.evalTask(new StringReader(str));
List<I18NText> names = new ArrayList<I18NText>();
  I18NText text = TaskModelProvider.getFactory().newI18NText();
  ((InternalTask)task).setNames(names);
taskService.addTask(task, new HashMap<String, Object>());
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", "en-UK");
assertEquals(1, tasks.size());
assertEquals(taskName, tasks.get(0).getName());
Task newTask = taskService.getTaskById(tasks.get(0).getId());
((InternalI18NText)newTask.getNames().get(0)).setText("New task name");
ut.commit();
newTask = taskService.getTaskById(newTasks.get(0).getId());
assertEquals("New task name", newTask.getNames().get(0).getText());

代码示例来源:origin: kiegroup/jbpm

@Override
public void afterTaskClaimedEvent(TaskEvent event) {
  String userId = event.getTaskContext().getUserId();
  Task ti = event.getTask();
  TaskEventImpl taskEvent = new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.CLAIMED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId);
  AuditTaskImpl auditTaskImpl = createAuditTask(ti, event.getEventDate());
  auditTaskImpl.setStatus(ti.getTaskData().getStatus().name());
  auditTaskImpl.setActualOwner(getActualOwner(ti));
  auditTaskImpl.setDescription(ti.getDescription());
  auditTaskImpl.setLastModificationDate(event.getEventDate());
  
  sendMessage(new AuditTaskData(auditTaskImpl, taskEvent), 8);
}

代码示例来源:origin: kiegroup/jbpm

@Override
public void afterTaskActivatedEvent(TaskEvent event) {
  String userId = event.getTaskContext().getUserId();
  Task ti = event.getTask();
  TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext)event.getTaskContext()).getPersistenceContext());
  try {            
    persistenceContext.persist(new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.ACTIVATED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId));
       
    AuditTaskImpl auditTaskImpl = getAuditTask(event, persistenceContext, ti);
    if (auditTaskImpl == null) {
      logger.warn("Unable find audit task entry for task id {} '{}', skipping audit task update", ti.getId(), ti.getName());
      return;
    }
    auditTaskImpl.setStatus(ti.getTaskData().getStatus().name());
    auditTaskImpl.setActualOwner(getActualOwner(ti));
    auditTaskImpl.setDescription(ti.getDescription());    
    auditTaskImpl.setLastModificationDate(event.getEventDate());
    persistenceContext.merge(auditTaskImpl);
  } finally {
    cleanup(persistenceContext);
  }
}

代码示例来源:origin: kiegroup/jbpm

@Test
public void testTaskExit() throws Exception {
  TestWorkItemManager manager = new TestWorkItemManager();
  ksession.setWorkItemManager(manager);
  WorkItemImpl workItem = new WorkItemImpl();
  workItem.setName("Human Task");
  workItem.setParameter("NodeName", "TaskName");
  workItem.setParameter("Comment", "Comment");
  workItem.setParameter("Priority", "10");
  workItem.setParameter("ActorId", "Darth Vader");
  workItem.setProcessInstanceId(10);
  getHandler().executeWorkItem(workItem, manager);
  
  Task task = taskService.getTaskByWorkItemId(workItem.getId());
  taskService.exit(task.getId(), "Administrator");
  
  task = taskService.getTaskByWorkItemId(workItem.getId());
  assertEquals("TaskName", task.getNames().get(0).getText());
  assertEquals(10, task.getPriority().intValue());
  assertEquals("Comment", task.getDescriptions().get(0).getText());
  assertEquals(Status.Exited, task.getTaskData().getStatus());
  
  List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
  assertEquals(0, tasks.size());
}
@Test

代码示例来源:origin: kiegroup/jbpm

private void testTaskWithExpectedDescription(final Task task, final String expectedDescription) {
  assertEquals("TaskName " + task.getTaskData().getProcessInstanceId(), task.getName());
  assertEquals(10, task.getPriority().intValue());
  assertEquals(expectedDescription, task.getDescription());
  assertEquals(Status.Reserved, task.getTaskData().getStatus());
  assertEquals("Darth Vader", task.getTaskData().getActualOwner().getId());
  assertEquals(10L, task.getTaskData().getProcessInstanceId());
}

代码示例来源:origin: org.kie.remote/kie-remote-client

private static org.kie.remote.jaxb.gen.Task convertKieTaskToGenTask( Task task ) {
  org.kie.remote.jaxb.gen.Task genTask = new org.kie.remote.jaxb.gen.Task();
  genTask.setDescription(task.getDescription());
  List<org.kie.remote.jaxb.gen.I18NText> genTextList = convertKieTextListToGenTextList(task.getDescriptions());
  if( genTextList != null ) {
    genTask.getDescriptions().addAll(genTextList);
  genTask.setId(task.getId());
  genTask.setName(task.getName());
  genTextList = convertKieTextListToGenTextList(task.getNames());
  if( genTextList != null ) {
    genTask.getNames().addAll(genTextList);
  PeopleAssignments kiePeepAssigns = task.getPeopleAssignments();
  if( kiePeepAssigns != null ) {
    org.kie.remote.jaxb.gen.PeopleAssignments genPeepAssigns = new org.kie.remote.jaxb.gen.PeopleAssignments();
  genTask.setPriority(task.getPriority());
  genTask.setSubject(task.getSubject());
  genTextList = convertKieTextListToGenTextList(task.getSubjects());
  if( genTextList != null ) {
    genTask.getSubjects().addAll(genTextList);
  genTask.setTaskType(task.getTaskType());
  TaskData kieTaskData = task.getTaskData();
  genTask.setTaskData(convertKieTaskDataToGenTaskData(kieTaskData));

代码示例来源:origin: org.jbpm/jbpm-examples

public static ChecklistItem createChecklistItem(Task task) {
  return new DefaultChecklistItem(
    getText(task.getNames()), 
    getStatus(task.getTaskData().getStatus()),
    task.getId(),
    "HumanTaskNode",
    getActors(task),
    task.getPriority(),
    task.getTaskData().getProcessId(),
    task.getTaskData().getProcessInstanceId(),
    getText(task.getDescriptions()));
}

代码示例来源:origin: kiegroup/jbpm

protected long createAndAssertTask(TaskFluent tf, String expectedOwner) {
  Task task = tf.getTask();
  taskService.addTask(task, data);
  long taskId = task.getId();
  assertEquals("Owner mismatch",expectedOwner,taskService.getTaskById(taskId).getTaskData().getActualOwner().getId());
  return taskId;
}

相关文章