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 2020/09/18 11:38:01 UTC

[GitHub] [incubator-dolphinscheduler] Technoboy- commented on a change in pull request #3764: [Improvement][API] simplify with stream

Technoboy- commented on a change in pull request #3764:
URL: https://github.com/apache/incubator-dolphinscheduler/pull/3764#discussion_r490889287



##########
File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
##########
@@ -232,25 +232,14 @@
      * @return resource ids
      */
     private String getResourceIds(ProcessData processData) {
-        List<TaskNode> tasks = processData.getTasks();
-        Set<Integer> resourceIds = new HashSet<>();
-        for (TaskNode taskNode : tasks) {
-            String taskParameter = taskNode.getParams();
-            AbstractParameters params = TaskParametersUtils.getParameters(taskNode.getType(), taskParameter);
-            if (CollectionUtils.isNotEmpty(params.getResourceFilesList())) {
-                Set<Integer> tempSet = params.getResourceFilesList().stream().map(t -> t.getId()).collect(Collectors.toSet());
-                resourceIds.addAll(tempSet);
-            }
-        }
-
-        StringBuilder sb = new StringBuilder();
-        for (int i : resourceIds) {
-            if (sb.length() > 0) {
-                sb.append(",");
-            }
-            sb.append(i);
-        }
-        return sb.toString();
+        return processData.getTasks()
+                .stream()
+                .map(taskNode -> TaskParametersUtils.getParameters(taskNode.getType(), taskNode.getParams()))
+                .filter(Objects::nonNull)

Review comment:
       Filter here is for - AbstractParameters.  not for params.getResourceFilesList(). please check.




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