Java Code Examples for org.activiti.engine.delegate.DelegateTask#addCandidateGroup()

The following examples show how to use org.activiti.engine.delegate.DelegateTask#addCandidateGroup() . 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: ActivitiPooledActorsPropertyHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void updateTaskCandidates(DelegateTask task, UserAndGroupUpdates updates)
{
    // Only new candidates are present in pooledUsers and pooledGroups, create Links for these
    for (String user : updates.getUsers())
    {
        task.addCandidateUser( user);
    }
    for (String group : updates.getGroups())
    {
        task.addCandidateGroup( group);
    }
    
    // Remove all candidates which have been removed
    for (IdentityLink link : updates.linksToRemove)
    {
        if (link.getUserId() != null)
        {
            task.deleteUserIdentityLink(link.getUserId(), link.getType());
        }
        else
        {
            task.deleteGroupIdentityLink(link.getGroupId(), link.getType());
        }
    }
}
 
Example 2
Source File: CandidateGroupAssignment.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void notify(DelegateTask delegateTask) {
  delegateTask.addCandidateGroup("management");
}
 
Example 3
Source File: CandidateGroupAssignment.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void notify(DelegateTask delegateTask) {
  delegateTask.addCandidateGroup("management");
}
 
Example 4
Source File: ConfUserTaskListener.java    From lemon with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(DelegateTask delegateTask) throws Exception {
    List<BpmConfUser> bpmConfUsers = bpmConfUserManager
            .find("from BpmConfUser where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?",
                    delegateTask.getProcessDefinitionId(), delegateTask
                            .getExecution().getCurrentActivityId());
    logger.debug("{}", bpmConfUsers);

    ExpressionManager expressionManager = Context
            .getProcessEngineConfiguration().getExpressionManager();

    try {
        for (BpmConfUser bpmConfUser : bpmConfUsers) {
            logger.debug("status : {}, type: {}", bpmConfUser.getStatus(),
                    bpmConfUser.getType());
            logger.debug("value : {}", bpmConfUser.getValue());

            String value = expressionManager
                    .createExpression(bpmConfUser.getValue())
                    .getValue(delegateTask).toString();

            if (bpmConfUser.getStatus() == 1) {
                if (bpmConfUser.getType() == 0) {
                    delegateTask.setAssignee(value);
                } else if (bpmConfUser.getType() == 1) {
                    delegateTask.addCandidateUser(value);
                } else if (bpmConfUser.getType() == 2) {
                    delegateTask.addCandidateGroup(value);
                }
            } else if (bpmConfUser.getStatus() == 2) {
                if (bpmConfUser.getType() == 0) {
                    if (delegateTask.getAssignee().equals(value)) {
                        delegateTask.setAssignee(null);
                    }
                } else if (bpmConfUser.getType() == 1) {
                    delegateTask.deleteCandidateUser(value);
                } else if (bpmConfUser.getType() == 2) {
                    delegateTask.deleteCandidateGroup(value);
                }
            }
        }
    } catch (Exception ex) {
        logger.debug(ex.getMessage(), ex);
    }
}
 
Example 5
Source File: HumanTaskUserTaskListener.java    From lemon with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(DelegateTask delegateTask) throws Exception {
    String processDefinitionId = delegateTask.getProcessDefinitionId();
    String businessKey = delegateTask.getExecution()
            .getProcessBusinessKey();
    String taskDefinitionKey = delegateTask.getExecution()
            .getCurrentActivityId();
    ProcessTaskDefinition processTaskDefinition = internalProcessConnector
            .findTaskDefinition(processDefinitionId, businessKey,
                    taskDefinitionKey);
    ExpressionManager expressionManager = Context
            .getProcessEngineConfiguration().getExpressionManager();

    for (ParticipantDefinition participantDefinition : processTaskDefinition
            .getParticipantDefinitions()) {
        if ("user".equals(participantDefinition.getType())) {
            if ("add".equals(participantDefinition.getStatus())) {
                delegateTask.addCandidateUser(participantDefinition
                        .getValue());
            } else {
                delegateTask.deleteCandidateUser(participantDefinition
                        .getValue());
            }
        } else {
            if ("add".equals(participantDefinition.getStatus())) {
                delegateTask.addCandidateGroup(participantDefinition
                        .getValue());
            } else {
                delegateTask.deleteCandidateGroup(participantDefinition
                        .getValue());
            }
        }
    }

    String assignee = null;

    if (processTaskDefinition.getAssignee() != null) {
        assignee = expressionManager
                .createExpression(processTaskDefinition.getAssignee())
                .getValue(delegateTask).toString();
    }

    if (assignee == null) {
        delegateTask.setAssignee(null);
    } else if ((assignee.indexOf("&&") != -1)
            || (assignee.indexOf("||") != -1)) {
        logger.debug("assignee : {}", assignee);

        List<String> candidateUsers = new Expr().evaluate(assignee, this);
        logger.debug("candidateUsers : {}", candidateUsers);
        delegateTask.addCandidateUsers(candidateUsers);
    } else {
        delegateTask.setAssignee(assignee);
    }
}