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
98b5054d
Commit
98b5054d
authored
May 19, 2022
by
qiuchaofei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.搜索孤立点
parent
9cecd572
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
2 deletions
+63
-2
DataRelationAnalyController.java
...adataRelation/controller/DataRelationAnalyController.java
+13
-2
DataRelationAnalyService.java
...ta/metadataRelation/service/DataRelationAnalyService.java
+2
-0
DataRelationAnalyServiceImpl.java
...taRelation/service/impl/DataRelationAnalyServiceImpl.java
+48
-0
No files found.
src/main/java/com/keymobile/metadata/metadataRelation/controller/DataRelationAnalyController.java
View file @
98b5054d
...
...
@@ -78,8 +78,19 @@ public class DataRelationAnalyController {
return
dataRelationAnalyService
.
findTableWithoutRelations
(
parentId
,
0
,
200000
);
}
//分页
@ApiOperation
(
tags
=
""
,
value
=
"分页查找孤立点的总数"
)
//搜索
@ApiOperation
(
tags
=
""
,
value
=
"搜索孤立点"
)
@RequestMapping
(
path
=
"/findIsolatedTableByName"
,
method
=
RequestMethod
.
GET
)
public
Map
<
String
,
ReturnNode
>
findIsolatedTableByName
(
String
parentId
,
String
keyWord
)
{
logger
.
info
(
"分页查找孤立点的总数:"
+
parentId
);
if
(
parentId
==
null
){
return
new
HashMap
<>();
}
return
dataRelationAnalyService
.
findTableWithoutRelationsByName
(
parentId
,
keyWord
);
}
//总数
@ApiOperation
(
tags
=
""
,
value
=
"查找孤立点的总数"
)
@RequestMapping
(
path
=
"/getIsolatedTableTotal"
,
method
=
RequestMethod
.
GET
)
public
Integer
getIsolatedTableTotal
(
String
parentId
)
{
logger
.
info
(
"分页查找孤立点的总数:"
+
parentId
);
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/DataRelationAnalyService.java
View file @
98b5054d
...
...
@@ -9,4 +9,6 @@ public interface DataRelationAnalyService {
Map
<
String
,
ReturnNode
>
findTableWithoutRelations
(
String
schemaId
,
int
start
,
int
end
);
Integer
findTableWithoutRelationsTotal
(
String
parentId
);
Map
<
String
,
ReturnNode
>
findTableWithoutRelationsByName
(
String
parentId
,
String
keyWord
);
}
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/DataRelationAnalyServiceImpl.java
View file @
98b5054d
...
...
@@ -95,4 +95,52 @@ public class DataRelationAnalyServiceImpl implements DataRelationAnalyService {
}
return
jdcount
;
}
@Override
public
Map
<
String
,
ReturnNode
>
findTableWithoutRelationsByName
(
String
parentId
,
String
keyWord
)
{
Map
<
String
,
ReturnNode
>
returnNodeMap
=
new
HashMap
<>();
//区分传入的id是环境id,系统id还是schema,还是为空,为空则找出所有的孤立点
//match (n:Neo4jTable) where not ((n)-[:`流向`]-(:Neo4jTable)) return n
// Neo4jConfig neo4jConfig = new Neo4jConfig();
// Driver neo4jConnection = neo4jConfig.getNeo4jConnection();
// Session session = neo4jConnection.session();
String
cypher
=
""
;
String
condition
=
""
;
if
(
parentId
!=
null
&&
parentId
.
startsWith
(
"System="
)){
condition
=
"<-[r1:Composition]-(:Neo4jSchema)<-[r2:Composition]-(m:Neo4jSystem{metadataId:\""
+
parentId
+
"\"})"
;
cypher
=
"match (n:Neo4jTable) "
+
condition
+
"where not ((n)-[:`流向`]-()) and n.name=~'.*"
+
keyWord
+
".*' return n order by n.name "
;
}
else
if
(
parentId
!=
null
&&
parentId
.
startsWith
(
"Schema="
)){
condition
=
"<-[r1:Composition]-(m:Neo4jSchema{metadataId:\""
+
parentId
+
"\"})"
;
cypher
=
"match (n:Neo4jTable) "
+
condition
+
"where not ((n)-[:`流向`]-()) and n.name=~'.*"
+
keyWord
+
".*' return n order by n.name "
;
}
else
if
(
parentId
!=
null
){
cypher
=
"match (n:Neo4jTable{isEnvironment:\""
+
parentId
+
"\"}) where not ((n)-[:`流向`]-()) and n.name=~'.*"
+
keyWord
+
".*' return n order by n.name "
;
}
int
count
=
0
;
logger
.
info
(
"查找孤立表的语句:"
+
cypher
);
StatementResult
result
=
session
.
run
(
cypher
);
while
(
result
.
hasNext
()){
Record
record
=
result
.
next
();
List
<
Value
>
values
=
record
.
values
();
for
(
Value
value
:
values
)
{
if
(
value
.
type
().
name
().
equals
(
"NODE"
)){
Node
node
=
value
.
asNode
();
Map
<
String
,
Object
>
stringObjectMap
=
node
.
asMap
();
MetaData
metaData
=
new
MetaData
();
Neo4jTool
.
transMap2Bean
(
stringObjectMap
,
metaData
);
if
(
metaData
.
getMetadataId
()
==
null
){
metaData
.
setMetadataId
(
"System="
+
metaData
.
getName
());
}
ReturnNode
returnNode
=
new
ReturnNode
();
returnNode
.
setName
(
metaData
.
getName
());
returnNode
.
setId
(
metaData
.
getMetadataId
());
returnNode
.
setType
(
metaData
.
getMetaModel
());
returnNode
.
setCnName
(
metaData
.
getCnName
());
returnNodeMap
.
put
(
""
+
count
++,
returnNode
);
}
}
}
return
returnNodeMap
;
}
}
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