Commit 96980932 by qiuchaofei

1.添加etljob,etlscript模型,2修改table的查找,3修改同步流向关系的方法

parent a7b76387
......@@ -145,9 +145,6 @@ public class RelationalGraphController {
@RequestMapping(path = "/getTableBySchemaIdAndKeyWord", method = RequestMethod.GET)
public Map<String, List<ReturnNode>> getTableBySchemaIdAndKeyWord(String schemaId,String keyWord){
//传入一个系统名称/id,返回系统下的所有schema,注意分层
Map<String, List<ReturnNode>> stringListMap = schemaService.getTablesBySchemaId(schemaId);
return tableService.autoMatchBySchemaIdAndInputWord(schemaId,keyWord);
......
......@@ -3,6 +3,7 @@ package com.keymobile.metadata.metadataRelation.pojo.metadata;
import com.keymobile.metadata.metadataRelation.pojo.BaseNode;
import org.neo4j.ogm.annotation.NodeEntity;
@NodeEntity(label="Neo4jJob")
public class Neo4jJob extends BaseNode {
@NodeEntity(label="Neo4jETLJob")
public class Neo4jETLJob extends BaseNode {
}
package com.keymobile.metadata.metadataRelation.pojo.metadata;
import com.keymobile.metadata.metadataRelation.pojo.BaseNode;
import org.neo4j.ogm.annotation.NodeEntity;
@NodeEntity(label="Neo4jETLScript")
public class Neo4jETLScript extends BaseNode {
}
package com.keymobile.metadata.metadataRelation.respository.metadata;
import com.keymobile.metadata.metadataRelation.pojo.metadata.Neo4jETLJob;
import com.keymobile.metadata.metadataRelation.pojo.metadata.Neo4jFunction;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface Neo4jETLJobRepository extends Neo4jRepository<Neo4jETLJob, Long> {
List<Neo4jETLJob> findNeo4jETLJobByMetadataId(String metadataId);
}
package com.keymobile.metadata.metadataRelation.respository.metadata;
import com.keymobile.metadata.metadataRelation.pojo.metadata.Neo4jETLScript;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface Neo4jETLScriptRepository extends Neo4jRepository<Neo4jETLScript, Long> {
List<Neo4jETLScript> findNeo4jETLScriptByMetadataId(String metadataId);
}
......@@ -13,10 +13,19 @@ import java.util.List;
public interface Neo4jTableRepository extends Neo4jRepository<Neo4jTable,Long> {
List<Neo4jTable> findNeo4jTableByMetadataId(String metadataId);
@Query("match (n{metadataId:{tableId}} )<-[r:流向]-(m) return m ")
@Query("match (n{metadataId:{tableId}} )<-[r:流向]-(m1)<-[r1:流向]-(m) return m ")
List<BaseNode> getSourceTable(@Param("tableId") String tableId);
@Query("match (n{metadataId:{tableId}} )-[r:流向]->(m) return m ")
@Query("match (n{metadataId:{tableId}} )-[r1:流向]->(m1)-[r:流向]->(m) return m ")
List<BaseNode> getTargetTable(@Param("tableId") String tableId);
@Query("match (n{metadataId:{tableId}} )<-[r1:流向]-(m1) <-[r:Composition]-(m) return m ")
List<BaseNode> getSourceEtlJob(@Param("tableId") String tableId);
@Query("match (n{metadataId:{tableId}} )-[r1:流向]->(m1) <-[r:Composition]-(m) return m ")
List<BaseNode> getTargetEtlJob(@Param("tableId") String tableId);
}
......@@ -32,13 +32,10 @@ public class AsyncDataFromMongoToNeo4j {
@Autowired
private JdbcTemplate jdbcTemplate;
@Async
public void asyncDataFromMongoToNeo4j(String catalogName) {
long start = System.currentTimeMillis();
String sql = "select scope_id, scope_name from auth_scope";
String sql = "select scope_id, scope_name from auth_scope where domain_id ="+ catalogName;
List<MongoData> mongoDataList = jdbcTemplate.query(sql, new RowMapper<MongoData>() {
@Override
public MongoData mapRow(ResultSet resultSet, int i) throws SQLException {
......
......@@ -23,6 +23,7 @@ public class MongoDbServiceImpl {
@Autowired
private MongoTemplate mongoTemplate;
private static final String PREFIX_MD_RELATION = "md_relation_";
......@@ -125,4 +126,16 @@ public class MongoDbServiceImpl {
query.with(pageable);
return mongoTemplate.count(query, Document.class, PREFIX_MD_RELATION_TEMP_NODE + catalogName);
}
public List<Document> findRelationByPage(Pageable pageable, String catalogName) {
Query query = new Query(new Criteria().orOperator(Criteria.where("type").is("Input"),Criteria.where("type").is("Output")));
query.with(pageable);
return mongoTemplate.find(query, Document.class, PREFIX_MD_RELATION + catalogName);
}
public long countRelation(Pageable pageable, String catalogName) {
Query query = new Query(new Criteria().orOperator(Criteria.where("type").is("Input"),Criteria.where("type").is("Output")));
query.with(pageable);
return mongoTemplate.count(query, Document.class, PREFIX_MD_RELATION + catalogName);
}
}
......@@ -50,23 +50,23 @@ public class TableServiceImpl implements ITableService {
//作业
List<ReturnNode> etlJobs = new ArrayList<>();
//获取关联作业,
List<BaseNode> sourceBaseNodes = neo4jTableRepository.getSourceTable(tableId);
List<BaseNode> sourceBaseNodes = neo4jTableRepository.getSourceEtlJob(tableId);
for(BaseNode sourceBaseNode:sourceBaseNodes){
if(sourceBaseNode.getMetadataId().startsWith("Procedure=")){
if(sourceBaseNode.getMetadataId().startsWith("ETLJob=")){
ReturnNode returnNode = new ReturnNode();
returnNode.setId(sourceBaseNode.getMetadataId());
returnNode.setName(sourceBaseNode.getName());
returnNode.setType("Procedure");
returnNode.setType("ETLJob");
etlJobs.add(returnNode);
}
}
List<BaseNode> targetBaseNodes = neo4jTableRepository.getTargetTable(tableId);
List<BaseNode> targetBaseNodes = neo4jTableRepository.getTargetEtlJob(tableId);
for(BaseNode targetBaseNode:targetBaseNodes){
if(targetBaseNode.getMetadataId().startsWith("Procedure=")){
if(targetBaseNode.getMetadataId().startsWith("ETLJob=")){
ReturnNode returnNode = new ReturnNode();
returnNode.setId(targetBaseNode.getMetadataId());
returnNode.setName(targetBaseNode.getName());
returnNode.setType("Procedure");
returnNode.setType("ETLJob");
etlJobs.add(returnNode);
}
}
......@@ -81,6 +81,7 @@ public class TableServiceImpl implements ITableService {
relationObjects.put("模型",modelList);
//资产
List<ReturnNode> assetList = new ArrayList<>();
try{
List<Map<String, String>> dataAssetGraphInfos = dataAssertRemoteService.getDataAssetGraphInfoByMetadataId(tableId);
for(Map<String, String> map : dataAssetGraphInfos){
ReturnNode returnNode = new ReturnNode();
......@@ -89,11 +90,17 @@ public class TableServiceImpl implements ITableService {
returnNode.setCnName(map.get("cnName"));
assetList.add(returnNode);
}
}catch (Exception e){
e.printStackTrace();
}
relationObjects.put("资产",assetList);
//标准
List<ReturnNode> standardList = new ArrayList<>();
Map<String,Object> maps = new HashMap<>();
maps.put("metadataId",tableId);
try{
Map<String, Object> standardMaps = dataStandardRemoteService.findStandardByMetadatId(1, 10,
maps);
List<LinkedHashMap<String,Object>> contentList = (List<LinkedHashMap<String,Object>>) standardMaps.get("content");
......@@ -109,6 +116,11 @@ public class TableServiceImpl implements ITableService {
standardList.add(returnNode);
}
relationObjects.put("标准",standardList);
}catch (Exception e){
e.printStackTrace();
}
List<ReturnNode> neo4jTableList = getCurrentTableInfo(tableId);
relationObjects.put("当前表",neo4jTableList);
......
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