Search in sources :

Example 21 with WorkflowTaskInstanceDto

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

the class ChangeIdentityPermissionTest method addSuperAdminRoleWithSubprocessRemoveTest.

@Test
@Transactional
public void addSuperAdminRoleWithSubprocessRemoveTest() {
    IdmIdentityDto test1 = helper.createIdentity("TestUser" + System.currentTimeMillis());
    IdmIdentityDto test2 = identityService.getByUsername(InitTestData.TEST_USER_2);
    loginAsAdmin(InitTestData.TEST_USER_2);
    IdmIdentityContractDto contract = identityContractService.getPrimeContract(test1.getId());
    IdmRoleDto adminRole = helper.createRole("testRole" + System.currentTimeMillis());
    adminRole.setApproveRemove(true);
    roleService.save(adminRole);
    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.setCandidateOrAssigned(securityService.getCurrentUsername());
    List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
    assertEquals(0, tasks.size());
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    // HELPDESK
    taskFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
    // MANAGER
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    taskFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
    // USER MANAGER
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    taskFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
    // SECURITY
    taskFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
    request = roleRequestService.get(request.getId());
    assertEquals(RoleRequestState.EXECUTED, request.getState());
    assertNotNull(request.getWfProcessId());
    concept = conceptRoleRequestService.get(concept.getId());
    assertNotNull(concept.getWfProcessId());
    IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
    filter.setIdentityId(test1.getId());
    Page<IdmIdentityRoleDto> page = identityRoleService.find(filter, null);
    assertEquals(1, page.getContent().size());
    loginAsAdmin(InitTestData.TEST_USER_2);
    // Guarantee
    int priority = 500;
    adminRole.setPriority(priority);
    IdmRoleGuaranteeDto guarantee = new IdmRoleGuaranteeDto();
    guarantee.setRole(adminRole.getId());
    guarantee.setGuarantee(test2.getId());
    adminRole.getGuarantees().add(guarantee);
    adminRole = roleService.save(adminRole);
    configurationService.setValue(IdmRoleService.WF_BY_ROLE_PRIORITY_PREFIX + (priority + priority), APPROVE_REMOVE_ROLE_BY_MANAGER_KEY);
    IdmRoleRequestDto requestRemove = createRoleRequest(test1);
    requestRemove = roleRequestService.save(requestRemove);
    IdmConceptRoleRequestDto conceptRemove = createRoleRemoveConcept(page.getContent().get(0).getId(), adminRole, contract, requestRemove);
    conceptRemove = conceptRoleRequestService.save(conceptRemove);
    roleRequestService.startRequestInternal(requestRemove.getId(), true);
    requestRemove = roleRequestService.get(requestRemove.getId());
    assertEquals(RoleRequestState.IN_PROGRESS, requestRemove.getState());
    WorkflowFilterDto taskRemoveFilter = new WorkflowFilterDto();
    // HELPDESK
    requestRemove = roleRequestService.get(requestRemove.getId());
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    taskRemoveFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskRemoveFilter, test1.getUsername(), "approve");
    // MANAGER
    requestRemove = roleRequestService.get(requestRemove.getId());
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    taskRemoveFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskRemoveFilter, test1.getUsername(), "approve");
    // USER MANAGER
    requestRemove = roleRequestService.get(requestRemove.getId());
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    taskRemoveFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskRemoveFilter, test1.getUsername(), "approve");
    // Subprocess - approve by GUARANTEE
    requestRemove = roleRequestService.get(requestRemove.getId());
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    taskRemoveFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskRemoveFilter, test1.getUsername(), "approve");
    // SECURITY
    requestRemove = roleRequestService.get(requestRemove.getId());
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    taskRemoveFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskRemoveFilter, test1.getUsername(), "approve");
    requestRemove = roleRequestService.get(requestRemove.getId());
    assertEquals(RoleRequestState.EXECUTED, requestRemove.getState());
    assertNotNull(requestRemove.getWfProcessId());
    conceptRemove = conceptRoleRequestService.get(conceptRemove.getId());
    assertNotNull(conceptRemove.getWfProcessId());
    IdmIdentityRoleFilter filterRemove = new IdmIdentityRoleFilter();
    filterRemove.setIdentityId(test1.getId());
    Page<IdmIdentityRoleDto> pageRemove = identityRoleService.find(filterRemove, null);
    assertEquals(0, pageRemove.getContent().size());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with WorkflowTaskInstanceDto

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

the class ChangeIdentityPermissionTest method addSuperAdminRoleApproveBySecurityTest.

