Java Code Examples for org.flowable.engine.impl.util.CommandContextUtil#getProcessDefinitionEntityManager()
The following examples show how to use
org.flowable.engine.impl.util.CommandContextUtil#getProcessDefinitionEntityManager() .
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: MergeByDateDeploymentMergeStrategy.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void finalizeMerge(CommandContext commandContext, String deploymentId, String newTenantId) { List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list(); ProcessDefinitionEntityManager processDefinitionEntityManager = CommandContextUtil.getProcessDefinitionEntityManager(commandContext); for (ProcessDefinition processDefinition : processDefinitions) { ProcessDefinitionQueryImpl processDefinitionQuery = new ProcessDefinitionQueryImpl(); if (StringUtils.isEmpty(newTenantId)) { processDefinitionQuery.processDefinitionWithoutTenantId(); } else { processDefinitionQuery.processDefinitionTenantId(newTenantId); } List<ProcessDefinition> allProcessDefinitionsWithKey = processDefinitionQuery .processDefinitionKey(processDefinition.getKey()) .list(); List<ProcessDefinition> orderedProcessDefinitions = sortProcessDefinitionsByDeploymentTime(allProcessDefinitionsWithKey); int versionNumber = allProcessDefinitionsWithKey.size(); for (ProcessDefinition alreadyExistingProcessDefinition : orderedProcessDefinitions) { processDefinitionEntityManager.updateProcessDefinitionVersionForProcessDefinitionId(alreadyExistingProcessDefinition.getId(), versionNumber--); } } }
Example 2
Source File: AddAsNewDeploymentMergeStrategy.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void finalizeMerge(CommandContext commandContext, String deploymentId, String newTenantId) { List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list(); ProcessDefinitionQueryImpl processDefinitionQuery = new ProcessDefinitionQueryImpl(); if (StringUtils.isEmpty(newTenantId)) { processDefinitionQuery.processDefinitionWithoutTenantId(); } else { processDefinitionQuery.processDefinitionTenantId(newTenantId); } Map<String, Integer> latestVersionNumberLookupTable = processDefinitionQuery .latestVersion() .list() .stream() .collect(Collectors.toMap(ProcessDefinition::getKey, ProcessDefinition::getVersion)); ProcessDefinitionEntityManager processDefinitionEntityManager = CommandContextUtil.getProcessDefinitionEntityManager(commandContext); for (ProcessDefinition processDefinition : processDefinitions) { int nextVersionNumber = latestVersionNumberLookupTable.getOrDefault(processDefinition.getKey(), 0) + 1; processDefinitionEntityManager.updateProcessDefinitionVersionForProcessDefinitionId(processDefinition.getId(), nextVersionNumber); } }
Example 3
Source File: AbstractDynamicStateManager.java From flowable-engine with Apache License 2.0 | 6 votes |
protected ProcessDefinition resolveProcessDefinition(String processDefinitionKey, Integer processDefinitionVersion, String tenantId, CommandContext commandContext) { ProcessDefinitionEntityManager processDefinitionEntityManager = CommandContextUtil.getProcessDefinitionEntityManager(commandContext); ProcessDefinition processDefinition; if (processDefinitionVersion != null) { processDefinition = processDefinitionEntityManager.findProcessDefinitionByKeyAndVersionAndTenantId(processDefinitionKey, processDefinitionVersion, tenantId); } else { if (tenantId == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId)) { processDefinition = processDefinitionEntityManager.findLatestProcessDefinitionByKey(processDefinitionKey); } else { processDefinition = processDefinitionEntityManager.findLatestProcessDefinitionByKeyAndTenantId(processDefinitionKey, tenantId); } } if (processDefinition == null) { DeploymentManager deploymentManager = CommandContextUtil.getProcessEngineConfiguration(commandContext).getDeploymentManager(); if (tenantId == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId)) { processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKey(processDefinitionKey); } else { processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitionKey, tenantId); } } return processDefinition; }
Example 4
Source File: ProcessInstanceMigrationManagerImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
protected ProcessDefinition resolveProcessDefinition(ProcessInstanceMigrationDocument document, CommandContext commandContext) { if (document.getMigrateToProcessDefinitionId() != null) { ProcessDefinitionEntityManager processDefinitionEntityManager = CommandContextUtil.getProcessDefinitionEntityManager(commandContext); return processDefinitionEntityManager.findById(document.getMigrateToProcessDefinitionId()); } else { return resolveProcessDefinition(document.getMigrateToProcessDefinitionKey(), document.getMigrateToProcessDefinitionVersion(), document.getMigrateToProcessDefinitionTenantId(), commandContext); } }
Example 5
Source File: AddAsOldDeploymentMergeStrategy.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void prepareMerge(CommandContext commandContext, String deploymentId, String newTenantId) { List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list(); ProcessDefinitionEntityManager processDefinitionEntityManager = CommandContextUtil.getProcessDefinitionEntityManager(commandContext); for (ProcessDefinition processDefinition : processDefinitions) { processDefinitionEntityManager.updateProcessDefinitionVersionForProcessDefinitionId(processDefinition.getId(), 0); } }
Example 6
Source File: AddAsOldDeploymentMergeStrategy.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void finalizeMerge(CommandContext commandContext, String deploymentId, String newTenantId) { List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list(); ProcessDefinitionEntityManager processDefinitionEntityManager = CommandContextUtil.getProcessDefinitionEntityManager(commandContext); for (ProcessDefinition processDefinition : processDefinitions) { ProcessDefinitionQueryImpl processDefinitionQuery = new ProcessDefinitionQueryImpl(); if (StringUtils.isEmpty(newTenantId)) { processDefinitionQuery.processDefinitionWithoutTenantId(); } else { processDefinitionQuery.processDefinitionTenantId(newTenantId); } List<ProcessDefinition> alreadyExistingProcessDefinitions = processDefinitionQuery .processDefinitionKey(processDefinition.getKey()) .orderByProcessDefinitionVersion() .desc() .list(); for (ProcessDefinition alreadyExistingProcessDefinition : alreadyExistingProcessDefinitions) { if (!alreadyExistingProcessDefinition.getId().equals(processDefinition.getId())) { processDefinitionEntityManager.updateProcessDefinitionVersionForProcessDefinitionId(alreadyExistingProcessDefinition.getId(), alreadyExistingProcessDefinition.getVersion() + 1); } } processDefinitionEntityManager.updateProcessDefinitionVersionForProcessDefinitionId(processDefinition.getId(), 1); } }
Example 7
Source File: MergeByDateDeploymentMergeStrategy.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void prepareMerge(CommandContext commandContext, String deploymentId, String newTenantId) { List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list(); ProcessDefinitionEntityManager processDefinitionEntityManager = CommandContextUtil.getProcessDefinitionEntityManager(commandContext); for (ProcessDefinition processDefinition : processDefinitions) { processDefinitionEntityManager.updateProcessDefinitionVersionForProcessDefinitionId(processDefinition.getId(), 0); } }
Example 8
Source File: AddAsNewDeploymentMergeStrategy.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void prepareMerge(CommandContext commandContext, String deploymentId, String newTenantId) { List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list(); ProcessDefinitionEntityManager processDefinitionEntityManager = CommandContextUtil.getProcessDefinitionEntityManager(commandContext); for (ProcessDefinition processDefinition : processDefinitions) { processDefinitionEntityManager.updateProcessDefinitionVersionForProcessDefinitionId(processDefinition.getId(), 0); } }
Example 9
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 5 votes |
/** * Saves each process definition. It is assumed that the deployment is new, the definitions have never been saved before, and that they have all their values properly set up. */ protected void persistProcessDefinitionsAndAuthorizations(ParsedDeployment parsedDeployment) { CommandContext commandContext = Context.getCommandContext(); ProcessDefinitionEntityManager processDefinitionManager = CommandContextUtil.getProcessDefinitionEntityManager(commandContext); for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) { processDefinitionManager.insert(processDefinition, false); bpmnDeploymentHelper.addAuthorizationsForNewProcessDefinition(parsedDeployment.getProcessModelForProcessDefinition(processDefinition), processDefinition); } }