use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowHistoricProcessInstanceService method toResource.
private WorkflowHistoricProcessInstanceDto toResource(HistoricProcessInstance instance, boolean trimmed) {
if (instance == null) {
return null;
}
String instanceName = instance.getName();
// processInstanceName
if (instanceName == null && instance.getProcessVariables() != null && instance.getProcessVariables().containsKey(WorkflowHistoricProcessInstanceService.PROCESS_INSTANCE_NAME)) {
instanceName = (String) instance.getProcessVariables().get(WorkflowHistoricProcessInstanceService.PROCESS_INSTANCE_NAME);
}
// historic variables
if (instanceName == null || instanceName.isEmpty()) {
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(instance.getId()).variableName(WorkflowHistoricProcessInstanceService.PROCESS_INSTANCE_NAME).singleResult();
instanceName = variableInstance != null ? (String) variableInstance.getValue() : null;
}
if (instanceName == null || instanceName.isEmpty()) {
instanceName = definitionService.get(instance.getProcessDefinitionId()).getName();
}
WorkflowHistoricProcessInstanceDto dto = new WorkflowHistoricProcessInstanceDto();
dto.setTrimmed(trimmed);
dto.setId(instance.getId());
dto.setName(instanceName);
dto.setProcessDefinitionId(instance.getProcessDefinitionId());
dto.setProcessDefinitionKey(instance.getProcessDefinitionKey());
dto.setProcessVariables(instance.getProcessVariables());
dto.setDeleteReason(instance.getDeleteReason());
dto.setDurationInMillis(instance.getDurationInMillis());
dto.setEndTime(instance.getEndTime());
dto.setStartActivityId(instance.getStartActivityId());
dto.setStartTime(instance.getStartTime());
dto.setStartUserId(instance.getStartUserId());
dto.setSuperProcessInstanceId(instance.getSuperProcessInstanceId());
return dto;
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto in project CzechIdMng by bcvsolutions.
the class HistoryProcessAndTaskTest method deployAndRunProcess.
@Test
public void deployAndRunProcess() {
// Deploy process
// Start instance of process
ProcessInstance instance = processInstanceService.startProcess(PROCESS_KEY, null, InitTestData.TEST_USER_1, null, null);
logout();
// Log as user without ADMIN rights
loginAsNoAdmin(InitTestData.TEST_USER_1);
WorkflowFilterDto filter = new WorkflowFilterDto();
filter.setProcessInstanceId(instance.getId());
ResourcesWrapper<WorkflowProcessInstanceDto> processes = processInstanceService.search(filter);
assertEquals(PROCESS_KEY, ((List<WorkflowProcessInstanceDto>) processes.getResources()).get(0).getName());
WorkflowHistoricProcessInstanceDto historicProcessDto = historicProcessService.get(instance.getId());
assertNotNull(historicProcessDto);
this.logout();
// Log as user without ADMIN rights
loginAsNoAdmin(InitTestData.TEST_USER_2);
// Applicant for this process is testUser1. For testUser2 must be result
// null
historicProcessDto = historicProcessService.get(instance.getId());
assertNull(historicProcessDto);
this.logout();
// Log as ADMIN
loginAsAdmin(InitTestData.TEST_USER_2);
// Applicant for this process is testUser1. For testUser2 must be result
// null, but as ADMIN can see all historic processes
historicProcessDto = historicProcessService.get(instance.getId());
assertNotNull(historicProcessDto);
this.logout();
this.loginAsAdmin(InitTestData.TEST_USER_1);
completeTasksAndCheckHistory();
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto in project CzechIdMng by bcvsolutions.
the class HistoryProcessAndTaskTest method completeTasksAndCheckHistory.
private void completeTasksAndCheckHistory() {
WorkflowFilterDto filter = new WorkflowFilterDto();
filter.setProcessDefinitionKey(PROCESS_KEY);
List<WorkflowTaskInstanceDto> tasks = (List<WorkflowTaskInstanceDto>) taskInstanceService.search(filter).getResources();
assertEquals(1, tasks.size());
assertEquals("userTaskFirst", tasks.get(0).getName());
String taskId = tasks.get(0).getId();
String processId = tasks.get(0).getProcessInstanceId();
taskInstanceService.completeTask(taskId, null);
// Check task history
checkTaskHistory(taskId, InitTestData.TEST_USER_1);
// Second task is for testUser2 (is candidate) for testUser1 must be null
filter.setCandidateOrAssigned(InitTestData.TEST_USER_1);
tasks = (List<WorkflowTaskInstanceDto>) taskInstanceService.search(filter).getResources();
assertEquals(0, tasks.size());
this.logout();
this.loginAsAdmin(InitTestData.TEST_USER_2);
filter.setCandidateOrAssigned(InitTestData.TEST_USER_2);
tasks = (List<WorkflowTaskInstanceDto>) taskInstanceService.search(filter).getResources();
assertEquals(1, tasks.size());
assertEquals("userTaskSecond", tasks.get(0).getName());
taskId = tasks.get(0).getId();
taskInstanceService.completeTask(taskId, null);
// Check task history
checkTaskHistory(taskId, InitTestData.TEST_USER_2);
tasks = (List<WorkflowTaskInstanceDto>) taskInstanceService.search(filter).getResources();
assertEquals(0, tasks.size());
// Find history of process. Historic process must exist and must be ended.
WorkflowHistoricProcessInstanceDto historicProcess = historicProcessService.get(processId);
assertNotNull(historicProcess);
assertNotNull(historicProcess.getEndTime());
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowHistoricProcessInstanceService method toDto.
private WorkflowHistoricProcessInstanceDto toDto(HistoricProcessInstance instance, boolean trimmed) {
if (instance == null) {
return null;
}
String instanceName = instance.getName();
// processInstanceName
if (instanceName == null && instance.getProcessVariables() != null && instance.getProcessVariables().containsKey(WorkflowHistoricProcessInstanceService.PROCESS_INSTANCE_NAME)) {
instanceName = (String) instance.getProcessVariables().get(WorkflowHistoricProcessInstanceService.PROCESS_INSTANCE_NAME);
}
// historic variables
if (instanceName == null || instanceName.isEmpty()) {
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().processInstanceId(instance.getId()).variableName(WorkflowHistoricProcessInstanceService.PROCESS_INSTANCE_NAME).singleResult();
instanceName = variableInstance != null ? (String) variableInstance.getValue() : null;
}
if (instanceName == null || instanceName.isEmpty()) {
instanceName = definitionService.get(instance.getProcessDefinitionId()).getName();
}
WorkflowHistoricProcessInstanceDto dto = new WorkflowHistoricProcessInstanceDto();
dto.setTrimmed(trimmed);
dto.setId(instance.getId());
dto.setName(instanceName);
dto.setProcessDefinitionId(instance.getProcessDefinitionId());
dto.setProcessDefinitionKey(instance.getProcessDefinitionKey());
dto.setProcessVariables(instance.getProcessVariables());
dto.setDeleteReason(instance.getDeleteReason());
dto.setDurationInMillis(instance.getDurationInMillis());
dto.setEndTime(instance.getEndTime());
dto.setStartActivityId(instance.getStartActivityId());
dto.setStartTime(instance.getStartTime());
dto.setStartUserId(instance.getStartUserId());
dto.setSuperProcessInstanceId(instance.getSuperProcessInstanceId());
return dto;
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto in project CzechIdMng by bcvsolutions.
the class RoleRequestByWfInvolvedIdentityEvaluator method getPermissions.
@Override
public Set<String> getPermissions(IdmRoleRequest entity, AuthorizationPolicy policy) {
Set<String> permissions = super.getPermissions(entity, policy);
if (entity == null || !securityService.isAuthenticated() || entity.getWfProcessId() == null) {
return permissions;
}
//
// Search process instance by role request - its returned, if currently logged identity was involved in wf.
WorkflowProcessInstanceDto processInstance = processService.get(entity.getWfProcessId(), true);
if (processInstance != null) {
permissions.addAll(policy.getPermissions());
}
if (processInstance == null) {
// Ok process was not returned, but we need to check historic process (on involved user) too.
WorkflowHistoricProcessInstanceDto historicProcess = historicProcessService.get(entity.getWfProcessId());
if (historicProcess != null) {
permissions.addAll(policy.getPermissions());
}
}
return permissions;
}
Aggregations