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;
}
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());
}
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);
}
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());
}
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;
}
Aggregations