Java Code Examples for org.flowable.engine.repository.ProcessDefinition#getKey()
The following examples show how to use
org.flowable.engine.repository.ProcessDefinition#getKey() .
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: SetProcessDefinitionVersionCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinition newProcessDefinition) { // check that the new process definition version contains the current activity org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(newProcessDefinition.getId()); if (execution.getActivityId() != null && process.getFlowElement(execution.getActivityId(), true) == null) { throw new FlowableException("The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '" + execution.getActivityId() + "') " + "of the process instance " + "(id = '" + processInstanceId + "')."); } // switch the process instance to the new process definition version execution.setProcessDefinitionId(newProcessDefinition.getId()); execution.setProcessDefinitionName(newProcessDefinition.getName()); execution.setProcessDefinitionKey(newProcessDefinition.getKey()); // and change possible existing tasks (as the process definition id is stored there too) List<TaskEntity> tasks = CommandContextUtil.getTaskService(commandContext).findTasksByExecutionId(execution.getId()); Clock clock = commandContext.getCurrentEngineConfiguration().getClock(); for (TaskEntity taskEntity : tasks) { taskEntity.setProcessDefinitionId(newProcessDefinition.getId()); CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordTaskInfoChange(taskEntity, clock.getCurrentTime()); } }
Example 2
Source File: TaskRepresentation.java From flowable-engine with Apache License 2.0 | 5 votes |
public TaskRepresentation(TaskInfo taskInfo, ProcessDefinition processDefinition) { initializeTaskDetails(taskInfo); if (processDefinition != null) { this.processDefinitionName = processDefinition.getName(); this.processDefinitionDescription = processDefinition.getDescription(); this.processDefinitionKey = processDefinition.getKey(); this.processDefinitionCategory = processDefinition.getCategory(); this.processDefinitionVersion = processDefinition.getVersion(); this.processDefinitionDeploymentId = processDefinition.getDeploymentId(); } }
Example 3
Source File: ProcessDefinitionRepresentation.java From flowable-engine with Apache License 2.0 | 5 votes |
public ProcessDefinitionRepresentation(ProcessDefinition processDefinition) { this.id = processDefinition.getId(); this.name = processDefinition.getName(); this.description = processDefinition.getDescription(); this.key = processDefinition.getKey(); this.category = processDefinition.getCategory(); this.version = processDefinition.getVersion(); this.deploymentId = processDefinition.getDeploymentId(); this.tenantId = processDefinition.getTenantId(); this.hasStartForm = processDefinition.hasStartFormKey(); }
Example 4
Source File: ProcessInstanceRepresentation.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void mapProcessDefinition(ProcessDefinition processDefinition) { if (processDefinition != null) { this.processDefinitionName = processDefinition.getName(); this.processDefinitionDescription = processDefinition.getDescription(); this.processDefinitionKey = processDefinition.getKey(); this.processDefinitionCategory = processDefinition.getCategory(); this.processDefinitionVersion = processDefinition.getVersion(); this.processDefinitionDeploymentId = processDefinition.getDeploymentId(); } }
Example 5
Source File: ExecutionQueryImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked" }) @Override public List<Execution> executeList(CommandContext commandContext) { ensureVariablesInitialized(); ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); if (processEngineConfiguration.getExecutionQueryInterceptor() != null) { processEngineConfiguration.getExecutionQueryInterceptor().beforeExecutionQueryExecute(this); } List<?> executions = CommandContextUtil.getExecutionEntityManager(commandContext).findExecutionsByQueryCriteria(this); if (processEngineConfiguration.getPerformanceSettings().isEnableLocalization()) { for (ExecutionEntity execution : (List<ExecutionEntity>) executions) { String activityId = null; if (execution.getId().equals(execution.getProcessInstanceId())) { if (execution.getProcessDefinitionId() != null) { ProcessDefinition processDefinition = processEngineConfiguration .getDeploymentManager() .findDeployedProcessDefinitionById(execution.getProcessDefinitionId()); activityId = processDefinition.getKey(); } } else { activityId = execution.getActivityId(); } if (activityId != null) { localize(execution, activityId); } } } if (processEngineConfiguration.getExecutionQueryInterceptor() != null) { processEngineConfiguration.getExecutionQueryInterceptor().afterExecutionQueryExecute(this, (List<Execution>) executions); } return (List<Execution>) executions; }
Example 6
Source File: ExecutionQueryImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings({"unchecked"}) public List<Execution> executeList(CommandContext commandContext, Page page) { checkQueryOk(); ensureVariablesInitialized(); List<?> executions = commandContext.getExecutionEntityManager().findExecutionsByQueryCriteria(this, page); for (ExecutionEntity execution : (List<ExecutionEntity>) executions) { String activityId = null; if (execution.getId().equals(execution.getProcessInstanceId())) { if (execution.getProcessDefinitionId() != null) { ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration() .getDeploymentManager() .findDeployedProcessDefinitionById(execution.getProcessDefinitionId()); activityId = processDefinition.getKey(); } } else { activityId = execution.getActivityId(); } if (activityId != null) { localize(execution, activityId); } } return (List<Execution>) executions; }
Example 7
Source File: FlowableBpmnProcessManager.java From syncope with Apache License 2.0 | 5 votes |
protected Model getModel(final ProcessDefinition procDef) { try { Model model = engine.getRepositoryService().createModelQuery(). deploymentId(procDef.getDeploymentId()).singleResult(); if (model == null) { throw new NotFoundException("Could not find Model for deployment " + procDef.getDeploymentId()); } return model; } catch (Exception e) { throw new WorkflowException("While accessing process " + procDef.getKey(), e); } }
Example 8
Source File: TenancyTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@Test public void testChangeDeploymentTenantId_withMergingTwoTenantsByDateOfdeployment_ensureDeploymentsOrderedCorrectly() { List<String> expectedOrderOfProcessDefinitionIds = new ArrayList<>(); expectedOrderOfProcessDefinitionIds.add(deployOneTaskTestProcess()); expectedOrderOfProcessDefinitionIds.add(deployOneTaskTestProcess()); String processDefinitionIdWithTenant = deployTestProcessWithTestTenant("tenantA"); expectedOrderOfProcessDefinitionIds.add(processDefinitionIdWithTenant); expectedOrderOfProcessDefinitionIds.add(deployOneTaskTestProcess()); expectedOrderOfProcessDefinitionIds.add(deployOneTaskTestProcess()); ProcessDefinition processDefinitionToBeMerged = this.repositoryService.createProcessDefinitionQuery() .processDefinitionId(processDefinitionIdWithTenant) .singleResult(); String processDefinitionKey = processDefinitionToBeMerged.getKey(); String deploymentId = processDefinitionToBeMerged.getDeploymentId(); // Act repositoryService.changeDeploymentTenantId(deploymentId, "", MergeMode.BY_DATE); // Assert // Since we are using the "by-date" merge strategy, the version number of the original one should be matches List<ProcessDefinition> allDeployedProcessDefinitions = this.repositoryService.createProcessDefinitionQuery() .processDefinitionKey(processDefinitionKey) .processDefinitionWithoutTenantId() .orderByProcessDefinitionVersion() .asc() .list(); assertThat(allDeployedProcessDefinitions).hasSize(5); assertThat(allDeployedProcessDefinitions) .extracting(ProcessDefinition::getId) .containsExactlyElementsOf(expectedOrderOfProcessDefinitionIds); assertThat(allDeployedProcessDefinitions) .extracting(ProcessDefinition::getVersion) .containsExactly(1, 2, 3, 4, 5); assertThat(this.repositoryService.createProcessDefinitionQuery() .processDefinitionTenantId("tenantA") .count()).isEqualTo(0); // Deploying another version should just up the version String processDefinitionIdNoTenant2 = deployOneTaskTestProcess(); assertThat(repositoryService.createProcessDefinitionQuery() .processDefinitionId(processDefinitionIdNoTenant2) .singleResult() .getVersion()) .isEqualTo(6); }