2929import org .flowable .engine .impl .persistence .entity .BpmnEngineEntityConstants ;
3030import org .flowable .engine .impl .persistence .entity .ExecutionEntity ;
3131import org .flowable .engine .impl .util .CommandContextUtil ;
32+ import org .flowable .engine .repository .ProcessDefinition ;
3233import org .flowable .engine .runtime .ProcessInstance ;
3334import org .flowable .engine .runtime .ProcessInstanceBuilder ;
3435import org .flowable .form .api .FormInfo ;
@@ -56,30 +57,27 @@ public String generateNewProcessInstanceId() {
5657 }
5758
5859 @ Override
59- public String startProcessInstanceByKey (String processDefinitionKey , String predefinedProcessInstanceId , String stageInstanceId ,
60- String tenantId , Boolean fallbackToDefaultTenant , String parentDeploymentId , Map <String , Object > inParametersMap , String businessKey ,
60+ public String startProcessInstance (String processDefinitionId , String predefinedProcessInstanceId , String stageInstanceId ,
61+ String tenantId , Map <String , Object > inParametersMap , String businessKey ,
6162 Map <String , Object > variableFormVariables , FormInfo variableFormInfo , String variableFormOutcome ) {
62-
63- return startProcessInstanceByKey ( processDefinitionKey , predefinedProcessInstanceId , null , stageInstanceId , tenantId , fallbackToDefaultTenant ,
64- parentDeploymentId , inParametersMap , businessKey , variableFormVariables , variableFormInfo , variableFormOutcome );
63+
64+ return startProcessInstance ( processDefinitionId , predefinedProcessInstanceId , null , stageInstanceId , tenantId ,
65+ inParametersMap , businessKey , variableFormVariables , variableFormInfo , variableFormOutcome );
6566 }
6667
6768 @ Override
68- public String startProcessInstanceByKey (String processDefinitionKey , String predefinedProcessInstanceId , String planItemInstanceId , String stageInstanceId ,
69- String tenantId , Boolean fallbackToDefaultTenant , String parentDeploymentId , Map <String , Object > inParametersMap , String businessKey ,
69+ public String startProcessInstance (String processDefinitionId , String predefinedProcessInstanceId , String planItemInstanceId , String stageInstanceId ,
70+ String tenantId , Map <String , Object > inParametersMap , String businessKey ,
7071 Map <String , Object > variableFormVariables , FormInfo variableFormInfo , String variableFormOutcome ) {
71-
72+
7273 ProcessInstanceBuilder processInstanceBuilder = processEngineConfiguration .getRuntimeService ().createProcessInstanceBuilder ();
73- processInstanceBuilder .processDefinitionKey (processDefinitionKey );
74+ processInstanceBuilder .processDefinitionId (processDefinitionId );
75+
7476 if (tenantId != null ) {
7577 processInstanceBuilder .tenantId (tenantId );
7678 processInstanceBuilder .overrideProcessDefinitionTenantId (tenantId );
7779 }
7880
79- if (parentDeploymentId != null ) {
80- processInstanceBuilder .processDefinitionParentDeploymentId (parentDeploymentId );
81- }
82-
8381 processInstanceBuilder .predefineProcessInstanceId (predefinedProcessInstanceId );
8482
8583 if (planItemInstanceId != null ) {
@@ -91,10 +89,6 @@ public String startProcessInstanceByKey(String processDefinitionKey, String pred
9189 processInstanceBuilder .variable (target , inParametersMap .get (target ));
9290 }
9391
94- if (fallbackToDefaultTenant != null && fallbackToDefaultTenant ) {
95- processInstanceBuilder .fallbackToDefaultTenant ();
96- }
97-
9892 if (businessKey != null ) {
9993 processInstanceBuilder .businessKey (businessKey );
10094 }
@@ -146,6 +140,30 @@ public List<IOParameter> getOutputParametersOfCaseTask(String executionId) {
146140 return cmmnParameters ;
147141 }
148142
143+ @ Override
144+ public String resolveProcessDefinitionId (String processDefinitionKey , String tenantId ,
145+ Boolean fallbackToDefaultTenant , String parentDeploymentId ) {
146+ ProcessDefinition processDefinition = processEngineConfiguration .getProcessInstanceHelper ()
147+ .resolveProcessDefinition (processDefinitionKey , tenantId ,
148+ Boolean .TRUE .equals (fallbackToDefaultTenant ) || processEngineConfiguration .isFallbackToDefaultTenant (),
149+ parentDeploymentId , processEngineConfiguration );
150+ return processDefinition .getId ();
151+ }
152+
153+ @ Override
154+ public boolean isHistoryEnabledForProcessDefinitionId (String processDefinitionId ) {
155+ return processEngineConfiguration .getHistoryConfigurationSettings ().isHistoryEnabled (processDefinitionId );
156+ }
157+
158+ @ Override
159+ public boolean isHistoryEnabledForProcessInstance (String processInstanceId ) {
160+ ExecutionEntity execution = processEngineConfiguration .getExecutionEntityManager ().findById (processInstanceId );
161+ if (execution != null ) {
162+ return processEngineConfiguration .getHistoryConfigurationSettings ().isHistoryEnabled (execution .getProcessDefinitionId ());
163+ }
164+ return processEngineConfiguration .getHistoryConfigurationSettings ().isHistoryEnabled ();
165+ }
166+
149167 @ Override
150168 public void deleteProcessInstance (String processInstanceId ) {
151169 processEngineConfiguration .getCommandExecutor ().execute (commandContext -> {
0 commit comments