Search in sources :

Example 1 with IdentityLinkDto

use of eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto in project CzechIdMng by bcvsolutions.

the class DefaultWorkflowTaskInstanceService method getPermissions.

@Override
public Set<String> getPermissions(WorkflowTaskInstanceDto dto) {
    Assert.notNull(dto);
    // 
    final Set<String> permissions = new HashSet<>();
    String loggedUserId = securityService.getCurrentId().toString();
    // 
    for (IdentityLinkDto identity : dto.getIdentityLinks()) {
        if ((identity.getType().equals(IdentityLinkType.ASSIGNEE) || identity.getType().equals(IdentityLinkType.CANDIDATE)) && identity.getUserId().equals(loggedUserId)) {
            permissions.add(IdmBasePermission.EXECUTE.getName());
        }
    }
    return permissions;
}
Also used : IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto) HashSet(java.util.HashSet)

Example 2 with IdentityLinkDto

use of eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto in project CzechIdMng by bcvsolutions.

the class DefaultWorkflowTaskInstanceService method toResource.

private IdentityLinkDto toResource(IdentityLink link) {
    if (link == null) {
        return null;
    }
    IdentityLinkDto dto = new IdentityLinkDto();
    dto.setGroupId(link.getGroupId());
    dto.setType(link.getType());
    dto.setUserId(link.getUserId());
    return dto;
}
Also used : IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto)

Example 3 with IdentityLinkDto

use of eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto in project CzechIdMng by bcvsolutions.

the class DefaultWorkflowTaskInstanceService method toResource.

private WorkflowTaskInstanceDto toResource(Task task) {
    if (task == null) {
        return null;
    }
    WorkflowTaskInstanceDto dto = new WorkflowTaskInstanceDto();
    dto.setId(task.getId());
    dto.setCreated(task.getCreateTime());
    dto.setFormKey(task.getFormKey());
    dto.setAssignee(task.getAssignee());
    dto.setName(task.getName());
    dto.setDescription(task.getDescription());
    dto.setProcessInstanceId(task.getProcessInstanceId());
    Map<String, Object> taksVariables = task.getTaskLocalVariables();
    Map<String, Object> processVariables = task.getProcessVariables();
    // Add applicant username to task dto (for easier work)
    if (processVariables != null && processVariables.containsKey(WorkflowProcessInstanceService.APPLICANT_IDENTIFIER)) {
        dto.setApplicant((String) processVariables.get(WorkflowProcessInstanceService.APPLICANT_IDENTIFIER).toString());
    }
    dto.setVariables(processVariables);
    convertToDtoVariables(dto, taksVariables);
    dto.setDefinition(workflowTaskDefinitionService.searchTaskDefinitionById(task.getProcessDefinitionId(), task.getTaskDefinitionKey()));
    if (!Strings.isNullOrEmpty(task.getProcessDefinitionId())) {
        WorkflowProcessDefinitionDto processDefinition = workflowProcessDefinitionService.get(task.getProcessDefinitionId());
        if (processDefinition != null) {
            dto.setProcessDefinitionKey(processDefinition.getKey());
        }
    }
    TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    // Add form data (it means form properties and value from WF)
    List<FormProperty> formProperties = taskFormData.getFormProperties();
    // Search and add identity links to dto (It means all user
    // (assigned/candidates/group) for this task)
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
    if (identityLinks != null) {
        List<IdentityLinkDto> identityLinksDtos = new ArrayList<>();
        for (IdentityLink il : identityLinks) {
            identityLinksDtos.add(toResource(il));
        }
        dto.getIdentityLinks().addAll(identityLinksDtos);
    }
    // Check if the logged user can complete this task
    boolean canExecute = this.canExecute(dto);
    if (formProperties != null && !formProperties.isEmpty()) {
        for (FormProperty property : formProperties) {
            resovleFormProperty(property, dto, canExecute);
        }
    }
    return dto;
}
Also used : FormProperty(org.activiti.engine.form.FormProperty) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) ArrayList(java.util.ArrayList) TaskFormData(org.activiti.engine.form.TaskFormData) IdentityLink(org.activiti.engine.task.IdentityLink) IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto) WorkflowProcessDefinitionDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto)

Aggregations

IdentityLinkDto (eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto)3 WorkflowProcessDefinitionDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto)1 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 FormProperty (org.activiti.engine.form.FormProperty)1 TaskFormData (org.activiti.engine.form.TaskFormData)1 IdentityLink (org.activiti.engine.task.IdentityLink)1