Search in sources :

Example 81 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project bamboobsc by billchen198318.

the class BusinessProcessManagementUtils method getProcessDefinitionDiagramById.

public static byte[] getProcessDefinitionDiagramById(String processDefinitionId) throws Exception {
    ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
    if (pd == null) {
        return null;
    }
    byte[] data = null;
    ProcessDefinitionEntity pde = (ProcessDefinitionEntity) pd;
    InputStream is = repositoryService.getResourceAsStream(pde.getDeploymentId(), pde.getDiagramResourceName());
    data = IOUtils.toByteArray(is);
    is.close();
    is = null;
    return data;
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 82 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project bamboobsc by billchen198318.

the class BusinessProcessManagementUtils method getTaskDiagramById.

public static byte[] getTaskDiagramById(String resourceId, String taskId) throws Exception {
    SysBpmnResourceVO resouce = loadResource(resourceId);
    Task task = getTaskById(taskId);
    if (null == task) {
        return null;
    }
    ProcessDefinitionQuery pdQuery = repositoryService.createProcessDefinitionQuery().processDefinitionKey(resourceId);
    List<ProcessDefinition> pdList = pdQuery.deploymentId(resouce.getDeploymentId()).list();
    byte[] data = null;
    for (ProcessDefinition pd : pdList) {
        List<ProcessInstance> piList = runtimeService.createProcessInstanceQuery().processDefinitionId(pd.getId()).list();
        for (ProcessInstance pi : piList) {
            if (pi.getProcessInstanceId().equals(task.getProcessInstanceId())) {
                data = getDiagramByte(pi);
            }
        }
    }
    return data;
}
Also used : Task(org.activiti.engine.task.Task) SysBpmnResourceVO(com.netsteadfast.greenstep.vo.SysBpmnResourceVO) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessInstance(org.activiti.engine.runtime.ProcessInstance)

Example 83 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project bamboobsc by billchen198318.

the class TestBPMN001 method queryProcessDefinition.

@Test
public void queryProcessDefinition() throws Exception {
    RepositoryService repositoryService = (RepositoryService) AppContext.getBean("repositoryService");
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
    List<ProcessDefinition> processDefs = processDefinitionQuery.processDefinitionKey("Employee360DegreeFeedbackProjectPublishProcess").orderByProcessDefinitionVersion().desc().list();
    for (ProcessDefinition pd : processDefs) {
        System.out.println(pd.getId() + " , " + pd.getName() + " , " + pd.getKey() + " , " + pd.getVersion());
        ProcessDefinitionImpl pdObj = (ProcessDefinitionImpl) repositoryService.getProcessDefinition(pd.getId());
        System.out.println(pdObj.getActivities());
    }
}
Also used : ProcessDefinitionImpl(org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) RepositoryService(org.activiti.engine.RepositoryService) Test(org.junit.Test)

Example 84 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project CzechIdMng by bcvsolutions.

the class DefaultWorkflowProcessDefinitionService method find.

@Override
public Page<WorkflowProcessDefinitionDto> find(WorkflowFilterDto filter, Pageable pageable, BasePermission... permission) {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
    query.active();
    query.latestVersion();
    if (filter != null && filter.getCategory() != null && !StringUtils.isEmpty(filter.getCategory())) {
        query.processDefinitionCategoryLike(filter.getCategory() + '%');
    }
    if (filter.getProcessDefinitionKey() != null) {
        query.processDefinitionKeyLike('%' + filter.getProcessDefinitionKey() + '%');
    }
    if (filter.getName() != null) {
        query.processDefinitionNameLike('%' + filter.getName() + '%');
    }
    if (pageable != null && pageable.getSort() != null) {
        pageable.getSort().forEach(order -> {
            if (SORT_BY_KEY.equals(order.getProperty())) {
                // Sort by key
                query.orderByProcessDefinitionKey();
                if (order.isAscending()) {
                    query.asc();
                } else {
                    query.desc();
                }
            }
            if (SORT_BY_NAME.equals(order.getProperty())) {
                // Sort by name
                query.orderByProcessDefinitionName();
                if (order.isAscending()) {
                    query.asc();
                } else {
                    query.desc();
                }
            }
        });
    }
    // paginator
    long count = query.count();
    List<ProcessDefinition> processInstances = // without pagination
    pageable == null ? // without pagination
    query.list() : query.listPage((pageable.getPageNumber() * pageable.getPageSize()), pageable.getPageSize());
    List<WorkflowProcessDefinitionDto> dtos = new ArrayList<>();
    if (processInstances != null) {
        for (ProcessDefinition instance : processInstances) {
            dtos.add(toDto(instance));
        }
    }
    return toPage(dtos, count, pageable != null ? pageable.getPageNumber() : -1, pageable != null ? pageable.getPageSize() : -1);
}
Also used : ArrayList(java.util.ArrayList) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) WorkflowProcessDefinitionDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto)

Example 85 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project CzechIdMng by bcvsolutions.

the class DefaultWorkflowProcessDefinitionService method findAllProcessDefinitions.

/**
 * Find all last version and active process definitions
 */
@Override
public List<WorkflowProcessDefinitionDto> findAllProcessDefinitions() {
    ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
    query.active();
    query.latestVersion();
    List<ProcessDefinition> processDefinitions = query.list();
    List<WorkflowProcessDefinitionDto> processDefinitionDtos = new ArrayList<>();
    if (processDefinitions == null) {
        return processDefinitionDtos;
    }
    for (ProcessDefinition p : processDefinitions) {
        processDefinitionDtos.add(toDto(p));
    }
    return processDefinitionDtos;
}
Also used : ArrayList(java.util.ArrayList) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) WorkflowProcessDefinitionDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto)

Aggregations

ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)211 Deployment (org.activiti.engine.test.Deployment)82 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)42 ArrayList (java.util.ArrayList)29 ActivitiException (org.activiti.engine.ActivitiException)25 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)23 RepositoryService (org.activiti.engine.RepositoryService)20 ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)19 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)19 Task (org.activiti.engine.task.Task)16 Date (java.util.Date)14 Test (org.junit.Test)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)12 HashMap (java.util.HashMap)12 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)11 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)11 InputStream (java.io.InputStream)10 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)10 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)9