use of org.flowable.engine.repository.ProcessDefinitionQuery in project petals-se-flowable by petalslink.
the class GetProcessInstancesOperation method searchProcessInstances.
/**
* Search process instances that are not ended (in state 'active' or 'suspended').
*/
private GetProcessInstancesResponse searchProcessInstances(final GetProcessInstances incomingObject, final ProcessInstanceState state) throws MessagingException {
final ProcessInstanceQuery processInstanceQuery = this.runtimeService.createProcessInstanceQuery();
if (state == ProcessInstanceState.ACTIVE) {
processInstanceQuery.active();
} else if (state == ProcessInstanceState.SUSPENDED) {
processInstanceQuery.suspended();
} else {
// we search all process instances independently of their state: ACTIVE and SUSPENDED
assert state == null;
}
final String processDefinitionId = incomingObject.getProcessDefinitionIdentifier();
if (processDefinitionId != null && !processDefinitionId.isEmpty()) {
processInstanceQuery.processDefinitionKey(processDefinitionId);
}
final String processInstanceId = incomingObject.getProcessInstanceIdentifier();
if (processInstanceId != null && !processInstanceId.isEmpty()) {
processInstanceQuery.processInstanceId(processInstanceId);
}
final Variables variables = incomingObject.getVariables();
if (variables != null && !variables.getVariable().isEmpty()) {
for (final Variable variable : variables.getVariable()) {
processInstanceQuery.variableValueEquals(variable.getName(), Utils.parseVariableValue(variable));
}
}
processInstanceQuery.includeProcessVariables();
final GetProcessInstancesResponse response = new GetProcessInstancesResponse();
final ProcessInstances responseProcessInstances = new ProcessInstances();
response.setProcessInstances(responseProcessInstances);
final List<ProcessInstance> processInstances = processInstanceQuery.list();
for (final ProcessInstance processInstance : processInstances) {
final org.ow2.petals.components.flowable.generic._1.ProcessInstance responseProcessInstance = new org.ow2.petals.components.flowable.generic._1.ProcessInstance();
responseProcessInstances.getProcessInstance().add(responseProcessInstance);
responseProcessInstance.setProcessInstanceIdentifier(processInstance.getProcessInstanceId());
if (processInstance.isSuspended()) {
responseProcessInstance.setState(ProcessInstanceState.SUSPENDED);
} else if (processInstance.isEnded()) {
responseProcessInstance.setState(ProcessInstanceState.FINISHED);
} else {
responseProcessInstance.setState(ProcessInstanceState.ACTIVE);
}
final ProcessDefinitionQuery processDefQuery = this.repositoryService.createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId());
final ProcessDefinition processDefinition = processDefQuery.singleResult();
responseProcessInstance.setProcessDefinitionIdentifier(processDefinition.getKey());
responseProcessInstance.setVariables(Utils.buildVariables(processInstance.getProcessVariables(), this.log));
}
return response;
}
use of org.flowable.engine.repository.ProcessDefinitionQuery in project ruoyi-vue-pro by YunaiV.
the class BpmProcessDefinitionServiceImpl method getProcessDefinitionList.
@Override
public List<BpmProcessDefinitionRespVO> getProcessDefinitionList(BpmProcessDefinitionListReqVO listReqVO) {
// 拼接查询条件
ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery();
if (Objects.equals(SuspensionState.SUSPENDED.getStateCode(), listReqVO.getSuspensionState())) {
definitionQuery.suspended();
} else if (Objects.equals(SuspensionState.ACTIVE.getStateCode(), listReqVO.getSuspensionState())) {
definitionQuery.active();
}
// 执行查询
List<ProcessDefinition> processDefinitions = definitionQuery.list();
// 获得 BpmProcessDefinitionDO Map
List<BpmProcessDefinitionExtDO> processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds(convertList(processDefinitions, ProcessDefinition::getId));
Map<String, BpmProcessDefinitionExtDO> processDefinitionDOMap = convertMap(processDefinitionDOs, BpmProcessDefinitionExtDO::getProcessDefinitionId);
// 执行查询,并返回
return BpmProcessDefinitionConvert.INSTANCE.convertList3(processDefinitions, processDefinitionDOMap);
}
use of org.flowable.engine.repository.ProcessDefinitionQuery in project RuoYi-Flowable-Plus by KonBAI-Q.
the class WfDefinitionServiceImpl method publishList.
@Override
public TableDataInfo<WfDefinitionVo> publishList(String processKey, PageQuery pageQuery) {
Page<WfDefinitionVo> page = new Page<>();
// 创建查询条件
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processKey).orderByProcessDefinitionVersion().asc();
long pageTotal = processDefinitionQuery.count();
if (pageTotal <= 0) {
return TableDataInfo.build();
}
// 根据查询条件,查询所有版本
int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(offset, pageQuery.getPageSize());
List<WfDefinitionVo> definitionVoList = processDefinitionList.stream().map(item -> {
WfDefinitionVo vo = new WfDefinitionVo();
vo.setDefinitionId(item.getId());
vo.setProcessKey(item.getKey());
vo.setProcessName(item.getName());
vo.setVersion(item.getVersion());
vo.setCategory(item.getCategory());
vo.setDeploymentId(item.getDeploymentId());
vo.setSuspended(item.isSuspended());
// BeanUtil.copyProperties(item, vo);
return vo;
}).collect(Collectors.toList());
page.setRecords(definitionVoList);
page.setTotal(pageTotal);
return TableDataInfo.build(page);
}
use of org.flowable.engine.repository.ProcessDefinitionQuery in project RuoYi-Flowable-Plus by KonBAI-Q.
the class WfProcessServiceImpl method processList.
/**
* 流程定义列表
*
* @param pageQuery 分页参数
* @return 流程定义分页列表数据
*/
@Override
public TableDataInfo<WfDefinitionVo> processList(PageQuery pageQuery) {
Page<WfDefinitionVo> page = new Page<>();
// 流程定义列表数据查询
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery().latestVersion().active().orderByProcessDefinitionKey().asc();
long pageTotal = processDefinitionQuery.count();
if (pageTotal <= 0) {
return TableDataInfo.build();
}
int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
List<ProcessDefinition> definitionList = processDefinitionQuery.listPage(offset, pageQuery.getPageSize());
List<WfDefinitionVo> definitionVoList = new ArrayList<>();
for (ProcessDefinition processDefinition : definitionList) {
String deploymentId = processDefinition.getDeploymentId();
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
WfDefinitionVo vo = new WfDefinitionVo();
vo.setDefinitionId(processDefinition.getId());
vo.setProcessKey(processDefinition.getKey());
vo.setProcessName(processDefinition.getName());
vo.setVersion(processDefinition.getVersion());
vo.setCategory(processDefinition.getCategory());
vo.setDeploymentId(processDefinition.getDeploymentId());
vo.setSuspended(processDefinition.isSuspended());
// 流程定义时间
vo.setCategory(deployment.getCategory());
vo.setDeploymentTime(deployment.getDeploymentTime());
definitionVoList.add(vo);
}
page.setRecords(definitionVoList);
page.setTotal(pageTotal);
return TableDataInfo.build(page);
}
use of org.flowable.engine.repository.ProcessDefinitionQuery in project ruoyi-vue-pro by YunaiV.
the class BpmProcessDefinitionServiceImpl method getProcessDefinitionPage.
@Override
public PageResult<BpmProcessDefinitionPageItemRespVO> getProcessDefinitionPage(BpmProcessDefinitionPageReqVO pageVO) {
ProcessDefinitionQuery definitionQuery = repositoryService.createProcessDefinitionQuery();
if (StrUtil.isNotBlank(pageVO.getKey())) {
definitionQuery.processDefinitionKey(pageVO.getKey());
}
// 执行查询
List<ProcessDefinition> processDefinitions = definitionQuery.orderByProcessDefinitionVersion().desc().listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
if (CollUtil.isEmpty(processDefinitions)) {
return new PageResult<>(emptyList(), definitionQuery.count());
}
// 获得 Deployment Map
Set<String> deploymentIds = new HashSet<>();
processDefinitions.forEach(definition -> addIfNotNull(deploymentIds, definition.getDeploymentId()));
Map<String, Deployment> deploymentMap = getDeploymentMap(deploymentIds);
// 获得 BpmProcessDefinitionDO Map
List<BpmProcessDefinitionExtDO> processDefinitionDOs = processDefinitionMapper.selectListByProcessDefinitionIds(convertList(processDefinitions, ProcessDefinition::getId));
Map<String, BpmProcessDefinitionExtDO> processDefinitionDOMap = convertMap(processDefinitionDOs, BpmProcessDefinitionExtDO::getProcessDefinitionId);
// 获得 Form Map
Set<Long> formIds = convertSet(processDefinitionDOs, BpmProcessDefinitionExtDO::getFormId);
Map<Long, BpmFormDO> formMap = formService.getFormMap(formIds);
// 拼接结果
long definitionCount = definitionQuery.count();
return new PageResult<>(BpmProcessDefinitionConvert.INSTANCE.convertList(processDefinitions, deploymentMap, processDefinitionDOMap, formMap), definitionCount);
}
Aggregations