jinyanhui2008 commented on code in PR #12142:
URL: https://github.com/apache/dolphinscheduler/pull/12142#discussion_r980679532
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java:
##########
@@ -506,28 +516,43 @@ public Map<String, Object> updateTaskWithUpstream(User
loginUser, long projectCo
ProcessTaskRelation taskRelation = upstreamTaskRelations.get(0);
List<ProcessTaskRelation> processTaskRelations =
processTaskRelationMapper.queryByProcessCode(projectCode,
taskRelation.getProcessDefinitionCode());
List<ProcessTaskRelation> processTaskRelationList =
Lists.newArrayList(processTaskRelations);
- List<ProcessTaskRelation> relationList = Lists.newArrayList();
for (ProcessTaskRelation processTaskRelation :
processTaskRelationList) {
if (processTaskRelation.getPostTaskCode() == taskCode) {
if
(queryUpStreamTaskCodeMap.containsKey(processTaskRelation.getPreTaskCode()) &&
processTaskRelation.getPreTaskCode() != 0L) {
queryUpStreamTaskCodeMap.remove(processTaskRelation.getPreTaskCode());
} else {
processTaskRelation.setPreTaskCode(0L);
processTaskRelation.setPreTaskVersion(0);
- relationList.add(processTaskRelation);
}
}
}
- processTaskRelationList.removeAll(relationList);
for (Map.Entry<Long, TaskDefinition> queryUpStreamTask :
queryUpStreamTaskCodeMap.entrySet()) {
- taskRelation.setPreTaskCode(queryUpStreamTask.getKey());
-
taskRelation.setPreTaskVersion(queryUpStreamTask.getValue().getVersion());
- processTaskRelationList.add(taskRelation);
+ ProcessTaskRelation processTaskRelation = new
ProcessTaskRelation();
+ processTaskRelation.setPreTaskCode(queryUpStreamTask.getKey());
+
processTaskRelation.setPreTaskVersion(queryUpStreamTask.getValue().getVersion());
+ processTaskRelation.setPostTaskCode(taskCode);
+
processTaskRelation.setPostTaskVersion(taskDefinitionToUpdate.getVersion());
+ processTaskRelation.setConditionType(ConditionType.NONE);
+ processTaskRelation.setConditionParams("{}");
+ processTaskRelationList.add(processTaskRelation);
}
if (queryUpStreamTaskCodeMap.isEmpty() &&
!processTaskRelationList.isEmpty()) {
processTaskRelationList.add(processTaskRelationList.get(0));
}
- updateDag(loginUser, result,
taskRelation.getProcessDefinitionCode(), processTaskRelations,
Lists.newArrayList(taskDefinitionToUpdate));
+ processTaskRelationList.sort((p1, p2) ->
Long.compare(p2.getPreTaskCode(), p1.getPreTaskCode()));
+ boolean sign = false;
+ for (int i = 0; i < processTaskRelationList.size(); i++) {
+ ProcessTaskRelation processTaskRelation =
processTaskRelationList.get(i);
+ if (processTaskRelation.getPostTaskCode() == taskCode) {
+ if (processTaskRelation.getPreTaskCode() != 0) {
+ sign = true;
+ } else if (sign) {
+ processTaskRelationList.remove(processTaskRelation);
+ }
+ }
+ }
Review Comment:
In the workflow and task definition relation table, the number of the
predecessor task is 0. At this time, if a new predecessor task is defined for a
task, the old predecessor task with ID 0 is not cleared, resulting in redundant
data.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]