Commit a3ba0768 by qiuchaofei

添加file类型,以及file与table的关系

parent 88802b2a
......@@ -44,6 +44,8 @@ public class RelationalGraphController {
private MultiModelService multiModelService;
@Autowired
private IFileService fileService ;
@Autowired
private IETLScriptService etlScriptService ;
@Autowired
private IETLJobService etlJobService ;
......@@ -231,7 +233,6 @@ public class RelationalGraphController {
ReturnReslult returnReslult = metadataRelationService.filterJosnByModelName(resultJson,filterModel,retainModel);
return returnReslult;
}
//表的分析,链路分析,表与其他表的上下游关系,其他表可以继续下钻,并且可以收缩。
@ApiOperation(tags = "", value = "传入表的id,返回表的上下游一层关系。")
@RequestMapping(path = "/getRelationTablesTableId", method = RequestMethod.GET)
......@@ -240,12 +241,12 @@ public class RelationalGraphController {
long start = System.currentTimeMillis();
if(tableId.startsWith("Table=")){
relationTables = tableService.getSourceAndTargetTableByTableId (tableId);
}else if(tableId.startsWith("ETLJob=")){
relationTables = etlJobService.getSourceAndTargetObjectByMedataDataId (tableId);
}else if(tableId.startsWith("ETLScript=")){
relationTables = etlScriptService.getSourceAndTargetObjectByMedataDataId (tableId);
}else if(tableId.startsWith("File=")){
relationTables = fileService.getSourceAndTargetObjectByMedataDataId (tableId);
}
long end = System.currentTimeMillis();
......
package com.keymobile.metadata.metadataRelation.pojo.metadata;
import com.keymobile.metadata.metadataRelation.pojo.BaseNode;
import org.neo4j.ogm.annotation.NodeEntity;
@NodeEntity(label="Neo4jFile")
public class Neo4jFile extends BaseNode {
}
package com.keymobile.metadata.metadataRelation.respository.metadata;
import com.keymobile.metadata.metadataRelation.pojo.BaseNode;
import com.keymobile.metadata.metadataRelation.pojo.metadata.Neo4jETLScript;
import com.keymobile.metadata.metadataRelation.pojo.metadata.Neo4jFile;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;
public interface Neo4jFileRepository extends Neo4jRepository<Neo4jFile, Long> {
//match(n:Neo4jFile{metadataId:"File=1=2d9c94edd4ef4a8db3d393934c4277e8"}) -[r:流向]-> (m:Neo4jTable) return m
Neo4jFile findNeo4jFileByMetadataId(String metadataId);
@Query("match(n:Neo4jFile{metadataId:{fileId}})<-[r1:流向]-(t:Neo4jTable) return t")
List<BaseNode> getSources(@Param("fileId") String fileId);
@Query("match(n:Neo4jFile{metadataId:{fileId}})-[r1:流向]->(t:Neo4jTable) return t" )
List<BaseNode> getTargets(@Param("fileId") String fileId);
}
package com.keymobile.metadata.metadataRelation.service;
import com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnNode;
import java.util.List;
import java.util.Map;
public interface IFileService {
Map<String, List<ReturnNode>> getSourceAndTargetObjectByMedataDataId(String tableId);
}
package com.keymobile.metadata.metadataRelation.service.impl;
import com.keymobile.metadata.metadataRelation.pojo.BaseNode;
import com.keymobile.metadata.metadataRelation.pojo.metadata.Neo4jFile;
import com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnNode;
import com.keymobile.metadata.metadataRelation.respository.metadata.Neo4jFileRepository;
import com.keymobile.metadata.metadataRelation.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
public class FileServiceImpl implements IFileService {
@Autowired
private Neo4jFileRepository neo4jFileRepository;
@Override
public Map<String, List<ReturnNode>> getSourceAndTargetObjectByMedataDataId(String fileId) {
Map<String, List<ReturnNode>> sourceAndTargetTable = new HashMap<>();
List<ReturnNode> sourceTables = new ArrayList<>();
List<ReturnNode> neo4jFileList = getCurrentFileInfo(fileId);
sourceAndTargetTable.put("当前文件",neo4jFileList);
getSource(fileId ,sourceTables);
List<ReturnNode> targetTables = new ArrayList<>();
getTarget(fileId ,targetTables);
sourceAndTargetTable.put("来源",sourceTables);
sourceAndTargetTable.put("目标",targetTables);
return sourceAndTargetTable;
}
private void getSource(String fileId, List<ReturnNode> sources) {
List<BaseNode> sourceBaseNodeList = neo4jFileRepository.getSources(fileId);
for(BaseNode baseNode:sourceBaseNodeList){
String metadataId = baseNode.getMetadataId();
if(metadataId.startsWith("Table=")){
ReturnNode returnNode = new ReturnNode();
returnNode.setId(baseNode.getMetadataId());
returnNode.setName(baseNode.getName());
returnNode.setType("Table");
// 获取属性
// Map<String,String> attributeMap = getAttributeMap(metadataId);
// List<BaseNode> sourceEtlScriptBetween2TableList = neo4jTableRepository.getSourceEtlScriptBetween2Table(tableId, metadataId);
// Map<String,String> relationMap = new HashMap<>();
// for(BaseNode sourceEtlScriptBetween2Table:sourceEtlScriptBetween2TableList){
// relationMap.put("name",sourceEtlScriptBetween2Table.getName());
// relationMap.put("metadataId",sourceEtlScriptBetween2Table.getMetadataId());
// }
if(!sources.contains(returnNode)){
sources.add(returnNode);
}
// returnNode.setRelationMaps(relationMap);
// returnNode.setAttributeMaps(attributeMap);
}else {
// getSource(metadataId,sourceTables);
}
}
}
private List<ReturnNode> getCurrentFileInfo(String fileId) {
Neo4jFile neo4jFile = neo4jFileRepository.findNeo4jFileByMetadataId(fileId);
List<ReturnNode> returnTableList = new ArrayList<>();
ReturnNode returnNode = new ReturnNode();
returnNode.setId(neo4jFile.getMetadataId());
returnNode.setName(neo4jFile.getName());
returnNode.setType("File");
returnTableList.add(returnNode);
// 获取属性
// Map<String,String> attributeMap = getAttributeMap(tableId);
//
// returnNode.setAttributeMaps(attributeMap);
return returnTableList;
}
private void getTarget(String fileId, List<ReturnNode> targets) {
List<BaseNode> sourceBaseNodeList = neo4jFileRepository.getTargets(fileId);
for(BaseNode baseNode:sourceBaseNodeList){
String metadataId = baseNode.getMetadataId();
if(metadataId.startsWith("Table=")){
ReturnNode returnNode = new ReturnNode();
returnNode.setId(baseNode.getMetadataId());
returnNode.setName(baseNode.getName());
returnNode.setType("Table");
// 获取属性
// Map<String,String> attributeMap = getAttributeMap(metadataId);
// List<BaseNode> sourceEtlScriptBetween2TableList = neo4jTableRepository.getSourceEtlScriptBetween2Table(tableId, metadataId);
// Map<String,String> relationMap = new HashMap<>();
// for(BaseNode sourceEtlScriptBetween2Table:sourceEtlScriptBetween2TableList){
// relationMap.put("name",sourceEtlScriptBetween2Table.getName());
// relationMap.put("metadataId",sourceEtlScriptBetween2Table.getMetadataId());
// }
if(!targets.contains(returnNode)){
targets.add(returnNode);
}
// returnNode.setRelationMaps(relationMap);
// returnNode.setAttributeMaps(attributeMap);
}else {
// getSource(metadataId,sourceTables);
}
}
}
}
......@@ -411,14 +411,17 @@ public class TableServiceImpl implements ITableService {
List<BaseNode> sourceBaseNodeList = neo4jTableRepository.getTargets(tableId);
for(BaseNode baseNode:sourceBaseNodeList){
String metadataId = baseNode.getMetadataId();
if(metadataId.startsWith("Table=") ||metadataId.startsWith("ETLScript=")){
if(metadataId.startsWith("Table=") ||metadataId.startsWith("ETLScript=")
||metadataId.startsWith("File=")){
ReturnNode returnNode = new ReturnNode();
returnNode.setId(baseNode.getMetadataId());
returnNode.setName(baseNode.getName());
if(metadataId.startsWith("Table=")){
returnNode.setType("Table");
}else {
}else if(metadataId.startsWith("ETLScript=")){
returnNode.setType("ETLScript");
} else {
returnNode.setType("File");
}
// 获取属性
// Map<String,String> attributeMap = getAttributeMap(metadataId);
......@@ -445,14 +448,17 @@ public class TableServiceImpl implements ITableService {
List<BaseNode> sourceBaseNodeList = neo4jTableRepository.getSources(tableId);
for(BaseNode baseNode:sourceBaseNodeList){
String metadataId = baseNode.getMetadataId();
if(metadataId.startsWith("Table=") ||metadataId.startsWith("ETLScript=")){
if(metadataId.startsWith("Table=")||metadataId.startsWith("File=")
||metadataId.startsWith("ETLScript=")){
ReturnNode returnNode = new ReturnNode();
returnNode.setId(baseNode.getMetadataId());
returnNode.setName(baseNode.getName());
if(metadataId.startsWith("Table=")){
returnNode.setType("Table");
}else {
}else if(metadataId.startsWith("ETLScript=")){
returnNode.setType("ETLScript");
} else {
returnNode.setType("File");
}
// 获取属性
// Map<String,String> attributeMap = getAttributeMap(metadataId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment