You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2021/01/25 09:16:17 UTC

[GitHub] [incubator-dolphinscheduler] lenboo commented on a change in pull request #4555: [FIX-2101]It solves the problem that the name of the branch will not change after the name of the branch is changed in the workflow page and instance page.

lenboo commented on a change in pull request #4555:
URL: https://github.com/apache/incubator-dolphinscheduler/pull/4555#discussion_r563565413



##########
File path: dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
##########
@@ -1990,4 +1990,60 @@ public String formatTaskAppId(TaskInstance taskInstance) {
             taskInstance.getId());
     }
 
+    /**
+     * solve the branch rename bug
+     *
+     * @param processData
+     * @param oldProcessData
+     * @return String
+     */
+    public String changeJson(ProcessData processData,ProcessData oldProcessData) {
+        HashMap<String, String> oldNameTaskId = new HashMap<>();
+        List<TaskNode> oldTasks = oldProcessData.getTasks();
+        for (int i = 0; i < oldTasks.size(); i++) {
+            TaskNode taskNode = oldTasks.get(i);
+            String oldName = taskNode.getName();
+            String oldId = taskNode.getId();
+            oldNameTaskId.put(oldName, oldId);
+        }
+
+        // take the processdefinitionjson saved this time, and then save the taskid and name
+        HashMap<String, String> newNameTaskId = new HashMap<>();
+        List<TaskNode> newTasks = processData.getTasks();
+        for (int i = 0; i < newTasks.size(); i++) {
+            TaskNode taskNode = newTasks.get(i);
+            String newId = taskNode.getId();
+            String newName = taskNode.getName();
+            newNameTaskId.put(newId, newName);
+        }
+
+        // replace the previous conditionresult with a new one
+        List<TaskNode> tasks = processData.getTasks();
+        for (int i = 0; i < tasks.size(); i++) {
+            TaskNode taskNode = newTasks.get(i);
+            String type = taskNode.getType();
+            if ("CONDITIONS".equals(type)) {

Review comment:
       you can use  enum TaskType instead of string.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org