Commit b1425e82 by qiuchaofei

1.在指定schema下搜索表

parent 6939ea2e
......@@ -138,6 +138,18 @@ public class RelationalGraphController {
int offsetInt = Integer.valueOf(offset);
int countInt = Integer.valueOf(count);
return tableService.autoMatchByInputWord(name,countInt,offsetInt);
}
//单个schema的数据,包括表,视图,函数,过程等,列表形势
@ApiOperation(tags = "", value = "传入schemaid,返回表,视图,函数,存储过程")
@RequestMapping(path = "/getTableBySchemaId", 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);
}
//同步数据,从mongo到neo4j,从“环境,系统,schema,表”的结构---完成
......
......@@ -11,4 +11,6 @@ public interface ITableService {
Map<String, List<ReturnNode>> getRelationObjectByTableId(String tableId);
public List<ReturnNode> autoMatchByInputWord(String name,int offsetInt,int countInt);
Map<String, List<ReturnNode>> autoMatchBySchemaIdAndInputWord(String schemaId, String keyWord);
}
......@@ -195,6 +195,51 @@ public class TableServiceImpl implements ITableService {
return returnNodeList;
}
@Override
public Map<String, List<ReturnNode>> autoMatchBySchemaIdAndInputWord(String schemaId, String keyWord) {
logger.info("开始在 "+schemaId+" 下模糊查找:" + keyWord);
List<ReturnNode> returnNodeList = new ArrayList<>();
Neo4jConfig neo4jConfig = new Neo4jConfig();
Driver neo4jConnection = neo4jConfig.getNeo4jConnection();
Session session = neo4jConnection.session();
// match(n) where (n:Neo4jTable or n:Neo4jSchema ) and (n.name =~'.*部门1.*' or n.cnName =~'.*部门1.*') return n
//match (n:MetaData) where n.name=~'(?i).*APP.*' return n
String cypher = // "match (n) where ( n:Neo4jTable or n:Neo4jSchema ) and (n.name=~'(?i).*"+name+".*' or n.name=~'(?i).*"+name+".*') return n skip "+offsetInt+" limit "+countInt;
"match (n:Neo4jSchema)-[r:Composition]->(m:Neo4jTable) where m.name =~'.*"+keyWord+".*' or m.name =~'.*"+keyWord+".*' return m ";
long starttime = System.currentTimeMillis();
StatementResult result = session.run(cypher);
while(result.hasNext()){
Record record = result.next();
List<Value> values = record.values();
for (Value value : values) {
if(value.type().name().equals("NODE")){
Node node = value.asNode();
Map<String, Object> stringObjectMap = node.asMap();
MetaData metaData = new MetaData();
Neo4jTool.transMap2Bean(stringObjectMap, metaData);
if(metaData.getMetadataId() == null ){
metaData.setMetadataId("System="+metaData.getName());
}
ReturnNode returnNode = new ReturnNode();
returnNode.setId(metaData.getMetadataId());
returnNode.setName(metaData.getName());
returnNode.setCnName(metaData.getCnName());
returnNode.setDataPath(metaData.getPath());
returnNodeList.add(returnNode);
}
}
}
long endtime = System.currentTimeMillis();
logger.info("模糊查找结束,返回数量:" + returnNodeList.size()+",耗时:"+(endtime-starttime));
Map<String, List<ReturnNode>> returnNodeMap = new HashMap<>();
returnNodeMap.put("表",returnNodeList);
return returnNodeMap;
}
@Override
public Map<String, List<ReturnNode>> getSourceAndTargetTableByTableId(String tableId) {
......
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