Commit 71a7fb41 by qiuchaofei

1添加表的属性,2提供接口用来同步schema的标签。

parent a8acf58c
......@@ -294,4 +294,19 @@ public class RelationalGraphController {
}
//同步数据,从mongo到neo4j,从“环境,系统,schema,表”的结构---完成
//同步单个schema的标签
@ApiOperation(tags = "", value = "传入schemaId 获取schema的标签")
@RequestMapping(path = "/updateTagFromOneSchema", method = RequestMethod.GET)
public boolean updateTagFromOneSchema(String schemaId){
return schemaService.updateTagFromSchema(schemaId);
}
//同步所有schema的标签
@ApiOperation(tags = "", value = "更新所有schema的标签")
@RequestMapping(path = "/updateAllTagFromSchema", method = RequestMethod.GET)
public boolean updateTagFromAllSchema(){
return schemaService.updateTagFromAllSchema();
}
}
......@@ -14,4 +14,8 @@ public interface ISchemaService {
String getLabelBySchemaId(String schemaId);
Map<String,String> getSchemaAndLabelMap(List<String> schemaIds);
boolean updateTagFromSchema(String schemaId);
boolean updateTagFromAllSchema();
}
......@@ -1580,6 +1580,8 @@ public class MetadataServiceImpl implements IMetadataService {
neo4jTable.setTableCount(""+tableDocument.get("tableRowsCount"));
neo4jTable.setUpdateTIme((String) tableDocument.get("lastUpdateTime"));
neo4jTable.setComment((String) tableDocument.get("comment"));
neo4jTable.setCnName((String)tableDocument.get("cnName"));
neo4jTable.setTableCount(""+tableDocument.get("tableRowsCount"));
neo4jTableList.add(neo4jTable);
CompositionRelation schem2Table = new CompositionRelation();
schem2Table.setStart(neo4jSchema);
......
......@@ -10,10 +10,8 @@ import com.keymobile.metadata.metadataRelation.service.ISchemaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service
public class SchemaServiceImpl implements ISchemaService {
......@@ -137,6 +135,47 @@ public class SchemaServiceImpl implements ISchemaService {
}
@Override
public boolean updateTagFromAllSchema() {
/**
* 1.获取所有的schema,
* 2.获取schema的tag,
* 3.更新schema
*/
List<String> layer = new ArrayList<>();
layer.add("贴源数据层");
layer.add("基础数据层");
layer.add("整合数据层");
layer.add("统计数据层");
layer.add("分析数据层");
layer.add("集市数据层");
layer.add("应用数据层");
List<String> schemaIdList = new ArrayList<>();
Map<String,Neo4jSchema> neo4jSchemaMap = new HashMap<>();
Iterable<Neo4jSchema> neo4jSchemas = neo4jSchemaRepository.findAll();
for(Neo4jSchema neo4jSchema:neo4jSchemas){
schemaIdList.add(neo4jSchema.getMetadataId());
neo4jSchemaMap.put(neo4jSchema.getMetadataId(),neo4jSchema);
}
Map<String,List<Map<String,Object>>> returnResults = tagRemoteService.getTagByMetadataId(schemaIdList, "metadata", "", true);
for(Object obj : returnResults.keySet()){
String schemaId = (String)obj;
System.out.println(obj+" : "+returnResults.get(obj));
List<Map<String,Object>> mapList = returnResults.get(obj);
for(Map<String,Object> map : mapList){
String label =(String) map.get("name");
if(layer.contains(label)){
Neo4jSchema neo4jSchema = neo4jSchemaMap.get(schemaId);
neo4jSchema.setLabel(label);
neo4jSchemaRepository.save(neo4jSchema);
}
}
}
return false;
}
@Override
public Map<String, String> getSchemaAndLabelMap(List<String> schemaIds) {
Map<String,String> schemaIdAndLabelMap = new HashMap<>();
......@@ -169,4 +208,15 @@ public class SchemaServiceImpl implements ISchemaService {
return schemaIdAndLabelMap;
}
@Override
public boolean updateTagFromSchema(String schemaId) {
String schemaLabel = getLabelBySchemaId(schemaId);
Neo4jSchema neo4jSchemaByMetadata = neo4jSchemaRepository.findNeo4jSchemaByMetadataId(schemaId);
neo4jSchemaByMetadata.setLabel(schemaLabel);
neo4jSchemaRepository.save(neo4jSchemaByMetadata);
return true;
}
}
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