Java Code Examples for org.activiti.engine.impl.persistence.entity.TaskEntity#getAssignee()

The following examples show how to use org.activiti.engine.impl.persistence.entity.TaskEntity#getAssignee() . 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: ClaimTaskCmd.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected Void execute(CommandContext commandContext, TaskEntity task) {

    if (userId != null) {
        if (task.getAssignee() != null) {
            if (!task.getAssignee().equals(userId)) {
                // When the task is already claimed by another user, throw exception. Otherwise, ignore
                // this, post-conditions of method already met.
                throw new ActivitiTaskAlreadyClaimedException(task.getId(), task.getAssignee());
            }
        } else {
            task.setAssignee(userId, true, true);
        }
    } else {
        // Task should be assigned to no one
        task.setAssignee(null, true, true);
    }

    // Add claim time
    commandContext.getHistoryManager().recordTaskClaim(taskId);

    return null;
}
 
Example 2
Source File: TaskAutoRedirectGlobalEventListener.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
@Override
public void onEvent(ActivitiEvent event) {
    ActivitiEntityEvent entityEvent = (ActivitiEntityEvent) event;
    Object entity = entityEvent.getEntity();
    if (entity instanceof TaskEntity) {
        TaskEntity task = (TaskEntity) entity;
        String originUserId = task.getAssignee();
        String newUserId = userMap.get(originUserId);
        if (StringUtils.isNotBlank(newUserId)) {
            task.setAssignee(newUserId);
            TaskService taskService = event.getEngineServices().getTaskService();
            String message = getClass().getName() + "-> 任务[" + task.getName() + "]的办理人[" +
                    originUserId + "]自动转办给了用户[" + newUserId + "]";
            taskService.addComment(task.getId(), task.getProcessInstanceId(), "redirect", message);
        }
    }
}
 
Example 3
Source File: ClaimTaskCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected Void execute(CommandContext commandContext, TaskEntity task) {
  if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) {
    Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); 
    activiti5CompatibilityHandler.claimTask(taskId, userId);
    return null;
  }
  
  if (userId != null) {
    task.setClaimTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime());

    if (task.getAssignee() != null) {
      if (!task.getAssignee().equals(userId)) {
        // When the task is already claimed by another user, throw
        // exception. Otherwise, ignore
        // this, post-conditions of method already met.
        throw new ActivitiTaskAlreadyClaimedException(task.getId(), task.getAssignee());
      }
    } else {
      commandContext.getTaskEntityManager().changeTaskAssignee(task, userId);
    }
  } else {
    // Task claim time should be null
    task.setClaimTime(null);

    // Task should be assigned to no one
    commandContext.getTaskEntityManager().changeTaskAssignee(task, null);
  }

  // Add claim time to historic task instance
  commandContext.getHistoryManager().recordTaskClaim(task);

  return null;
}
 
Example 4
Source File: TaskDelagationAssignmentHandler.java    From openwebflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void overwriteAssignee(TaskEntity task)
{
	String assignee = task.getAssignee();

	//受理人是否被代理
	if (assignee != null)
	{
		String[] delegates = _delegationManager.getDelegates(assignee);
		if (delegates != null && delegates.length > 0)
		{
			task.setAssignee(delegates[0]);
		}
	}
}