caishunfeng commented on code in PR #16288:
URL:
https://github.com/apache/dolphinscheduler/pull/16288#discussion_r1673354117
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -1013,14 +1077,12 @@ private void
processDefinitionUsedInOtherTaskValid(ProcessDefinition processDefi
}
// check process used by other task, including subprocess and
dependent task type
- Set<TaskMainInfo> taskDepOnProcess = workFlowLineageService
- .queryTaskDepOnProcess(processDefinition.getProjectCode(),
processDefinition.getCode());
- if (CollectionUtils.isNotEmpty(taskDepOnProcess)) {
- String taskDepDetail = taskDepOnProcess.stream()
- .map(task -> String.format(Constants.FORMAT_S_S_COLON,
task.getProcessDefinitionName(),
- task.getTaskName()))
- .collect(Collectors.joining(Constants.COMMA));
- throw new
ServiceException(Status.DELETE_PROCESS_DEFINITION_USE_BY_OTHER_FAIL,
taskDepDetail);
+ Optional<String> taskDepMsg =
processLineageService.taskDependentMsg(processDefinition.getProjectCode(),
+ processDefinition.getCode(), 0);
+
+ if (taskDepMsg.isPresent()) {
+ log.error("Process definition cannot be deleted because it has
dependent, {}", taskDepMsg.get());
+ throw new ServiceException(taskDepMsg.get());
Review Comment:
```suggestion
throw new ServiceException("Process definition cannot be deleted
because it has dependent, " + taskDepMsg.get());
```
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/constants/Constants.java:
##########
@@ -482,11 +482,9 @@ private Constants() {
public static final String TOTAL = "total";
- /**
- * workflow
- */
- public static final String WORKFLOW_LIST = "workFlowList";
- public static final String WORKFLOW_RELATION_LIST = "workFlowRelationList";
+ public static final long DEFAULT_PROJECT_CODE = 0;
+
+ public static final long DEFAULT_TASK_CODE = 0;
Review Comment:
```suggestion
public static final long DEPENDENT_ALL_TASK = 0;
```
##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessLineageMapper.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.dao.mapper;
+
+import org.apache.dolphinscheduler.dao.entity.ProcessLineage;
+import org.apache.dolphinscheduler.dao.entity.WorkFlowRelationDetail;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+public interface ProcessLineageMapper extends BaseMapper<ProcessLineage> {
+
+ int batchDeleteByProcessDefinitionCode(@Param("processDefinitionCodes")
List<Long> processDefinitionCodes);
+
+ int batchInsert(@Param("processLineages") List<ProcessLineage>
processLineages);
+
+ List<ProcessLineage> queryByProjectCode(@Param("projectCode") long
projectCode);
+
+ List<WorkFlowRelationDetail>
queryWorkFlowLineageByCode(@Param("processDefinitionCode") long
processDefinitionCode);
+
+ List<WorkFlowRelationDetail>
queryWorkFlowLineageByName(@Param("projectCode") long projectCode,
+
@Param("processDefinitionName") String processDefinitionName);
+
+ List<ProcessLineage> queryWorkFlowLineageByDept(@Param("deptProjectCode")
long deptProjectCode,
+
@Param("deptProcessDefinitionCode") long deptProcessDefinitionCode,
+
@Param("deptTaskDefinitionCode") long deptTaskDefinitionCode);
+
+ List<ProcessLineage>
queryByProcessDefinitionCode(@Param("processDefinitionCode") long
processDefinitionCode);
+
+ void truncateTable();
Review Comment:
Should remove this method because we don't need to truncate table in ds.
##########
dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.0_schema/mysql/dolphinscheduler_ddl.sql:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+DROP TABLE IF EXISTS `t_ds_process_lineage`;
+CREATE TABLE `t_ds_process_lineage`
Review Comment:
It's better to add table check, which can make the upgrade script more
stronger, although this process does satisfy the current version iteration
strategy.
--
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]