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 2022/08/29 05:27:16 UTC

[GitHub] [dolphinscheduler] HomminLee commented on a diff in pull request #11682: [Improvement-11678][API] Improvement the error message when batch delete workflow

HomminLee commented on code in PR #11682:
URL: https://github.com/apache/dolphinscheduler/pull/11682#discussion_r956906155


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -698,6 +699,43 @@ public Map<String, Object> verifyProcessDefinitionName(User loginUser, long proj
         return result;
     }
 
+    @Override
+    public Map<String, Object> batchDeleteProcessDefinitionByCodes(User loginUser,
+                                                                   long projectCode,
+                                                                   String codes){
+        Map<String, Object> result = new HashMap<>();
+        Set<String> deleteFailedCodeSet = new HashSet<>();
+        if (!StringUtils.isEmpty(codes)) {
+            String[] processDefinitionCodeArray = codes.split(",");
+            for (String strProcessDefinitionCode : processDefinitionCodeArray) {
+                long code = Long.parseLong(strProcessDefinitionCode);
+                ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(code);
+                // check workflow exists, avoid null exception
+                if (processDefinition == null || projectCode != processDefinition.getProjectCode()) {
+                    deleteFailedCodeSet.add(MessageFormat.format(Status.PROCESS_DEFINE_NOT_EXIST.getMsg(), String.valueOf(code)));
+                    continue;
+                }
+                try {
+                    Map<String, Object> deleteResult = this.deleteProcessDefinitionByCode(loginUser, projectCode, code);
+                    if (!Status.SUCCESS.equals(deleteResult.get(Constants.STATUS))) {
+                        String errorMsg = MessageFormat.format(Status.DELETE_PROCESS_DEFINE_BY_CODES_ERROR.getMsg(), processDefinition.getName(), deleteResult.get(Constants.MSG));
+                        deleteFailedCodeSet.add(errorMsg);
+                        logger.error(errorMsg);
+                    }
+                } catch (Exception e) {
+                    deleteFailedCodeSet.add(MessageFormat.format(Status.DELETE_PROCESS_DEFINE_BY_CODES_ERROR.getMsg(), processDefinition.getName(), e.getMessage()));
+                }
+            }
+        }
+
+        if (!deleteFailedCodeSet.isEmpty()) {
+            putMsg(result, Status.BATCH_DELETE_PROCESS_DEFINE_BY_CODES_ERROR, "\n " + String.join("\n ", deleteFailedCodeSet));

Review Comment:
   You mean should write another interface which receive the names, instead of query the name by codes?



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

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