Skip to content

Commit 88bb1cf

Browse files
committed
chore(PR): implement PR comments
1 parent f9109f8 commit 88bb1cf

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

data-migrator/core/src/main/java/io/camunda/migration/data/impl/history/migrator/ProcessInstanceMigrator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public Long migrateTransactionally(HistoricProcessInstance c7ProcessInstance) {
9191
var builder = new ProcessInstanceDbModelBuilder();
9292

9393
Long processInstanceKey = getNextKey();
94+
Long rootProcessInstanceKey = null;
9495
builder.processInstanceKey(processInstanceKey);
9596
if (processDefinitionKey != null) {
9697
builder.processDefinitionKey(processDefinitionKey);
@@ -113,6 +114,7 @@ public Long migrateTransactionally(HistoricProcessInstance c7ProcessInstance) {
113114
} else if (c7RootProcessInstanceId != null && isMigrated(c7RootProcessInstanceId, HISTORY_PROCESS_INSTANCE)) {
114115
ProcessInstanceEntity rootProcessInstance = findProcessInstanceByC7Id(c7RootProcessInstanceId);
115116
if (rootProcessInstance != null && rootProcessInstance.processInstanceKey() != null) {
117+
rootProcessInstanceKey = rootProcessInstance.processInstanceKey();
116118
builder.rootProcessInstanceKey(rootProcessInstance.processInstanceKey());
117119
}
118120
}
@@ -125,7 +127,7 @@ public Long migrateTransactionally(HistoricProcessInstance c7ProcessInstance) {
125127
builder
126128
.historyCleanupDate(c8HistoryCleanupDate)
127129
.endDate(c8EndTime)
128-
.treePath(generateTreepath(builder.build().rootProcessInstanceKey(), processInstanceKey));
130+
.treePath(generateTreepath(rootProcessInstanceKey, processInstanceKey));
129131

130132
ProcessInstanceDbModel dbModel = convert(C7Entity.of(c7ProcessInstance), builder);
131133

@@ -180,7 +182,7 @@ protected void resolveParentFlowNodeInstanceKey(
180182

181183
/**
182184
* Generates a tree path for process instances in the format:
183-
* PI_rootProcessInstanceKey/processInstanceKey or
185+
* PI_rootProcessInstanceKey/PI_processInstanceKey or
184186
* PI_processInstanceKey if this instance is the root of the hierarchy
185187
*
186188
* @param rootProcessInstanceKey the root process instance key

data-migrator/qa/integration-tests/src/test/java/io/camunda/migration/data/qa/history/entity/HistoryProcessInstanceTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ public void shouldPopulateRootProcessInstanceKeyForCallActivity() {
223223

224224
// Sub process should have rootProcessInstanceKey pointing to the parent
225225
assertThat(sub.rootProcessInstanceKey()).isEqualTo(parent.processInstanceKey());
226-
227-
226+
228227
// Verify that flow nodes also have rootProcessInstanceKey
229228
List<FlowNodeInstanceEntity> subFlowNodes = searchHistoricFlowNodes(sub.processInstanceKey());
230229
assertThat(subFlowNodes).isNotEmpty();

0 commit comments

Comments
 (0)