Search in sources :

Example 11 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.find(filter, null).getContent();
    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, InitTestDataProcessor.TEST_USER_1);
    // Second task is for testUser2 (is candidate) for testUser1 must be null
    filter.setCandidateOrAssigned(InitTestDataProcessor.TEST_USER_1);
    tasks = (List<WorkflowTaskInstanceDto>) taskInstanceService.find(filter, null).getContent();
    assertEquals(0, tasks.size());
    this.logout();
    this.loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
    filter.setCandidateOrAssigned(InitTestDataProcessor.TEST_USER_2);
    tasks = (List<WorkflowTaskInstanceDto>) taskInstanceService.find(filter, null).getContent();
    assertEquals(1, tasks.size());
    assertEquals("userTaskSecond", tasks.get(0).getName());
    taskId = tasks.get(0).getId();
    taskInstanceService.completeTask(taskId, null);
    // Check task history
    checkTaskHistory(taskId, InitTestDataProcessor.TEST_USER_2);
    tasks = (List<WorkflowTaskInstanceDto>) taskInstanceService.find(filter, null).getContent();
    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 12 with WorkflowHistoricProcessInstanceDto

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

the class DefaultIdmRequestService method toDto.

@Override
public IdmRequestDto toDto(IdmRequest entity, IdmRequestDto dto) {
    IdmRequestDto requestDto = super.toDto(entity, dto);
    // Load and add WF process DTO to embedded. Prevents of many requests from FE.
    if (requestDto != null && requestDto.getWfProcessId() != null) {
        if (RequestState.IN_PROGRESS == requestDto.getState()) {
            // Instance of process should exists only in 'IN_PROGRESS' state
            WorkflowProcessInstanceDto processInstanceDto = workflowProcessInstanceService.get(requestDto.getWfProcessId());
            // size
            if (processInstanceDto != null) {
                processInstanceDto.setProcessVariables(null);
            }
            requestDto.getEmbedded().put(AbstractRequestDto.WF_PROCESS_FIELD, processInstanceDto);
        } else {
            // In others states we need load historic process
            WorkflowHistoricProcessInstanceDto processHistDto = workflowHistoricProcessInstanceService.get(requestDto.getWfProcessId());
            // size
            if (processHistDto != null) {
                processHistDto.setProcessVariables(null);
            }
            requestDto.getEmbedded().put(AbstractRequestDto.WF_PROCESS_FIELD, processHistDto);
        }
    }
    // Load and add owner DTO to embedded. Prevents of many requests from FE.
    if (requestDto != null && requestDto.getOwnerId() != null && requestDto.getOwnerType() != null) {
        try {
            @SuppressWarnings("unchecked") Requestable requestable = requestManager.get(requestDto.getId(), requestDto.getOwnerId(), (Class<Requestable>) Class.forName(requestDto.getOwnerType()));
            if (requestable instanceof AbstractDto) {
                // If is requestable realized REMOVE, then requestable DTO does not contains
                // data (only ID). In this case we don't want send this DTO to FE.
                AbstractDto requestableDto = (AbstractDto) requestable;
                IdmRequestItemDto itemDto = DtoUtils.getEmbedded(requestableDto, Requestable.REQUEST_ITEM_FIELD, IdmRequestItemDto.class, null);
                if (itemDto != null && RequestOperationType.REMOVE == itemDto.getOperation() && itemDto.getState().isTerminatedState()) {
                    requestable = null;
                }
                // Minimise response size
                requestableDto.setEmbedded(null);
            }
            if (requestable == null) {
                // Entity was not found ... maybe was deleted or not exists yet
                LOG.debug(MessageFormat.format("Owner [{0}, {1}] not found for request {2}.", requestDto.getOwnerType(), requestDto.getOwnerId(), requestDto.getId()));
            }
            requestDto.getEmbedded().put(IdmRequestDto.OWNER_FIELD, requestable);
        } catch (ClassNotFoundException e) {
            // Only print warning
            LOG.warn(MessageFormat.format("Class not found for request {0}.", requestDto.getId()), e);
        }
    }
    return requestDto;
}
Also used : IdmRequestItemDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemDto) Requestable(eu.bcvsolutions.idm.core.api.domain.Requestable) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestDto) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto) WorkflowHistoricProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)

Example 13 with WorkflowHistoricProcessInstanceDto

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

the class DefaultWorkflowProcessInstanceService method canReadProcessOrHistoricProcess.

@Override
public boolean canReadProcessOrHistoricProcess(String id) {
    // Try to get the process. Process will returned only if user has permission to read that process (or history of that process).
    WorkflowProcessInstanceDto processInstance = this.get(id, true);
    if (processInstance != null) {
        return true;
    }
    // Ok, process was not returned, but we need to check historic process (on involved user) too.
    WorkflowHistoricProcessInstanceDto historicProcess = historicProcessInstanceService.get(id);
    return historicProcess != null;
}
Also used : WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto) WorkflowHistoricProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)

Example 14 with WorkflowHistoricProcessInstanceDto

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

the class DefaultWorkflowHistoricProcessInstanceService method find.

@Override
public Page<WorkflowHistoricProcessInstanceDto> find(WorkflowFilterDto filter, Pageable pageable, BasePermission... permission) {
    HistoricProcessInstanceQuery query = this.getQuery(filter, pageable, permission);
    if (pageable == null) {
        pageable = PageRequest.of(0, Integer.MAX_VALUE);
    }
    long count = query.count();
    List<HistoricProcessInstance> processInstances = query.listPage((pageable.getPageNumber()) * pageable.getPageSize(), pageable.getPageSize());
    String processInstanceId = filter.getProcessInstanceId();
    boolean trimmed = true;
    if (processInstanceId != null) {
        // Process variables will be included only for get by instance ID
        trimmed = false;
        query.includeProcessVariables();
        query.processInstanceId(processInstanceId);
    }
    List<WorkflowHistoricProcessInstanceDto> dtos = new ArrayList<>();
    if (processInstances != null) {
        for (HistoricProcessInstance instance : processInstances) {
            dtos.add(toDto(instance, trimmed));
        }
    }
    return new PageImpl<>(dtos, pageable, count);
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) WorkflowHistoricProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)

Example 15 with WorkflowHistoricProcessInstanceDto

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

the class DefaultWorkflowHistoricProcessInstanceService method get.

/**
 * Rights on involved user are evolved here!
 */
@Override
public WorkflowHistoricProcessInstanceDto get(String historicProcessInstanceId) {
    WorkflowFilterDto filter = new WorkflowFilterDto();
    filter.setProcessInstanceId(historicProcessInstanceId);
    List<WorkflowHistoricProcessInstanceDto> resources = this.find(filter, PageRequest.of(0, 1)).getContent();
    return !resources.isEmpty() ? resources.get(0) : null;
}
Also used : WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) 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