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