Commit 1559d4c1 by qiuchaofei

1 修改按照id查找的返回类型,2 添加sql,字段的同步

parent 0f43e75f
...@@ -112,7 +112,15 @@ public class RelationalGraphController { ...@@ -112,7 +112,15 @@ public class RelationalGraphController {
return metadataService.getMetaDataByMetadataId(metadataId); return metadataService.getMetaDataByMetadataId(metadataId);
} }
//展开当前节点
@ApiOperation(tags = "", value = "传入一个节点的元数据id,返回当前节点的关系")
@RequestMapping(path = "/expandNode", method = RequestMethod.GET)
public ReturnReslult expandNode(String dataId,String size) {
logger.info("传入的元模型名称是:"+dataId);
ReturnReslult returnReslult = new ReturnReslult();
return returnReslult;
}
//表的分析,链路分析,表与其他表的上下游关系,其他表可以继续下钻,并且可以收缩。 //表的分析,链路分析,表与其他表的上下游关系,其他表可以继续下钻,并且可以收缩。
......
...@@ -11,8 +11,25 @@ import java.util.List; ...@@ -11,8 +11,25 @@ import java.util.List;
@Repository @Repository
public interface Neo4jSchemaRepository extends Neo4jRepository<Neo4jSchema, Long> { public interface Neo4jSchemaRepository extends Neo4jRepository<Neo4jSchema, Long> {
Neo4jSchema findNeo4jSchemaByMetadataId(String metadataId); Neo4jSchema findNeo4jSchemaByMetadataId(String metadataId);
@Query("match (n:Neo4jSchema{metadataId:{schemaId}} )-[r:Composition]->(m) return m ") @Query("match (n:Neo4jSchema{metadataId:{schemaId}} )-[r:Composition]->(m) return m order by m.name ")
List<BaseNode> getChildrenBySchemaId(@Param("schemaId") String schemaId);
@Query("match (n:Neo4jSchema{metadataId:{schemaId}} )-[r:Composition]->(m:neo4jTable) return m order by m.name ")
List<BaseNode> getTableBySchemaId(@Param("schemaId") String schemaId); List<BaseNode> getTableBySchemaId(@Param("schemaId") String schemaId);
@Query("match (n:Neo4jSchema{metadataId:{schemaId}} )-[r:Composition]->(m:neo4jView) return m order by m.name ")
List<BaseNode> getViewBySchemaId(@Param("schemaId") String schemaId);
@Query("match (n:Neo4jSchema{metadataId:{schemaId}} )-[r:Composition]->(m:neo4jFunction) return m order by m.name ")
List<BaseNode> getFunctionBySchemaId(@Param("schemaId") String schemaId);
@Query("match (n:Neo4jSchema{metadataId:{schemaId}} )-[r:Composition]->(m:neo4jProcedure) return m order by m.name ")
List<BaseNode> getProcedureBySchemaId(@Param("schemaId") String schemaId);
} }
...@@ -10,5 +10,5 @@ import java.util.List; ...@@ -10,5 +10,5 @@ import java.util.List;
@Repository @Repository
public interface Neo4jViewRepository extends Neo4jRepository<Neo4jView,Long> { public interface Neo4jViewRepository extends Neo4jRepository<Neo4jView,Long> {
List<Neo4jView> findNeo4jViewByMetadataId(String metadataId); Neo4jView findNeo4jViewByMetadataId(String metadataId);
} }
...@@ -1356,35 +1356,35 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -1356,35 +1356,35 @@ public class MetadataServiceImpl implements IMetadataService {
compositionRelationList.add(compositionRelation); compositionRelationList.add(compositionRelation);
} }
// List<MongoData> eltSqlMongoList = mongoDbServiceImpl.findDataByparentId(etlScriptMongo.get_id(),catalogName); List<MongoData> eltSqlMongoList = mongoDbServiceImpl.findDataByparentId(etlScriptMongo.get_id(),catalogName);
// for (MongoData eltSqlMongo:eltSqlMongoList){ for (MongoData eltSqlMongo:eltSqlMongoList){
//
// String etlSqlId = eltSqlMongo.get_id(); String etlSqlId = eltSqlMongo.get_id();
// Neo4jETLSql neo4jETLSql = neo4jETLSqlRepository.findNeo4jETLSqlByMetadataId(etlSqlId); Neo4jETLSql neo4jETLSql = neo4jETLSqlRepository.findNeo4jETLSqlByMetadataId(etlSqlId);
// if(neo4jETLSql == null){ if(neo4jETLSql == null){
// neo4jETLSql = new Neo4jETLSql(); neo4jETLSql = new Neo4jETLSql();
//
// neo4jETLSql.setMetadataId(eltSqlMongo.get_id()); neo4jETLSql.setMetadataId(eltSqlMongo.get_id());
// neo4jETLSql.setName(neo4jETLJob.getName()); neo4jETLSql.setName(neo4jETLJob.getName());
// neo4jETLSql.setCnName(neo4jETLJob.getCnName()); neo4jETLSql.setCnName(neo4jETLJob.getCnName());
// neo4jETLSqlArrayList.add(neo4jETLSql); neo4jETLSqlArrayList.add(neo4jETLSql);
//
// CompositionRelation compositionRelation = new CompositionRelation(); CompositionRelation compositionRelation = new CompositionRelation();
// compositionRelation.setStart(neo4jETLScript); compositionRelation.setStart(neo4jETLScript);
// compositionRelation.setEnd(neo4jETLSql); compositionRelation.setEnd(neo4jETLSql);
// compositionRelation.setName("Script--sql"); compositionRelation.setName("Script--sql");
// compositionRelationList.add(compositionRelation); compositionRelationList.add(compositionRelation);
//
// etlSqlCount++; etlSqlCount++;
//
// } }
//
// if(etlSqlCount%200==0){ if(etlSqlCount%200==0){
// neo4jETLSqlRepository.saveAll(neo4jETLSqlArrayList); neo4jETLSqlRepository.saveAll(neo4jETLSqlArrayList);
// neo4jETLSqlArrayList.clear(); neo4jETLSqlArrayList.clear();
// } }
//
// } }
} }
if(neo4jETLScriptList !=null && neo4jETLScriptList.size()!=0 ){ if(neo4jETLScriptList !=null && neo4jETLScriptList.size()!=0 ){
...@@ -1416,9 +1416,7 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -1416,9 +1416,7 @@ public class MetadataServiceImpl implements IMetadataService {
neo4jSchema.setMetadataId(schemaData_id); neo4jSchema.setMetadataId(schemaData_id);
neo4jSchema.setName(schemaData.getName()); neo4jSchema.setName(schemaData.getName());
neo4jSchema.setCnName(schemaData.getCnName()); neo4jSchema.setCnName(schemaData.getCnName());
if("ORACLE_OCM".equals(schemaData.getName())){
System.out.println("ORACLE_OCM");
}
Neo4jSystem neo4jSystem = null; Neo4jSystem neo4jSystem = null;
List<String> systemIdList = dataBaseData.getSysList(); List<String> systemIdList = dataBaseData.getSysList();
for(String systemId:systemIdList){ for(String systemId:systemIdList){
...@@ -1440,8 +1438,8 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -1440,8 +1438,8 @@ public class MetadataServiceImpl implements IMetadataService {
neo4jSchema.setLabel(label); neo4jSchema.setLabel(label);
} }
//如果存在,就不用创建 //如果存在,就不用创建
List<Neo4jSchema> neo4jSchemaList = null;//neo4jSchemaRepository.findNeo4jSchemaByMetadataId(neo4jSchema.getMetadataId()); Neo4jSchema neo4jSchemaList = neo4jSchemaRepository.findNeo4jSchemaByMetadataId(neo4jSchema.getMetadataId());
if(neo4jSchemaList==null || neo4jSchemaList.size()==0){ if(neo4jSchemaList==null ){
neo4jSchemaRepository.save(neo4jSchema); neo4jSchemaRepository.save(neo4jSchema);
schemaCount++; schemaCount++;
} }
...@@ -1476,7 +1474,6 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -1476,7 +1474,6 @@ public class MetadataServiceImpl implements IMetadataService {
String tablePath = schemaPath+";"+metadataName; String tablePath = schemaPath+";"+metadataName;
if(metadataId.startsWith("Table=")){ if(metadataId.startsWith("Table=")){
if(tableCount %100==0){ if(tableCount %100==0){
// break;
logger.info("同步了:"+tableCount+"个表。"); logger.info("同步了:"+tableCount+"个表。");
neo4jTableRepository.saveAll(neo4jTableList); neo4jTableRepository.saveAll(neo4jTableList);
neo4jTableList.clear(); neo4jTableList.clear();
...@@ -1506,32 +1503,32 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -1506,32 +1503,32 @@ public class MetadataServiceImpl implements IMetadataService {
compositionRelationList.add(schem2Table); compositionRelationList.add(schem2Table);
tableCount++; tableCount++;
// List<MongoData> columnMongoDataList = mongoDbServiceImpl.findDataByparentId(metadataId, catalogName); List<MongoData> columnMongoDataList = mongoDbServiceImpl.findDataByparentId(metadataId, catalogName);
// for(MongoData columnMongoData:columnMongoDataList){ for(MongoData columnMongoData:columnMongoDataList){
// String columnId = columnMongoData.get_id(); String columnId = columnMongoData.get_id();
// Neo4jColumn neo4jColumnList1 = neo4jColumnRepository.findNeo4jColumnByMetadataId(columnId); Neo4jColumn neo4jColumnList1 = neo4jColumnRepository.findNeo4jColumnByMetadataId(columnId);
//
// if(neo4jColumnList1==null){ if(neo4jColumnList1==null){
// Neo4jColumn neo4jColumn = new Neo4jColumn(); Neo4jColumn neo4jColumn = new Neo4jColumn();
// neo4jColumn.setMetadataId(columnId); neo4jColumn.setMetadataId(columnId);
// neo4jColumn.setName(columnMongoData.getName()); neo4jColumn.setName(columnMongoData.getName());
// neo4jColumn.setCnName(columnMongoData.getCnName()); neo4jColumn.setCnName(columnMongoData.getCnName());
// neo4jColumnList.add(neo4jColumn); neo4jColumnList.add(neo4jColumn);
//
// CompositionRelation table2Column = new CompositionRelation(); CompositionRelation table2Column = new CompositionRelation();
// table2Column.setStart(neo4jTable); table2Column.setStart(neo4jTable);
// table2Column.setEnd(neo4jColumn); table2Column.setEnd(neo4jColumn);
// table2Column.setName("Table--Column"); table2Column.setName("Table--Column");
// compositionRelationList.add(table2Column); compositionRelationList.add(table2Column);
//
// columnCount++; columnCount++;
// } }
// if(columnCount %100==0){ if(columnCount %100==0){
// logger.info("同步了:"+columnCount+"个字段。"); logger.info("同步了:"+columnCount+"个字段。");
// neo4jColumnRepository.saveAll(neo4jColumnList); neo4jColumnRepository.saveAll(neo4jColumnList);
// neo4jColumnList.clear(); neo4jColumnList.clear();
// } }
// } }
} }
}else if(metadataId.startsWith("View=")){ }else if(metadataId.startsWith("View=")){
if(viewCount %100==0){ if(viewCount %100==0){
...@@ -1540,8 +1537,8 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -1540,8 +1537,8 @@ public class MetadataServiceImpl implements IMetadataService {
viewTableList.clear(); viewTableList.clear();
} }
List<Neo4jView> neo4jViewList = null;//neo4jViewRepository.findNeo4jViewByMetadataId(metadataId); Neo4jView neo4jViewListExist = neo4jViewRepository.findNeo4jViewByMetadataId(metadataId);
if(neo4jViewList==null || neo4jViewList.size()==0){ if(neo4jViewListExist==null ){
Neo4jView neo4jView = new Neo4jView(); Neo4jView neo4jView = new Neo4jView();
neo4jView.setMetadataId(metadataId); neo4jView.setMetadataId(metadataId);
...@@ -1570,8 +1567,8 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -1570,8 +1567,8 @@ public class MetadataServiceImpl implements IMetadataService {
neo4jFunction.setCnName(metadataCnName); neo4jFunction.setCnName(metadataCnName);
neo4jFunction.setDataPath(tablePath); neo4jFunction.setDataPath(tablePath);
List<Neo4jFunction> neo4jFunctionList = null;//neo4jFunctionRepository.findNeo4jFunctionByMetadataId(metadataId); Neo4jFunction neo4jFunctionExist = neo4jFunctionRepository.findNeo4jFunctionByMetadataId(metadataId);
if(neo4jFunctionList==null || neo4jFunctionList.size()==0){ if(neo4jFunctionExist==null){
functionTableList.add(neo4jFunction); functionTableList.add(neo4jFunction);
CompositionRelation schem2Function = new CompositionRelation(); CompositionRelation schem2Function = new CompositionRelation();
schem2Function.setStart(neo4jSchema); schem2Function.setStart(neo4jSchema);
...@@ -1592,8 +1589,8 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -1592,8 +1589,8 @@ public class MetadataServiceImpl implements IMetadataService {
neo4jProcedure.setName(metadataName); neo4jProcedure.setName(metadataName);
neo4jProcedure.setCnName(metadataCnName); neo4jProcedure.setCnName(metadataCnName);
neo4jProcedure.setDataPath(tablePath); neo4jProcedure.setDataPath(tablePath);
List<Neo4jProcedure> neo4jProcedureList = null;//neo4jProcedureRepository.findNeo4jProcedureByMetadataId(metadataId); Neo4jProcedure neo4jProcedureExist = neo4jProcedureRepository.findNeo4jProcedureByMetadataId(metadataId);
if(neo4jProcedureList==null || neo4jProcedureList.size()==0){ if(neo4jProcedureExist ==null ){
procedureTableList.add(neo4jProcedure); procedureTableList.add(neo4jProcedure);
...@@ -1675,7 +1672,7 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -1675,7 +1672,7 @@ public class MetadataServiceImpl implements IMetadataService {
String targetId =relation.getString("target"); // relationMongo.getTarget(); String targetId =relation.getString("target"); // relationMongo.getTarget();
//本身的字段级关系也要同步 //本身的字段级关系也要同步
// edgeIdMap.put(sourceId+"_"+targetId,""); edgeIdMap.put(sourceId+"_"+targetId,"");
Map<String, Object> sourceData = metadataRepoRemoteService.getMetadata(sourceId); Map<String, Object> sourceData = metadataRepoRemoteService.getMetadata(sourceId);
Map<String, Object> targetData = metadataRepoRemoteService.getMetadata(targetId); Map<String, Object> targetData = metadataRepoRemoteService.getMetadata(targetId);
...@@ -2114,6 +2111,11 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -2114,6 +2111,11 @@ public class MetadataServiceImpl implements IMetadataService {
} }
returnMap.put("路径",sb.toString()); returnMap.put("路径",sb.toString());
} }
//按照元数据id 查看子节点
return returnMap; return returnMap;
} }
...@@ -2274,7 +2276,6 @@ public class MetadataServiceImpl implements IMetadataService { ...@@ -2274,7 +2276,6 @@ public class MetadataServiceImpl implements IMetadataService {
String etlJobId = relation.getString("etlJobId"); String etlJobId = relation.getString("etlJobId");
deleteTempNodeByCatalogName(sqlId); deleteTempNodeByCatalogName(sqlId);
Neo4jETLSql neo4jETLSql = neo4jETLSqlRepository.findNeo4jETLSqlByMetadataId(sqlId); Neo4jETLSql neo4jETLSql = neo4jETLSqlRepository.findNeo4jETLSqlByMetadataId(sqlId);
// MetaData metadata = metadataRepository.findMetaDataByMetadataId(sqlId);
Neo4jETLScript neo4jETLScript = neo4jETLScriptRepository.findNeo4jETLScriptByMetadataId(etlScriptId); Neo4jETLScript neo4jETLScript = neo4jETLScriptRepository.findNeo4jETLScriptByMetadataId(etlScriptId);
Long srciptId = neo4jETLScript.getId(); Long srciptId = neo4jETLScript.getId();
String source = relation.getString("source"); String source = relation.getString("source");
......
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