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
d71b787e
Commit
d71b787e
authored
Nov 26, 2021
by
qiuchaofei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,添加系统总图的接口,2修改关系类型的接口
parent
90b12cd7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
124 additions
and
2 deletions
+124
-2
MetaDataController.java
...adata/metadataRelation/controller/MetaDataController.java
+9
-0
IMetadataService.java
...e/metadata/metadataRelation/service/IMetadataService.java
+2
-0
BaseRelationshipServiceImpl.java
...ataRelation/service/impl/BaseRelationshipServiceImpl.java
+1
-1
MetadataServiceImpl.java
...ta/metadataRelation/service/impl/MetadataServiceImpl.java
+112
-1
No files found.
src/main/java/com/keymobile/metadata/metadataRelation/controller/MetaDataController.java
View file @
d71b787e
...
@@ -226,6 +226,15 @@ public class MetaDataController {
...
@@ -226,6 +226,15 @@ public class MetaDataController {
return
returnReslult
;
return
returnReslult
;
}
}
@ApiOperation
(
tags
=
""
,
value
=
"系统总图"
)
@RequestMapping
(
path
=
"/getSystemGraph"
,
method
=
RequestMethod
.
GET
)
public
ReturnReslult
getSystemGraph
(){
return
metadataService
.
getSystemGraph
();
}
private
String
getParentId
(
String
neo4jId
,
Map
<
String
,
String
>
child2Parent
)
{
private
String
getParentId
(
String
neo4jId
,
Map
<
String
,
String
>
child2Parent
)
{
String
parentId
=
neo4jId
;
String
parentId
=
neo4jId
;
while
(
child2Parent
.
containsKey
(
neo4jId
))
{
while
(
child2Parent
.
containsKey
(
neo4jId
))
{
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/IMetadataService.java
View file @
d71b787e
...
@@ -15,6 +15,8 @@ public interface IMetadataService {
...
@@ -15,6 +15,8 @@ public interface IMetadataService {
ReturnReslult
findResultByModelName
(
String
modelName
);
ReturnReslult
findResultByModelName
(
String
modelName
);
ReturnReslult
getSystemGraph
();
List
<
MetaData
>
findChildrenByParentId
(
String
parentId
);
List
<
MetaData
>
findChildrenByParentId
(
String
parentId
);
List
<
MetaData
>
findChildrenByParentName
(
String
parentName
);
List
<
MetaData
>
findChildrenByParentName
(
String
parentName
);
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/BaseRelationshipServiceImpl.java
View file @
d71b787e
...
@@ -76,7 +76,7 @@ public class BaseRelationshipServiceImpl implements IBaseRelationshipService {
...
@@ -76,7 +76,7 @@ public class BaseRelationshipServiceImpl implements IBaseRelationshipService {
Neo4jConfig
neo4jConfig
=
new
Neo4jConfig
();
Neo4jConfig
neo4jConfig
=
new
Neo4jConfig
();
Driver
neo4jConnection
=
neo4jConfig
.
getNeo4jConnection
();
Driver
neo4jConnection
=
neo4jConfig
.
getNeo4jConnection
();
Session
session
=
neo4jConnection
.
session
();
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"
;
String
cypher
=
" MATCH (n)-[r]->() RETURN id(STARTNODE(r)) as startId,id(endNode(r)) as endId, type(r) as name"
;
logger
.
info
(
"cypher:"
+
cypher
);
logger
.
info
(
"cypher:"
+
cypher
);
StatementResult
result
=
session
.
run
(
cypher
);
StatementResult
result
=
session
.
run
(
cypher
);
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/MetadataServiceImpl.java
View file @
d71b787e
...
@@ -333,6 +333,106 @@ public class MetadataServiceImpl implements IMetadataService {
...
@@ -333,6 +333,106 @@ public class MetadataServiceImpl implements IMetadataService {
return
returnReslult
;
return
returnReslult
;
}
}
@Override
public
ReturnReslult
getSystemGraph
()
{
ReturnReslult
returnReslult
=
new
ReturnReslult
();
Neo4jConfig
neo4jConfig
=
new
Neo4jConfig
();
Driver
neo4jConnection
=
neo4jConfig
.
getNeo4jConnection
();
Session
session
=
neo4jConnection
.
session
();
// match (n:MetaData ) where n.metadataId =~"Table=.*" return n
String
cypher
=
"match data=(na:softplatform)-[r]->(nb:softplatform) return data"
;
logger
.
info
(
"cypher:"
+
cypher
);
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashMap
<>();
long
starttime
=
System
.
currentTimeMillis
();
StatementResult
result
=
session
.
run
(
cypher
);
long
endtime
=
System
.
currentTimeMillis
();
logger
.
info
(
"查询耗时:"
+(
endtime
-
starttime
));
String
modelName
=
"System"
;
List
<
String
>
metadataIdList
=
new
ArrayList
<>();
while
(
result
.
hasNext
())
{
Record
record
=
result
.
next
();
List
<
Value
>
values
=
record
.
values
();
for
(
Value
value
:
values
)
{
if
(
value
.
type
().
name
().
equals
(
"PATH"
))
{
Path
p
=
value
.
asPath
();
Iterable
<
Node
>
nodes
=
p
.
nodes
();
Map
<
Long
,
MetaData
>
nodesMap
=
new
HashMap
<>();
for
(
Node
node
:
nodes
)
{
Map
<
String
,
Object
>
stringObjectMap
=
node
.
asMap
();
MetaData
metaData
=
new
MetaData
();
Neo4jTool
.
transMap2Bean
(
stringObjectMap
,
metaData
);
// metaDataList.add(data);
if
(
metaData
.
getMetadataId
()
==
null
){
metaData
.
setMetadataId
(
"System="
+
metaData
.
getName
());
}
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
.
Node
returnNode
=
new
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
.
Node
();
returnNode
.
setId
(
metaData
.
getMetadataId
());
returnNode
.
setName
(
metaData
.
getName
());
String
[]
strings
=
metaData
.
getMetadataId
().
split
(
"="
);
returnNode
.
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
);
}
returnNode
.
setType
(
"MetaData"
);
returnReslult
.
getNodes
().
add
(
returnNode
);
nodesMap
.
put
(
node
.
id
(),
metaData
);
}
Iterable
<
Relationship
>
relationships
=
p
.
relationships
();
for
(
Relationship
relationship
:
relationships
)
{
Long
startID
=
relationship
.
startNodeId
();
Long
endID
=
relationship
.
endNodeId
();
String
rType
=
relationship
.
type
();
/**
* asMap 相当于 节点的properties属性信息
*/
// relationship.id();
//
Edge
edge
=
new
Edge
();
String
relationName
=
nodesMap
.
get
(
startID
).
getMetadataId
()
+
"-"
+
rType
+
"-"
+
nodesMap
.
get
(
endID
).
getMetadataId
();
edge
.
setEdgeId
(
String
.
valueOf
(
relationship
.
id
()));
String
startMetaId
=
""
;
String
endMEtaId
=
""
;
if
(
nodesMap
.
containsKey
(
startID
))
{
startMetaId
=
nodesMap
.
get
(
startID
).
getMetadataId
();
}
if
(
nodesMap
.
containsKey
(
endID
))
{
endMEtaId
=
nodesMap
.
get
(
endID
).
getMetadataId
();
}
edge
.
setFromId
(
startMetaId
);
edge
.
setToId
(
endMEtaId
);
edge
.
setType
(
rType
);
returnReslult
.
getEdges
().
add
(
edge
);
}
}
}
}
returnReslult
.
setMetaModelMap
(
metaModelMap
);
return
returnReslult
;
}
public
String
getIconByModelId
(
String
modelId
)
{
public
String
getIconByModelId
(
String
modelId
)
{
ApplicationHome
applicationHome
=
new
ApplicationHome
(
getClass
());
ApplicationHome
applicationHome
=
new
ApplicationHome
(
getClass
());
File
jarFile
=
applicationHome
.
getSource
();
File
jarFile
=
applicationHome
.
getSource
();
...
@@ -621,10 +721,10 @@ public class MetadataServiceImpl implements IMetadataService {
...
@@ -621,10 +721,10 @@ public class MetadataServiceImpl implements IMetadataService {
@Override
@Override
public
List
<
String
>
findAllNodeTypes
()
{
public
List
<
String
>
findAllNodeTypes
()
{
Iterable
<
MetaData
>
dataIterable
=
metadataRepository
.
findAll
();
Iterable
<
MetaData
>
dataIterable
=
metadataRepository
.
findAll
();
List
<
String
>
labels
=
new
ArrayList
<>();
List
<
String
>
labels
=
new
ArrayList
<>();
labels
.
add
(
"All"
);
labels
.
add
(
"All"
);
labels
.
add
(
"System"
);
for
(
MetaData
data
:
dataIterable
){
for
(
MetaData
data
:
dataIterable
){
String
metadataId
=
data
.
getMetadataId
();
String
metadataId
=
data
.
getMetadataId
();
String
[]
metadataIds
=
metadataId
.
split
(
"="
);
String
[]
metadataIds
=
metadataId
.
split
(
"="
);
...
@@ -634,6 +734,17 @@ public class MetadataServiceImpl implements IMetadataService {
...
@@ -634,6 +734,17 @@ public class MetadataServiceImpl implements IMetadataService {
}
}
}
}
Iterable
<
TempNode
>
nodeIterable
=
tempNodeRepository
.
findAll
();
labels
.
add
(
"All"
);
for
(
TempNode
node
:
nodeIterable
){
String
metadataId
=
node
.
getMetadataId
();
String
[]
metadataIds
=
metadataId
.
split
(
"="
);
String
modelName
=
metadataIds
[
0
];
if
(!
labels
.
contains
(
modelName
)){
labels
.
add
(
modelName
);
}
}
return
labels
;
return
labels
;
}
}
...
...
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