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
527c2ec0
Commit
527c2ec0
authored
Nov 16, 2021
by
linxu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://132.232.112.242:7022/qiucf/neo4jRelation
parents
6d986d16
8e8c413d
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
285 additions
and
273 deletions
+285
-273
MetadataRelationApplication.java
...etadata/metadataRelation/MetadataRelationApplication.java
+0
-0
FeignClientConfig.java
...e/metadata/metadataRelation/config/FeignClientConfig.java
+0
-0
Neo4jConfig.java
...ymobile/metadata/metadataRelation/config/Neo4jConfig.java
+2
-2
MetaDataController.java
...adata/metadataRelation/controller/MetaDataController.java
+102
-98
BaseRelationship.java
...bile/metadata/metadataRelation/pojo/BaseRelationship.java
+7
-6
CompositionRelation.java
...e/metadata/metadataRelation/pojo/CompositionRelation.java
+1
-1
DependencyRelation.java
...le/metadata/metadataRelation/pojo/DependencyRelation.java
+1
-1
ExecuteRelation.java
...obile/metadata/metadataRelation/pojo/ExecuteRelation.java
+1
-1
InputRelation.java
...ymobile/metadata/metadataRelation/pojo/InputRelation.java
+1
-1
MetaData.java
...om/keymobile/metadata/metadataRelation/pojo/MetaData.java
+7
-5
OutputRelation.java
...mobile/metadata/metadataRelation/pojo/OutputRelation.java
+1
-1
RelationMongo.java
...ymobile/metadata/metadataRelation/pojo/RelationMongo.java
+0
-0
TempNode.java
...om/keymobile/metadata/metadataRelation/pojo/TempNode.java
+0
-0
Edge.java
...obile/metadata/metadataRelation/pojo/returnBean/Edge.java
+0
-2
MetaModel.java
.../metadata/metadataRelation/pojo/returnBean/MetaModel.java
+1
-0
Node.java
...obile/metadata/metadataRelation/pojo/returnBean/Node.java
+1
-0
ReturnReslult.java
...adata/metadataRelation/pojo/returnBean/ReturnReslult.java
+2
-3
BaseRelationshipRepository.java
...adataRelation/respository/BaseRelationshipRepository.java
+1
-1
CompositionRelationRespository.java
...aRelation/respository/CompositionRelationRespository.java
+2
-1
ExecuteRelationRepository.java
...tadataRelation/respository/ExecuteRelationRepository.java
+2
-2
InputRelationReRepository.java
...tadataRelation/respository/InputRelationReRepository.java
+2
-1
MetadataRepository.java
...data/metadataRelation/respository/MetadataRepository.java
+7
-7
OutputRelationRepository.java
...etadataRelation/respository/OutputRelationRepository.java
+2
-1
IBaseRelationshipService.java
...ta/metadataRelation/service/IBaseRelationshipService.java
+8
-9
IMetadataService.java
...e/metadata/metadataRelation/service/IMetadataService.java
+12
-10
BaseRelationshipServiceImpl.java
...ataRelation/service/impl/BaseRelationshipServiceImpl.java
+19
-18
MetadataServiceImpl.java
...ta/metadataRelation/service/impl/MetadataServiceImpl.java
+94
-94
MongoDbServiceImpl.java
...ata/metadataRelation/service/impl/MongoDbServiceImpl.java
+8
-7
Neo4jTool.java
...m/keymobile/metadata/metadataRelation/util/Neo4jTool.java
+1
-1
No files found.
src/main/java/com/keymobile/metadata/metadataRelation/MetadataRelationApplication.java
View file @
527c2ec0
src/main/java/com/keymobile/metadata/metadataRelation/config/FeignClientConfig.java
View file @
527c2ec0
src/main/java/com/keymobile/metadata/metadataRelation/config/Neo4jConfig.java
View file @
527c2ec0
...
...
@@ -26,9 +26,9 @@ public class Neo4jConfig {
@Bean
public
Driver
getNeo4jConnection
()
{
if
(
driver
!=
null
)
{
if
(
driver
!=
null
)
{
}
else
{
}
else
{
driver
=
GraphDatabase
.
driver
(
neo4jUrl
,
AuthTokens
.
basic
(
neo4jUsername
,
neo4jPassword
));
}
return
driver
;
...
...
src/main/java/com/keymobile/metadata/metadataRelation/controller/MetaDataController.java
View file @
527c2ec0
...
...
@@ -45,41 +45,42 @@ public class MetaDataController {
@Autowired
private
IBaseRelationshipService
baseRelationshipService
;
/**
* 查询元数据,关系
* 返回 node,edge,icon
*/
@ApiOperation
(
tags
=
""
,
value
=
"获取所有的节点与关系"
)
@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
<
Long
,
Node
>
nodeMap
=
new
HashMap
<>();
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashMap
<>();
for
(
MetaData
metaData:
metaDataList
)
{
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
))
{
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
);
metaModelMap
.
put
(
modelName
,
model
);
}
node
.
setName
(
metaData
.
getName
());
node
.
setType
(
"MetaData"
);
result
.
getNodes
().
add
(
node
);
nodeMap
.
put
(
metaData
.
getId
(),
node
);
nodeMap
.
put
(
metaData
.
getId
(),
node
);
}
List
<
TempNode
>
allTempNode
=
metadataService
.
findAllTempNode
();
...
...
@@ -90,36 +91,36 @@ public class MetaDataController {
node
.
setId
(
tempNode
.
getMetadataId
());
node
.
setIcon
(
modelName
);
if
(!
metaModelMap
.
containsKey
(
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
);
metaModelMap
.
put
(
modelName
,
model
);
}
node
.
setName
(
tempNode
.
getName
());
node
.
setType
(
"TempNode"
);
result
.
getNodes
().
add
(
node
);
nodeMap
.
put
(
tempNode
.
getId
(),
node
);
nodeMap
.
put
(
tempNode
.
getId
(),
node
);
}
logger
.
info
(
"节点的数量:"
+
result
.
getNodes
().
size
());
logger
.
info
(
"节点的数量:"
+
result
.
getNodes
().
size
());
List
<
BaseRelationship
>
baseRelationshipList
=
baseRelationshipService
.
findAllRelation
();
for
(
BaseRelationship
baseRelationship:
baseRelationshipList
)
{
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
))
{
String
endMEtaId
=
""
;
if
(
nodeMap
.
containsKey
(
startId
))
{
startMetaId
=
nodeMap
.
get
(
startId
).
getId
();
}
if
(
nodeMap
.
containsKey
(
endId
))
{
if
(
nodeMap
.
containsKey
(
endId
))
{
endMEtaId
=
nodeMap
.
get
(
endId
).
getId
();
}
...
...
@@ -134,18 +135,18 @@ public class MetaDataController {
}
logger
.
info
(
"关系的数量:"
+
result
.
getEdges
().
size
());
logger
.
info
(
"关系的数量:"
+
result
.
getEdges
().
size
());
result
.
setMetaModelMap
(
metaModelMap
);
return
result
;
}
@ApiOperation
(
tags
=
""
,
value
=
"传入元模型名称,返回该元模型的元数据所有关系"
)
@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
(
""
))
{
if
(
modelName
==
null
||
modelName
.
equals
(
""
))
{
modelName
=
"Table"
;
}
ReturnReslult
returnReslult
=
metadataService
.
findResultByModelName
(
modelName
);
...
...
@@ -154,6 +155,7 @@ public class MetaDataController {
return
returnReslult
;
}
/**
* 查询元数据
*/
...
...
@@ -167,75 +169,75 @@ public class MetaDataController {
/**
* 返回一个系统级的大图
*/
@ApiOperation
(
tags
=
""
,
value
=
"系统级的大图"
)
@ApiOperation
(
tags
=
""
,
value
=
"系统级的大图"
)
// @RequestMapping(path = "/getBigGraph", method = RequestMethod.GET)
@RequestMapping
(
path
=
"/result"
,
method
=
RequestMethod
.
GET
)
public
ReturnReslult
getBigGraph
(){
public
ReturnReslult
getBigGraph
()
{
logger
.
info
(
"开始获取系统级的大图"
);
ReturnReslult
result
=
new
ReturnReslult
();
List
<
MetaData
>
metaDataList
=
metadataService
.
finAllMetaData
();
Map
<
String
,
Node
>
nodeMap
=
new
HashMap
<>();
Map
<
String
,
Node
>
nodeMap
=
new
HashMap
<>();
Map
<
String
,
String
>
child2Parent
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
parent2Children
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
source2Target
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
target2Source
=
new
HashMap
<>();
Map
<
String
,
String
>
child2Parent
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
parent2Children
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
source2Target
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
target2Source
=
new
HashMap
<>();
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashMap
<>();
for
(
MetaData
metaData:
metaDataList
)
{
for
(
MetaData
metaData
:
metaDataList
)
{
Node
node
=
new
Node
();
String
[]
strings
=
metaData
.
getMetadataId
().
split
(
"="
);
String
modelName
=
strings
[
0
];
//如果有system,则虚拟创建一个节点,用来做顶层节点
if
(
metaData
.
getSystem
()!=
null
&&
!
metaData
.
getSystem
().
equals
(
""
))
{
if
(
metaData
.
getSystem
()
!=
null
&&
!
metaData
.
getSystem
().
equals
(
""
))
{
String
systemName
=
metaData
.
getSystem
();
Node
systemNode
=
new
Node
();
systemNode
.
setId
(
"catalog="
+
systemName
);
systemNode
.
setId
(
"catalog="
+
systemName
);
systemNode
.
setName
(
systemName
);
String
newModelName
=
"Catalog"
;
systemNode
.
setIcon
(
newModelName
);
if
(!
metaModelMap
.
containsKey
(
newModelName
))
{
if
(!
metaModelMap
.
containsKey
(
newModelName
))
{
MetaModel
model
=
new
MetaModel
();
String
iconContext
=
getIconByModelId
(
newModelName
);
model
.
setModelName
(
newModelName
);
model
.
setCnName
(
newModelName
);
model
.
setDescription
(
""
);
model
.
setIcon
(
iconContext
);
metaModelMap
.
put
(
newModelName
,
model
);
metaModelMap
.
put
(
newModelName
,
model
);
}
systemNode
.
setType
(
"MetaData"
);
result
.
getNodes
().
add
(
systemNode
);
nodeMap
.
put
(
""
+
systemNode
.
getId
(),
systemNode
);
child2Parent
.
put
(
""
+
metaData
.
getId
(),
systemNode
.
getId
());
nodeMap
.
put
(
""
+
systemNode
.
getId
(),
systemNode
);
child2Parent
.
put
(
""
+
metaData
.
getId
(),
systemNode
.
getId
());
}
node
.
setId
(
metaData
.
getMetadataId
());
node
.
setIcon
(
modelName
);
if
(!
metaModelMap
.
containsKey
(
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
);
metaModelMap
.
put
(
modelName
,
model
);
}
node
.
setName
(
metaData
.
getName
());
node
.
setType
(
"MetaData"
);
result
.
getNodes
().
add
(
node
);
nodeMap
.
put
(
""
+
metaData
.
getId
(),
node
);
nodeMap
.
put
(
""
+
metaData
.
getId
(),
node
);
}
logger
.
info
(
"节点的数量:"
+
result
.
getNodes
().
size
());
logger
.
info
(
"节点的数量:"
+
result
.
getNodes
().
size
());
List
<
BaseRelationship
>
baseRelationshipList
=
baseRelationshipService
.
findAllRelation
();
...
...
@@ -244,75 +246,75 @@ public class MetaDataController {
*
*/
for
(
BaseRelationship
baseRelationship:
baseRelationshipList
)
{
for
(
BaseRelationship
baseRelationship
:
baseRelationshipList
)
{
Long
startId
=
baseRelationship
.
getStart
().
getId
();
Long
endId
=
baseRelationship
.
getEnd
().
getId
();
if
(
baseRelationship
.
getName
().
equals
(
"流入"
)
||
baseRelationship
.
getName
().
equals
(
"流出"
)){
if
(
baseRelationship
.
getName
().
equals
(
"流入"
)
||
baseRelationship
.
getName
().
equals
(
"流出"
))
{
if
(
source2Target
.
get
(
startId
)!=
null
)
{
source2Target
.
get
(
startId
).
add
(
""
+
endId
);
}
else
{
if
(
source2Target
.
get
(
startId
)
!=
null
)
{
source2Target
.
get
(
startId
).
add
(
""
+
endId
);
}
else
{
List
<
String
>
targets
=
new
ArrayList
<>();
targets
.
add
(
""
+
endId
);
source2Target
.
put
(
""
+
startId
,
targets
);
targets
.
add
(
""
+
endId
);
source2Target
.
put
(
""
+
startId
,
targets
);
}
if
(
target2Source
.
get
(
endId
)!=
null
)
{
target2Source
.
get
(
endId
).
add
(
""
+
startId
);
}
else
{
if
(
target2Source
.
get
(
endId
)
!=
null
)
{
target2Source
.
get
(
endId
).
add
(
""
+
startId
);
}
else
{
List
<
String
>
sources
=
new
ArrayList
<>();
sources
.
add
(
""
+
startId
);
target2Source
.
put
(
""
+
endId
,
sources
);
sources
.
add
(
""
+
startId
);
target2Source
.
put
(
""
+
endId
,
sources
);
}
}
else
if
(
baseRelationship
.
getName
().
equals
(
"流出"
))
{
}
else
if
(
baseRelationship
.
getName
().
equals
(
"流出"
))
{
}
else
if
(
baseRelationship
.
getName
().
equals
(
"组合"
)
)
{
child2Parent
.
put
(
""
+
endId
,
""
+
startId
);
if
(
parent2Children
.
get
(
""
+
startId
)!=
null
)
{
parent2Children
.
get
(
""
+
startId
).
add
(
""
+
endId
);
}
else
{
}
else
if
(
baseRelationship
.
getName
().
equals
(
"组合"
))
{
child2Parent
.
put
(
""
+
endId
,
""
+
startId
);
if
(
parent2Children
.
get
(
""
+
startId
)
!=
null
)
{
parent2Children
.
get
(
""
+
startId
).
add
(
""
+
endId
);
}
else
{
List
<
String
>
children
=
new
ArrayList
<>();
children
.
add
(
""
+
endId
);
children
.
add
(
""
+
endId
);
parent2Children
.
put
(
""
+
startId
,
children
);
parent2Children
.
put
(
""
+
startId
,
children
);
}
}
}
//专门处理流入 流出的关系
for
(
BaseRelationship
baseRelationship:
baseRelationshipList
)
{
for
(
BaseRelationship
baseRelationship
:
baseRelationshipList
)
{
String
startId
=
baseRelationship
.
getStart
().
getId
()
+
""
;
String
endId
=
baseRelationship
.
getEnd
().
getId
()
+
""
;
String
startId
=
baseRelationship
.
getStart
().
getId
()
+
""
;
String
endId
=
baseRelationship
.
getEnd
().
getId
()
+
""
;
String
startMetaId
=
""
;
String
endMetaId
=
""
;
String
endMetaId
=
""
;
if
(
baseRelationship
.
getName
().
equals
(
"流入"
)
||
baseRelationship
.
getName
().
equals
(
"流出"
)){
if
(
baseRelationship
.
getName
().
equals
(
"流入"
)
||
baseRelationship
.
getName
().
equals
(
"流出"
))
{
startId
=
getParentId
(
""
+
startId
,
child2Parent
);
startId
=
getParentId
(
""
+
startId
,
child2Parent
);
// if(child2Parent . containsKey(startId)){
// startId = child2Parent.get(startId);
// }
endId
=
getParentId
(
""
+
endId
,
child2Parent
);
endId
=
getParentId
(
""
+
endId
,
child2Parent
);
// if(child2Parent . containsKey(endId)){
// endId = child2Parent.get(endId);
// }
if
(
nodeMap
.
containsKey
(
""
+
startId
))
{
Node
startNode
=
nodeMap
.
get
(
""
+
startId
);
if
(
nodeMap
.
containsKey
(
""
+
startId
))
{
Node
startNode
=
nodeMap
.
get
(
""
+
startId
);
startMetaId
=
nodeMap
.
get
(
""
+
startId
).
getId
();
startMetaId
=
nodeMap
.
get
(
""
+
startId
).
getId
();
}
if
(
nodeMap
.
containsKey
(
""
+
endId
))
{
endMetaId
=
nodeMap
.
get
(
""
+
endId
).
getId
();
if
(
nodeMap
.
containsKey
(
""
+
endId
))
{
endMetaId
=
nodeMap
.
get
(
""
+
endId
).
getId
();
}
Edge
edge
=
new
Edge
();
edge
.
setEdgeId
(
""
+
baseRelationship
.
getId
());
edge
.
setEdgeId
(
""
+
baseRelationship
.
getId
());
edge
.
setFromId
(
startMetaId
);
edge
.
setToId
(
endMetaId
);
edge
.
setType
(
baseRelationship
.
getName
());
...
...
@@ -349,15 +351,15 @@ public class MetaDataController {
// }
logger
.
info
(
"关系的数量:"
+
result
.
getEdges
().
size
());
logger
.
info
(
"关系的数量:"
+
result
.
getEdges
().
size
());
result
.
setMetaModelMap
(
metaModelMap
);
return
result
;
}
private
String
getParentId
(
String
neo4jId
,
Map
<
String
,
String
>
child2Parent
)
{
private
String
getParentId
(
String
neo4jId
,
Map
<
String
,
String
>
child2Parent
)
{
String
parentId
=
neo4jId
;
while
(
child2Parent
.
containsKey
(
neo4jId
))
{
while
(
child2Parent
.
containsKey
(
neo4jId
))
{
parentId
=
child2Parent
.
get
(
neo4jId
);
neo4jId
=
parentId
;
}
...
...
@@ -370,38 +372,38 @@ public class MetaDataController {
* 传入一个节点与层数,返回指定节点的直接下层节点
*/
@ApiOperation
(
tags
=
""
,
value
=
"开始获取直接下层节点"
)
@ApiOperation
(
tags
=
""
,
value
=
"开始获取直接下层节点"
)
@RequestMapping
(
path
=
"/getNextDrill"
,
method
=
RequestMethod
.
GET
)
public
ReturnReslult
getNextDrill
(
String
dataId
){
public
ReturnReslult
getNextDrill
(
String
dataId
)
{
logger
.
info
(
"开始获取直接下层节点"
);
List
<
MetaData
>
metaDataList
=
new
ArrayList
<>();
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashMap
<>();
ReturnReslult
result
=
new
ReturnReslult
();
//如果是系统,就用名称去查询,如果是其他类型,就用id去查询
if
(
dataId
.
startsWith
(
"catalog="
))
{
if
(
dataId
.
startsWith
(
"catalog="
))
{
String
[]
dataIds
=
dataId
.
split
(
"="
);
String
dataName
=
dataIds
[
1
];
metaDataList
=
metadataService
.
findChildrenByParentName
(
dataName
);
}
else
{
}
else
{
metaDataList
=
metadataService
.
findChildrenByParentId
(
dataId
);
}
for
(
MetaData
metaData:
metaDataList
)
{
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
))
{
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
);
metaModelMap
.
put
(
modelName
,
model
);
}
node
.
setName
(
metaData
.
getName
());
...
...
@@ -417,9 +419,9 @@ public class MetaDataController {
* 修改图片的接口,传入元模型id,新图标
*/
@ApiOperation
(
tags
=
""
,
value
=
"修改元模型图标的接口"
)
@PostMapping
(
value
=
"/modifyIcon"
,
consumes
=
"multipart/*"
,
headers
=
"content-type=multipart/form-date"
)
public
String
modifyIcon
(
String
modelId
,
@ApiParam
(
value
=
"上传的文件"
,
required
=
true
)
@ApiOperation
(
tags
=
""
,
value
=
"修改元模型图标的接口"
)
@PostMapping
(
value
=
"/modifyIcon"
,
consumes
=
"multipart/*"
,
headers
=
"content-type=multipart/form-date"
)
public
String
modifyIcon
(
String
modelId
,
@ApiParam
(
value
=
"上传的文件"
,
required
=
true
)
MultipartFile
file
)
{
if
(
file
.
isEmpty
())
{
logger
.
info
(
"文件为空空"
);
...
...
@@ -429,14 +431,14 @@ public class MetaDataController {
ApplicationHome
applicationHome
=
new
ApplicationHome
(
getClass
());
File
jarFile
=
applicationHome
.
getSource
();
String
dirPath
=
jarFile
.
getParentFile
().
toString
()
+
"/Icon/"
+
modelId
+
"/"
;
String
dirPath
=
jarFile
.
getParentFile
().
toString
()
+
"/Icon/"
+
modelId
+
"/"
;
logger
.
info
(
"存放图标的路径:"
+
dirPath
);
logger
.
info
(
"存放图标的路径:"
+
dirPath
);
// fileName = "Icon_"+modelId + suffixName; // 新文件名
File
dest
=
new
File
(
dirPath
+
fileName
);
if
(!
dest
.
getParentFile
().
exists
())
{
//如果文件夹不存在,就创建,
dest
.
getParentFile
().
mkdirs
();
}
else
{
//如果文件夹存在,就先清空里面的文件
}
else
{
//如果文件夹存在,就先清空里面的文件
File
[]
files
=
dest
.
getParentFile
().
listFiles
();
if
(
files
!=
null
)
{
//如果包含文件进行删除操作
...
...
@@ -463,21 +465,21 @@ public class MetaDataController {
/**
* 获取元模型的图标,
*/
@ApiOperation
(
tags
=
""
,
value
=
"获取元模型的图标"
)
@RequestMapping
(
value
=
"/getIconByModelId"
,
method
=
RequestMethod
.
GET
)
@ApiOperation
(
tags
=
""
,
value
=
"获取元模型的图标"
)
@RequestMapping
(
value
=
"/getIconByModelId"
,
method
=
RequestMethod
.
GET
)
public
String
getIconByModelId
(
String
modelId
)
{
ApplicationHome
applicationHome
=
new
ApplicationHome
(
getClass
());
File
jarFile
=
applicationHome
.
getSource
();
String
dirPath
=
jarFile
.
getParentFile
().
toString
()
+
"/Icon/"
+
modelId
+
"/"
;
String
dirPath
=
jarFile
.
getParentFile
().
toString
()
+
"/Icon/"
+
modelId
+
"/"
;
String
encodeIcon
=
""
;
File
dest
=
new
File
(
dirPath
);
File
[]
files
=
dest
.
listFiles
();
if
(
files
!=
null
&&
files
.
length
!=
0
)
{
if
(
files
!=
null
&&
files
.
length
!=
0
)
{
File
iconFile
=
files
[
0
];
String
fileName
=
iconFile
.
getAbsolutePath
();
encodeIcon
=
GetImageStr
(
fileName
);
}
else
{
}
else
{
}
return
encodeIcon
;
...
...
@@ -485,7 +487,7 @@ public class MetaDataController {
// 图片转化成base64字符串
public
static
String
GetImageStr
(
String
imgFile
)
{
// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
logger
.
info
(
"存放图标的路径:"
+
imgFile
);
logger
.
info
(
"存放图标的路径:"
+
imgFile
);
InputStream
in
=
null
;
byte
[]
data
=
null
;
// 读取图片字节数组
...
...
@@ -505,7 +507,7 @@ public class MetaDataController {
/**
* 查询所有的关系类型
*/
@ApiOperation
(
tags
=
""
,
value
=
"查询所有的关系类型"
)
@ApiOperation
(
tags
=
""
,
value
=
"查询所有的关系类型"
)
@RequestMapping
(
path
=
"/listAllRelationType"
,
method
=
RequestMethod
.
GET
)
public
List
<
String
>
getAllRelationType
()
{
...
...
@@ -515,20 +517,21 @@ public class MetaDataController {
/**
* 查询所有的节点类型
*/
@ApiOperation
(
tags
=
""
,
value
=
"查询所有的节点类型"
)
@ApiOperation
(
tags
=
""
,
value
=
"查询所有的节点类型"
)
@RequestMapping
(
path
=
"/listAllNodeType"
,
method
=
RequestMethod
.
GET
)
public
List
<
String
>
getAllNodeType
()
{
return
metadataService
.
findAllNodeTypes
();
}
/**
* 传入元数据id,显示的层数,查找出与该元数据有关系的数据
*/
@ApiOperation
(
tags
=
""
,
value
=
"传入元数据id,显示的层数,查找出与该元数据有关系的数据"
)
@ApiOperation
(
tags
=
""
,
value
=
"传入元数据id,显示的层数,查找出与该元数据有关系的数据"
)
@RequestMapping
(
path
=
"/getNodeByDataId"
,
method
=
RequestMethod
.
GET
)
public
ReturnReslult
getNodeByDataId
(
String
metadataId
,
int
depth
)
{
return
metadataService
.
findNodeByDataId
(
metadataId
,
depth
);
return
metadataService
.
findNodeByDataId
(
metadataId
,
depth
);
}
/**
...
...
@@ -555,11 +558,12 @@ public class MetaDataController {
/**
* 同步元数据关系的接口,传入一个环境名称(catalognName),从mongo读取关系,存入到neo4j中
*
* @return
*/
@ApiOperation
(
tags
=
""
,
value
=
"同步元数据关系的接口"
)
@ApiOperation
(
tags
=
""
,
value
=
"同步元数据关系的接口"
)
@RequestMapping
(
path
=
"/syschroRelationFromMongo"
,
method
=
RequestMethod
.
GET
)
public
String
syschroRelationFromMongo
(
String
catalogName
){
public
String
syschroRelationFromMongo
(
String
catalogName
)
{
logger
.
info
(
"开始同步元数据:从mongo到neo4j"
);
String
flag
=
"success"
;
metadataService
.
syschroRelationFromMongo
(
catalogName
);
...
...
src/main/java/com/keymobile/metadata/metadataRelation/pojo/BaseRelationship.java
View file @
527c2ec0
...
...
@@ -5,7 +5,7 @@ import org.neo4j.ogm.annotation.Property;
import
org.neo4j.ogm.annotation.RelationshipEntity
;
import
org.neo4j.ogm.annotation.StartNode
;
public
class
BaseRelationship
<
S
extends
BaseNode
,
E
extends
BaseNode
>
extends
AllBaseEntity
{
public
class
BaseRelationship
<
S
extends
BaseNode
,
E
extends
BaseNode
>
extends
AllBaseEntity
{
@Property
private
String
name
;
//关系名称
...
...
@@ -15,13 +15,14 @@ public class BaseRelationship <S extends BaseNode, E extends BaseNode> extends A
@EndNode
private
E
end
;
public
BaseRelationship
(){
public
BaseRelationship
()
{
}
public
BaseRelationship
(
String
name
,
S
start
,
E
end
)
{
this
.
name
=
name
;
this
.
start
=
start
;
this
.
end
=
end
;
public
BaseRelationship
(
String
name
,
S
start
,
E
end
)
{
this
.
name
=
name
;
this
.
start
=
start
;
this
.
end
=
end
;
}
@Override
...
...
src/main/java/com/keymobile/metadata/metadataRelation/pojo/CompositionRelation.java
View file @
527c2ec0
...
...
@@ -3,5 +3,5 @@ package com.keymobile.metadata.metadataRelation.pojo;
import
org.neo4j.ogm.annotation.RelationshipEntity
;
@RelationshipEntity
(
type
=
"Composition"
)
public
class
CompositionRelation
extends
BaseRelationship
{
public
class
CompositionRelation
extends
BaseRelationship
{
}
src/main/java/com/keymobile/metadata/metadataRelation/pojo/DependencyRelation.java
View file @
527c2ec0
...
...
@@ -3,5 +3,5 @@ package com.keymobile.metadata.metadataRelation.pojo;
import
org.neo4j.ogm.annotation.RelationshipEntity
;
@RelationshipEntity
(
type
=
"Dependency"
)
public
class
DependencyRelation
extends
BaseRelationship
{
public
class
DependencyRelation
extends
BaseRelationship
{
}
src/main/java/com/keymobile/metadata/metadataRelation/pojo/ExecuteRelation.java
View file @
527c2ec0
...
...
@@ -3,6 +3,6 @@ package com.keymobile.metadata.metadataRelation.pojo;
import
org.neo4j.ogm.annotation.RelationshipEntity
;
@RelationshipEntity
(
type
=
"Execute"
)
public
class
ExecuteRelation
extends
BaseRelationship
{
public
class
ExecuteRelation
extends
BaseRelationship
{
}
src/main/java/com/keymobile/metadata/metadataRelation/pojo/InputRelation.java
View file @
527c2ec0
...
...
@@ -3,5 +3,5 @@ package com.keymobile.metadata.metadataRelation.pojo;
import
org.neo4j.ogm.annotation.RelationshipEntity
;
@RelationshipEntity
(
type
=
"Input"
)
public
class
InputRelation
extends
BaseRelationship
{
public
class
InputRelation
extends
BaseRelationship
{
}
src/main/java/com/keymobile/metadata/metadataRelation/pojo/MetaData.java
View file @
527c2ec0
...
...
@@ -6,6 +6,7 @@ import org.neo4j.ogm.annotation.Relationship;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
@NodeEntity
(
label
=
"MetaData"
)
public
class
MetaData
extends
BaseNode
{
public
String
getMetadataId
()
{
...
...
@@ -77,15 +78,15 @@ public class MetaData extends BaseNode {
}
public
void
addRelation
(
DependencyRelation
friendshipRelation
){
if
(
this
.
dependencyRelationList
==
null
)
{
public
void
addRelation
(
DependencyRelation
friendshipRelation
)
{
if
(
this
.
dependencyRelationList
==
null
)
{
dependencyRelationList
=
new
ArrayList
<
DependencyRelation
>();
}
dependencyRelationList
.
add
(
friendshipRelation
);
}
public
List
<
DependencyRelation
>
getDependencyRelationList
()
{
if
(
this
.
dependencyRelationList
==
null
)
{
if
(
this
.
dependencyRelationList
==
null
)
{
dependencyRelationList
=
new
ArrayList
<
DependencyRelation
>();
}
return
dependencyRelationList
;
...
...
@@ -94,12 +95,13 @@ public class MetaData extends BaseNode {
public
void
setDependencyRelationList
(
List
<
DependencyRelation
>
dependencyRelationList
)
{
this
.
dependencyRelationList
=
dependencyRelationList
;
}
@Relationship
(
type
=
"Dependency_RELATION"
)
private
List
<
DependencyRelation
>
dependencyRelationList
;
public
List
<
DependencyRelation
>
getCompositionRelationList
()
{
if
(
this
.
compositionRelationList
==
null
)
{
if
(
this
.
compositionRelationList
==
null
)
{
compositionRelationList
=
new
ArrayList
<
DependencyRelation
>();
}
return
compositionRelationList
;
...
...
@@ -110,7 +112,7 @@ public class MetaData extends BaseNode {
}
@Relationship
(
type
=
"Composition_RELATION"
)
private
List
<
DependencyRelation
>
compositionRelationList
;
private
List
<
DependencyRelation
>
compositionRelationList
;
public
String
getNode
()
{
...
...
src/main/java/com/keymobile/metadata/metadataRelation/pojo/OutputRelation.java
View file @
527c2ec0
...
...
@@ -3,5 +3,5 @@ package com.keymobile.metadata.metadataRelation.pojo;
import
org.neo4j.ogm.annotation.RelationshipEntity
;
@RelationshipEntity
(
type
=
"Output"
)
public
class
OutputRelation
extends
BaseRelationship
{
public
class
OutputRelation
extends
BaseRelationship
{
}
src/main/java/com/keymobile/metadata/metadataRelation/pojo/RelationMongo.java
View file @
527c2ec0
src/main/java/com/keymobile/metadata/metadataRelation/pojo/TempNode.java
View file @
527c2ec0
src/main/java/com/keymobile/metadata/metadataRelation/pojo/returnBean/Edge.java
View file @
527c2ec0
...
...
@@ -9,8 +9,6 @@ public class Edge {
private
String
type
;
public
String
getEdgeId
()
{
return
edgeId
;
}
...
...
src/main/java/com/keymobile/metadata/metadataRelation/pojo/returnBean/MetaModel.java
View file @
527c2ec0
...
...
@@ -6,6 +6,7 @@ public class MetaModel {
private
String
cnName
;
private
String
description
;
public
String
getModelName
()
{
return
modelName
;
}
...
...
src/main/java/com/keymobile/metadata/metadataRelation/pojo/returnBean/Node.java
View file @
527c2ec0
...
...
@@ -16,6 +16,7 @@ public class Node {
private
String
icon
;
private
String
type
;
public
String
getType
()
{
return
type
;
}
...
...
src/main/java/com/keymobile/metadata/metadataRelation/pojo/returnBean/ReturnReslult.java
View file @
527c2ec0
...
...
@@ -9,7 +9,7 @@ import java.util.Map;
public
class
ReturnReslult
{
private
List
<
Edge
>
edges
=
new
ArrayList
<>();
private
List
<
Edge
>
edges
=
new
ArrayList
<>();
private
List
<
Node
>
nodes
=
new
ArrayList
<>();
...
...
@@ -21,8 +21,7 @@ public class ReturnReslult {
this
.
metaModelMap
=
metaModelMap
;
}
private
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashedMap
();
private
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashedMap
();
public
List
<
Edge
>
getEdges
()
{
...
...
src/main/java/com/keymobile/metadata/metadataRelation/respository/BaseRelationshipRepository.java
View file @
527c2ec0
...
...
@@ -9,6 +9,6 @@ import org.springframework.stereotype.Repository;
import
java.util.List
;
@Repository
public
interface
BaseRelationshipRepository
extends
Neo4jRepository
<
BaseRelationship
,
Long
>
{
public
interface
BaseRelationshipRepository
extends
Neo4jRepository
<
BaseRelationship
,
Long
>
{
}
src/main/java/com/keymobile/metadata/metadataRelation/respository/CompositionRelationRespository.java
View file @
527c2ec0
...
...
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Repository;
import
java.util.List
;
@Repository
public
interface
CompositionRelationRespository
extends
Neo4jRepository
<
CompositionRelation
,
Long
>
{
public
interface
CompositionRelationRespository
extends
Neo4jRepository
<
CompositionRelation
,
Long
>
{
@Query
(
"MATCH (n:MetaData{metadataId: $startId}),(n1:MetaData{metadataId: $endId}),p=(n)-[]-(n1) return p"
)
List
<
CompositionRelation
>
findCompositionRelationship
(
@Param
(
"startId"
)
String
startId
,
@Param
(
"endId"
)
String
endId
);
...
...
@@ -17,6 +17,7 @@ public interface CompositionRelationRespository extends Neo4jRepository<Composit
/**
* 添加组合关系
*
* @param sourceId
* @param targetId
* @return
...
...
src/main/java/com/keymobile/metadata/metadataRelation/respository/ExecuteRelationRepository.java
View file @
527c2ec0
...
...
@@ -9,10 +9,11 @@ import org.springframework.stereotype.Repository;
import
java.util.List
;
@Repository
public
interface
ExecuteRelationRepository
extends
Neo4jRepository
<
ExecuteRelation
,
Long
>
{
public
interface
ExecuteRelationRepository
extends
Neo4jRepository
<
ExecuteRelation
,
Long
>
{
/**
* 添加excute关系
*
* @param sourceId
* @param targetId
* @return
...
...
@@ -24,5 +25,4 @@ public interface ExecuteRelationRepository extends Neo4jRepository<ExecuteRelati
List
<
ExecuteRelation
>
findExecuteRelationship
(
@Param
(
"startId"
)
String
startId
,
@Param
(
"endId"
)
String
endId
);
}
src/main/java/com/keymobile/metadata/metadataRelation/respository/InputRelationReRepository.java
View file @
527c2ec0
...
...
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Repository;
import
java.util.List
;
@Repository
public
interface
InputRelationReRepository
extends
Neo4jRepository
<
InputRelation
,
Long
>
{
public
interface
InputRelationReRepository
extends
Neo4jRepository
<
InputRelation
,
Long
>
{
@Query
(
"MATCH (n:MetaData{metadataId: $startId}),(n1:MetaData{metadataId: $endId}),p=(n)-[]-(n1) return p"
)
...
...
@@ -18,6 +18,7 @@ public interface InputRelationReRepository extends Neo4jRepository<InputRelation
/**
* 添加input关系
*
* @param sourceId
* @param targetId
* @return
...
...
src/main/java/com/keymobile/metadata/metadataRelation/respository/MetadataRepository.java
View file @
527c2ec0
...
...
@@ -10,30 +10,30 @@ import org.springframework.stereotype.Repository;
import
java.util.List
;
@Repository
public
interface
MetadataRepository
extends
Neo4jRepository
<
MetaData
,
Long
>
{
public
interface
MetadataRepository
extends
Neo4jRepository
<
MetaData
,
Long
>
{
MetaData
findMetadataByName
(
String
name
);
@Query
(
"match (n:MetaData ) where n.metadataId =~{modelName} return n"
)
List
<
MetaData
>
findMetaDataByModelName
(
@Param
(
"modelName"
)
String
dataName
);
List
<
MetaData
>
findMetaDataByModelName
(
@Param
(
"modelName"
)
String
dataName
);
//MATCH p=(a:MetaData{metadataId:"Table=1=b148ad31504d4487bd81ecebbc7522c3"})-[r:Composition]->() -[*]->()<-[r1:Composition]-(b:MetaData{metadataId:"Table=368=600efbf1fb4a4bd1910dbc1b567d6691"})
//MATCH p=(a:MetaData{metadataId:"Table=1=b148ad31504d4487bd81ecebbc7522c3"})-[r:Composition]->() -[*]->()<-[r1:Composition]-(b:MetaData{metadataId:"Table=368=600efbf1fb4a4bd1910dbc1b567d6691"})
//RETURN p
MetaData
findMetaDataByMetadataId
(
String
id
);
/**
* @Query("MATCH (n : MetaData { metadataId : $startId }), (n1 : MetaData { metadataId : $endId }), p=(n)-[]-(n1) return p")
* List<OutputRelation> findOutputRelationship(@Param("startId") String startId, @Param("endId") String endId);
* @param dataName
* @return
* @Query("MATCH (n : MetaData { metadataId : $startId }), (n1 : MetaData { metadataId : $endId }), p=(n)-[]-(n1) return p")
* List<OutputRelation> findOutputRelationship(@Param("startId") String startId, @Param("endId") String endId);
*/
@Query
(
"match data=(na:MetaData{name:{0}})<-[rel*1..3]->(nb:MetaData) return data"
)
List
<
MetaData
>
findMetaData
(
@Param
(
"dataName"
)
String
dataName
,
@Param
(
"n"
)
int
n
);
List
<
MetaData
>
findMetaData
(
@Param
(
"dataName"
)
String
dataName
,
@Param
(
"n"
)
int
n
);
@Query
(
"match (data:MetaData{system:{parentName}}) return data"
)
List
<
MetaData
>
findMetaDataByParentName
(
@Param
(
"parentName"
)
String
parentName
);
List
<
MetaData
>
findMetaDataByParentName
(
@Param
(
"parentName"
)
String
parentName
);
@Query
(
"MATCH p=(n:MetaData {metadataId:{parentId}})-[r:Composition]->(m) RETURN m"
)
List
<
MetaData
>
findMetaDataByParentId
(
@Param
(
"parentId"
)
String
parentId
);
...
...
src/main/java/com/keymobile/metadata/metadataRelation/respository/OutputRelationRepository.java
View file @
527c2ec0
...
...
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Repository;
import
java.util.List
;
@Repository
public
interface
OutputRelationRepository
extends
Neo4jRepository
<
OutputRelation
,
Long
>
{
public
interface
OutputRelationRepository
extends
Neo4jRepository
<
OutputRelation
,
Long
>
{
@Query
(
"MATCH (n:MetaData{metadataId: $startId}),(n1:MetaData{metadataId: $endId}),p=(n)-[]-(n1) return p"
)
List
<
OutputRelation
>
findOutputRelationship
(
@Param
(
"startId"
)
String
startId
,
@Param
(
"endId"
)
String
endId
);
...
...
@@ -17,6 +17,7 @@ public interface OutputRelationRepository extends Neo4jRepository<OutputRelation
/**
* 添加output关系
*
* @param sourceId
* @param targetId
* @return
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/IBaseRelationshipService.java
View file @
527c2ec0
...
...
@@ -20,52 +20,51 @@ public interface IBaseRelationshipService {
List
<
String
>
findAllRelationTypes
();
/**
* @desc 添加关系
* @param relationship
* @desc 添加关系
*/
BaseRelationship
addRelationship
(
BaseRelationship
relationship
);
/**
* @desc 添加关系
* @param name 关系名称
* @param startNode 开始节点
* @param endNode 结束节点
* @desc 添加关系
*/
BaseRelationship
addRelationship
(
String
name
,
BaseNode
startNode
,
BaseNode
endNode
);
/**
* @desc 删除关系
* @param id
* @desc 删除关系
*/
boolean
deleteRelationshipById
(
Long
id
);
/**
* @desc 获取关系 根据开始节点名称和关系名称
* @param name 关系名称
* @param startName 开始节点名称
* @param endName 结束节点名称
* @desc 获取关系 根据开始节点名称和关系名称
*/
List
<
BaseRelationship
>
findMetadataRelationshipByAllName
(
String
name
,
String
startName
,
String
endName
);
/**
* @desc 获取关系 根据节点名称和关系名称
* @param name 关系名称
* @param startName 开始节点名称
* @desc 获取关系 根据节点名称和关系名称
*/
List
<
BaseRelationship
>
findMetadataRelationshipByStartNameAndName
(
String
name
,
String
startName
);
/**
* @desc 获取关系 根据节点名称和关系名称
* @param startName 开始节点名称
* @desc 获取关系 根据节点名称和关系名称
*/
List
<
BaseRelationship
>
findMetadataRelationshipByStartName
(
String
startName
);
/**
* @desc 根据节点名称,获取所有有关系的节点
* @param startName 开始节点名称
* @desc 根据节点名称, 获取所有有关系的节点
*/
List
<
BaseNode
>
findMetadataByStartName
(
String
startName
);
}
src/main/java/com/keymobile/metadata/metadataRelation/service/IMetadataService.java
View file @
527c2ec0
...
...
@@ -9,66 +9,68 @@ import java.util.List;
public
interface
IMetadataService
{
List
<
MetaData
>
findNodeByName
(
String
dataName
);
List
<
MetaData
>
findNodeByName
(
String
dataName
);
ReturnReslult
findNodeByDataId
(
String
metadataId
,
int
depth
);
ReturnReslult
findNodeByDataId
(
String
metadataId
,
int
depth
);
ReturnReslult
findResultByModelName
(
String
modelName
);
ReturnReslult
findResultByModelName
(
String
modelName
);
List
<
MetaData
>
findChildrenByParentId
(
String
parentId
);
List
<
MetaData
>
findChildrenByParentName
(
String
parentName
);
List
<
MetaData
>
finAllMetaData
();
/**
* 添加元数据对象
*
* @param metaData
*/
MetaData
addMetaData
(
MetaData
metaData
);
/**
* @desc 根据名称添加元数据
* @param name
* @desc 根据名称添加元数据
*/
MetaData
addMetadataByName
(
String
name
);
void
syschroRelationFromMongo
(
String
catalogName
);
/**
* 添加元数据对象
*
* @param id
*/
MetaData
getMetaDataById
(
Long
id
);
/**
* @desc 根据名称获取元数据
* @param name
* @desc 根据名称获取元数据
*/
MetaData
getMetadataByName
(
String
name
);
/**
* @desc 根据ID删除人物节点
* @param id
* @desc 根据ID删除人物节点
*/
boolean
deleteMetadata
(
Long
id
);
/**
* @desc 添加元数据的关系
* @param name 关系名称
* @param startName 开始节点名称
* @param endName 结束节点名称
* @return BaseRelationship
* @desc 添加元数据的关系
*/
BaseRelationship
addMetadataRelationship
(
String
name
,
String
startName
,
String
endName
);
/**
* @desc 获取任务关系
* @param name 关系名称
* @param startName 开始节点名称
* @param endName 结束节点名称
* @desc 获取任务关系
*/
List
<
BaseRelationship
>
getMetadataRelationship
(
String
name
,
String
startName
,
String
endName
);
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/BaseRelationshipServiceImpl.java
View file @
527c2ec0
...
...
@@ -26,9 +26,9 @@ public class BaseRelationshipServiceImpl implements IBaseRelationshipService {
@Autowired
BaseRelationshipRepository
refRepository
;
@Autowired
private
CompositionRelationRespository
compositionRelationRespository
;
private
CompositionRelationRespository
compositionRelationRespository
;
@Autowired
private
InputRelationReRepository
inputRelationReRepository
;
private
InputRelationReRepository
inputRelationReRepository
;
@Autowired
private
OutputRelationRepository
outputRelationRepository
;
@Autowired
...
...
@@ -37,30 +37,30 @@ public class BaseRelationshipServiceImpl implements IBaseRelationshipService {
@Override
public
List
<
BaseRelationship
>
findAllRelation
()
{
List
<
CompositionRelation
>
compositionRelationList
=
(
List
<
CompositionRelation
>)
compositionRelationRespository
.
findAll
();
List
<
CompositionRelation
>
compositionRelationList
=
(
List
<
CompositionRelation
>)
compositionRelationRespository
.
findAll
();
List
<
InputRelation
>
inputRelationList
=
(
List
<
InputRelation
>)
inputRelationReRepository
.
findAll
();
List
<
InputRelation
>
inputRelationList
=
(
List
<
InputRelation
>)
inputRelationReRepository
.
findAll
();
List
<
OutputRelation
>
outputRelationList
=
(
List
<
OutputRelation
>)
outputRelationRepository
.
findAll
();
List
<
OutputRelation
>
outputRelationList
=
(
List
<
OutputRelation
>)
outputRelationRepository
.
findAll
();
List
<
ExecuteRelation
>
executeRelationList
=
(
List
<
ExecuteRelation
>)
executeRelationRepository
.
findAll
();
List
<
ExecuteRelation
>
executeRelationList
=
(
List
<
ExecuteRelation
>)
executeRelationRepository
.
findAll
();
List
<
BaseRelationship
>
baseRelationshipList
=
new
ArrayList
<>();
for
(
CompositionRelation
compositionRelation:
compositionRelationList
)
{
for
(
CompositionRelation
compositionRelation
:
compositionRelationList
)
{
compositionRelation
.
setName
(
"组合"
);
baseRelationshipList
.
add
(
compositionRelation
);
}
for
(
InputRelation
inputRelation:
inputRelationList
)
{
for
(
InputRelation
inputRelation
:
inputRelationList
)
{
inputRelation
.
setName
(
"流入"
);
baseRelationshipList
.
add
(
inputRelation
);
}
for
(
OutputRelation
outputRelation:
outputRelationList
)
{
for
(
OutputRelation
outputRelation
:
outputRelationList
)
{
outputRelation
.
setName
(
"流出"
);
baseRelationshipList
.
add
(
outputRelation
);
}
for
(
ExecuteRelation
executeRelation:
executeRelationList
)
{
for
(
ExecuteRelation
executeRelation
:
executeRelationList
)
{
executeRelation
.
setName
(
"执行"
);
baseRelationshipList
.
add
(
executeRelation
);
}
...
...
@@ -76,8 +76,8 @@ public class BaseRelationshipServiceImpl implements IBaseRelationshipService {
Neo4jConfig
neo4jConfig
=
new
Neo4jConfig
();
Driver
neo4jConnection
=
neo4jConfig
.
getNeo4jConnection
();
Session
session
=
neo4jConnection
.
session
();
String
cypher
=
" MATCH (n:MetaData)-[r]->() RETURN id(STARTNODE(r)) as startId,id(endNode(r)) as endId, type(r) as name"
;
logger
.
info
(
"cypher:"
+
cypher
);
String
cypher
=
" MATCH (n:MetaData)-[r]->() RETURN id(STARTNODE(r)) as startId,id(endNode(r)) as endId, type(r) as name"
;
logger
.
info
(
"cypher:"
+
cypher
);
StatementResult
result
=
session
.
run
(
cypher
);
while
(
result
.
hasNext
())
{
...
...
@@ -86,13 +86,13 @@ public class BaseRelationshipServiceImpl implements IBaseRelationshipService {
Long
endId
=
record
.
get
(
"endId"
).
asLong
();
String
name
=
record
.
get
(
"name"
).
asString
();
if
(
name
.
equals
(
"Input"
))
{
if
(
name
.
equals
(
"Input"
))
{
name
=
"流入"
;
}
else
if
(
name
.
equals
(
"Output"
))
{
}
else
if
(
name
.
equals
(
"Output"
))
{
name
=
"流出"
;
}
else
if
(
name
.
equals
(
"Composition"
))
{
}
else
if
(
name
.
equals
(
"Composition"
))
{
name
=
"组合"
;
}
else
if
(
name
.
equals
(
"Execute"
))
{
}
else
if
(
name
.
equals
(
"Execute"
))
{
name
=
"执行"
;
}
...
...
@@ -101,7 +101,7 @@ public class BaseRelationshipServiceImpl implements IBaseRelationshipService {
// } else {
// name = startId + "-" + name + "-" + endId;
// }
if
(!
relationTypes
.
contains
(
name
))
{
if
(!
relationTypes
.
contains
(
name
))
{
relationTypes
.
add
(
name
);
}
}
...
...
@@ -116,7 +116,7 @@ public class BaseRelationshipServiceImpl implements IBaseRelationshipService {
@Override
public
BaseRelationship
addRelationship
(
String
name
,
BaseNode
startNode
,
BaseNode
endNode
)
{
BaseRelationship
relationship
=
new
BaseRelationship
(
name
,
startNode
,
endNode
);
BaseRelationship
relationship
=
new
BaseRelationship
(
name
,
startNode
,
endNode
);
return
refRepository
.
save
(
relationship
);
}
...
...
@@ -152,6 +152,7 @@ public class BaseRelationshipServiceImpl implements IBaseRelationshipService {
// }
return
null
;
}
@Override
public
List
<
BaseNode
>
findMetadataByStartName
(
String
startName
)
{
// List<BaseNode> nodes = refRepository.findBaseNodeByStartName(startName);
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/MetadataServiceImpl.java
View file @
527c2ec0
...
...
@@ -45,7 +45,7 @@ public class MetadataServiceImpl implements IMetadataService {
@Autowired
private
CompositionRelationRespository
compositionRelationRespository
;
@Autowired
private
InputRelationReRepository
inputRelationReRepository
;
private
InputRelationReRepository
inputRelationReRepository
;
@Autowired
private
OutputRelationRepository
outputRelationRepository
;
@Autowired
...
...
@@ -68,7 +68,7 @@ public class MetadataServiceImpl implements IMetadataService {
@Override
public
List
<
MetaData
>
findNodeByName
(
String
dataName
)
{
return
metadataRepository
.
findMetaData
(
dataName
,
3
);
return
metadataRepository
.
findMetaData
(
dataName
,
3
);
}
@Override
...
...
@@ -80,12 +80,12 @@ public class MetadataServiceImpl implements IMetadataService {
Neo4jConfig
neo4jConfig
=
new
Neo4jConfig
();
Driver
neo4jConnection
=
neo4jConfig
.
getNeo4jConnection
();
Session
session
=
neo4jConnection
.
session
();
String
cypher
=
"match data=(na:MetaData{metadataId:'"
+
metadataId
+
"'})<-[*1.."
+
depth
+
"]->(nb:MetaData) return data"
;
logger
.
info
(
"cypher:"
+
cypher
);
String
cypher
=
"match data=(na:MetaData{metadataId:'"
+
metadataId
+
"'})<-[*1.."
+
depth
+
"]->(nb:MetaData) return data"
;
logger
.
info
(
"cypher:"
+
cypher
);
StatementResult
result
=
session
.
run
(
cypher
);
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashMap
<>();
while
(
result
.
hasNext
()
)
{
while
(
result
.
hasNext
())
{
Record
record
=
result
.
next
();
List
<
Value
>
values
=
record
.
values
();
for
(
Value
value
:
values
)
{
...
...
@@ -97,7 +97,7 @@ public class MetadataServiceImpl implements IMetadataService {
Map
<
String
,
Object
>
stringObjectMap
=
node
.
asMap
();
MetaData
metaData
=
new
MetaData
();
Neo4jTool
.
transMap2Bean
(
stringObjectMap
,
metaData
);
Neo4jTool
.
transMap2Bean
(
stringObjectMap
,
metaData
);
// metaDataList.add(data);
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
.
Node
returnNode
=
new
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
.
Node
();
...
...
@@ -108,14 +108,14 @@ public class MetadataServiceImpl implements IMetadataService {
String
modelName
=
strings
[
0
];
returnNode
.
setIcon
(
modelName
);
if
(!
metaModelMap
.
containsKey
(
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
);
metaModelMap
.
put
(
modelName
,
model
);
}
returnNode
.
setType
(
"MetaData"
);
returnReslult
.
getNodes
().
add
(
returnNode
);
...
...
@@ -140,12 +140,12 @@ public class MetadataServiceImpl implements IMetadataService {
edge
.
setEdgeId
(
String
.
valueOf
(
relationship
.
id
()));
String
startMetaId
=
""
;
String
endMEtaId
=
""
;
if
(
nodesMap
.
containsKey
(
startID
))
{
String
endMEtaId
=
""
;
if
(
nodesMap
.
containsKey
(
startID
))
{
startMetaId
=
nodesMap
.
get
(
startID
).
getMetadataId
();
}
if
(
nodesMap
.
containsKey
(
endID
))
{
if
(
nodesMap
.
containsKey
(
endID
))
{
endMEtaId
=
nodesMap
.
get
(
endID
).
getMetadataId
();
}
edge
.
setFromId
(
startMetaId
);
...
...
@@ -170,14 +170,14 @@ public class MetadataServiceImpl implements IMetadataService {
Driver
neo4jConnection
=
neo4jConfig
.
getNeo4jConnection
();
Session
session
=
neo4jConnection
.
session
();
// match (n:MetaData ) where n.metadataId =~"Table=.*" return n
String
cypher
=
"match (n:MetaData ) where n.metadataId =~\""
+
modelName
+
".*\" return n"
;
logger
.
info
(
"cypher:"
+
cypher
);
String
cypher
=
"match (n:MetaData ) where n.metadataId =~\""
+
modelName
+
".*\" return n"
;
logger
.
info
(
"cypher:"
+
cypher
);
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashMap
<>();
StatementResult
result
=
session
.
run
(
cypher
);
List
<
String
>
metadataIdList
=
new
ArrayList
<>();
while
(
result
.
hasNext
()
)
{
while
(
result
.
hasNext
())
{
Record
record
=
result
.
next
();
List
<
Value
>
values
=
record
.
values
();
for
(
Value
value
:
values
)
{
...
...
@@ -188,7 +188,7 @@ public class MetadataServiceImpl implements IMetadataService {
Map
<
String
,
Object
>
stringObjectMap
=
node
.
asMap
();
MetaData
metaData
=
new
MetaData
();
Neo4jTool
.
transMap2Bean
(
stringObjectMap
,
metaData
);
Neo4jTool
.
transMap2Bean
(
stringObjectMap
,
metaData
);
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
.
Node
returnNode
=
new
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
.
Node
();
returnNode
.
setId
(
metaData
.
getMetadataId
());
...
...
@@ -197,14 +197,14 @@ public class MetadataServiceImpl implements IMetadataService {
metadataIdList
.
add
(
metaData
.
getMetadataId
());
returnNode
.
setIcon
(
modelName
);
if
(!
metaModelMap
.
containsKey
(
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
);
metaModelMap
.
put
(
modelName
,
model
);
}
returnNode
.
setType
(
"MetaData"
);
returnReslult
.
getNodes
().
add
(
returnNode
);
...
...
@@ -217,43 +217,43 @@ public class MetadataServiceImpl implements IMetadataService {
int
count
=
0
;
//遍历每两个节点的关系
for
(
String
metadataId:
metadataIdList
)
{
logger
.
info
(
"dataId:"
+
metadataId
);
for
(
String
metadataId
:
metadataIdList
)
{
logger
.
info
(
"dataId:"
+
metadataId
);
analysisId
.
add
(
metadataId
);
for
(
String
metadataId1:
metadataIdList
)
{
logger
.
info
(
"---------dataId1:"
+
metadataId1
);
if
(
metadataId
.
equals
(
metadataId1
))
{
for
(
String
metadataId1
:
metadataIdList
)
{
logger
.
info
(
"---------dataId1:"
+
metadataId1
);
if
(
metadataId
.
equals
(
metadataId1
))
{
continue
;
}
if
(
analysisId
.
contains
(
metadataId1
))
{
if
(
analysisId
.
contains
(
metadataId1
))
{
continue
;
}
String
impactCypher
=
"MATCH p=(a:MetaData{metadataId:\""
+
metadataId
+
"\"})-[r:Composition]->()-->()-->()<-[r1:Composition]-(b:MetaData{metadataId:\""
+
metadataId1
+
"\"})\n"
+
String
impactCypher
=
"MATCH p=(a:MetaData{metadataId:\""
+
metadataId
+
"\"})-[r:Composition]->()-->()-->()<-[r1:Composition]-(b:MetaData{metadataId:\""
+
metadataId1
+
"\"})\n"
+
"RETURN p"
;
StatementResult
impactResult
=
session
.
run
(
impactCypher
);
if
(
impactResult
.
hasNext
())
{
logger
.
info
(
metadataId
+
" --->>"
+
metadataId1
);
if
(
impactResult
.
hasNext
())
{
logger
.
info
(
metadataId
+
" --->>"
+
metadataId1
);
Edge
edge
=
new
Edge
();
// edge.setEdgeId();
edge
.
setFromId
(
metadataId
);
edge
.
setToId
(
metadataId1
);
edge
.
setType
(
"流入"
);
edge
.
setEdgeId
(
""
+
count
++);
edge
.
setEdgeId
(
""
+
count
++);
returnReslult
.
getEdges
().
add
(
edge
);
}
String
lineageCypher
=
"MATCH p=(a:MetaData{metadataId:\""
+
metadataId1
+
"\"})-[r:Composition]->() -->()-->()<-[r1:Composition]-(b:MetaData{metadataId:\""
+
metadataId
+
"\"})\n"
+
String
lineageCypher
=
"MATCH p=(a:MetaData{metadataId:\""
+
metadataId1
+
"\"})-[r:Composition]->() -->()-->()<-[r1:Composition]-(b:MetaData{metadataId:\""
+
metadataId
+
"\"})\n"
+
"RETURN p"
;
StatementResult
lineageResult
=
session
.
run
(
lineageCypher
);
if
(
lineageResult
.
hasNext
())
{
if
(
lineageResult
.
hasNext
())
{
logger
.
info
(
metadataId
+
"<<-- "
+
metadataId1
);
logger
.
info
(
metadataId
+
"<<-- "
+
metadataId1
);
Edge
edge
=
new
Edge
();
edge
.
setEdgeId
(
""
+
count
++);
edge
.
setEdgeId
(
""
+
count
++);
// edge.setEdgeId();
edge
.
setFromId
(
metadataId1
);
edge
.
setFromId
(
metadataId1
);
edge
.
setToId
(
metadataId
);
edge
.
setType
(
"流出"
);
returnReslult
.
getEdges
().
add
(
edge
);
...
...
@@ -268,16 +268,16 @@ public class MetadataServiceImpl implements IMetadataService {
public
String
getIconByModelId
(
String
modelId
)
{
ApplicationHome
applicationHome
=
new
ApplicationHome
(
getClass
());
File
jarFile
=
applicationHome
.
getSource
();
String
dirPath
=
jarFile
.
getParentFile
().
toString
()
+
"/Icon/"
+
modelId
+
"/"
;
String
dirPath
=
jarFile
.
getParentFile
().
toString
()
+
"/Icon/"
+
modelId
+
"/"
;
String
encodeIcon
=
""
;
File
dest
=
new
File
(
dirPath
);
File
[]
files
=
dest
.
listFiles
();
if
(
files
!=
null
&&
files
.
length
!=
0
)
{
if
(
files
!=
null
&&
files
.
length
!=
0
)
{
File
iconFile
=
files
[
0
];
String
fileName
=
iconFile
.
getAbsolutePath
();
encodeIcon
=
GetImageStr
(
fileName
);
}
else
{
}
else
{
}
return
encodeIcon
;
...
...
@@ -285,7 +285,7 @@ public class MetadataServiceImpl implements IMetadataService {
// 图片转化成base64字符串
public
static
String
GetImageStr
(
String
imgFile
)
{
// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
logger
.
info
(
"存放图标的路径:"
+
imgFile
);
logger
.
info
(
"存放图标的路径:"
+
imgFile
);
InputStream
in
=
null
;
byte
[]
data
=
null
;
// 读取图片字节数组
...
...
@@ -301,6 +301,7 @@ public class MetadataServiceImpl implements IMetadataService {
BASE64Encoder
encoder
=
new
BASE64Encoder
();
return
encoder
.
encode
(
data
);
// 返回Base64编码过的字节数组字符串
}
@Override
public
List
<
MetaData
>
findChildrenByParentId
(
String
parentId
)
{
...
...
@@ -314,16 +315,15 @@ public class MetadataServiceImpl implements IMetadataService {
@Override
public
List
<
MetaData
>
finAllMetaData
()
{
return
(
List
<
MetaData
>)
metadataRepository
.
findAll
();
return
(
List
<
MetaData
>)
metadataRepository
.
findAll
();
}
@Override
public
MetaData
addMetaData
(
MetaData
metaData
)
{
try
{
try
{
return
metadataRepository
.
save
(
metaData
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
...
...
@@ -337,11 +337,11 @@ public class MetadataServiceImpl implements IMetadataService {
@Override
public
void
syschroRelationFromMongo
(
String
catalogName
)
{
//先从mongo读取关系,写入neo4j
Map
<
String
,
MetaData
>
metaDataMap
=
new
HashMap
<>();
Map
<
String
,
MetaData
>
metaDataMap
=
new
HashMap
<>();
logger
.
info
(
"开始从mongo获取数据。"
);
List
<
RelationMongo
>
relationMongoList
=
mongoDbServiceImpl
.
findAll
(
catalogName
);
logger
.
info
(
"mongo获取数据完成。"
);
for
(
RelationMongo
relationMongo:
relationMongoList
)
{
for
(
RelationMongo
relationMongo
:
relationMongoList
)
{
// 获取元数据属性
// System.out.println(relationMongo.getId());
// logger.info("同步元数据:从mongo到neo4j");
...
...
@@ -350,94 +350,94 @@ public class MetadataServiceImpl implements IMetadataService {
String
type
=
relationMongo
.
getType
();
if
(!
metaDataMap
.
containsKey
(
sourceId
))
{
if
(!
metaDataMap
.
containsKey
(
sourceId
))
{
//不存在源
Map
<
String
,
Object
>
attriuteMap
=
metadataRepoRemoteService
.
getMetadata
(
sourceId
);
if
(
attriuteMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
sourceId
+
"的元数据。"
);
if
(
attriuteMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
sourceId
+
"的元数据。"
);
continue
;
}
String
name
=
(
String
)
attriuteMap
.
get
(
"name"
);
if
(
attriuteMap
.
get
(
"cnName"
)!=
null
&&
!
attriuteMap
.
get
(
"cnName"
).
equals
(
""
))
{
if
(
attriuteMap
.
get
(
"cnName"
)
!=
null
&&
!
attriuteMap
.
get
(
"cnName"
).
equals
(
""
))
{
name
=
(
String
)
attriuteMap
.
get
(
"cnName"
);
}
MetaData
metaData
=
new
MetaData
();
metaData
.
setMetadataId
(
sourceId
);
metaData
.
setName
(
name
);
metaDataMap
.
put
(
sourceId
,
metaData
);
metaDataMap
.
put
(
sourceId
,
metaData
);
MetaData
metadata
=
metadataRepository
.
findMetaDataByMetadataId
(
sourceId
);
if
(
metadata
!=
null
)
{
if
(
metadata
!=
null
)
{
}
else
{
}
else
{
metadataRepository
.
save
(
metaData
);
}
//如果是字段级的,需要上升查找父节点
if
(
sourceId
.
startsWith
(
"Column="
)
||
sourceId
.
startsWith
(
"Header="
)
)
{
if
(
sourceId
.
startsWith
(
"Column="
)
||
sourceId
.
startsWith
(
"Header="
))
{
Map
<
String
,
Object
>
parentAlttriuteMap
=
metadataRepoRemoteService
.
getParent
(
sourceId
);
if
(
parentAlttriuteMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
sourceId
+
"的父节点元数据。"
);
if
(
parentAlttriuteMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
sourceId
+
"的父节点元数据。"
);
continue
;
}
String
parentId
=
(
String
)
parentAlttriuteMap
.
get
(
"_id"
);
if
(!
metaDataMap
.
containsKey
(
parentId
))
{
if
(!
metaDataMap
.
containsKey
(
parentId
))
{
//不存在,先创建父节点
MetaData
parentData
=
new
MetaData
();
parentData
.
setMetadataId
(
parentId
);
String
parentName
=
(
String
)
parentAlttriuteMap
.
get
(
"name"
);
MetaData
parentMetadata
=
metadataRepository
.
findMetaDataByMetadataId
(
parentId
);
parentData
.
setName
(
parentName
);
if
(
parentMetadata
!=
null
)
{
if
(
parentMetadata
!=
null
)
{
}
else
{
}
else
{
metadataRepository
.
save
(
parentData
);
}
metaDataMap
.
put
(
parentId
,
parentData
);
metaDataMap
.
put
(
parentId
,
parentData
);
}
List
<
CompositionRelation
>
relationship
=
compositionRelationRespository
.
findCompositionRelationship
(
parentId
,
sourceId
);
if
(
relationship
==
null
||
relationship
.
size
()==
0
)
{
if
(
relationship
==
null
||
relationship
.
size
()
==
0
)
{
compositionRelationRespository
.
addConpositionRelation
(
parentId
,
sourceId
);
compositionRelationRespository
.
addConpositionRelation
(
parentId
,
sourceId
);
}
}
}
if
(!
metaDataMap
.
containsKey
(
targetId
))
{
if
(!
metaDataMap
.
containsKey
(
targetId
))
{
//不存在目标
MetaData
metaData
=
new
MetaData
();
metaData
.
setMetadataId
(
targetId
);
Map
<
String
,
Object
>
attriuteMap
=
metadataRepoRemoteService
.
getMetadata
(
targetId
);
if
(
attriuteMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
targetId
+
"的元数据。"
);
if
(
attriuteMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
targetId
+
"的元数据。"
);
continue
;
}
String
name
=
(
String
)
attriuteMap
.
get
(
"name"
);
if
(
attriuteMap
.
get
(
"cnName"
)!=
null
&&
!
attriuteMap
.
get
(
"cnName"
).
equals
(
""
))
{
if
(
attriuteMap
.
get
(
"cnName"
)
!=
null
&&
!
attriuteMap
.
get
(
"cnName"
).
equals
(
""
))
{
name
=
(
String
)
attriuteMap
.
get
(
"cnName"
);
}
metaData
.
setName
(
name
);
metaDataMap
.
put
(
targetId
,
metaData
);
metaDataMap
.
put
(
targetId
,
metaData
);
MetaData
neo4jData
=
metadataRepository
.
findMetaDataByMetadataId
(
targetId
);
if
(
neo4jData
!=
null
)
{
if
(
neo4jData
!=
null
)
{
}
else
{
}
else
{
metadataRepository
.
save
(
metaData
);
}
if
(
targetId
.
startsWith
(
"Column="
)
||
targetId
.
startsWith
(
"Header="
)
)
{
if
(
targetId
.
startsWith
(
"Column="
)
||
targetId
.
startsWith
(
"Header="
))
{
Map
<
String
,
Object
>
parentAlttriuteMap
=
metadataRepoRemoteService
.
getParent
(
targetId
);
if
(
parentAlttriuteMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
targetId
+
"的父节点元数据。"
);
if
(
parentAlttriuteMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
targetId
+
"的父节点元数据。"
);
continue
;
}
String
parentId
=
(
String
)
parentAlttriuteMap
.
get
(
"_id"
);
if
(!
metaDataMap
.
containsKey
(
parentId
))
{
if
(!
metaDataMap
.
containsKey
(
parentId
))
{
//不存在,先创建父节点
MetaData
parentData
=
new
MetaData
();
parentData
.
setMetadataId
(
parentId
);
...
...
@@ -445,41 +445,41 @@ public class MetadataServiceImpl implements IMetadataService {
parentData
.
setName
(
parentName
);
MetaData
parentMetadata
=
metadataRepository
.
findMetaDataByMetadataId
(
parentId
);
if
(
parentMetadata
!=
null
)
{
if
(
parentMetadata
!=
null
)
{
}
else
{
}
else
{
metadataRepository
.
save
(
parentData
);
}
metaDataMap
.
put
(
parentId
,
parentData
);
metaDataMap
.
put
(
parentId
,
parentData
);
}
List
<
CompositionRelation
>
relationship
=
compositionRelationRespository
.
findCompositionRelationship
(
parentId
,
targetId
);
if
(
relationship
==
null
||
relationship
.
size
()==
0
)
{
if
(
relationship
==
null
||
relationship
.
size
()
==
0
)
{
compositionRelationRespository
.
addConpositionRelation
(
parentId
,
targetId
);
compositionRelationRespository
.
addConpositionRelation
(
parentId
,
targetId
);
}
}
}
if
(
"input"
.
equalsIgnoreCase
(
type
))
{
List
<
InputRelation
>
relationship
=
inputRelationReRepository
.
findInputRelationship
(
sourceId
,
targetId
);
if
(
relationship
==
null
||
relationship
.
size
()==
0
)
{
inputRelationReRepository
.
addInputRelation
(
sourceId
,
targetId
);
if
(
"input"
.
equalsIgnoreCase
(
type
))
{
List
<
InputRelation
>
relationship
=
inputRelationReRepository
.
findInputRelationship
(
sourceId
,
targetId
);
if
(
relationship
==
null
||
relationship
.
size
()
==
0
)
{
inputRelationReRepository
.
addInputRelation
(
sourceId
,
targetId
);
}
}
else
if
(
"output"
.
equalsIgnoreCase
(
type
))
{
}
else
if
(
"output"
.
equalsIgnoreCase
(
type
))
{
List
<
OutputRelation
>
relationship
=
outputRelationRepository
.
findOutputRelationship
(
sourceId
,
targetId
);
if
(
relationship
==
null
||
relationship
.
size
()==
0
)
{
outputRelationRepository
.
addOutRelation
(
sourceId
,
targetId
);
List
<
OutputRelation
>
relationship
=
outputRelationRepository
.
findOutputRelationship
(
sourceId
,
targetId
);
if
(
relationship
==
null
||
relationship
.
size
()
==
0
)
{
outputRelationRepository
.
addOutRelation
(
sourceId
,
targetId
);
}
}
else
if
(
"execute"
.
equalsIgnoreCase
(
type
))
{
}
else
if
(
"execute"
.
equalsIgnoreCase
(
type
))
{
List
<
ExecuteRelation
>
relationship
=
executeRelationRepository
.
findExecuteRelationship
(
sourceId
,
targetId
);
if
(
relationship
==
null
||
relationship
.
size
()==
0
)
{
executeRelationRepository
.
addExecuteRelation
(
sourceId
,
targetId
);
List
<
ExecuteRelation
>
relationship
=
executeRelationRepository
.
findExecuteRelationship
(
sourceId
,
targetId
);
if
(
relationship
==
null
||
relationship
.
size
()
==
0
)
{
executeRelationRepository
.
addExecuteRelation
(
sourceId
,
targetId
);
}
}
else
if
(
"post"
.
equalsIgnoreCase
(
type
))
{
postRelationRepository
.
mergePostRelation
(
sourceId
,
targetId
);
...
...
@@ -520,20 +520,20 @@ public class MetadataServiceImpl implements IMetadataService {
* 3.开始元数据节点不存在,结束元数据节点存在
* 4.元数据节点均不存在
*/
if
(
startMetadata
!=
null
&&
endMetadata
!=
null
)
{
// 1.元数据节点全部存在
List
<
BaseRelationship
>
relationship
=
relationshipService
.
findMetadataRelationshipByAllName
(
name
,
startName
,
endName
);
if
(
relationship
!=
null
)
{
if
(
startMetadata
!=
null
&&
endMetadata
!=
null
)
{
// 1.元数据节点全部存在
List
<
BaseRelationship
>
relationship
=
relationshipService
.
findMetadataRelationshipByAllName
(
name
,
startName
,
endName
);
if
(
relationship
!=
null
)
{
return
relationship
.
get
(
0
);
}
}
else
if
(
startMetadata
!=
null
&&
endMetadata
==
null
)
{
//2.开始元数据节点存在,结束元数据节点不存在
}
else
if
(
startMetadata
!=
null
&&
endMetadata
==
null
)
{
//2.开始元数据节点存在,结束元数据节点不存在
endMetadata
=
addMetadataByName
(
endName
);
}
else
if
(
startMetadata
==
null
&&
endMetadata
!=
null
)
{
//3.开始元数据节点不存在,结束元数据节点存在
}
else
if
(
startMetadata
==
null
&&
endMetadata
!=
null
)
{
//3.开始元数据节点不存在,结束元数据节点存在
startMetadata
=
addMetadataByName
(
startName
);
}
else
if
(
startMetadata
==
null
&&
endMetadata
==
null
)
{
//4.元数据节点均不存在
}
else
if
(
startMetadata
==
null
&&
endMetadata
==
null
)
{
//4.元数据节点均不存在
startMetadata
=
addMetadataByName
(
startName
);
endMetadata
=
addMetadataByName
(
endName
);
}
BaseRelationship
relationship
=
relationshipService
.
addRelationship
(
name
,
startMetadata
,
endMetadata
);
BaseRelationship
relationship
=
relationshipService
.
addRelationship
(
name
,
startMetadata
,
endMetadata
);
//更新开始节点关系
// Set<BaseRelationship> relationships = startMetadata.getRelationships();
// if(relationships == null) {
...
...
@@ -568,7 +568,7 @@ public class MetadataServiceImpl implements IMetadataService {
List
<
Object
>
objects
=
name
.
asList
();
int
size
=
objects
.
size
();
String
type
=
""
;
Object
object
=
objects
.
get
(
size
-
1
);
Object
object
=
objects
.
get
(
size
-
1
);
labels
.
add
(
object
.
toString
());
}
return
labels
;
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/MongoDbServiceImpl.java
View file @
527c2ec0
...
...
@@ -27,26 +27,27 @@ public class MongoDbServiceImpl {
*
* @return
*/
public
List
<
RelationMongo
>
findAll
(
String
catalogName
)
{
public
List
<
RelationMongo
>
findAll
(
String
catalogName
)
{
logger
.
info
(
"--------------------->[MongoDB find start]"
);
try
{
return
mongoTemplate
.
findAll
(
RelationMongo
.
class
,
"md_relation_"
+
catalogName
);
}
catch
(
Exception
e
)
{
return
mongoTemplate
.
findAll
(
RelationMongo
.
class
,
"md_relation_"
+
catalogName
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
/**
* 查询所有
*
* @return
*/
public
List
<
RelationMongo
>
findAll
(
)
{
public
List
<
RelationMongo
>
findAll
()
{
logger
.
info
(
"--------------------->[MongoDB find start]"
);
try
{
return
mongoTemplate
.
findAll
(
RelationMongo
.
class
,
"md_relational"
);
}
catch
(
Exception
e
)
{
return
mongoTemplate
.
findAll
(
RelationMongo
.
class
,
"md_relational"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
...
...
@@ -55,7 +56,7 @@ public class MongoDbServiceImpl {
public
void
saveTempRelation
(
List
<
JSONObject
>
list
,
String
catalogName
)
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
;
return
;
}
list
.
forEach
(
o
->
mongoTemplate
.
save
(
o
,
PREFIX_MD_RELATION_TEMP_NODE
+
catalogName
));
}
...
...
src/main/java/com/keymobile/metadata/metadataRelation/util/Neo4jTool.java
View file @
527c2ec0
...
...
@@ -18,7 +18,7 @@ public class Neo4jTool {
Object
value
=
map
.
get
(
key
);
// 得到property对应的setter方法
Method
setter
=
property
.
getWriteMethod
();
if
(
setter
!=
null
)
{
if
(
setter
!=
null
)
{
try
{
setter
.
invoke
(
obj
,
value
);
}
catch
(
Exception
e
)
{
...
...
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