|
|
@ -20,11 +20,11 @@ package org.apache.dolphinscheduler.api.service.impl; |
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
import org.apache.dolphinscheduler.api.service.WorkFlowLineageService; |
|
|
|
import org.apache.dolphinscheduler.api.service.WorkFlowLineageService; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.utils.StringUtils; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessLineage; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessLineage; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Project; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Project; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.WorkFlowLineage; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.WorkFlowLineage; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.WorkFlowRelation; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.WorkFlowRelation; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.WorkFlowLineageMapper; |
|
|
|
import org.apache.dolphinscheduler.dao.mapper.WorkFlowLineageMapper; |
|
|
|
|
|
|
|
|
|
|
@ -46,9 +46,6 @@ public class WorkFlowLineageServiceImpl extends BaseServiceImpl implements WorkF |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private WorkFlowLineageMapper workFlowLineageMapper; |
|
|
|
private WorkFlowLineageMapper workFlowLineageMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private ProcessDefinitionMapper processDefinitionMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ProjectMapper projectMapper; |
|
|
|
private ProjectMapper projectMapper; |
|
|
|
|
|
|
|
|
|
|
@ -66,48 +63,41 @@ public class WorkFlowLineageServiceImpl extends BaseServiceImpl implements WorkF |
|
|
|
Set<WorkFlowRelation> workFlowRelations, |
|
|
|
Set<WorkFlowRelation> workFlowRelations, |
|
|
|
ProcessLineage processLineage) { |
|
|
|
ProcessLineage processLineage) { |
|
|
|
List<ProcessLineage> relations = workFlowLineageMapper.queryCodeRelation( |
|
|
|
List<ProcessLineage> relations = workFlowLineageMapper.queryCodeRelation( |
|
|
|
processLineage.getPostTaskCode(), processLineage.getPostTaskVersion() |
|
|
|
processLineage.getPostTaskCode(), processLineage.getPostTaskVersion(), |
|
|
|
, processLineage.getProcessDefinitionCode(), processLineage.getProjectCode()); |
|
|
|
processLineage.getProcessDefinitionCode(), processLineage.getProjectCode()); |
|
|
|
|
|
|
|
if (!relations.isEmpty()) { |
|
|
|
for (ProcessLineage relation : relations) { |
|
|
|
Set<Integer> preWorkFlowIds = new HashSet<>(); |
|
|
|
if (relation.getProcessDefinitionCode() != null) { |
|
|
|
List<ProcessLineage> preRelations = workFlowLineageMapper.queryCodeRelation( |
|
|
|
|
|
|
|
processLineage.getPreTaskCode(), processLineage.getPreTaskVersion(), |
|
|
|
relation.setPreTaskCode(processLineage.getPostTaskCode()); |
|
|
|
processLineage.getProcessDefinitionCode(), processLineage.getProjectCode()); |
|
|
|
relation.setPreTaskVersion(processLineage.getPostTaskVersion()); |
|
|
|
for (ProcessLineage preRelation : preRelations) { |
|
|
|
|
|
|
|
WorkFlowLineage pre = workFlowLineageMapper.queryWorkFlowLineageByCode( |
|
|
|
WorkFlowLineage pre = workFlowLineageMapper |
|
|
|
preRelation.getProcessDefinitionCode(), preRelation.getProjectCode()); |
|
|
|
.queryWorkFlowLineageByCode(processLineage.getProcessDefinitionCode(), processLineage.getProjectCode()); |
|
|
|
preWorkFlowIds.add(pre.getWorkFlowId()); |
|
|
|
// sourceWorkFlowId = ""
|
|
|
|
|
|
|
|
if (!workFlowLineageMap.containsKey(pre.getWorkFlowId())) { |
|
|
|
|
|
|
|
workFlowLineageMap.put(pre.getWorkFlowId(), pre); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ProcessLineage postRelation = relations.get(0); |
|
|
|
WorkFlowLineage post = workFlowLineageMapper |
|
|
|
WorkFlowLineage post = workFlowLineageMapper.queryWorkFlowLineageByCode( |
|
|
|
.queryWorkFlowLineageByCode(relation.getProcessDefinitionCode(), relation.getProjectCode()); |
|
|
|
postRelation.getProcessDefinitionCode(), postRelation.getProjectCode()); |
|
|
|
|
|
|
|
if (!workFlowLineageMap.containsKey(post.getWorkFlowId())) { |
|
|
|
if (workFlowLineageMap.containsKey(post.getWorkFlowId())) { |
|
|
|
post.setSourceWorkFlowId(StringUtils.join(preWorkFlowIds, ",")); |
|
|
|
|
|
|
|
workFlowLineageMap.put(post.getWorkFlowId(), post); |
|
|
|
|
|
|
|
} else { |
|
|
|
WorkFlowLineage workFlowLineage = workFlowLineageMap.get(post.getWorkFlowId()); |
|
|
|
WorkFlowLineage workFlowLineage = workFlowLineageMap.get(post.getWorkFlowId()); |
|
|
|
String sourceWorkFlowId = workFlowLineage.getSourceWorkFlowId(); |
|
|
|
String sourceWorkFlowId = workFlowLineage.getSourceWorkFlowId(); |
|
|
|
if (sourceWorkFlowId.equals("")) { |
|
|
|
if (sourceWorkFlowId.equals("")) { |
|
|
|
workFlowLineage.setSourceWorkFlowId(String.valueOf(pre.getWorkFlowId())); |
|
|
|
workFlowLineage.setSourceWorkFlowId(StringUtils.join(preWorkFlowIds, ",")); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
workFlowLineage.setSourceWorkFlowId(sourceWorkFlowId + "," + pre.getWorkFlowId()); |
|
|
|
if (!preWorkFlowIds.isEmpty()) { |
|
|
|
|
|
|
|
workFlowLineage.setSourceWorkFlowId(sourceWorkFlowId + "," + StringUtils.join(preWorkFlowIds, ",")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
post.setSourceWorkFlowId(String.valueOf(pre.getWorkFlowId())); |
|
|
|
|
|
|
|
workFlowLineageMap.put(post.getWorkFlowId(), post); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WorkFlowRelation workFlowRelation = new WorkFlowRelation(); |
|
|
|
|
|
|
|
workFlowRelation.setSourceWorkFlowId(pre.getWorkFlowId()); |
|
|
|
|
|
|
|
workFlowRelation.setTargetWorkFlowId(post.getWorkFlowId()); |
|
|
|
|
|
|
|
if (workFlowRelations.contains(workFlowRelation)) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
workFlowRelations.add(workFlowRelation); |
|
|
|
if (preWorkFlowIds.isEmpty()) { |
|
|
|
getRelation(workFlowLineageMap, workFlowRelations, relation); |
|
|
|
workFlowRelations.add(new WorkFlowRelation(0, post.getWorkFlowId())); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
for (Integer workFlowId : preWorkFlowIds) { |
|
|
|
|
|
|
|
workFlowRelations.add(new WorkFlowRelation(workFlowId, post.getWorkFlowId())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|