Search in sources :

Example 1 with IdentityLinkEntity

use of org.activiti.engine.impl.persistence.entity.IdentityLinkEntity in project Activiti by Activiti.

the class GetIdentityLinksForTaskCmd method execute.

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
    TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);
    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.setType(IdentityLinkType.ASSIGNEE);
        identityLink.setTaskId(task.getId());
        identityLinks.add(identityLink);
    }
    if (task.getOwner() != null) {
        IdentityLinkEntity identityLink = new IdentityLinkEntity();
        identityLink.setUserId(task.getOwner());
        identityLink.setTaskId(task.getId());
        identityLink.setType(IdentityLinkType.OWNER);
        identityLinks.add(identityLink);
    }
    return (List) task.getIdentityLinks();
}
Also used : IdentityLinkEntity(org.activiti.engine.impl.persistence.entity.IdentityLinkEntity) TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) List(java.util.List) IdentityLink(org.activiti.engine.task.IdentityLink)

Example 2 with IdentityLinkEntity

use of org.activiti.engine.impl.persistence.entity.IdentityLinkEntity in project Activiti by Activiti.

the class BpmnDeployer method addAuthorizationsFromIterator.

private void addAuthorizationsFromIterator(Set<Expression> exprSet, ProcessDefinitionEntity processDefinition, ExprType exprType) {
    if (exprSet != null) {
        Iterator<Expression> iterator = exprSet.iterator();
        while (iterator.hasNext()) {
            Expression expr = (Expression) iterator.next();
            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.insert();
        }
    }
}
Also used : IdentityLinkEntity(org.activiti.engine.impl.persistence.entity.IdentityLinkEntity) Expression(org.activiti.engine.delegate.Expression)

Example 3 with IdentityLinkEntity

use of org.activiti.engine.impl.persistence.entity.IdentityLinkEntity in project Activiti by Activiti.

the class ActivitiEventBuilder method populateEventWithCurrentContext.

protected static void populateEventWithCurrentContext(ActivitiEventImpl event) {
    boolean extractedFromContext = false;
    if (Context.isExecutionContextActive()) {
        ExecutionContext executionContext = Context.getExecutionContext();
        if (executionContext != null) {
            extractedFromContext = true;
            event.setExecutionId(executionContext.getExecution().getId());
            event.setProcessInstanceId(executionContext.getExecution().getProcessInstanceId());
            event.setProcessDefinitionId(executionContext.getExecution().getProcessDefinitionId());
        }
    }
    // Fallback to fetching context from the object itself
    if (!extractedFromContext) {
        if (event instanceof ActivitiEntityEvent) {
            Object persistendObject = ((ActivitiEntityEvent) event).getEntity();
            if (persistendObject instanceof Job) {
                event.setExecutionId(((Job) persistendObject).getExecutionId());
                event.setProcessInstanceId(((Job) persistendObject).getProcessInstanceId());
                event.setProcessDefinitionId(((Job) persistendObject).getProcessDefinitionId());
            } else if (persistendObject instanceof DelegateExecution) {
                event.setExecutionId(((DelegateExecution) persistendObject).getId());
                event.setProcessInstanceId(((DelegateExecution) persistendObject).getProcessInstanceId());
                event.setProcessDefinitionId(((DelegateExecution) persistendObject).getProcessDefinitionId());
            } else if (persistendObject instanceof IdentityLinkEntity) {
                IdentityLinkEntity idLink = (IdentityLinkEntity) persistendObject;
                if (idLink.getProcessDefinitionId() != null) {
                    event.setProcessDefinitionId(idLink.getProcessDefId());
                } else if (idLink.getProcessInstance() != null) {
                    event.setProcessDefinitionId(idLink.getProcessInstance().getProcessDefinitionId());
                    event.setProcessInstanceId(idLink.getProcessInstanceId());
                    event.setExecutionId(idLink.getProcessInstanceId());
                } else if (idLink.getTask() != null) {
                    event.setProcessDefinitionId(idLink.getTask().getProcessDefinitionId());
                    event.setProcessInstanceId(idLink.getTask().getProcessInstanceId());
                    event.setExecutionId(idLink.getTask().getExecutionId());
                }
            } else if (persistendObject instanceof Task) {
                event.setProcessInstanceId(((Task) persistendObject).getProcessInstanceId());
                event.setExecutionId(((Task) persistendObject).getExecutionId());
                event.setProcessDefinitionId(((Task) persistendObject).getProcessDefinitionId());
            } else if (persistendObject instanceof ProcessDefinition) {
                event.setProcessDefinitionId(((ProcessDefinition) persistendObject).getId());
            }
        }
    }
}
Also used : IdentityLinkEntity(org.activiti.engine.impl.persistence.entity.IdentityLinkEntity) Task(org.activiti.engine.task.Task) ExecutionContext(org.activiti.engine.impl.context.ExecutionContext) ActivitiEntityEvent(org.activiti.engine.delegate.event.ActivitiEntityEvent) DelegateExecution(org.activiti.engine.delegate.DelegateExecution) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Job(org.activiti.engine.runtime.Job)

Aggregations

IdentityLinkEntity (org.activiti.engine.impl.persistence.entity.IdentityLinkEntity)3 List (java.util.List)1 DelegateExecution (org.activiti.engine.delegate.DelegateExecution)1 Expression (org.activiti.engine.delegate.Expression)1 ActivitiEntityEvent (org.activiti.engine.delegate.event.ActivitiEntityEvent)1 ExecutionContext (org.activiti.engine.impl.context.ExecutionContext)1 TaskEntity (org.activiti.engine.impl.persistence.entity.TaskEntity)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 Job (org.activiti.engine.runtime.Job)1 IdentityLink (org.activiti.engine.task.IdentityLink)1 Task (org.activiti.engine.task.Task)1