Search in sources :

Example 1 with WorkflowHistoricTaskInstanceDto

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

the class DefaultWorkflowHistoricTaskInstanceService method get.

@Override
public WorkflowHistoricTaskInstanceDto get(String historicTaskInstanceId) {
    WorkflowFilterDto filter = new WorkflowFilterDto();
    filter.setId(UUID.fromString(historicTaskInstanceId));
    filter.setSortAsc(true);
    Collection<WorkflowHistoricTaskInstanceDto> resources = this.search(filter).getResources();
    return !resources.isEmpty() ? resources.iterator().next() : null;
}
Also used : WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowHistoricTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto)

Example 2 with WorkflowHistoricTaskInstanceDto

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

the class HistoryProcessAndTaskTest method checkTaskHistory.

/**
 * Check task history
 * @param taskId
 */
private void checkTaskHistory(String taskId, String assignee) {
    IdmIdentityDto assigneeIdentity = (IdmIdentityDto) lookupService.getDtoLookup(IdmIdentityDto.class).lookup(assignee);
    WorkflowHistoricTaskInstanceDto taskHistory = historicTaskService.get(taskId);
    assertNotNull(taskHistory);
    assertEquals("completed", taskHistory.getDeleteReason());
    assertEquals(assigneeIdentity.getId().toString(), taskHistory.getAssignee());
    assertEquals(taskId, taskHistory.getId());
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) WorkflowHistoricTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto)

Example 3 with WorkflowHistoricTaskInstanceDto

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

the class ChangeIdentityPermissionTest method testGetHistoricTaskByUserInvolvedInProcess.

@Test
public void testGetHistoricTaskByUserInvolvedInProcess() {
    ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    getHelper().waitForResult(null, 1, 1);
    loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
    IdmIdentityDto test1 = identityService.getByUsername(InitTestDataProcessor.TEST_USER_1);
    IdmIdentityDto test2 = identityService.getByUsername(InitTestDataProcessor.TEST_USER_2);
    // Guarantee
    int priority = 500;
    IdmRoleDto adminRole = roleConfiguration.getAdminRole();
    adminRole.setPriority(priority);
    getHelper().createRoleGuarantee(adminRole, test2);
    adminRole = roleService.save(adminRole);
    configurationService.setValue(IdmRoleService.WF_BY_ROLE_PRIORITY_PREFIX + priority, APPROVE_ROLE_BY_SECURITY_KEY);
    getHelper().setConfigurationValue(APPROVE_BY_SECURITY_ENABLE, true);
    IdmIdentityContractDto contract = getHelper().getPrimeContract(test1.getId());
    IdmRoleRequestDto request = createRoleRequest(test1);
    request = roleRequestService.save(request);
    IdmConceptRoleRequestDto concept = createRoleConcept(adminRole, contract, request);
    concept = conceptRoleRequestService.save(concept);
    roleRequestService.startRequestInternal(request.getId(), true);
    request = roleRequestService.get(request.getId());
    assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
    WorkflowFilterDto taskFilter = new WorkflowFilterDto();
    taskFilter.setCreatedAfter(now);
    taskFilter.setCandidateOrAssigned(securityService.getCurrentUsername());
    List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
    assertEquals(0, tasks.size());
    // Help Desk
    request = roleRequestService.get(request.getId());
    loginAsAdmin();
    taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
    // Manager
    request = roleRequestService.get(request.getId());
    loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
    taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_USER_2);
    WorkflowTaskInstanceDto approvedTask = checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
    // Approver of this task has permission to read this task.
    loginWithout(InitTestDataProcessor.TEST_USER_2, IdmGroupPermission.APP_ADMIN, CoreGroupPermission.WORKFLOW_TASK_ADMIN);
    WorkflowTaskInstanceDto task = workflowTaskInstanceService.get(UUID.fromString(approvedTask.getId()));
    assertNotNull(task);
    assertTrue(task instanceof WorkflowHistoricTaskInstanceDto);
    // Login as applicant.
    loginWithout(test1.getUsername(), IdmGroupPermission.APP_ADMIN, CoreGroupPermission.WORKFLOW_TASK_ADMIN);
    // Applicant can read a process -> but cannot read all tasks of a process.
    task = workflowTaskInstanceService.get(UUID.fromString(approvedTask.getId()));
    assertNull(task);
    assertTrue(workflowProcessInstanceService.canReadProcessOrHistoricProcess(approvedTask.getProcessInstanceId()));
    // Login as random user.
    IdmIdentityDto randomUser = getHelper().createIdentity();
    loginWithout(randomUser.getUsername(), IdmGroupPermission.APP_ADMIN, CoreGroupPermission.WORKFLOW_TASK_ADMIN);
    // Random user doesn't have read permission on the task and process.
    task = workflowTaskInstanceService.get(UUID.fromString(approvedTask.getId()));
    assertNull(task);
    assertFalse(workflowProcessInstanceService.canReadProcessOrHistoricProcess(approvedTask.getProcessInstanceId()));
    // Random user can read the task if filter has set OnlyInvolved to FALSE.
    WorkflowFilterDto taskFilterApproved = new WorkflowFilterDto();
    taskFilterApproved.setOnlyInvolved(Boolean.FALSE);
    task = workflowTaskInstanceService.get(UUID.fromString(approvedTask.getId()), taskFilterApproved);
    assertNotNull(task);
    assertTrue(task instanceof WorkflowHistoricTaskInstanceDto);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) ZonedDateTime(java.time.ZonedDateTime) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) WorkflowHistoricTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 4 with WorkflowHistoricTaskInstanceDto

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