@Test
@Transactional
public void addSuperAdminRoleApproveBySecurityTest() {
    configurationService.setValue(APPROVE_BY_SECURITY_ENABLE, "true");
    configurationService.setValue(APPROVE_BY_MANAGER_ENABLE, "false");
    configurationService.setValue(APPROVE_BY_HELPDESK_ENABLE, "false");
    configurationService.setValue(APPROVE_BY_USERMANAGER_ENABLE, "false");
    // Set security role test
    configurationService.setValue(APPROVE_BY_SECURITY_ROLE, SECURITY_ROLE_TEST);
    // Create test role for load candidates on security department (TEST_USER_1)
    IdmRoleDto role = new IdmRoleDto();
    role.setName(SECURITY_ROLE_TEST);
    role = roleService.save(role);
    helper.createIdentityRole(identityService.getByUsername(InitTestData.TEST_USER_1), role);
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    IdmIdentityDto test1 = identityService.getByUsername(InitTestData.TEST_USER_1);
    IdmRoleDto adminRole = roleService.getByCode(InitTestData.TEST_ADMIN_ROLE);
    IdmIdentityContractDto contract = identityContractService.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.setCandidateOrAssigned(securityService.getCurrentUsername());
    List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
    assertEquals(0, tasks.size());
    // HELPDESK turn off
    // MANAGER turn off
    // USER MANAGER turn off
    // SECURITY
    loginAsAdmin(InitTestData.TEST_USER_1);
    taskFilter.setCandidateOrAssigned(InitTestData.TEST_USER_1);
    checkAndCompleteOneTask(taskFilter, InitTestData.TEST_USER_1, "approve");
    request = roleRequestService.get(request.getId());
    assertEquals(RoleRequestState.EXECUTED, request.getState());
    assertNotNull(request.getWfProcessId());
    concept = conceptRoleRequestService.get(concept.getId());
    assertNotNull(concept.getWfProcessId());
}
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) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with WorkflowTaskInstanceDto

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

the class DefaultIdmAutomaticRoleRequestServiceIntegrationTest method completeTasksFromUsers.

/**
 * Complete all tasks from user given in parameters. Complete will be done by
 * currently logged user.
 *
 * @param approverUser
 * @param decision
 */
private void completeTasksFromUsers(String approverUser, String decision) {
    WorkflowFilterDto taskFilter = new WorkflowFilterDto();
    taskFilter.setCandidateOrAssigned(approverUser);
    List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
    // 
    for (WorkflowTaskInstanceDto task : tasks) {
        workflowTaskInstanceService.completeTask(task.getId(), decision);
    }
}
Also used : WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)

Example 24 with WorkflowTaskInstanceDto

use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto 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)

Example 25 with WorkflowTaskInstanceDto

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

the class SendNotificationToApplicantAndImplementerTest method requestRejectedByHelpdeskNotSameTest.

@Test
public void requestRejectedByHelpdeskNotSameTest() {
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    configurationService.setValue(SENT_TO_APPLICANT, "false");
    configurationService.setValue(SENT_TO_IMPLEMENTER, "false");
    // 
    IdmIdentityDto testUser3 = createTestUser();
    loginAsAdmin(testUser3.getUsername());
    IdmIdentityDto test1 = createTestUser();
    IdmRoleDto test_role = createRole("test_role" + System.currentTimeMillis());
    // 
    IdmIdentityContractDto contract = identityContractService.getPrimeContract(test1.getId());
    IdmRoleRequestDto request = createRoleRequest(test1);
    request = roleRequestService.save(request);
    IdmConceptRoleRequestDto concept = createRoleConcept(test_role, 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();
    List<WorkflowTaskInstanceDto> tasks = (List<WorkflowTaskInstanceDto>) workflowTaskInstanceService.search(taskFilter).getResources();
    assertEquals(0, tasks.size());
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    // HELPDESK
    checkAndCompleteOneTask(taskFilter, test1.getUsername(), "disapprove");
    // test notification to applicant
    IdmNotificationFilter filter = new IdmNotificationFilter();
    filter.setRecipient(test1.getUsername());
    filter.setNotificationType(IdmNotificationLog.class);
    List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
    assertEquals(0, notifications.size());
    // test notification to implementer
    filter = new IdmNotificationFilter();
    filter.setRecipient(testUser3.getUsername());
    filter.setNotificationType(IdmNotificationLog.class);
    notifications = notificationLogService.find(filter, null).getContent();
    assertEquals(0, notifications.size());
}
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) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) ArrayList(java.util.ArrayList) List(java.util.List) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Aggregations

WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)44 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)39 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)38 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)35 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)35 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)35 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)35 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)35 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)26 List (java.util.List)25 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)24 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)24 Transactional (org.springframework.transaction.annotation.Transactional)11 IdmRoleGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto)6 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)2 IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)2 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)2 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)1 ResourcesWrapper (eu.bcvsolutions.idm.core.api.rest.domain.ResourcesWrapper)1