org.kie.api.task.model.Task.getPriority()方法的使用及代码示例

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

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

Task.getPriority介绍

暂无

代码示例

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

public int getPriority(long taskId) {
  Task task = persistenceContext.findTask(taskId);
  return task.getPriority();
}

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

private void testPriorityUpdate(int oldPriority,
                int newPriority,
                boolean changeExpected) {
  Task task = new TaskFluent()
      .setPriority(oldPriority)
      .setAdminUser("Administrator")
      .getTask();
  taskService.addTask(task, new HashMap<String, Object>());
  long taskId = task.getId();
  taskService.setPriority(taskId, newPriority);
  task = taskService.getTaskById(taskId);
  Assertions.assertThat(task.getPriority()).isEqualTo(newPriority);
  List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
  Assertions.assertThat(auditTasks).hasSize(1);
  Assertions.assertThat(auditTasks.get(0).getPriority()).isEqualTo(newPriority);
  List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
  if (changeExpected) {
    Assertions.assertThat(taskEvents).hasSize(2);
    Assertions.assertThat(taskEvents.get(1).getMessage()).isEqualTo("Updated Priority {From: '0' to: '10'}");
  } else {
    Assertions.assertThat(taskEvents).hasSize(1);
  }
}

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

@Override
public void afterTaskForwardedEvent(TaskEvent event) {
  String userId = event.getTaskContext().getUserId();
  Task ti = event.getTask();
  StringBuilder message = new StringBuilder();
  String entitiesAsString = (ti.getPeopleAssignments().getPotentialOwners()).stream().map(oe -> oe.getId()).collect(Collectors.joining(","));
  message.append("Forward to [" + entitiesAsString + "]");
  TaskEventImpl taskEvent = new TaskEventImpl(ti.getId(), org.kie.internal.task.api.model.TaskEvent.TaskEventType.FORWARDED, ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getWorkItemId(), userId, message.toString());
  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

@Override
public void afterTaskNominatedEvent(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.NOMINATED, userId, new Date());
  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

@Override
public void afterTaskNominatedEvent(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.NOMINATED, userId, new Date()));

    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.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());
    persistenceContext.merge(auditTaskImpl);
  } finally {
    cleanup(persistenceContext);
  }
}

代码示例来源: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: 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

@Override
public void afterTaskReleasedEvent(TaskEvent event) {
  Task ti = event.getTask();
  TaskPersistenceContext persistenceContext = getPersistenceContext(((TaskContext)event.getTaskContext()).getPersistenceContext());
  try {
         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.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());
    persistenceContext.merge(auditTaskImpl);
  } finally {
    cleanup(persistenceContext);
  }
}

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

@Override
public void afterTaskReleasedEvent(TaskEvent event) {        
  Task ti = event.getTask();
  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), 8);
}

代码示例来源: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

@Test
public void testTaskExitByCustomBusinessAdmin() 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.setParameter("BusinessAdministratorId", "Luke Cage");
  workItem.setProcessInstanceId(10);
  getHandler().executeWorkItem(workItem, manager);
  
  Task task = taskService.getTaskByWorkItemId(workItem.getId());
  assertNotNull(task);
  
  getHandler().abortWorkItem(workItem, manager);
  
  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());
}

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

@Override
public void afterTaskResumedEvent(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.RESUMED, 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.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());
    persistenceContext.merge(auditTaskImpl);
  } finally {
    cleanup(persistenceContext);
  }
}

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

@Override
public void afterTaskDelegatedEvent(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.DELEGATED, 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.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());
    persistenceContext.merge(auditTaskImpl);
  } finally {
    cleanup(persistenceContext);
  }
}

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

@Override
public void afterTaskReassignedEvent(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.DELEGATED, 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.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());
    persistenceContext.merge(auditTaskImpl);
  } finally {
    cleanup(persistenceContext);
  }
}

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

@Override
public void afterTaskResumedEvent(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.RESUMED, 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), 6);
}

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

@Override
public void afterTaskExitedEvent(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.EXITED, 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), 2);
}

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

@Override
public void afterTaskSuspendedEvent(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.SUSPENDED, 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), 6);
}

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

@Override
public void afterTaskReassignedEvent(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

@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

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;
}

相关文章