use of org.activiti.bpmn.model.FlowElement 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 org.activiti.bpmn.model.FlowElement in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowTaskDefinitionService method searchTaskDefinitions.
@Override
public List<WorkflowTaskDefinitionDto> searchTaskDefinitions(String processDefinitionId) {
List<WorkflowTaskDefinitionDto> taskDefinitions = new ArrayList<>();
BpmnModel model = repositoryService.getBpmnModel(processDefinitionId);
for (FlowElement element : model.getMainProcess().getFlowElements()) {
if (element instanceof UserTask) {
taskDefinitions.add(toResorce((UserTask) element));
}
}
return taskDefinitions;
}
Aggregations