Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neo4jRelation
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qiuchaofei
neo4jRelation
Commits
06a96f10
Commit
06a96f10
authored
Nov 16, 2021
by
qiuchaofei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并获取图形的接口。
parent
eda41b4c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
166 deletions
+17
-166
MetaDataController.java
...adata/metadataRelation/controller/MetaDataController.java
+17
-166
No files found.
src/main/java/com/keymobile/metadata/metadataRelation/controller/MetaDataController.java
View file @
06a96f10
...
...
@@ -47,116 +47,6 @@ public class MetaDataController {
private
IBaseRelationshipService
baseRelationshipService
;
/**
* 查询元数据,关系
* 返回 node,edge,icon
*/
@ApiOperation
(
tags
=
""
,
value
=
"获取所有的节点与关系"
)
@RequestMapping
(
path
=
"/result1"
,
method
=
RequestMethod
.
GET
)
public
ReturnReslult
getAllNodeAndRelation
()
{
logger
.
info
(
"开始获取所有的节点与关系"
);
ReturnReslult
result
=
new
ReturnReslult
();
List
<
MetaData
>
metaDataList
=
metadataService
.
finAllMetaData
();
Map
<
Long
,
Node
>
nodeMap
=
new
HashMap
<>();
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashMap
<>();
for
(
MetaData
metaData
:
metaDataList
)
{
Node
node
=
new
Node
();
String
[]
strings
=
metaData
.
getMetadataId
().
split
(
"="
);
String
modelName
=
strings
[
0
];
node
.
setId
(
metaData
.
getMetadataId
());
node
.
setIcon
(
modelName
);
if
(!
metaModelMap
.
containsKey
(
modelName
))
{
MetaModel
model
=
new
MetaModel
();
String
iconContext
=
getIconByModelId
(
modelName
);
model
.
setModelName
(
modelName
);
model
.
setCnName
(
modelName
);
model
.
setDescription
(
""
);
model
.
setIcon
(
iconContext
);
metaModelMap
.
put
(
modelName
,
model
);
}
node
.
setName
(
metaData
.
getName
());
node
.
setType
(
"MetaData"
);
result
.
getNodes
().
add
(
node
);
nodeMap
.
put
(
metaData
.
getId
(),
node
);
}
List
<
TempNode
>
allTempNode
=
metadataService
.
findAllTempNode
();
for
(
TempNode
tempNode
:
allTempNode
)
{
Node
node
=
new
Node
();
String
[]
strings
=
tempNode
.
getMetadataId
().
split
(
"="
);
String
modelName
=
strings
[
0
];
node
.
setId
(
tempNode
.
getMetadataId
());
node
.
setIcon
(
modelName
);
if
(!
metaModelMap
.
containsKey
(
modelName
))
{
MetaModel
model
=
new
MetaModel
();
String
iconContext
=
getIconByModelId
(
modelName
);
model
.
setModelName
(
modelName
);
model
.
setCnName
(
modelName
);
model
.
setDescription
(
""
);
model
.
setIcon
(
iconContext
);
metaModelMap
.
put
(
modelName
,
model
);
}
node
.
setName
(
tempNode
.
getName
());
node
.
setType
(
"TempNode"
);
result
.
getNodes
().
add
(
node
);
nodeMap
.
put
(
tempNode
.
getId
(),
node
);
}
logger
.
info
(
"节点的数量:"
+
result
.
getNodes
().
size
());
List
<
BaseRelationship
>
baseRelationshipList
=
baseRelationshipService
.
findAllRelation
();
for
(
BaseRelationship
baseRelationship
:
baseRelationshipList
)
{
Edge
edge
=
new
Edge
();
edge
.
setEdgeId
(
String
.
valueOf
(
baseRelationship
.
getId
()));
Long
startId
=
baseRelationship
.
getStart
().
getId
();
Long
endId
=
baseRelationship
.
getEnd
().
getId
();
String
startMetaId
=
""
;
String
endMEtaId
=
""
;
if
(
nodeMap
.
containsKey
(
startId
))
{
startMetaId
=
nodeMap
.
get
(
startId
).
getId
();
}
if
(
nodeMap
.
containsKey
(
endId
))
{
endMEtaId
=
nodeMap
.
get
(
endId
).
getId
();
}
if
(
StringUtils
.
isNotBlank
(
startMetaId
)
&&
StringUtils
.
isNotBlank
(
endMEtaId
))
{
edge
.
setFromId
(
startMetaId
);
edge
.
setToId
(
endMEtaId
);
edge
.
setType
(
baseRelationship
.
getName
());
result
.
getEdges
().
add
(
edge
);
}
}
logger
.
info
(
"关系的数量:"
+
result
.
getEdges
().
size
());
result
.
setMetaModelMap
(
metaModelMap
);
return
result
;
}
@ApiOperation
(
tags
=
""
,
value
=
"传入元模型名称,返回该元模型的元数据所有关系"
)
// @RequestMapping(path = "/getNodeAndRelationByModel", method = RequestMethod.GET)
@RequestMapping
(
path
=
"/getNodeAndRelationByModel"
,
method
=
RequestMethod
.
GET
)
public
ReturnReslult
getNodeAndRelationByModel
(
String
modelName
)
{
if
(
modelName
==
null
||
modelName
.
equals
(
""
))
{
modelName
=
"Table"
;
}
ReturnReslult
returnReslult
=
metadataService
.
findResultByModelName
(
modelName
);
return
returnReslult
;
}
/**
* 查询元数据
*/
@RequestMapping
(
path
=
"/list"
,
method
=
RequestMethod
.
GET
)
...
...
@@ -170,14 +60,17 @@ public class MetaDataController {
* 返回一个系统级的大图
*/
@ApiOperation
(
tags
=
""
,
value
=
"系统级的大图"
)
// @RequestMapping(path = "/getBigGraph", method = RequestMethod.GET)
@RequestMapping
(
path
=
"/result"
,
method
=
RequestMethod
.
GET
)
public
ReturnReslult
getBigGraph
()
{
logger
.
info
(
"开始获取系统级的大图"
);
ReturnReslult
result
=
new
ReturnReslult
();
public
ReturnReslult
getBigGraph
(
String
modelName0
)
{
logger
.
info
(
"传入的元模型名称是:"
+
modelName0
);
ReturnReslult
returnReslult
=
new
ReturnReslult
();
if
(
modelName0
==
null
||
modelName0
.
equals
(
""
))
{
modelName0
=
"Table"
;
}
if
(!
modelName0
.
toLowerCase
().
equals
(
"all"
)){
returnReslult
=
metadataService
.
findResultByModelName
(
modelName0
);
}
else
{
List
<
MetaData
>
metaDataList
=
metadataService
.
finAllMetaData
();
Map
<
String
,
Node
>
nodeMap
=
new
HashMap
<>();
...
...
@@ -215,7 +108,7 @@ public class MetaDataController {
}
systemNode
.
setType
(
"MetaData"
);
res
ult
.
getNodes
().
add
(
systemNode
);
returnResl
ult
.
getNodes
().
add
(
systemNode
);
nodeMap
.
put
(
""
+
systemNode
.
getId
(),
systemNode
);
child2Parent
.
put
(
""
+
metaData
.
getId
(),
systemNode
.
getId
());
}
...
...
@@ -233,13 +126,11 @@ public class MetaDataController {
}
node
.
setName
(
metaData
.
getName
());
node
.
setType
(
"MetaData"
);
res
ult
.
getNodes
().
add
(
node
);
returnResl
ult
.
getNodes
().
add
(
node
);
nodeMap
.
put
(
""
+
metaData
.
getId
(),
node
);
}
logger
.
info
(
"节点的数量:"
+
result
.
getNodes
().
size
());
logger
.
info
(
"节点的数量:"
+
returnReslult
.
getNodes
().
size
());
List
<
BaseRelationship
>
baseRelationshipList
=
baseRelationshipService
.
findAllRelation
();
/**
* 分成两部分,一个是组合关系,一个是依赖关系。
...
...
@@ -318,43 +209,15 @@ public class MetaDataController {
edge
.
setFromId
(
startMetaId
);
edge
.
setToId
(
endMetaId
);
edge
.
setType
(
baseRelationship
.
getName
());
res
ult
.
getEdges
().
add
(
edge
);
returnResl
ult
.
getEdges
().
add
(
edge
);
}
}
// for(Object obj : child2Parent.keySet()){
// logger.info("child:"+ obj + " ,parent:"+ child2Parent.get(obj));
// }
// for(Object obj : parent2Children.keySet()){
// List<String> children = parent2Children.get(obj);
// logger.info("parent:"+ obj);
// for(String child:children){
// logger.info(" child:" + child );
// }
// }
//
// for(Object obj : source2Target.keySet()){
// List<String> targets = source2Target.get(obj);
// logger.info("source:"+ obj);
// for(String target:targets){
// logger.info(" target:" + target );
// }
// }
//
//
// for(Object obj : target2Source.keySet()){
// List<String> sources = target2Source.get(obj);
// logger.info("target:"+ obj);
// for(String source:sources){
// logger.info(" source:" + source );
// }
// }
logger
.
info
(
"关系的数量:"
+
result
.
getEdges
().
size
());
result
.
setMetaModelMap
(
metaModelMap
);
logger
.
info
(
"关系的数量:"
+
returnReslult
.
getEdges
().
size
());
returnReslult
.
setMetaModelMap
(
metaModelMap
);
}
return
re
s
ult
;
return
re
turnResl
ult
;
}
private
String
getParentId
(
String
neo4jId
,
Map
<
String
,
String
>
child2Parent
)
{
...
...
@@ -530,7 +393,6 @@ public class MetaDataController {
@ApiOperation
(
tags
=
""
,
value
=
"传入元数据id,显示的层数,查找出与该元数据有关系的数据"
)
@RequestMapping
(
path
=
"/getNodeByDataId"
,
method
=
RequestMethod
.
GET
)
public
ReturnReslult
getNodeByDataId
(
String
metadataId
,
int
depth
)
{
return
metadataService
.
findNodeByDataId
(
metadataId
,
depth
);
}
...
...
@@ -544,17 +406,6 @@ public class MetaDataController {
}
/**
* 添加元数据的接口
*/
@RequestMapping
(
path
=
"/addMetadata"
,
method
=
RequestMethod
.
POST
)
public
MetaData
addMetadata
(
@RequestBody
MetaData
metaData
)
{
System
.
out
.
println
(
"这是写入元数据的方法。"
);
MetaData
metaData1
=
metadataService
.
addMetaData
(
metaData
);
return
metaData1
;
}
/**
* 同步元数据关系的接口,传入一个环境名称(catalognName),从mongo读取关系,存入到neo4j中
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment