kevinjmh commented on code in PR #11490:
URL: https://github.com/apache/dolphinscheduler/pull/11490#discussion_r999030930


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -1025,11 +1025,26 @@ public void deleteProcessDefinitionByCode(User 
loginUser, long code) {
             logger.error("Delete process definition error, 
processDefinitionCode:{}.", code);
             throw new 
ServiceException(Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR);
         }
-        int deleteRelation = 
processTaskRelationMapper.deleteByCode(project.getCode(), 
processDefinition.getCode());
-        if (deleteRelation == 0) {
-            logger.warn(
+        processDefinitionLogMapper.deleteByProcessDefinitionCode(code);
+        List<ProcessTaskRelation> processTaskRelations =
+                
processTaskRelationMapper.queryByProcessCode(project.getCode(), code);
+        if (!processTaskRelations.isEmpty()) {
+            int deleteRelation = 
processTaskRelationMapper.deleteByCode(project.getCode(), code);
+            if (deleteRelation == 0) {
+                logger.warn(
                     "The process definition has not relation, it will be 
delete successfully, processDefinitionCode:{}.",
                     code);
+            } else {
+                processTaskRelationLogMapper.deleteByProcessCode(code);
+                // delete relation task definition
+                List<Long> taskCodeList = 
processTaskRelations.stream().map(ProcessTaskRelation::getPostTaskCode)
+                        .collect(Collectors.toList());
+                int deleteTask = 
taskDefinitionMapper.deleteByCodeList(taskCodeList);
+                if (deleteTask == 0) {
+                    throw new 
ServiceException(Status.DELETE_TASK_DEFINE_BY_CODE_ERROR);

Review Comment:
   use warning instead of 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