Search in sources :

Example 1 with WorkflowHistoricProcessInstanceDto

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;
}
Also used : HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) WorkflowHistoricProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)

Example 2 with WorkflowHistoricProcessInstanceDto

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();
}
Also used : WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) List(java.util.List) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto) WorkflowHistoricProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto) Test(org.junit.Test) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)

Example 3 with WorkflowHistoricProcessInstanceDto

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());
}
Also used : WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) List(java.util.List) WorkflowHistoricProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)

Example 4 with WorkflowHistoricProcessInstanceDto

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;
}
Also used : HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) WorkflowHistoricProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)

Example 5 with WorkflowHistoricProcessInstanceDto

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;
}
Also used : WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto) WorkflowHistoricProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)

Aggregations

WorkflowHistoricProcessInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)17 WorkflowProcessInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto)9 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)5 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)3 List (java.util.List)3 Test (org.junit.Test)3 Requestable (eu.bcvsolutions.idm.core.api.domain.Requestable)2 IdmRequestItemDto (eu.bcvsolutions.idm.core.api.dto.IdmRequestItemDto)2 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)2 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)2 IOException (java.io.IOException)2 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)2 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)1 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)1 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRequestDto)1