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
1a8c3783
Commit
1a8c3783
authored
Dec 01, 2021
by
qiuchaofei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,按照字符串模糊匹配的接口
parent
9a173cc6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
1 deletion
+116
-1
MetaDataController.java
...adata/metadataRelation/controller/MetaDataController.java
+11
-0
IMetadataService.java
...e/metadata/metadataRelation/service/IMetadataService.java
+2
-0
MetadataServiceImpl.java
...ta/metadataRelation/service/impl/MetadataServiceImpl.java
+103
-1
No files found.
src/main/java/com/keymobile/metadata/metadataRelation/controller/MetaDataController.java
View file @
1a8c3783
...
@@ -108,6 +108,17 @@ public class MetaDataController {
...
@@ -108,6 +108,17 @@ public class MetaDataController {
/**
/**
* 搜索的自动匹配接口,按照输入的字符,自动匹配名字,返回前10个匹配到的。
* 搜索的自动匹配接口,按照输入的字符,自动匹配名字,返回前10个匹配到的。
*/
*/
@ApiOperation
(
tags
=
""
,
value
=
"模糊匹配输入结果,不区分大小写"
)
@RequestMapping
(
path
=
"/autoMatchByInput"
,
method
=
RequestMethod
.
GET
)
public
Map
<
String
,
String
>
getAutoMatchByInput
(
String
name
,
String
count
)
{
if
(
count
==
null
||
count
.
equals
(
""
)){
count
=
"1000"
;
}
Integer
returnCount
=
Integer
.
valueOf
(
count
);
return
metadataService
.
getAutoMatchByInput
(
name
,
returnCount
);
}
/**
/**
* 返回一个系统级的大图
* 返回一个系统级的大图
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/IMetadataService.java
View file @
1a8c3783
...
@@ -93,4 +93,6 @@ public interface IMetadataService {
...
@@ -93,4 +93,6 @@ public interface IMetadataService {
void
deleteTempNodeByCatalogName
(
String
catalogName
);
void
deleteTempNodeByCatalogName
(
String
catalogName
);
List
<
TempNode
>
findAllTempNode
();
List
<
TempNode
>
findAllTempNode
();
Map
<
String
,
String
>
getAutoMatchByInput
(
String
name
,
int
returnCount
);
}
}
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/MetadataServiceImpl.java
View file @
1a8c3783
...
@@ -442,6 +442,50 @@ public class MetadataServiceImpl implements IMetadataService {
...
@@ -442,6 +442,50 @@ public class MetadataServiceImpl implements IMetadataService {
}
}
@Override
public
Map
<
String
,
String
>
getAutoMatchByInput
(
String
name
,
int
returnCount
)
{
logger
.
info
(
"开始模糊查找:"
+
name
);
Map
<
String
,
String
>
metadataId2Name
=
new
HashMap
<>();
Neo4jConfig
neo4jConfig
=
new
Neo4jConfig
();
Driver
neo4jConnection
=
neo4jConfig
.
getNeo4jConnection
();
Session
session
=
neo4jConnection
.
session
();
//match (n:MetaData) where n.name=~'(?i).*APP.*' return n
String
cypher
=
"match (n:MetaData) where n.name=~'(?i).*"
+
name
+
".*' return n"
;
//"match (n:MetaData ) where n.name =~\"" + name + ".*\" return n";
long
starttime
=
System
.
currentTimeMillis
();
StatementResult
result
=
session
.
run
(
cypher
);
long
endtime
=
System
.
currentTimeMillis
();
logger
.
info
(
"查询:"
+
cypher
+
", 耗时:"
+(
endtime
-
starttime
));
int
count
=
0
;
while
(
result
.
hasNext
()){
if
(
count
>=
returnCount
){
break
;
}
count
++;
Record
record
=
result
.
next
();
List
<
Value
>
values
=
record
.
values
();
for
(
Value
value
:
values
)
{
System
.
out
.
println
(
"type:"
+
value
.
type
().
name
());
if
(
value
.
type
().
name
().
equals
(
"NODE"
)){
Node
node
=
value
.
asNode
();
Map
<
String
,
Object
>
stringObjectMap
=
node
.
asMap
();
MetaData
metaData
=
new
MetaData
();
Neo4jTool
.
transMap2Bean
(
stringObjectMap
,
metaData
);
metadataId2Name
.
put
(
metaData
.
getMetadataId
(),
metaData
.
getName
());
}
}
}
return
metadataId2Name
;
}
@Override
@Override
public
ReturnReslult
searchGraph
(
String
metadataId
,
int
layer
)
{
public
ReturnReslult
searchGraph
(
String
metadataId
,
int
layer
)
{
logger
.
info
(
"开始获取图形。。。"
);
logger
.
info
(
"开始获取图形。。。"
);
...
@@ -973,6 +1017,34 @@ public class MetadataServiceImpl implements IMetadataService {
...
@@ -973,6 +1017,34 @@ public class MetadataServiceImpl implements IMetadataService {
compositionRelationRespository
.
addConpositionRelation
(
parentId
,
sourceId
);
compositionRelationRespository
.
addConpositionRelation
(
parentId
,
sourceId
);
}
}
//如果是表,要把schema也找出来
if
(
parentId
.
startsWith
(
"Table="
)){
Map
<
String
,
Object
>
schemaAttributeMap
=
metadataRepoRemoteService
.
getParent
(
parentId
);
if
(
schemaAttributeMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
parentId
+
"的父节点元数据。"
);
continue
;
}
String
schemaId
=
(
String
)
schemaAttributeMap
.
get
(
"_id"
);
if
(!
metaDataMap
.
containsKey
(
schemaId
))
{
//不存在,先创建父节点
MetaData
schemaData
=
new
MetaData
();
schemaData
.
setMetadataId
(
schemaId
);
String
schemaName
=
(
String
)
schemaAttributeMap
.
get
(
"name"
);
MetaData
parentMetadata
=
metadataRepository
.
findMetaDataByMetadataId
(
schemaId
);
schemaData
.
setName
(
schemaName
);
if
(
parentMetadata
!=
null
)
{
}
else
{
metadataRepository
.
save
(
schemaData
);
}
metaDataMap
.
put
(
schemaId
,
schemaData
);
}
List
<
CompositionRelation
>
schema2Table
=
compositionRelationRespository
.
findCompositionRelationship
(
schemaId
,
parentId
);
if
(
schema2Table
==
null
||
schema2Table
.
size
()
==
0
)
{
compositionRelationRespository
.
addConpositionRelation
(
schemaId
,
parentId
);
}
}
}
}
}
}
...
@@ -1027,9 +1099,37 @@ public class MetadataServiceImpl implements IMetadataService {
...
@@ -1027,9 +1099,37 @@ public class MetadataServiceImpl implements IMetadataService {
}
}
List
<
CompositionRelation
>
relationship
=
compositionRelationRespository
.
findCompositionRelationship
(
parentId
,
targetId
);
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
);
}
}
//如果是表,要把schema也找出来
if
(
parentId
.
startsWith
(
"Table="
)){
Map
<
String
,
Object
>
schemaAttributeMap
=
metadataRepoRemoteService
.
getParent
(
parentId
);
if
(
schemaAttributeMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
parentId
+
"的父节点元数据。"
);
continue
;
}
String
schemaId
=
(
String
)
schemaAttributeMap
.
get
(
"_id"
);
if
(!
metaDataMap
.
containsKey
(
schemaId
))
{
//不存在,先创建父节点
MetaData
schemaData
=
new
MetaData
();
schemaData
.
setMetadataId
(
schemaId
);
String
schemaName
=
(
String
)
schemaAttributeMap
.
get
(
"name"
);
MetaData
parentMetadata
=
metadataRepository
.
findMetaDataByMetadataId
(
schemaId
);
schemaData
.
setName
(
schemaName
);
if
(
parentMetadata
!=
null
)
{
}
else
{
metadataRepository
.
save
(
schemaData
);
}
metaDataMap
.
put
(
schemaId
,
schemaData
);
}
List
<
CompositionRelation
>
schema2Table
=
compositionRelationRespository
.
findCompositionRelationship
(
schemaId
,
parentId
);
if
(
schema2Table
==
null
||
schema2Table
.
size
()
==
0
)
{
compositionRelationRespository
.
addConpositionRelation
(
schemaId
,
parentId
);
}
}
}
}
}
}
...
@@ -1276,6 +1376,8 @@ public class MetadataServiceImpl implements IMetadataService {
...
@@ -1276,6 +1376,8 @@ public class MetadataServiceImpl implements IMetadataService {
public
List
<
TempNode
>
findAllTempNode
()
{
public
List
<
TempNode
>
findAllTempNode
()
{
return
(
List
<
TempNode
>)
tempNodeRepository
.
findAll
();
return
(
List
<
TempNode
>)
tempNodeRepository
.
findAll
();
}
}
}
}
class
neo4jRelaionTask
implements
Callable
<
List
<
Edge
>>{
class
neo4jRelaionTask
implements
Callable
<
List
<
Edge
>>{
...
...
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