Search in sources :

Example 6 with WorkflowProcessInstanceDto

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

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

the class DefaultWorkflowProcessInstanceService method find.

@Override
public Page<WorkflowProcessInstanceDto> find(WorkflowFilterDto filter, Pageable pageable, BasePermission... permission) {
    // we must call original method search because is there check flag checkRight
    if (pageable != null) {
        filter.setPageNumber(pageable.getPageNumber());
        filter.setPageSize(pageable.getPageSize());
        // 
        String fieldForSort = null;
        boolean ascSort = false;
        boolean descSort = false;
        if (pageable != null) {
            Sort sort = pageable.getSort();
            if (sort != null) {
                for (Order order : sort) {
                    if (!StringUtils.isEmpty(order.getProperty())) {
                        // TODO: now is implemented only one property sort
                        fieldForSort = order.getProperty();
                        if (order.getDirection() == Direction.ASC) {
                            ascSort = true;
                        } else if (order.getDirection() == Direction.DESC) {
                            descSort = true;
                        }
                        break;
                    }
                }
            }
        }
        filter.setSortAsc(ascSort);
        filter.setSortDesc(descSort);
        filter.setSortByFields(fieldForSort);
    }
    ResourcesWrapper<WorkflowProcessInstanceDto> search = this.search(filter);
    // 
    ResourcePage pages = search.getPage();
    List<WorkflowProcessInstanceDto> processes = (List<WorkflowProcessInstanceDto>) search.getResources();
    // 
    return new PageImpl<WorkflowProcessInstanceDto>(processes, pageable, pages.getTotalElements());
}
Also used : Order(org.springframework.data.domain.Sort.Order) PageImpl(org.springframework.data.domain.PageImpl) Sort(org.springframework.data.domain.Sort) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto) ResourcePage(eu.bcvsolutions.idm.core.api.rest.domain.ResourcePage)

Example 8 with WorkflowProcessInstanceDto

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

the class DefaultWorkflowProcessInstanceService method toResource.

private WorkflowProcessInstanceDto toResource(ProcessInstance instance) {
    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);
    }
    if (instanceName == null || instanceName.isEmpty()) {
        instanceName = instance.getProcessDefinitionName();
    }
    WorkflowProcessInstanceDto dto = new WorkflowProcessInstanceDto();
    dto.setId(instance.getId());
    dto.setActivityId(instance.getActivityId());
    dto.setBusinessKey(instance.getBusinessKey());
    dto.setName(instanceName);
    dto.setProcessDefinitionId(instance.getProcessDefinitionId());
    dto.setProcessDefinitionKey(instance.getProcessDefinitionKey());
    dto.setProcessDefinitionName(instance.getProcessDefinitionName());
    dto.setProcessVariables(instance.getProcessVariables());
    dto.setEnded(instance.isEnded());
    dto.setProcessInstanceId(instance.getProcessInstanceId());
    // Add current activity name and documentation
    BpmnModel model = repositoryService.getBpmnModel(instance.getProcessDefinitionId());
    for (FlowElement element : model.getMainProcess().getFlowElements()) {
        if (element.getId().equals(instance.getActivityId())) {
            dto.setCurrentActivityName(element.getName());
            dto.setCurrentActivityDocumentation(element.getDocumentation());
        }
    }
    Task task = taskService.createTaskQuery().processInstanceId(instance.getProcessInstanceId()).singleResult();
    if (task != null) {
        List<HistoricIdentityLink> identityLinks = historyService.getHistoricIdentityLinksForTask(task.getId());
        if (identityLinks != null && !identityLinks.isEmpty()) {
            List<String> candicateUsers = new ArrayList<>();
            for (HistoricIdentityLink identity : identityLinks) {
                if (IdentityLinkType.CANDIDATE.equals(identity.getType())) {
                    candicateUsers.add(identity.getUserId());
                }
            }
            dto.setCandicateUsers(candicateUsers);
        }
    }
    return dto;
}
Also used : Task(org.activiti.engine.task.Task) HistoricIdentityLink(org.activiti.engine.history.HistoricIdentityLink) FlowElement(org.activiti.bpmn.model.FlowElement) ArrayList(java.util.ArrayList) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 9 with WorkflowProcessInstanceDto

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

the class DefaultWorkflowProcessInstanceService method get.

@Override
public WorkflowProcessInstanceDto get(String processInstanceId) {
    WorkflowFilterDto filter = new WorkflowFilterDto();
    filter.setProcessInstanceId(processInstanceId);
    filter.setSortAsc(true);
    Collection<WorkflowProcessInstanceDto> resources = this.search(filter).getResources();
    return !resources.isEmpty() ? resources.iterator().next() : null;
}
Also used : WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto)

Example 10 with WorkflowProcessInstanceDto

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

the class DefaultWorkflowProcessInstanceService method get.

@Override
public WorkflowProcessInstanceDto get(String processInstanceId, boolean checkRight) {
    WorkflowFilterDto filter = new WorkflowFilterDto();
    filter.setProcessInstanceId(processInstanceId);
    filter.setSortAsc(true);
    Collection<WorkflowProcessInstanceDto> resources = this.searchInternal(filter, checkRight).getResources();
    return !resources.isEmpty() ? resources.iterator().next() : null;
}
Also used : WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto)

Aggregations

WorkflowProcessInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto)14 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)7 ArrayList (java.util.ArrayList)3 List (java.util.List)2 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)2 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)1 IdmAutomaticRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleRequestDto)1 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 ResourcePage (eu.bcvsolutions.idm.core.api.rest.domain.ResourcePage)1 ResourcesWrapper (eu.bcvsolutions.idm.core.api.rest.domain.ResourcesWrapper)1 WorkflowHistoricProcessInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto)1 HashSet (java.util.HashSet)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 FlowElement (org.activiti.bpmn.model.FlowElement)1 HistoricIdentityLink (org.activiti.engine.history.HistoricIdentityLink)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)1 ProcessInstanceQuery (org.activiti.engine.runtime.ProcessInstanceQuery)1 Task (org.activiti.engine.task.Task)1