Search in sources :

Example 76 with FlowElement

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;
}
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 77 with FlowElement

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;
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) ArrayList(java.util.ArrayList) UserTask(org.activiti.bpmn.model.UserTask) WorkflowTaskDefinitionDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskDefinitionDto) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Aggregations

FlowElement (org.activiti.bpmn.model.FlowElement)77 SubProcess (org.activiti.bpmn.model.SubProcess)27 UserTask (org.activiti.bpmn.model.UserTask)26 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)24 StartEvent (org.activiti.bpmn.model.StartEvent)14 Process (org.activiti.bpmn.model.Process)13 ArrayList (java.util.ArrayList)11 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)11 HashMap (java.util.HashMap)9 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)9 Activity (org.activiti.bpmn.model.Activity)9 ServiceTask (org.activiti.bpmn.model.ServiceTask)9 Gateway (org.activiti.bpmn.model.Gateway)8 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)7 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)7 Artifact (org.activiti.bpmn.model.Artifact)6 FlowNode (org.activiti.bpmn.model.FlowNode)6 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)6 BpmnModel (org.activiti.bpmn.model.BpmnModel)5 EventDefinition (org.activiti.bpmn.model.EventDefinition)5