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
07d5ccc6
Commit
07d5ccc6
authored
Nov 30, 2021
by
qiuchaofei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,搜索的接口,包括纵向关系,横向关系2获取属性的接口。
parent
d9a69b9a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
499 additions
and
2 deletions
+499
-2
MetaDataController.java
...adata/metadataRelation/controller/MetaDataController.java
+35
-0
ReturnReslult.java
...adata/metadataRelation/pojo/returnBean/ReturnReslult.java
+11
-0
MetadataRepository.java
...data/metadataRelation/respository/MetadataRepository.java
+2
-1
IMetadataService.java
...e/metadata/metadataRelation/service/IMetadataService.java
+9
-0
MetadataServiceImpl.java
...ta/metadataRelation/service/impl/MetadataServiceImpl.java
+442
-1
No files found.
src/main/java/com/keymobile/metadata/metadataRelation/controller/MetaDataController.java
View file @
07d5ccc6
...
@@ -58,6 +58,41 @@ public class MetaDataController {
...
@@ -58,6 +58,41 @@ public class MetaDataController {
return
metadataService
.
finAllMetaData
();
return
metadataService
.
finAllMetaData
();
}
}
/**
* 搜索展示图形,传入一个元数据名称(路径),返回该元数据的图形,
* 图形包括,纵向到它的,横向关系
* 如果是表,需要包含 表的所属系统,所属schema,拥有的字段,表依赖的表(3层),表影响的表(3层)。
* 如果是字段,系统--schema--表--字段,字段依赖的字段,字段依赖的字段
* 如果是etljob,则查找job的拥有的节点,job的前后关系
*/
//
@ApiOperation
(
tags
=
""
,
value
=
"查询结果的图形"
)
@RequestMapping
(
path
=
"/searchGraph"
,
method
=
RequestMethod
.
GET
)
public
ReturnReslult
searchGraph
(
String
metadataId
,
String
layer
){
int
layerLong
=
Integer
.
valueOf
(
layer
);
return
metadataService
.
searchGraph
(
metadataId
,
layerLong
);
}
/**
* 显示节点的属性,传入元数据id,返回元数据的主要属性(5个),需要调用元数据服务的接口。
* 路径,别名,描述
*/
@ApiOperation
(
tags
=
""
,
value
=
"根据元数据id获取元数据属性"
)
@RequestMapping
(
path
=
"/getPropertiesById"
,
method
=
RequestMethod
.
GET
)
public
Map
<
String
,
String
>
getPropertiesById
(
String
metadataId
)
{
return
metadataService
.
getMetaDataByMetadataId
(
metadataId
);
}
/**
* 搜索的自动匹配接口,按照输入的字符,自动匹配名字,返回前10个匹配到的。
*/
/**
/**
* 返回一个系统级的大图
* 返回一个系统级的大图
...
...
src/main/java/com/keymobile/metadata/metadataRelation/pojo/returnBean/ReturnReslult.java
View file @
07d5ccc6
...
@@ -9,6 +9,17 @@ import java.util.Map;
...
@@ -9,6 +9,17 @@ import java.util.Map;
public
class
ReturnReslult
{
public
class
ReturnReslult
{
//统计遍历的层次
int
count
;
public
int
getCount
()
{
return
count
;
}
public
void
setCount
(
int
count
)
{
this
.
count
=
count
;
}
private
List
<
Edge
>
edges
=
new
ArrayList
<>();
private
List
<
Edge
>
edges
=
new
ArrayList
<>();
private
List
<
Node
>
nodes
=
new
ArrayList
<>();
private
List
<
Node
>
nodes
=
new
ArrayList
<>();
...
...
src/main/java/com/keymobile/metadata/metadataRelation/respository/MetadataRepository.java
View file @
07d5ccc6
package
com
.
keymobile
.
metadata
.
metadataRelation
.
respository
;
package
com
.
keymobile
.
metadata
.
metadataRelation
.
respository
;
import
com.keymobile.metadata.metadataRelation.pojo.MetaData
;
import
com.keymobile.metadata.metadataRelation.pojo.MetaData
;
import
org.springframework.data.mongodb.core.query.Meta
;
import
org.springframework.data.neo4j.annotation.Query
;
import
org.springframework.data.neo4j.annotation.Query
;
import
org.springframework.data.neo4j.repository.Neo4jRepository
;
import
org.springframework.data.neo4j.repository.Neo4jRepository
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.data.repository.query.Param
;
...
@@ -37,4 +36,6 @@ public interface MetadataRepository extends Neo4jRepository<MetaData, Long> {
...
@@ -37,4 +36,6 @@ public interface MetadataRepository extends Neo4jRepository<MetaData, Long> {
@Query
(
"MATCH p=(n:MetaData {metadataId:{parentId}})-[r:Composition]->(m) RETURN m limit {limit} "
)
@Query
(
"MATCH p=(n:MetaData {metadataId:{parentId}})-[r:Composition]->(m) RETURN m limit {limit} "
)
List
<
MetaData
>
findMetaDataByParentId
(
@Param
(
"parentId"
)
String
parentId
,
@Param
(
"limit"
)
Integer
count
);
List
<
MetaData
>
findMetaDataByParentId
(
@Param
(
"parentId"
)
String
parentId
,
@Param
(
"limit"
)
Integer
count
);
}
}
src/main/java/com/keymobile/metadata/metadataRelation/service/IMetadataService.java
View file @
07d5ccc6
...
@@ -6,6 +6,7 @@ import com.keymobile.metadata.metadataRelation.pojo.TempNode;
...
@@ -6,6 +6,7 @@ import com.keymobile.metadata.metadataRelation.pojo.TempNode;
import
com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnReslult
;
import
com.keymobile.metadata.metadataRelation.pojo.returnBean.ReturnReslult
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
public
interface
IMetadataService
{
public
interface
IMetadataService
{
...
@@ -17,6 +18,8 @@ public interface IMetadataService {
...
@@ -17,6 +18,8 @@ public interface IMetadataService {
ReturnReslult
getSystemGraph
();
ReturnReslult
getSystemGraph
();
ReturnReslult
searchGraph
(
String
metadataId
,
int
layer
);
List
<
MetaData
>
findChildrenByParentId
(
String
parentId
,
Integer
count
);
List
<
MetaData
>
findChildrenByParentId
(
String
parentId
,
Integer
count
);
List
<
MetaData
>
findChildrenByParentName
(
String
parentName
,
Integer
count
);
List
<
MetaData
>
findChildrenByParentName
(
String
parentName
,
Integer
count
);
...
@@ -47,6 +50,12 @@ public interface IMetadataService {
...
@@ -47,6 +50,12 @@ public interface IMetadataService {
MetaData
getMetaDataById
(
Long
id
);
MetaData
getMetaDataById
(
Long
id
);
/**
/**
* 添加元数据对象
*
* @param metadataId
*/
Map
<
String
,
String
>
getMetaDataByMetadataId
(
String
metadataId
);
/**
* @param name
* @param name
* @desc 根据名称获取元数据
* @desc 根据名称获取元数据
*/
*/
...
...
src/main/java/com/keymobile/metadata/metadataRelation/service/impl/MetadataServiceImpl.java
View file @
07d5ccc6
...
@@ -33,6 +33,8 @@ import org.springframework.stereotype.Service;
...
@@ -33,6 +33,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
sun.misc.BASE64Encoder
;
import
sun.misc.BASE64Encoder
;
import
javax.swing.*
;
@Service
@Service
public
class
MetadataServiceImpl
implements
IMetadataService
{
public
class
MetadataServiceImpl
implements
IMetadataService
{
...
@@ -430,7 +432,6 @@ public class MetadataServiceImpl implements IMetadataService {
...
@@ -430,7 +432,6 @@ public class MetadataServiceImpl implements IMetadataService {
returnReslult
.
getEdges
().
add
(
edge
);
returnReslult
.
getEdges
().
add
(
edge
);
}
}
}
}
}
}
}
}
...
@@ -440,6 +441,402 @@ public class MetadataServiceImpl implements IMetadataService {
...
@@ -440,6 +441,402 @@ public class MetadataServiceImpl implements IMetadataService {
}
}
@Override
public
ReturnReslult
searchGraph
(
String
metadataId
,
int
layer
)
{
logger
.
info
(
"开始获取图形。。。"
);
long
start
=
System
.
currentTimeMillis
();
ReturnReslult
returnReslult
=
new
ReturnReslult
();
Neo4jConfig
neo4jConfig
=
new
Neo4jConfig
();
Driver
neo4jConnection
=
neo4jConfig
.
getNeo4jConnection
();
Session
session
=
neo4jConnection
.
session
();
Map
<
String
,
MetaModel
>
metaModelMap
=
new
HashMap
<>();
if
(
metadataId
.
startsWith
(
"Table="
)){
//向上获取路径
String
cypher
=
"match (n:MetaData{metadataId:\""
+
metadataId
+
"\"}) with n match p=(n)<-[r:Composition*0..10]-(m) return m,length(p) as dist "
;
logger
.
info
(
"cypher:"
+
cypher
);
String
childId
=
metadataId
;
StatementResult
result
=
session
.
run
(
cypher
);
while
(
result
.
hasNext
()){
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
<
Long
,
MetaData
>
nodesMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
stringObjectMap
=
node
.
asMap
();
MetaData
metaData
=
new
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
());
returnNode
.
setName
(
metaData
.
getName
());
returnReslult
.
getNodes
().
add
(
returnNode
);
String
[]
strings
=
metaData
.
getMetadataId
().
split
(
"="
);
String
modelName
=
strings
[
0
];
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"
);
if
(
returnNode
.
getId
().
equals
(
metadataId
)){
continue
;
}
Edge
edge
=
new
Edge
();
edge
.
setFromId
(
returnNode
.
getId
());
edge
.
setToId
(
childId
);
childId
=
returnNode
.
getId
();
edge
.
setType
(
"组合"
);
}
else
if
(
value
.
type
().
name
().
equals
(
"INTEGER"
))
{
}
}
}
//向下获取拥有
String
getChilerenCypher
=
"match (n:MetaData{metadataId:\""
+
metadataId
+
"\"}) -[r:Composition]->(m) return m"
;
logger
.
info
(
"getChilerenCypher:"
+
getChilerenCypher
);
StatementResult
getChilerenResult
=
session
.
run
(
getChilerenCypher
);
while
(
getChilerenResult
.
hasNext
()){
Record
record
=
getChilerenResult
.
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
);
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
.
Node
returnNode
=
new
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
.
Node
();
returnNode
.
setId
(
metaData
.
getMetadataId
());
returnNode
.
setName
(
metaData
.
getName
());
returnReslult
.
getNodes
().
add
(
returnNode
);
String
[]
strings
=
metaData
.
getMetadataId
().
split
(
"="
);
String
modelName
=
strings
[
0
];
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"
);
if
(
returnNode
.
getId
().
equals
(
metadataId
)){
continue
;
}
Edge
edge
=
new
Edge
();
edge
.
setFromId
(
metadataId
);
edge
.
setToId
(
returnNode
.
getId
());
edge
.
setType
(
"组合"
);
returnReslult
.
getEdges
().
add
(
edge
);
}
else
if
(
value
.
type
().
name
().
equals
(
"INTEGER"
))
{
}
}
}
}
else
if
(
metadataId
.
startsWith
(
"Column="
)){
// match (n:MetaData ) where n.metadataId =~"Table=.*" return n
String
cypher
=
"match (n:MetaData{metadataId:\""
+
metadataId
+
"\"}) with n match p=(n)<-[r:Composition*0..10]-(m) return m,length(p) as dist "
;
logger
.
info
(
"cypher:"
+
cypher
);
String
childId
=
metadataId
;
//先获取纵向节点,
StatementResult
result
=
session
.
run
(
cypher
);
while
(
result
.
hasNext
()){
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
<
Long
,
MetaData
>
nodesMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
stringObjectMap
=
node
.
asMap
();
MetaData
metaData
=
new
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
());
returnNode
.
setName
(
metaData
.
getName
());
returnReslult
.
getNodes
().
add
(
returnNode
);
String
[]
strings
=
metaData
.
getMetadataId
().
split
(
"="
);
String
modelName
=
strings
[
0
];
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"
);
if
(
returnNode
.
getId
().
equals
(
metadataId
)){
continue
;
}
Edge
edge
=
new
Edge
();
edge
.
setFromId
(
returnNode
.
getId
());
edge
.
setToId
(
childId
);
childId
=
returnNode
.
getId
();
returnReslult
.
getEdges
().
add
(
edge
);
}
else
if
(
value
.
type
().
name
().
equals
(
"INTEGER"
))
{
}
}
}
}
else
if
(
metadataId
.
startsWith
(
"EtlJob="
)){
//先上下,后左后的关系
String
cypher
=
"match p=(n:MetaData{metadataId:\""
+
metadataId
+
"\"})-[r:Execute*0..10]->(m) return p"
;
logger
.
info
(
"cypher:"
+
cypher
);
Map
<
Long
,
MetaData
>
longMetaDataMap
=
new
HashMap
<>();
Map
<
String
,
Edge
>
edgeMap
=
new
HashMap
<>();
//先获取纵向节点,
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
(
"PATH"
)){
Path
path
=
value
.
asPath
();
Iterable
<
Node
>
nodes
=
path
.
nodes
();
for
(
Node
node:
nodes
){
if
(
longMetaDataMap
.
containsKey
(
node
.
id
())){
continue
;
}
Map
<
String
,
Object
>
stringObjectMap
=
node
.
asMap
();
MetaData
metaData
=
new
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
());
returnNode
.
setName
(
metaData
.
getName
());
returnReslult
.
getNodes
().
add
(
returnNode
);
String
[]
strings
=
metaData
.
getMetadataId
().
split
(
"="
);
String
modelName
=
strings
[
0
];
longMetaDataMap
.
put
(
node
.
id
(),
metaData
);
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"
);
if
(
returnNode
.
getId
().
equals
(
metadataId
)){
continue
;
}
}
Iterable
<
Relationship
>
relationships
=
path
.
relationships
();
for
(
Relationship
relationship:
relationships
){
long
startLong
=
relationship
.
startNodeId
();
long
endLong
=
relationship
.
endNodeId
();
if
(
longMetaDataMap
.
containsKey
(
startLong
)&&
longMetaDataMap
.
containsKey
(
endLong
)){
Edge
edge
=
new
Edge
();
String
edgeId
=
startLong
+
"_"
+
endLong
;
if
(
edgeMap
.
containsKey
(
edgeId
)){
continue
;
}
edgeMap
.
put
(
edgeId
,
edge
);
edge
.
setFromId
(
longMetaDataMap
.
get
(
startLong
).
getMetadataId
());
edge
.
setToId
(
longMetaDataMap
.
get
(
endLong
).
getMetadataId
());
edge
.
setType
(
"执行"
);
}
}
}
}
}
for
(
Object
obj
:
edgeMap
.
keySet
()){
Edge
edge
=
(
Edge
)
edgeMap
.
get
(
obj
);
returnReslult
.
getEdges
().
add
(
edge
);
}
}
else
{
logger
.
info
(
"暂不支持该类型节点。"
);
}
//获取横向节点,
getPreNode
(
metadataId
,
session
,
returnReslult
,
layer
);
returnReslult
.
setCount
(
0
);
getToNode
(
metadataId
,
session
,
returnReslult
,
layer
);
returnReslult
.
setMetaModelMap
(
metaModelMap
);
return
returnReslult
;
}
private
void
getToNode
(
String
metadataId
,
Session
session
,
ReturnReslult
returnReslult
,
int
layer
)
{
int
count
=
returnReslult
.
getCount
();
if
(
count
>
layer
){
count
=
count
-
1
;
returnReslult
.
setCount
(
count
);
return
;
}
count
=
count
+
1
;
returnReslult
.
setCount
(
count
);
String
cypher
=
""
;
if
(
metadataId
.
startsWith
(
"Table="
)){
cypher
=
"match (n:MetaData{metadataId:\""
+
metadataId
+
"\"})-->(m)-[r:Input]->(q)-[r0:TempInput*0..]->(w)-[r1:Output]->(p)<-[r2:Composition]-(t)\n"
+
"return t "
;
}
else
if
(
metadataId
.
startsWith
(
"Column="
)){
cypher
=
"match ({metadataId:\""
+
metadataId
+
"\"})-[r:Input]->(q)-[r0:TempInput*0..]->(w)-[r1:Output]->(c)\n"
+
"return c"
;
}
else
if
(
metadataId
.
startsWith
(
"EtlJob="
)){
cypher
=
"match (n:MetaData{metadataId:\""
+
metadataId
+
"\"})-->(n1)-->(n2)-[r:Output]->(p)-[r0:Input]->(p1)<-[r2:Execute]-(m0)<-[r3:Execute]-(job) "
+
"return job "
;
}
StatementResult
result1
=
session
.
run
(
cypher
);
while
(
result1
.
hasNext
())
{
Record
record
=
result1
.
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
);
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
.
Node
returnNode
=
new
com
.
keymobile
.
metadata
.
metadataRelation
.
pojo
.
returnBean
.
Node
();
returnNode
.
setId
(
metaData
.
getMetadataId
());
returnNode
.
setName
(
metaData
.
getName
());
returnReslult
.
getNodes
().
add
(
returnNode
);
String
[]
strings
=
metaData
.
getMetadataId
().
split
(
"="
);
String
modelName
=
strings
[
0
];
returnNode
.
setIcon
(
modelName
);
returnNode
.
setType
(
"MetaData"
);
if
(
returnNode
.
getId
().
equals
(
metadataId
)){
continue
;
}
Edge
edge
=
new
Edge
();
edge
.
setFromId
(
metadataId
);
edge
.
setToId
(
returnNode
.
getId
());
edge
.
setType
(
"流向"
);
returnReslult
.
getEdges
().
add
(
edge
);
getToNode
(
returnNode
.
getId
(),
session
,
returnReslult
,
layer
);
}
}
}
}
private
void
getPreNode
(
String
metadataId
,
Session
session
,
ReturnReslult
returnReslult
,
int
layer
)
{
int
count
=
returnReslult
.
getCount
();
if
(
count
>
layer
){
return
;
}
String
cypher
=
""
;
if
(
metadataId
.
startsWith
(
"Table="
)){
cypher
=
"match (n:MetaData{metadataId:\""
+
metadataId
+
"\"})-->(m)<-[r:Output]-(q)<-[r0:TempInput*0..]-(w)-[r1:Input]-(p)<-[r2:Composition]-(t)\n"
+
"return t"
;
}
else
if
(
metadataId
.
startsWith
(
"Column="
)){
cypher
=
"match ({metadataId:\""
+
metadataId
+
"\"})<-[r:Output]->(q)<-[r0:TempInput*0..]-(w)-[r1:Input]-(c) "
+
"return c"
;
}
else
if
(
metadataId
.
startsWith
(
"EtlJob="
)){
cypher
=
"match (n:MetaData{metadataId:\""
+
metadataId
+
"\"})-->(n1)-->(n2)<-[r:Input]->(p)-[r0:Output]-(p1)<-[r2:Execute]-(m0)<-[r3:Execute]-(job) "
+
"return job"
;
}
StatementResult
result1
=
session
.
run
(
cypher
);
while
(
result1
.
hasNext
())
{
Record
record
=
result1
.
next
();
List
<
Value
>
values
=
record
.
values
();
for
(
Value
value
:
values
)
{
if
(
value
.
type
().
name
().
equals
(
"NODE"
)){
Node
node
=
value
.
asNode
();
count
=
returnReslult
.
getCount
();
count
=
count
+
1
;
returnReslult
.
setCount
(
count
);
Map
<
Long
,
MetaData
>
nodesMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
stringObjectMap
=
node
.
asMap
();
MetaData
metaData
=
new
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
());
returnNode
.
setName
(
metaData
.
getName
());
returnReslult
.
getNodes
().
add
(
returnNode
);
String
[]
strings
=
metaData
.
getMetadataId
().
split
(
"="
);
String
modelName
=
strings
[
0
];
returnNode
.
setIcon
(
modelName
);
returnNode
.
setType
(
"MetaData"
);
if
(
returnNode
.
getId
().
equals
(
metadataId
)){
continue
;
}
Edge
edge
=
new
Edge
();
edge
.
setFromId
(
returnNode
.
getId
());
edge
.
setToId
(
metadataId
);
edge
.
setType
(
"流向"
);
returnReslult
.
getEdges
().
add
(
edge
);
getPreNode
(
returnNode
.
getId
(),
session
,
returnReslult
,
layer
);
}
}
}
}
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
();
...
@@ -671,6 +1068,50 @@ public class MetadataServiceImpl implements IMetadataService {
...
@@ -671,6 +1068,50 @@ public class MetadataServiceImpl implements IMetadataService {
}
}
@Override
@Override
public
Map
<
String
,
String
>
getMetaDataByMetadataId
(
String
metadataId
)
{
Map
<
String
,
String
>
returnMap
=
new
HashMap
<>();
// name,路径,别名,描述
Map
<
String
,
Object
>
attriuteMap
=
metadataRepoRemoteService
.
getMetadata
(
metadataId
);
if
(
attriuteMap
==
null
)
{
logger
.
info
(
"没有找到id:"
+
metadataId
+
"的元数据。"
);
}
String
name
=
(
String
)
attriuteMap
.
get
(
"name"
);
if
(
attriuteMap
.
get
(
"cnName"
)
!=
null
&&
!
attriuteMap
.
get
(
"cnName"
).
equals
(
""
))
{
name
=
(
String
)
attriuteMap
.
get
(
"cnName"
);
}
returnMap
.
put
(
"名称"
,
name
);
String
cnName
=
(
String
)
attriuteMap
.
get
(
"cnName"
);
returnMap
.
put
(
"中文名"
,
cnName
);
String
comment
=
(
String
)
attriuteMap
.
get
(
"comment"
);
returnMap
.
put
(
"备注"
,
comment
);
String
remark
=
(
String
)
attriuteMap
.
get
(
"remark"
);
returnMap
.
put
(
"标记"
,
cnName
);
String
lastUpdateTime
=
(
String
)
attriuteMap
.
get
(
"lastUpdateTime"
);
returnMap
.
put
(
"最后更新时间"
,
lastUpdateTime
);
if
(
metadataId
.
startsWith
(
"Column="
)){
//字段,就获取类型,长度
String
typeName
=
(
String
)
attriuteMap
.
get
(
"typeName"
);
returnMap
.
put
(
"数据类型"
,
typeName
);
}
List
<
String
>
paths
=(
List
<
String
>)
attriuteMap
.
get
(
"namePathList"
);
if
(
paths
!=
null
){
StringBuffer
sb
=
new
StringBuffer
();
int
size
=
paths
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++){
sb
.
append
(
paths
.
get
(
i
)+
";"
);
}
returnMap
.
put
(
"路径"
,
sb
.
toString
());
}
return
returnMap
;
}
@Override
public
MetaData
getMetadataByName
(
String
name
)
{
public
MetaData
getMetadataByName
(
String
name
)
{
return
null
;
return
null
;
}
}
...
...
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