JinyLeeChina commented on a change in pull request #5828:
URL: https://github.com/apache/dolphinscheduler/pull/5828#discussion_r671253950



##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
##########
@@ -97,28 +100,53 @@
             return result;
         }
 
-        TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, 
TaskNode.class);
-        checkTaskNode(result, taskNode, taskDefinitionJson);
-        if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID
-                || result.get(Constants.STATUS) == 
Status.PROCESS_NODE_S_PARAMETER_INVALID) {
-            return result;
+        List<TaskDefinition> taskDefinitions = 
JSONUtils.toList(taskDefinitionJson, TaskDefinition.class);

Review comment:
       JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class)

##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
##########
@@ -232,6 +260,17 @@ public void checkTaskNode(Map<String, Object> result, 
TaskNode taskNode, String
         }
     }
 
+    public void checkTaskDefinition(Map<String, Object> result, TaskDefinition 
taskDefinition, String taskDefinitionJson) {
+        if (taskDefinition == null) {

Review comment:
       It's not necessary, and please use private method

##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
##########
@@ -97,28 +100,53 @@
             return result;
         }
 
-        TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, 
TaskNode.class);
-        checkTaskNode(result, taskNode, taskDefinitionJson);
-        if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID
-                || result.get(Constants.STATUS) == 
Status.PROCESS_NODE_S_PARAMETER_INVALID) {
-            return result;
+        List<TaskDefinition> taskDefinitions = 
JSONUtils.toList(taskDefinitionJson, TaskDefinition.class);
+        int totalSuccessNumber = 0;
+        List<Long> totalSuccessCode = new ArrayList<>();
+        List<TaskDefinition> taskDefinitionList = new ArrayList<>();
+        List<TaskDefinitionLog> taskDefinitionLogsList = new ArrayList<>();
+        for (TaskDefinition taskDefinition : taskDefinitions) {
+            checkTaskDefinition(result, taskDefinition, taskDefinitionJson);
+            if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID
+                    || result.get(Constants.STATUS) == 
Status.PROCESS_NODE_S_PARAMETER_INVALID) {
+                return result;
+            }
+            taskDefinition.setProjectCode(projectCode);
+            taskDefinition.setUserId(loginUser.getId());
+            taskDefinition.setVersion(1);
+            Date now = new Date();
+            taskDefinition.setCreateTime(now);
+            taskDefinition.setUpdateTime(now);
+            long code = 0L;
+            try {
+                code = SnowFlakeUtils.getInstance().nextId();
+                taskDefinition.setCode(code);
+            } catch (SnowFlakeException e) {
+                logger.error("Task code get error, ", e);
+            }
+            if (code == 0L) {

Review comment:
       It's unnecessary to judge the code here. You can put the if code block 
into the catch

##########
File path: 
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/TaskDefinition.java
##########
@@ -395,6 +395,10 @@ public void setDelayTime(int delayTime) {
         this.delayTime = delayTime;
     }
 
+    public String getDependence() {
+        return JSONUtils.getNodeString(this.taskParams, "dependence");

Review comment:
       It's better to use Constants.DEPENDENCE instead of "dependence"

##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
##########
@@ -97,28 +100,53 @@
             return result;
         }
 
-        TaskNode taskNode = JSONUtils.parseObject(taskDefinitionJson, 
TaskNode.class);
-        checkTaskNode(result, taskNode, taskDefinitionJson);
-        if (result.get(Constants.STATUS) == DATA_IS_NOT_VALID
-                || result.get(Constants.STATUS) == 
Status.PROCESS_NODE_S_PARAMETER_INVALID) {
-            return result;
+        List<TaskDefinition> taskDefinitions = 
JSONUtils.toList(taskDefinitionJson, TaskDefinition.class);
+        int totalSuccessNumber = 0;
+        List<Long> totalSuccessCode = new ArrayList<>();
+        List<TaskDefinition> taskDefinitionList = new ArrayList<>();

Review comment:
       There is no need to define a taskDefinition list here, you can use 
taskDefinitonLog list




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


Reply via email to