Commit cd4ccaf6 by qiuchaofei

1同步的时候把属性也存到图库,要用时不用再从mongo读取

parent cf860251
......@@ -16,10 +16,7 @@ import com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnEdge;
import com.keymobile.metadata.metadataRelation.pojo.returnBean.MetaModel;
import com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnNode;
import com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnReslult;
import com.keymobile.metadata.metadataRelation.service.AsyncDataFromMongoToNeo4j;
import com.keymobile.metadata.metadataRelation.service.IBaseRelationshipService;
import com.keymobile.metadata.metadataRelation.service.IMetadataService;
import com.keymobile.metadata.metadataRelation.service.MultiModelService;
import com.keymobile.metadata.metadataRelation.service.*;
import com.keymobile.metadata.metadataRelation.service.impl.MongoDbServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -55,6 +52,12 @@ public class MetaDataController {
@Autowired
private MultiModelService multiModelService;
@Autowired
private ITableService tableService;
/**
* 获取所有的节点
*/
......@@ -110,13 +113,16 @@ public class MetaDataController {
* 显示节点的属性,传入元数据id,返回元数据的主要属性(5个),需要调用元数据服务的接口。
* 路径,别名,描述
*/
@ApiOperation(tags = "", value = "根据元数据id获取元数据属性")
@RequestMapping(path = "/getPropertiesById", method = RequestMethod.GET)
public Map<String,String> getPropertiesById(String metadataId) {
return metadataService.getMetaDataByMetadataId(metadataId);
Map<String,String> attributeMap = new HashMap<>();
if(metadataId.startsWith("Table=")){
attributeMap = tableService.getAttributeByTableId(metadataId);
} else {
attributeMap = metadataService.getMetaDataByMetadataId(metadataId);
}
return attributeMap;
}
......
......@@ -2,8 +2,15 @@ package com.keymobile.metadata.metadataRelation.pojo;
public class BaseNode extends AllBaseEntity {
private String name; //名称
private String metadataId;//元数据id
private String cnName;//中文名
private String dataPath;//路径
private String environment; //所属环境
public String getCnName() {
return cnName;
}
......@@ -20,8 +27,6 @@ public class BaseNode extends AllBaseEntity {
this.metadataId = metadataId;
}
private String metadataId;
private String cnName;
public String getDataPath() {
return dataPath;
......@@ -31,7 +36,6 @@ public class BaseNode extends AllBaseEntity {
this.dataPath = dataPath;
}
private String dataPath;
// @Relationship(type= NodeType.REF)
// private Set<BaseRelationship> relationships; //关系列表
......
......@@ -5,4 +5,84 @@ import org.neo4j.ogm.annotation.NodeEntity;
@NodeEntity(label ="Neo4jTable")
public class Neo4jTable extends BaseNode {
private String isEnvironment;//所属环境
private String isSystem;//所属系统
private String isLayer;//所属分层
private String isSchema;//所属Schema
private String tableSize;//表大小
private String tableCount;//表记录行数
private String comment;//说明
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getUpdateTIme() {
return updateTIme;
}
public void setUpdateTIme(String updateTIme) {
this.updateTIme = updateTIme;
}
private String updateTIme;//修改时间
public String getIsEnvironment() {
return isEnvironment;
}
public void setIsEnvironment(String isEnvironment) {
this.isEnvironment = isEnvironment;
}
public String getIsSystem() {
return isSystem;
}
public void setIsSystem(String isSystem) {
this.isSystem = isSystem;
}
public String getIsLayer() {
return isLayer;
}
public void setIsLayer(String isLayer) {
this.isLayer = isLayer;
}
public String getIsSchema() {
return isSchema;
}
public void setIsSchema(String isSchema) {
this.isSchema = isSchema;
}
public String getTableSize() {
return tableSize;
}
public void setTableSize(String tableSize) {
this.tableSize = tableSize;
}
public String getTableCount() {
return tableCount;
}
public void setTableCount(String tableCount) {
this.tableCount = tableCount;
}
}
......@@ -13,4 +13,7 @@ public interface ITableService {
public List<ReturnNode> autoMatchByInputWord(String name,int offsetInt,int countInt);
Map<String, List<ReturnNode>> autoMatchBySchemaIdAndInputWord(String schemaId, String keyWord);
Map<String ,String> getAttributeByTableId(String tableId);
}
......@@ -26,6 +26,7 @@ public class MongoDbServiceImpl {
private static final String PREFIX_MD_RELATION = "md_relation_";
private static final String PREFIX_METADATA_NODE = "Metadata_";
/**
* 查询所有
......@@ -87,6 +88,32 @@ public class MongoDbServiceImpl {
}
}
/**
* 分页查询所有子节点,返回document
*
* 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 List<Document> getDocumentByparentIdByPage(Pageable pageable, String catalogName,String parentId) {
logger.info("开始从mongo查找子节点:"+ parentId);
Query query = Query.query(Criteria.where("parentId").is(parentId));
query.with(pageable);
return mongoTemplate.find(query, Document.class, PREFIX_METADATA_NODE + catalogName);
}
public long countDocumentByParentId(Pageable pageable, String catalogName,String parentId) {
Query query = Query.query(Criteria.where("parentId").is(parentId));
query.with(pageable);
return mongoTemplate.count(query, Document.class, PREFIX_METADATA_NODE + catalogName);
}
/**
* 查询所有
*
......
......@@ -40,8 +40,6 @@ public class SystemServiceImpl implements ISystemService {
List<ReturnNode> jsshcList = new ArrayList<>();
List<ReturnNode> yysjcList = new ArrayList<>();
List<Neo4jSchema> neo4jSchemaList = new ArrayList<>();
// schemaMap.put("未分层", new ArrayList<>() );
try{
......
......@@ -260,6 +260,12 @@ public class TableServiceImpl implements ITableService {
return returnNodeMap;
}
@Override
public Map<String, String> getAttributeByTableId(String tableId) {
Map<String,String> attributeMap = getAttributeMap(tableId);
return attributeMap;
}
@Override
public Map<String, List<ReturnNode>> getSourceAndTargetTableByTableId(String tableId) {
......@@ -287,104 +293,31 @@ public class TableServiceImpl implements ITableService {
}
private Map<String,String> getAttributeMap(String tableId){
Map<String,String> returnMap = new HashMap<>();
Map<String, Object> attriuteMap = null;
try{
long start = System.currentTimeMillis();
attriuteMap = metadataRepoRemoteService.getMetadata(tableId);
long end = System.currentTimeMillis();
logger.info(tableId+"调用repo服务用时:"+(end-start));
}catch (Exception e){
logger.info("元数据服务异常:"+e.getMessage());
}
Map<String,String> returnMap = new LinkedHashMap<>();
List<Neo4jTable> neo4jTableList = neo4jTableRepository.findNeo4jTableByMetadataId(tableId);
Neo4jTable neo4jTable = neo4jTableList.get(0);
if (attriuteMap == null) {
logger.info("没有找到id:" + tableId + "的元数据。");
List<Neo4jTable> neo4jTableList = neo4jTableRepository.findNeo4jTableByMetadataId(tableId);
Neo4jTable neo4jTable = neo4jTableList.get(0);
returnMap.put("名字", neo4jTable.getName());
returnMap.put("别名", neo4jTable.getCnName());
returnMap.put("中文名","");
returnMap.put("最后更新时间","");
returnMap.put("所属系统",neo4jTable.getDataPath());
return returnMap;
}
// 英文名称,中文名称,说明,表规模(行),表大小(字节),更新时间,
// 所属系统,所属分层,加载脚本,质量情况,相关模型
String name = (String) attriuteMap.get("name");
returnMap.put("英文名称",name);
String cnName = (String) attriuteMap.get("cnName");
returnMap.put("中文名称",cnName);
returnMap.put("英文名称",neo4jTable.getName());
returnMap.put("中文名称",neo4jTable.getCnName());
String comment = (String) attriuteMap.get("comment");
returnMap.put("说明",comment);
returnMap.put("说明",neo4jTable.getComment());
returnMap.put("表规模(行)",attriuteMap.get("tableRowsCount")+"");
returnMap.put("所属系统",neo4jTable.getIsSystem());
returnMap.put("所属分层",neo4jTable.getIsLayer());
returnMap.put("所属Schema",neo4jTable.getIsSchema());
returnMap.put("表大小(字节)",attriuteMap.get("tableSize")+"");
returnMap.put("表规模(行)",neo4jTable.getTableCount());
String lastUpdateTime = (String) attriuteMap.get("lastUpdateTime");
returnMap.put("最后更新时间",lastUpdateTime);
returnMap.put("表大小(字节)",neo4jTable.getTableSize());
//所属系统
String belongSystemString = "";
List<String> belongSystems = (List<String>) attriuteMap.get("sysList");
for(String belongSystem:belongSystems){
belongSystemString +=belongSystem+",";
}
returnMap.put("所属系统",belongSystemString);
//所属分层,从schema获取
String parentId = (String) attriuteMap.get("parentId");
String label = null;
String schemaName = "";
try{
long start = System.currentTimeMillis();
neo4jTableRepository.getSchema(tableId);
List<Neo4jSchema> neo4jSchemaList = neo4jSchemaRepository.findNeo4jSchemaByMetadataId(parentId);
if(neo4jSchemaList !=null && neo4jSchemaList.size()!=0){
Neo4jSchema neo4jSchema = neo4jSchemaList.get(0);
schemaName = neo4jSchema.getName();
label = neo4jSchema.getLabel();
}
long end = System.currentTimeMillis();
logger.info(tableId+"调用repo服务用时:"+(end-start));
}catch (Exception e){
returnMap.put("更新时间",neo4jTable.getUpdateTIme());
logger.info("元数据服务异常:"+e.getMessage());
}
if(label== null ){
List<String> layer = new ArrayList<>();
layer.add("贴源数据层");
layer.add("基础数据层");
layer.add("整合数据层");
layer.add("统计数据层");
layer.add("分析数据层");
layer.add("集市数据层");
layer.add("应用数据层");
Random r = new Random(1);
int ran1 = r.nextInt(6);
if(ran1>6){
ran1 = 6;
}
label = layer.get(ran1);
}
returnMap.put("所属分层",label);
returnMap.put("所属Schema",schemaName);
// List<String> paths =(List<String>) attriuteMap.get("namePathList");
// if(paths !=null ){
// StringBuffer sb = new StringBuffer();
// int size = paths.size();
// for(int i =0 ;i<size;i++){
// sb.append(paths.get(i)+";");
// }
// returnMap.put("路径",sb.toString());
// }
//所属系统
return returnMap;
}
......
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