Java Code Examples for org.flowable.bpmn.model.BpmnModel#getProcessById()
The following examples show how to use
org.flowable.bpmn.model.BpmnModel#getProcessById() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowableProcessDefinitionService.java From flowable-engine with Apache License 2.0 | 6 votes |
protected FormInfo getStartForm(ProcessDefinition processDefinition) { FormInfo formInfo = null; BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); Process process = bpmnModel.getProcessById(processDefinition.getKey()); FlowElement startElement = process.getInitialFlowElement(); if (startElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) startElement; if (StringUtils.isNotEmpty(startEvent.getFormKey())) { Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(processDefinition.getDeploymentId()).singleResult(); formInfo = formRepositoryService.getFormModelByKeyAndParentDeploymentId(startEvent.getFormKey(), deployment.getParentDeploymentId(), processDefinition.getTenantId(), processEngineConfiguration.isFallbackToDefaultTenant()); } } if (formInfo == null) { // Definition found, but no form attached throw new NotFoundException("Process definition does not have a form defined: " + processDefinition.getId()); } return formInfo; }
Example 2
Source File: ProcessDefinitionResource.java From flowable-engine with Apache License 2.0 | 6 votes |
protected FormInfo getStartForm(ProcessDefinition processDefinition) { FormInfo formInfo = null; BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); Process process = bpmnModel.getProcessById(processDefinition.getKey()); FlowElement startElement = process.getInitialFlowElement(); if (startElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) startElement; if (StringUtils.isNotEmpty(startEvent.getFormKey())) { if (startEvent.isSameDeployment()) { Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(processDefinition.getDeploymentId()).singleResult(); formInfo = formRepositoryService.getFormModelByKeyAndParentDeploymentId(startEvent.getFormKey(), deployment.getParentDeploymentId(), processDefinition.getTenantId(), processEngineConfiguration.isFallbackToDefaultTenant()); } else { formInfo = formRepositoryService.getFormModelByKey(startEvent.getFormKey(), processDefinition.getTenantId(), processEngineConfiguration.isFallbackToDefaultTenant()); } } } if (formInfo == null) { // Definition found, but no form attached throw new FlowableObjectNotFoundException("Process definition does not have a form defined: " + processDefinition.getId()); } return formInfo; }
Example 3
Source File: GetProcessDefinitionHistoryLevelModelCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public HistoryLevel execute(CommandContext commandContext) { if (processDefinitionId == null) { throw new FlowableIllegalArgumentException("processDefinitionId is null"); } HistoryLevel historyLevel = null; ProcessDefinition processDefinition = CommandContextUtil.getProcessDefinitionEntityManager(commandContext).findById(processDefinitionId); BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId); Process process = bpmnModel.getProcessById(processDefinition.getKey()); if (process.getExtensionElements().containsKey("historyLevel")) { ExtensionElement historyLevelElement = process.getExtensionElements().get("historyLevel").iterator().next(); String historyLevelValue = historyLevelElement.getElementText(); if (StringUtils.isNotEmpty(historyLevelValue)) { try { historyLevel = HistoryLevel.getHistoryLevelForKey(historyLevelValue); } catch (Exception e) { } } } if (historyLevel == null) { historyLevel = CommandContextUtil.getProcessEngineConfiguration(commandContext).getHistoryLevel(); } return historyLevel; }
Example 4
Source File: AbstractDynamicInjectionCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
protected BpmnModel createBpmnModel(CommandContext commandContext, ProcessDefinitionEntity originalProcessDefinitionEntity, DeploymentEntity newDeploymentEntity) { ResourceEntity originalBpmnResource = CommandContextUtil.getResourceEntityManager(commandContext) .findResourceByDeploymentIdAndResourceName(originalProcessDefinitionEntity.getDeploymentId(), originalProcessDefinitionEntity.getResourceName()); BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(new BytesStreamSource(originalBpmnResource.getBytes()), false, false); org.flowable.bpmn.model.Process process = bpmnModel.getProcessById(originalProcessDefinitionEntity.getKey()); updateBpmnProcess(commandContext, process, bpmnModel, originalProcessDefinitionEntity, newDeploymentEntity); return bpmnModel; }
Example 5
Source File: GetStartFormModelCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public FormInfo execute(CommandContext commandContext) { ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); FormService formService = CommandContextUtil.getFormService(commandContext); if (formService == null) { throw new FlowableIllegalArgumentException("Form engine is not initialized"); } FormInfo formInfo = null; ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId); BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId); Process process = bpmnModel.getProcessById(processDefinition.getKey()); FlowElement startElement = process.getInitialFlowElement(); if (startElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) startElement; if (StringUtils.isNotEmpty(startEvent.getFormKey())) { Deployment deployment = CommandContextUtil.getDeploymentEntityManager(commandContext).findById(processDefinition.getDeploymentId()); formInfo = formService.getFormInstanceModelByKeyAndParentDeploymentId(startEvent.getFormKey(), deployment.getParentDeploymentId(), null, processInstanceId, null, processDefinition.getTenantId(), processEngineConfiguration.isFallbackToDefaultTenant()); } } // If form does not exists, we don't want to leak out this info to just anyone if (formInfo == null) { throw new FlowableObjectNotFoundException("Form model for process definition " + processDefinitionId + " cannot be found"); } FormFieldHandler formFieldHandler = processEngineConfiguration.getFormFieldHandler(); formFieldHandler.enrichFormFields(formInfo); return formInfo; }
Example 6
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void addProcessDefinitionToCache(ProcessDefinitionEntity processDefinition, Map<String, BpmnModel> bpmnModelMap, ProcessEngineConfigurationImpl processEngineConfiguration, CommandContext commandContext) { // Add to cache DeploymentManager deploymentManager = processEngineConfiguration.getDeploymentManager(); BpmnModel bpmnModel = bpmnModelMap.get(processDefinition.getKey()); ProcessDefinitionCacheEntry cacheEntry = new ProcessDefinitionCacheEntry(processDefinition, bpmnModel, bpmnModel.getProcessById(processDefinition.getKey())); deploymentManager.getProcessDefinitionCache().add(processDefinition.getId(), cacheEntry); addDefinitionInfoToCache(processDefinition, processEngineConfiguration, commandContext); }
Example 7
Source File: ParsedDeployment.java From flowable-engine with Apache License 2.0 | 4 votes |
public Process getProcessModelForProcessDefinition(ProcessDefinitionEntity processDefinition) { BpmnModel model = getBpmnModelForProcessDefinition(processDefinition); return (model == null ? null : model.getProcessById(processDefinition.getKey())); }