77 */
88package io .camunda .migration .data .impl .clients ;
99
10+ import static io .camunda .db .rdbms .write .domain .DecisionInstanceDbModel .*;
11+ import static io .camunda .db .rdbms .write .domain .ProcessInstanceDbModel .*;
1012import static io .camunda .migration .data .constants .MigratorConstants .C8_DEFAULT_TENANT ;
1113import static io .camunda .migration .data .impl .logging .C8ClientLogs .FAILED_TO_ACTIVATE_JOBS ;
1214import static io .camunda .migration .data .impl .logging .C8ClientLogs .FAILED_TO_CREATE_PROCESS_INSTANCE ;
3537import static io .camunda .migration .data .impl .logging .C8ClientLogs .FAILED_TO_SEARCH_DECISION_INSTANCES ;
3638import static io .camunda .migration .data .impl .logging .C8ClientLogs .FAILED_TO_SEARCH_FLOW_NODE_INSTANCES ;
3739import static io .camunda .migration .data .impl .logging .C8ClientLogs .FAILED_TO_SEARCH_PROCESS_DEFINITIONS ;
38- import static io .camunda .migration .data .impl .logging .C8ClientLogs .FAILED_TO_SEARCH_PROCESS_INSTANCE ;
3940import static io .camunda .migration .data .impl .logging .C8ClientLogs .FAILED_TO_SEARCH_USER_TASKS ;
4041import static io .camunda .migration .data .impl .util .ConverterUtil .getTenantId ;
4142import static io .camunda .migration .data .impl .util .ExceptionUtils .callApi ;
5960import io .camunda .db .rdbms .read .domain .DecisionInstanceDbQuery ;
6061import io .camunda .db .rdbms .read .domain .FlowNodeInstanceDbQuery ;
6162import io .camunda .db .rdbms .read .domain .ProcessDefinitionDbQuery ;
62- import io .camunda .db .rdbms .read .domain .ProcessInstanceDbQuery ;
6363import io .camunda .db .rdbms .read .domain .UserTaskDbQuery ;
6464import io .camunda .db .rdbms .sql .AuditLogMapper ;
6565import io .camunda .db .rdbms .sql .DecisionDefinitionMapper ;
8585import io .camunda .db .rdbms .write .domain .VariableDbModel ;
8686import io .camunda .db .rdbms .write .queue .BatchInsertDto ;
8787import io .camunda .migration .data .config .property .MigratorProperties ;
88+ import io .camunda .migration .data .impl .DataSourceRegistry ;
8889import io .camunda .migration .data .impl .identity .C8Authorization ;
8990import io .camunda .migration .data .impl .model .FlowNodeActivation ;
9091import io .camunda .search .entities .DecisionDefinitionEntity ;
@@ -113,6 +114,9 @@ public class C8Client {
113114 @ Autowired
114115 protected CamundaClient camundaClient ;
115116
117+ @ Autowired
118+ protected DataSourceRegistry dataSourceRegistry ;
119+
116120 // MyBatis mappers for history migration
117121 // These are optional because they're only available when C8 data source is configured
118122 @ Autowired (required = false )
@@ -267,7 +271,17 @@ public void insertProcessInstance(ProcessInstanceDbModel dbModel) {
267271 * Inserts Process Instance tags into the database.
268272 */
269273 public void insertProcessInstanceTags (ProcessInstanceDbModel dbModel ) {
270- callApi (() -> processInstanceMapper .insertTags (dbModel ), FAILED_TO_INSERT_PROCESS_INSTANCE );
274+ if (dataSourceRegistry .isOracle19 ()) {
275+ dbModel .tags ().forEach (tag -> callApi (() -> {
276+ var finalTag = new ProcessInstanceDbModelBuilder ()
277+ .processInstanceKey (dbModel .processInstanceKey ())
278+ .tags (Set .of (tag ))
279+ .build ();
280+ processInstanceMapper .insertTags (finalTag );
281+ }, FAILED_TO_INSERT_PROCESS_INSTANCE ));
282+ } else {
283+ callApi (() -> processInstanceMapper .insertTags (dbModel ), FAILED_TO_INSERT_PROCESS_INSTANCE );
284+ }
271285 }
272286
273287 /**
@@ -303,12 +317,33 @@ public List<DecisionDefinitionEntity> searchDecisionDefinitions(DecisionDefiniti
303317 */
304318 public void insertDecisionInstance (DecisionInstanceDbModel dbModel ) {
305319 callApi (() -> decisionInstanceMapper .insert (dbModel ), FAILED_TO_INSERT_DECISION_INSTANCE );
320+
306321 if (!dbModel .evaluatedInputs ().isEmpty ()) {
307- callApi (() -> decisionInstanceMapper .insertInput (dbModel ), FAILED_TO_INSERT_DECISION_INSTANCE_INPUT );
322+ if (dataSourceRegistry .isOracle19 ()) {
323+ dbModel .evaluatedInputs ().forEach (input -> callApi (() -> {
324+ var finalInput = new Builder ()
325+ .decisionInstanceId (dbModel .decisionInstanceId ())
326+ .evaluatedInputs (List .of (input ))
327+ .build ();
328+ decisionInstanceMapper .insertInput (finalInput );
329+ }, FAILED_TO_INSERT_DECISION_INSTANCE_INPUT ));
330+ } else {
331+ decisionInstanceMapper .insertInput (dbModel );
332+ }
308333 }
309334
310335 if (!dbModel .evaluatedOutputs ().isEmpty ()) {
311- callApi (() -> decisionInstanceMapper .insertOutput (dbModel ), FAILED_TO_INSERT_DECISION_INSTANCE_OUTPUT );
336+ if (dataSourceRegistry .isOracle19 ()) {
337+ dbModel .evaluatedOutputs ().forEach (output -> callApi (() -> {
338+ var finalOutput = new Builder ()
339+ .decisionInstanceId (dbModel .decisionInstanceId ())
340+ .evaluatedOutputs (List .of (output ))
341+ .build ();
342+ decisionInstanceMapper .insertOutput (finalOutput );
343+ }, FAILED_TO_INSERT_DECISION_INSTANCE_OUTPUT ));
344+ } else {
345+ decisionInstanceMapper .insertOutput (dbModel );
346+ }
312347 }
313348 }
314349
@@ -330,7 +365,7 @@ public void insertIncident(IncidentDbModel dbModel) {
330365 * Inserts a Variable into the database.
331366 */
332367 public void insertVariable (VariableDbModel dbModel ) {
333- callApi (() -> variableMapper .insert (new BatchInsertDto (List .of (dbModel ))), FAILED_TO_INSERT_VARIABLE );
368+ callApi (() -> variableMapper .insert (new BatchInsertDto <> (List .of (dbModel ))), FAILED_TO_INSERT_VARIABLE );
334369 }
335370
336371 /**
@@ -344,7 +379,17 @@ public void insertUserTask(UserTaskDbModel dbModel) {
344379 * Inserts User Task tags into the database.
345380 */
346381 public void insertUserTaskTags (UserTaskDbModel dbModel ) {
347- callApi (() -> userTaskMapper .insertTags (dbModel ), FAILED_TO_INSERT_USER_TASK );
382+ if (!dataSourceRegistry .isOracle19 ()) {
383+ callApi (() -> userTaskMapper .insertTags (dbModel ), FAILED_TO_INSERT_USER_TASK );
384+ } else {
385+ dbModel .tags ().forEach (tag -> callApi (() -> {
386+ var finalTag = new UserTaskDbModel .Builder ()
387+ .userTaskKey (dbModel .userTaskKey ())
388+ .tags (Set .of (tag ))
389+ .build ();
390+ userTaskMapper .insertTags (finalTag );
391+ }, FAILED_TO_INSERT_USER_TASK ));
392+ }
348393 }
349394
350395 /**
0 commit comments