SbloodyS commented on code in PR #16288:
URL:
https://github.com/apache/dolphinscheduler/pull/16288#discussion_r1671714317
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -828,7 +888,7 @@ private void taskUsedInOtherTaskValid(ProcessDefinition
processDefinition,
boolean oldTaskExists = taskRelationList.stream()
.anyMatch(relation ->
oldProcessTaskRelation.getPostTaskCode() == relation.getPostTaskCode());
if (!oldTaskExists) {
- Optional<String> taskDepMsg =
workFlowLineageService.taskDepOnTaskMsg(
+ Optional<String> taskDepMsg =
processLineageService.taskDependentMsg(
Review Comment:
I think this needs to be retained for now, because the front end uses this
to show the results of dependencies.
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -2219,6 +2280,30 @@ public Map<String, Object>
switchProcessDefinitionVersion(User loginUser, long p
putMsg(result, Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR);
throw new
ServiceException(Status.SWITCH_PROCESS_DEFINITION_VERSION_ERROR);
}
+
+ List<ProcessTaskRelation> processTaskRelationList =
processTaskRelationMapper
+
.queryProcessTaskRelationsByProcessDefinitionCode(processDefinitionLog.getCode(),
+ processDefinitionLog.getVersion());
+ List<TaskDefinition> taskDefinitionList = new ArrayList<>();
+ for (ProcessTaskRelation processTaskRelation :
processTaskRelationList) {
+ if (processTaskRelation.getPreTaskCode() != 0) {
+ TaskDefinition taskDefinition = new TaskDefinition();
+ taskDefinition.setCode(processTaskRelation.getPreTaskCode());
+
taskDefinition.setVersion(processTaskRelation.getPreTaskVersion());
+ taskDefinitionList.add(taskDefinition);
+ }
+ if (processTaskRelation.getPostTaskCode() != 0) {
+ TaskDefinition taskDefinition = new TaskDefinition();
+ taskDefinition.setCode(processTaskRelation.getPostTaskCode());
+
taskDefinition.setVersion(processTaskRelation.getPostTaskVersion());
+ taskDefinitionList.add(taskDefinition);
Review Comment:
Fixed.
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessLineageServiceImpl.java:
##########
@@ -0,0 +1,321 @@
+/*
+ * 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.api.service.impl;
+
+import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.exceptions.ServiceException;
+import org.apache.dolphinscheduler.api.service.ProcessLineageService;
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.dao.entity.DependentLineageTask;
+import org.apache.dolphinscheduler.dao.entity.DependentProcessDefinition;
+import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
+import org.apache.dolphinscheduler.dao.entity.ProcessLineage;
+import org.apache.dolphinscheduler.dao.entity.Project;
+import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
+import org.apache.dolphinscheduler.dao.entity.WorkFlowRelation;
+import org.apache.dolphinscheduler.dao.entity.WorkFlowRelationDetail;
+import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
+import org.apache.dolphinscheduler.dao.mapper.ProcessLineageMapper;
+import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
+import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper;
+import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+/**
+ * work flow lineage service impl
+ */
+@Slf4j
+@Service
+public class ProcessLineageServiceImpl extends BaseServiceImpl implements
ProcessLineageService {
+
+ @Autowired
+ private ProjectMapper projectMapper;
+
+ @Autowired
+ private TaskDefinitionLogMapper taskDefinitionLogMapper;
+
+ @Autowired
+ private TaskDefinitionMapper taskDefinitionMapper;
+
+ @Autowired
+ private ProcessLineageMapper processLineageMapper;
+ @Autowired
+ private ProcessDefinitionMapper processDefinitionMapper;
+
+ @Override
+ public List<WorkFlowRelationDetail> queryWorkFlowLineageByName(long
projectCode, String processDefinitionName) {
+ Project project = projectMapper.queryByCode(projectCode);
+ if (project == null) {
+ throw new ServiceException(Status.PROJECT_NOT_FOUND, projectCode);
+ }
+ return processLineageMapper.queryWorkFlowLineageByName(projectCode,
processDefinitionName);
+ }
+
+ @Override
+ public Map<String, Object> queryWorkFlowLineageByCode(long projectCode,
long processDefinitionCode) {
+ Map<String, Object> result = new HashMap<>();
+ Project project = projectMapper.queryByCode(projectCode);
+ if (project == null) {
+ log.error("Project does not exist, projectCode:{}.", projectCode);
+ putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
+ return result;
+ }
+ List<ProcessLineage> upstreamProcessLineageList =
+
processLineageMapper.queryByProcessDefinitionCode(processDefinitionCode);
+ List<ProcessLineage> downstreamProcessLineageList =
+ processLineageMapper.queryWorkFlowLineageByDept(projectCode,
processDefinitionCode, 0);
+ List<ProcessLineage> totalProcessLineageList =
+ Stream.of(upstreamProcessLineageList,
downstreamProcessLineageList)
+ .flatMap(List::stream)
+ .collect(Collectors.toList());
+
+ List<WorkFlowRelation> workFlowRelationList =
getWorkFlowRelations(totalProcessLineageList);
+ List<WorkFlowRelationDetail> workFlowRelationDetailList =
+ getWorkflowRelationDetails(totalProcessLineageList.stream()
+ .flatMap(pl -> {
+ List<Long> processDefinitionCodes = new
ArrayList<>();
+
processDefinitionCodes.add(pl.getProcessDefinitionCode());
+
processDefinitionCodes.add(pl.getDeptProcessDefinitionCode());
+ return processDefinitionCodes.stream();
+ }).distinct().collect(Collectors.toList()));
+
+ Map<String, Object> workFlowLists = new HashMap<>();
+ workFlowLists.put(Constants.WORKFLOW_RELATION_DETAIL_LIST,
workFlowRelationDetailList);
+ workFlowLists.put(Constants.WORKFLOW_RELATION_LIST,
workFlowRelationList);
+ result.put(Constants.DATA_LIST, workFlowLists);
+ putMsg(result, Status.SUCCESS);
Review Comment:
Fixed.
--
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]