Search in sources :

Example 11 with WorkflowProcessInstanceDto

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

the class DefaultWorkflowProcessInstanceService method delete.

@Override
public WorkflowProcessInstanceDto delete(String processInstanceId, String deleteReason) {
    if (processInstanceId == null) {
        return null;
    }
    if (deleteReason == null) {
        deleteReason = "Deleted by " + securityService.getUsername();
    }
    WorkflowFilterDto filter = new WorkflowFilterDto();
    filter.setProcessInstanceId(processInstanceId);
    Collection<WorkflowProcessInstanceDto> resources = this.searchInternal(filter, false).getResources();
    WorkflowProcessInstanceDto processInstanceToDelete = null;
    if (!resources.isEmpty()) {
        processInstanceToDelete = resources.iterator().next();
    }
    if (processInstanceToDelete == null) {
        throw new ResultCodeException(CoreResultCode.FORBIDDEN, "You do not have permission for delete process instance with ID: %s !", ImmutableMap.of("processInstanceId", processInstanceId));
    }
    runtimeService.deleteProcessInstance(processInstanceToDelete.getProcessInstanceId(), deleteReason);
    return processInstanceToDelete;
}
Also used : WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto)

Example 12 with WorkflowProcessInstanceDto

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

the class DefaultIdmAutomaticRoleRequestService method toDto.

@Override
public IdmAutomaticRoleRequestDto toDto(IdmAutomaticRoleRequest entity, IdmAutomaticRoleRequestDto dto) {
    IdmAutomaticRoleRequestDto requestDto = super.toDto(entity, dto);
    if (requestDto != null && requestDto.getWfProcessId() != null) {
        WorkflowProcessInstanceDto processDto = workflowProcessInstanceService.get(requestDto.getWfProcessId(), false);
        // TODO: create trimmed variant in workflow process instance service
        if (processDto != null) {
            processDto.setProcessVariables(null);
        }
        requestDto.getEmbedded().put(IdmRoleRequestDto.WF_PROCESS_FIELD, processDto);
    }
    return requestDto;
}
Also used : IdmAutomaticRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleRequestDto) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto)

Example 13 with WorkflowProcessInstanceDto

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

the class DefaultIdmConceptRoleRequestService method deleteInternal.

@Override
public void deleteInternal(IdmConceptRoleRequestDto dto) {
    if (!Strings.isNullOrEmpty(dto.getWfProcessId())) {
        WorkflowFilterDto filter = new WorkflowFilterDto();
        filter.setProcessInstanceId(dto.getWfProcessId());
        Collection<WorkflowProcessInstanceDto> resources = workflowProcessInstanceService.searchInternal(filter, false).getResources();
        if (resources.isEmpty()) {
            // Process with this ID not exist ... maybe was ended
            this.addToLog(dto, MessageFormat.format("Workflow process with ID [{0}] was not deleted, because was not found. Maybe was ended before.", dto.getWfProcessId()));
        } else {
            workflowProcessInstanceService.delete(dto.getWfProcessId(), "Role concept use this WF, was deleted. This WF was deleted too.");
            this.addToLog(dto, MessageFormat.format("Workflow process with ID [{0}] was deleted, because this concept is deleted/canceled", dto.getWfProcessId()));
        }
    }
    super.deleteInternal(dto);
}
Also used : WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto)

Example 14 with WorkflowProcessInstanceDto

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

the class DefaultIdmRoleRequestService method toDto.

@Override
public IdmRoleRequestDto toDto(IdmRoleRequest entity, IdmRoleRequestDto dto) {
    IdmRoleRequestDto requestDto = super.toDto(entity, dto);
    // Set concepts to request DTO
    if (requestDto != null) {
        requestDto.setConceptRoles(conceptRoleRequestService.findAllByRoleRequest(requestDto.getId()));
    }
    if (requestDto != null && requestDto.getWfProcessId() != null) {
        WorkflowProcessInstanceDto processDto = workflowProcessInstanceService.get(requestDto.getWfProcessId(), false);
        // TODO: create trimmed variant in workflow process instance service
        if (processDto != null) {
            processDto.setProcessVariables(null);
        }
        requestDto.getEmbedded().put(IdmRoleRequestDto.WF_PROCESS_FIELD, processDto);
    }
    return requestDto;
}
Also used : WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)

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