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

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

    if (IdentityLinkType.ASSIGNEE.equals(type)) {
        task.setAssignee(null, true, true);
    } else if (IdentityLinkType.OWNER.equals(type)) {
        task.setOwner(null, true);
    } else {
        task.deleteIdentityLink(userId, groupId, type);
    }

    commandContext.getHistoryManager()
            .createIdentityLinkComment(taskId, userId, groupId, type, false);

    return null;
}
 
Example 3
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 4
Source File: TestActivitiEntityEventTaskListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected Task copy(Task aTask) {
  TaskEntity ent = Context.getCommandContext().getTaskEntityManager().create();
	ent.setId(aTask.getId());
	ent.setName(aTask.getName());
	ent.setDescription(aTask.getDescription());
	ent.setOwner(aTask.getOwner());
	ent.setDueDate(aTask.getDueDate());
	ent.setAssignee(aTask.getAssignee());
	ent.setPriority(aTask.getPriority());
	return ent;
}
 
Example 5
Source File: TestFlowableEntityEventTaskListener.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
private Task copy(Task aTask) {
    TaskEntity ent = TaskEntity.create(aTask.getCreateTime());
    ent.setId(aTask.getId());
    ent.setName(aTask.getName());
    ent.setDescription(aTask.getDescription());
    ent.setOwner(aTask.getOwner());
    ent.setDueDateWithoutCascade(aTask.getDueDate());
    ent.setAssignee(aTask.getAssignee());
    ent.setPriority(aTask.getPriority());
    return ent;
}
 
Example 6
Source File: AddIdentityLinkCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected Void execute(CommandContext commandContext, TaskEntity task) {

    boolean assignedToNoOne = false;
    if (IdentityLinkType.ASSIGNEE.equals(identityType)) {
        task.setAssignee(identityId, true, true);
        assignedToNoOne = identityId == null;
    } else if (IdentityLinkType.OWNER.equals(identityType)) {
        task.setOwner(identityId, true);
    } else if (IDENTITY_USER == identityIdType) {
        task.addUserIdentityLink(identityId, identityType);
    } else if (IDENTITY_GROUP == identityIdType) {
        task.addGroupIdentityLink(identityId, identityType);
    }

    boolean forceNullUserId = false;
    if (assignedToNoOne) {
        // ACT-1317: Special handling when assignee is set to NULL, a
        // CommentEntity notifying of assignee-delete should be created
        forceNullUserId = true;

    }

    if (IDENTITY_USER == identityIdType) {
        commandContext.getHistoryManager().createUserIdentityLinkComment(taskId, identityId, identityType, true, forceNullUserId);
    } else {
        commandContext.getHistoryManager().createGroupIdentityLinkComment(taskId, identityId, identityType, true);
    }

    return null;
}
 
Example 7
Source File: ActivityPermissionAssignmentHandler.java    From openwebflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void handleAssignment(TaskAssignmentHandlerChain chain, Expression assigneeExpression,
		Expression ownerExpression, Set<Expression> candidateUserExpressions,
		Set<Expression> candidateGroupExpressions, TaskEntity task, ActivityExecution execution)
{
	//设置assignment信息
	String processDefinitionId = task.getProcessDefinitionId();
	String taskDefinitionKey = task.getTaskDefinitionKey();

	ActivityPermissionEntity entity;
	try
	{
		entity = _activityPermissionManager.load(processDefinitionId, taskDefinitionKey, true);
	}
	catch (Exception e)
	{
		throw new OwfException(e);
	}

	//没有自定义授权规则
	if (entity == null)
	{
		chain.resume(assigneeExpression, ownerExpression, candidateUserExpressions,
			      candidateGroupExpressions, task, execution);
		return;
	}

	//彻底忽略原有规则
	task.setAssignee(entity.getAssignee());
	task.addCandidateGroups(asList(entity.getGrantedGroupIds()));
	task.addCandidateUsers(asList(entity.getGrantedUserIds()));
}
 
Example 8
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]);
		}
	}
}