Search in sources :

Example 1 with IdentityLinkEntity

use of org.camunda.bpm.engine.impl.persistence.entity.IdentityLinkEntity in project camunda-bpm-platform by camunda.

the class BpmnDeployer method addAuthorizationsFromIterator.

protected void addAuthorizationsFromIterator(Set<Expression> exprSet, ProcessDefinitionEntity processDefinition, ExprType exprType) {
    if (exprSet != null) {
        for (Expression expr : exprSet) {
            IdentityLinkEntity identityLink = new IdentityLinkEntity();
            identityLink.setProcessDef(processDefinition);
            if (exprType.equals(ExprType.USER)) {
                identityLink.setUserId(expr.toString());
            } else if (exprType.equals(ExprType.GROUP)) {
                identityLink.setGroupId(expr.toString());
            }
            identityLink.setType(IdentityLinkType.CANDIDATE);
            identityLink.setTenantId(processDefinition.getTenantId());
            identityLink.insert();
        }
    }
}
Also used : IdentityLinkEntity(org.camunda.bpm.engine.impl.persistence.entity.IdentityLinkEntity) Expression(org.camunda.bpm.engine.delegate.Expression)

Example 2 with IdentityLinkEntity

use of org.camunda.bpm.engine.impl.persistence.entity.IdentityLinkEntity in project camunda-bpm-platform by camunda.

the class GetIdentityLinksForTaskCmd method execute.

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
    ensureNotNull("taskId", taskId);
    TaskManager taskManager = commandContext.getTaskManager();
    TaskEntity task = taskManager.findTaskById(taskId);
    ensureNotNull("Cannot find task with id " + taskId, "task", task);
    checkGetIdentityLink(task, commandContext);
    List<IdentityLink> identityLinks = (List) task.getIdentityLinks();
    // and of course this leads to exception while trying to delete a non-existing identityLink
    if (task.getAssignee() != null) {
        IdentityLinkEntity identityLink = new IdentityLinkEntity();
        identityLink.setUserId(task.getAssignee());
        identityLink.setTask(task);
        identityLink.setType(IdentityLinkType.ASSIGNEE);
        identityLinks.add(identityLink);
    }
    if (task.getOwner() != null) {
        IdentityLinkEntity identityLink = new IdentityLinkEntity();
        identityLink.setUserId(task.getOwner());
        identityLink.setTask(task);
        identityLink.setType(IdentityLinkType.OWNER);
        identityLinks.add(identityLink);
    }
    return (List) task.getIdentityLinks();
}
Also used : IdentityLinkEntity(org.camunda.bpm.engine.impl.persistence.entity.IdentityLinkEntity) TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) List(java.util.List) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Aggregations

IdentityLinkEntity (org.camunda.bpm.engine.impl.persistence.entity.IdentityLinkEntity)2 List (java.util.List)1 Expression (org.camunda.bpm.engine.delegate.Expression)1 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)1 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)1 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)1