HomminLee commented on code in PR #11682:
URL: https://github.com/apache/dolphinscheduler/pull/11682#discussion_r956906424
##########
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:
> In fact, it's better to return the error process name rather than code,
but the interface receive codes...
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]