zhongjiajie commented on code in PR #14089:
URL: 
https://github.com/apache/dolphinscheduler/pull/14089#discussion_r1192961906


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java:
##########
@@ -76,6 +57,8 @@
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.tags.Tag;
 
+import static org.apache.dolphinscheduler.api.enums.Status.*;

Review Comment:
   Hi, please run `./mvnw spotless:apply` to auto-format your code, BTW, we do 
not accept wildcard import 



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -3054,4 +3057,46 @@ public void deleteOtherRelation(Project project, 
Map<String, Object> result, Pro
 
     }
 
+    /**
+     * Batch release process definitions by code states.
+     *
+     * @param loginUser    Login user.
+     * @param projectCode  Project code.
+     * @param codeStates   Code states in JSON format.
+     * @return Result of the batch release process definitions.
+     */
+    @Override
+    @Transactional
+    public Map<String, Object> batchReleaseProcessDefinitions(User loginUser, 
long projectCode, String codeStates) {
+        Map<String, Object> result = new HashMap<>();
+        if (StringUtils.isEmpty(codeStates)) {
+            log.error("Parameter codeStates is empty, projectCode is {}.", 
projectCode);
+            putMsg(new HashMap<>(), Status.PROCESS_DEFINITION_CODES_IS_EMPTY);

Review Comment:
   could you directly throw an exception instead of return hash 
map?https://github.com/apache/dolphinscheduler/blob/73b505f6397155ccdd007cf5fcabca9f6cc6447f/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java#L629



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java:
##########
@@ -521,4 +521,15 @@ void saveOtherRelation(User loginUser, ProcessDefinition 
processDefinition, Map<
      * @return variables data
      */
     Map<String, Object> viewVariables(User loginUser, long projectCode, long 
code);
+
+    /**
+     * Batch release process definitions by code states.
+     *
+     * @param loginUser    Login user.
+     * @param projectCode  Project code.
+     * @param codeStates   Code states in JSON format.
+     * @return Result of the batch release process definitions.
+     */
+    Map<String, Object> batchReleaseProcessDefinitions(User loginUser, long 
projectCode, String codeStates);

Review Comment:
   do you combine release or unreleased in one single interface? how about add 
two separate interface `batch release` and `batch unreleased`? which will keep 
our code more easier to read



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -3054,4 +3057,46 @@ public void deleteOtherRelation(Project project, 
Map<String, Object> result, Pro
 
     }
 
+    /**
+     * Batch release process definitions by code states.
+     *
+     * @param loginUser    Login user.
+     * @param projectCode  Project code.
+     * @param codeStates   Code states in JSON format.
+     * @return Result of the batch release process definitions.
+     */
+    @Override
+    @Transactional
+    public Map<String, Object> batchReleaseProcessDefinitions(User loginUser, 
long projectCode, String codeStates) {
+        Map<String, Object> result = new HashMap<>();
+        if (StringUtils.isEmpty(codeStates)) {
+            log.error("Parameter codeStates is empty, projectCode is {}.", 
projectCode);
+            putMsg(new HashMap<>(), Status.PROCESS_DEFINITION_CODES_IS_EMPTY);
+            return result;
+        }
+
+        try {
+            Map<String, String> codeStateMap = new Gson().fromJson(codeStates, 
new TypeToken<Map<String, String>>() {}.getType());
+
+            for (Map.Entry<String, String> entry : codeStateMap.entrySet()) {
+                String code = entry.getKey();
+                String releaseState = entry.getValue();
+
+                try {
+                    ReleaseState releaseStateEnum = 
ReleaseState.valueOf(releaseState);
+                    result = releaseProcessDefinition(loginUser, projectCode, 
Long.parseLong(code), releaseStateEnum);
+                } catch (IllegalArgumentException e) {
+                    log.error("Invalid releaseState '{}' in codeStates JSON, 
projectCode is {}.", releaseState, projectCode);
+                    putMsg(result, Status.INVALID_CODE_STATES_JSON);

Review Comment:
   same here. exception.



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