the class ChangeIdentityPermissionTest method testSwitchUserAuditVariables.

@Test
public void testSwitchUserAuditVariables() {
    IdmIdentityDto adminOriginal = getHelper().createIdentity();
    IdmIdentityDto adminSwitched = getHelper().createIdentity();
    IdmIdentityDto adminHelpdesk = getHelper().createIdentity();
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    IdmRoleDto adminRole = roleConfiguration.getAdminRole();
    getHelper().createIdentityRole(adminOriginal, adminRole);
    getHelper().createIdentityRole(adminSwitched, adminRole);
    IdmRoleDto helpdeskRole = getHelper().createRole();
    configurationService.setValue(APPROVE_BY_HELPDESK_ROLE, helpdeskRole.getCode());
    getHelper().setConfigurationValue(APPROVE_BY_SECURITY_ENABLE, false);
    getHelper().setConfigurationValue(APPROVE_BY_MANAGER_ENABLE, false);
    getHelper().setConfigurationValue(APPROVE_BY_HELPDESK_ENABLE, true);
    getHelper().setConfigurationValue(APPROVE_BY_USERMANAGER_ENABLE, false);
    getHelper().createIdentityRole(adminHelpdesk, helpdeskRole);
    IdmRoleRequestDto request = createRoleRequest(identity);
    IdmConceptRoleRequestDto concept = null;
    // 
    try {
        getHelper().login(adminOriginal);
        loginService.switchUser(adminSwitched);
        // 
        IdmIdentityContractDto contract = getHelper().getPrimeContract(identity);
        request = roleRequestService.save(request);
        concept = createRoleConcept(adminRole, contract, request);
        concept = conceptRoleRequestService.save(concept);
        roleRequestService.startRequestInternal(request.getId(), true);
        request = roleRequestService.get(request.getId());
        assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
        // 
        // check original identity is filled in process variables
        WorkflowProcessInstanceDto workflowProcessInstanceDto = workflowProcessInstanceService.get(request.getWfProcessId());
        Assert.assertEquals(adminSwitched.getId().toString(), workflowProcessInstanceDto.getProcessVariables().get(WorkflowProcessInstanceService.IMPLEMENTER_IDENTIFIER));
        Assert.assertEquals(adminOriginal.getId().toString(), workflowProcessInstanceDto.getProcessVariables().get(WorkflowProcessInstanceService.ORIGINAL_IMPLEMENTER_IDENTIFIER));
    } finally {
        logout();
    }
    // 
    try {
        getHelper().login(adminOriginal);
        loginService.switchUser(adminHelpdesk);
        // 
        // change concept - modify dates
        concept.setValidTill(LocalDate.now().minusDays(10));
        concept = conceptRoleRequestService.save(concept);
        Assert.assertEquals(adminHelpdesk.getId(), concept.getModifierId());
        Assert.assertEquals(adminOriginal.getId(), concept.getOriginalModifierId());
        // 
        // complete the first task (~helpdesk)
        WorkflowFilterDto taskFilter = new WorkflowFilterDto();
        taskFilter.setCandidateOrAssigned(securityService.getCurrentUsername());
        List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
        Assert.assertEquals(1, tasks.size());
        Assert.assertEquals(identity.getId().toString(), tasks.get(0).getApplicant());
        workflowTaskInstanceService.completeTask(tasks.get(0).getId(), "approve");
        // 
        // check original identity is filled in task variables
        WorkflowHistoricTaskInstanceDto workflowHistoricTaskInstanceDto = workflowHistoricTaskInstanceService.get(tasks.get(0).getId());
        Assert.assertEquals(adminHelpdesk.getId().toString(), workflowHistoricTaskInstanceDto.getAssignee());
        Assert.assertEquals(adminOriginal.getId(), workflowHistoricTaskInstanceDto.getVariables().get(WorkflowProcessInstanceService.ORIGINAL_IMPLEMENTER_IDENTIFIER));
    } finally {
        logout();
    }
    // 
    // request has to be approved
    request = roleRequestService.get(request.getId());
    assertEquals(RoleRequestState.EXECUTED, request.getState());
    // 
    // check created identity role audit fields
    List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
    // 
    Assert.assertEquals(1, assignedRoles.size());
    IdmIdentityRoleDto assignedRole = assignedRoles.get(0);
    Assert.assertEquals(adminHelpdesk.getId(), assignedRole.getCreatorId());
    Assert.assertEquals(adminOriginal.getId(), assignedRole.getOriginalCreatorId());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) WorkflowHistoricTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 5 with WorkflowHistoricTaskInstanceDto

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

the class WorkflowHistoricTaskInstanceController method getDto.

@Override
public WorkflowHistoricTaskInstanceDto getDto(Serializable backendId) {
    WorkflowHistoricTaskInstanceDto dto = super.getDto(backendId);
    // Add delegation to a task.
    addDelegationToTask(dto, IdmBasePermission.READ);
    return dto;
}
Also used : WorkflowHistoricTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto)

Aggregations

WorkflowHistoricTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto)16 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)10 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)7 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)7 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)4 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)4 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)4 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)4 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)2 IdentityLinkDto (eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto)2 WorkflowProcessDefinitionDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto)2 List (java.util.List)2 PageImpl (org.springframework.data.domain.PageImpl)2 PageRequest (org.springframework.data.domain.PageRequest)2 Pageable (org.springframework.data.domain.Pageable)2 Sort (org.springframework.data.domain.Sort)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1