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();
}
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());
}
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;
}
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;
}
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;
}
Aggregations