Search in sources :

Example 1 with WorkflowTaskInstanceAbstractDto

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

the class ManualWorkflowTaskDelegationBulkAction method getDtoById.

@Override
protected WorkflowTaskInstanceAbstractDto getDtoById(UUID id) {
    WorkflowTaskInstanceDto task = workflowTaskInstanceService.get(id.toString());
    if (task != null) {
        WorkflowTaskInstanceAbstractDto mockTask = new WorkflowTaskInstanceAbstractDto();
        mockTask.setId(task.getId());
        mockTask.setIdentityLinks(task.getIdentityLinks());
        mockTask.setApplicant(task.getApplicant());
        return mockTask;
    }
    return null;
}
Also used : WorkflowTaskInstanceAbstractDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceAbstractDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)

Example 2 with WorkflowTaskInstanceAbstractDto

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

the class ManualWorkflowTaskDelegationBulkAction method processDto.

@Override
protected OperationResult processDto(WorkflowTaskInstanceAbstractDto task) {
    IdmBulkActionDto action = this.getAction();
    Assert.notNull(action, "Bulk action is required.");
    IdmIdentityDto delegator = findDelegator();
    if (delegator == null) {
        throw new ResultCodeException(CoreResultCode.MANUAL_TASK_DELEGATION_DELEGATOR_MISSING);
    }
    UUID delegateId = this.getDelegateId();
    UUID delegatorId = delegator.getId();
    Assert.notNull(delegateId, "Delegate ID cannot be null!");
    IdmIdentityDto delegate = identityService.get(delegateId);
    Assert.notNull(delegate, "Delegate cannot be null!");
    boolean delegatorIsCandidate = task.getIdentityLinks().stream().filter(identityLink -> IdentityLinkType.CANDIDATE.equals(identityLink.getType()) || IdentityLinkType.ASSIGNEE.equals(identityLink.getType())).filter(identityLink -> UUID.fromString(identityLink.getUserId()).equals(delegatorId)).findFirst().isPresent();
    // Delegator have to be candidate or assigned task user!
    if (!delegatorIsCandidate) {
        throw new ResultCodeException(CoreResultCode.MANUAL_TASK_DELEGATION_DELEGATOR_IS_NOT_CANDIDATE, ImmutableMap.of("delegator", delegator.getUsername(), "task", task.getId()));
    }
    // Find delegation definitions for delegator and delegate.
    IdmDelegationDefinitionDto delegationDefinition = findDelegationDefinition(delegateId, delegatorId);
    WorkflowTaskInstanceDto mockTask = new WorkflowTaskInstanceDto();
    mockTask.setId(task.getId().toString());
    // Create delegation for this task.
    delegationManager.delegate(mockTask, delegationDefinition);
    // Add delegate as task candidat.
    taskService.addCandidateUser(mockTask.getId(), delegationDefinition.getDelegate().toString());
    // Delete delegator form the task's candidats.
    taskService.deleteCandidateUser(mockTask.getId(), delegationDefinition.getDelegator().toString());
    // Add delegator as participant to this task.
    taskService.addUserIdentityLink(mockTask.getId(), delegationDefinition.getDelegator().toString(), IdentityLinkType.PARTICIPANT);
    return new OperationResult.Builder(OperationState.EXECUTED).build();
}
Also used : ResultModels(eu.bcvsolutions.idm.core.api.dto.ResultModels) DelegationManager(eu.bcvsolutions.idm.core.api.service.DelegationManager) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmDelegationDefinitionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmDelegationDefinitionFilter) TaskService(org.activiti.engine.TaskService) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdentityLinkType(org.activiti.engine.task.IdentityLinkType) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) Lists(com.google.common.collect.Lists) BaseEntity(eu.bcvsolutions.idm.core.api.entity.BaseEntity) CollectionUtils(org.apache.commons.collections.CollectionUtils) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) WorkflowTaskInstanceService(eu.bcvsolutions.idm.core.workflow.service.WorkflowTaskInstanceService) BaseFaceType(eu.bcvsolutions.idm.core.eav.api.domain.BaseFaceType) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) Description(org.springframework.context.annotation.Description) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractBulkAction(eu.bcvsolutions.idm.core.api.bulk.action.AbstractBulkAction) WorkflowTaskInstanceAbstractDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceAbstractDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) ReadWriteDtoService(eu.bcvsolutions.idm.core.api.service.ReadWriteDtoService) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) UUID(java.util.UUID) List(java.util.List) Component(org.springframework.stereotype.Component) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) ManualTaskDelegationType(eu.bcvsolutions.idm.core.model.delegation.type.ManualTaskDelegationType) Lazy(org.springframework.context.annotation.Lazy) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmDelegationDefinitionService(eu.bcvsolutions.idm.core.api.service.IdmDelegationDefinitionService) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) IdmDelegationDefinitionDto(eu.bcvsolutions.idm.core.api.dto.IdmDelegationDefinitionDto) Assert(org.springframework.util.Assert) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmDelegationDefinitionDto(eu.bcvsolutions.idm.core.api.dto.IdmDelegationDefinitionDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID)

Aggregations

WorkflowTaskInstanceAbstractDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceAbstractDto)2 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 AbstractBulkAction (eu.bcvsolutions.idm.core.api.bulk.action.AbstractBulkAction)1 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)1 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)1 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)1 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)1 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)1 IdmDelegationDefinitionDto (eu.bcvsolutions.idm.core.api.dto.IdmDelegationDefinitionDto)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 ResultModels (eu.bcvsolutions.idm.core.api.dto.ResultModels)1 IdmDelegationDefinitionFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmDelegationDefinitionFilter)1 BaseEntity (eu.bcvsolutions.idm.core.api.entity.BaseEntity)1 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 DelegationManager (eu.bcvsolutions.idm.core.api.service.DelegationManager)1 IdmDelegationDefinitionService (eu.bcvsolutions.idm.core.api.service.IdmDelegationDefinitionService)1 IdmIdentityService (eu.bcvsolutions.idm.core.api.service.IdmIdentityService)1