Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
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
dataplatform
atlas
Commits
e4921452
Commit
e4921452
authored
6 years ago
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2984: export should include type defintions of relationships referenced by entities
parent
9a555373
master
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
0 deletions
+55
-0
ExportService.java
...ava/org/apache/atlas/repository/impexp/ExportService.java
+30
-0
ExportTypeProcessor.java
...g/apache/atlas/repository/impexp/ExportTypeProcessor.java
+24
-0
ImportTypeDefProcessor.java
...pache/atlas/repository/impexp/ImportTypeDefProcessor.java
+1
-0
No files found.
repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
View file @
e4921452
...
...
@@ -32,6 +32,7 @@ import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasRelationshipDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
...
...
@@ -43,6 +44,7 @@ import org.apache.atlas.type.AtlasClassificationType;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasEnumType
;
import
org.apache.atlas.type.AtlasMapType
;
import
org.apache.atlas.type.AtlasRelationshipType
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasStructType.AtlasAttribute
;
import
org.apache.atlas.type.AtlasType
;
...
...
@@ -175,6 +177,12 @@ public class ExportService {
typesDef
.
getEnumDefs
().
add
(
enumDef
);
}
for
(
String
relationshipType
:
context
.
relationshipTypes
)
{
AtlasRelationshipDef
relationshipDef
=
typeRegistry
.
getRelationshipDefByName
(
relationshipType
);
typesDef
.
getRelationshipDefs
().
add
(
relationshipDef
);
}
}
private
AtlasExportResult
.
OperationStatus
[]
processItems
(
AtlasExportRequest
request
,
ExportContext
context
)
{
...
...
@@ -611,6 +619,8 @@ public class ExportService {
addStructType
((
AtlasStructType
)
type
,
context
);
}
else
if
(
type
instanceof
AtlasEnumType
)
{
addEnumType
((
AtlasEnumType
)
type
,
context
);
}
else
if
(
type
instanceof
AtlasRelationshipType
)
{
addRelationshipType
((
AtlasRelationshipType
)
type
,
context
);
}
}
...
...
@@ -619,6 +629,7 @@ public class ExportService {
context
.
entityTypes
.
add
(
entityType
.
getTypeName
());
addAttributeTypes
(
entityType
,
context
);
addRelationshipTypes
(
entityType
,
context
);
if
(
CollectionUtils
.
isNotEmpty
(
entityType
.
getAllSuperTypes
()))
{
for
(
String
superType
:
entityType
.
getAllSuperTypes
())
{
...
...
@@ -656,12 +667,30 @@ public class ExportService {
}
}
private
void
addRelationshipType
(
AtlasRelationshipType
relationshipType
,
ExportContext
context
)
{
if
(!
context
.
relationshipTypes
.
contains
(
relationshipType
.
getTypeName
()))
{
context
.
relationshipTypes
.
add
(
relationshipType
.
getTypeName
());
addAttributeTypes
(
relationshipType
,
context
);
addEntityType
(
relationshipType
.
getEnd1Type
(),
context
);
addEntityType
(
relationshipType
.
getEnd2Type
(),
context
);
}
}
private
void
addAttributeTypes
(
AtlasStructType
structType
,
ExportContext
context
)
{
for
(
AtlasAttributeDef
attributeDef
:
structType
.
getStructDef
().
getAttributeDefs
())
{
addType
(
attributeDef
.
getTypeName
(),
context
);
}
}
private
void
addRelationshipTypes
(
AtlasEntityType
entityType
,
ExportContext
context
)
{
for
(
List
<
AtlasRelationshipType
>
relationshipTypes
:
entityType
.
getRelationshipAttributesType
().
values
())
{
for
(
AtlasRelationshipType
relationshipType
:
relationshipTypes
)
{
addRelationshipType
(
relationshipType
,
context
);
}
}
}
private
List
<
Map
<
String
,
Object
>>
executeGremlinQuery
(
String
query
,
ExportContext
context
)
{
try
{
return
(
List
<
Map
<
String
,
Object
>>)
atlasGraph
.
executeGremlinScript
(
context
.
scriptEngine
,
context
.
bindings
,
query
,
false
);
...
...
@@ -724,6 +753,7 @@ public class ExportService {
final
Set
<
String
>
classificationTypes
=
new
HashSet
<>();
final
Set
<
String
>
structTypes
=
new
HashSet
<>();
final
Set
<
String
>
enumTypes
=
new
HashSet
<>();
final
Set
<
String
>
relationshipTypes
=
new
HashSet
<>();
final
AtlasExportResult
result
;
private
final
ZipSink
sink
;
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/impexp/ExportTypeProcessor.java
View file @
e4921452
...
...
@@ -28,6 +28,7 @@ import org.apache.atlas.type.AtlasClassificationType;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasEnumType
;
import
org.apache.atlas.type.AtlasMapType
;
import
org.apache.atlas.type.AtlasRelationshipType
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
...
...
@@ -35,6 +36,8 @@ import org.apache.commons.collections.CollectionUtils;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.List
;
class
ExportTypeProcessor
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ExportTypeProcessor
.
class
);
...
...
@@ -106,6 +109,8 @@ class ExportTypeProcessor {
addStructType
((
AtlasStructType
)
type
,
context
);
}
else
if
(
type
instanceof
AtlasEnumType
)
{
addEnumType
((
AtlasEnumType
)
type
,
context
);
}
else
if
(
type
instanceof
AtlasRelationshipType
)
{
addRelationshipType
((
AtlasRelationshipType
)
type
,
context
);
}
}
...
...
@@ -114,6 +119,7 @@ class ExportTypeProcessor {
context
.
entityTypes
.
add
(
entityType
.
getTypeName
());
addAttributeTypes
(
entityType
,
context
);
addRelationshipTypes
(
entityType
,
context
);
if
(
CollectionUtils
.
isNotEmpty
(
entityType
.
getAllSuperTypes
()))
{
for
(
String
superType
:
entityType
.
getAllSuperTypes
())
{
...
...
@@ -151,9 +157,27 @@ class ExportTypeProcessor {
}
}
private
void
addRelationshipType
(
AtlasRelationshipType
relationshipType
,
ExportService
.
ExportContext
context
)
{
if
(!
context
.
relationshipTypes
.
contains
(
relationshipType
.
getTypeName
()))
{
context
.
relationshipTypes
.
add
(
relationshipType
.
getTypeName
());
addAttributeTypes
(
relationshipType
,
context
);
addEntityType
(
relationshipType
.
getEnd1Type
(),
context
);
addEntityType
(
relationshipType
.
getEnd2Type
(),
context
);
}
}
private
void
addAttributeTypes
(
AtlasStructType
structType
,
ExportService
.
ExportContext
context
)
{
for
(
AtlasStructDef
.
AtlasAttributeDef
attributeDef
:
structType
.
getStructDef
().
getAttributeDefs
())
{
addType
(
attributeDef
.
getTypeName
(),
context
);
}
}
private
void
addRelationshipTypes
(
AtlasEntityType
entityType
,
ExportService
.
ExportContext
context
)
{
for
(
List
<
AtlasRelationshipType
>
relationshipTypes
:
entityType
.
getRelationshipAttributesType
().
values
())
{
for
(
AtlasRelationshipType
relationshipType
:
relationshipTypes
)
{
addRelationshipType
(
relationshipType
,
context
);
}
}
}
}
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/impexp/ImportTypeDefProcessor.java
View file @
e4921452
...
...
@@ -75,5 +75,6 @@ public class ImportTypeDefProcessor {
result
.
incrementMeticsCounter
(
"typedef:enum"
,
typeDefinitionMap
.
getEnumDefs
().
size
());
result
.
incrementMeticsCounter
(
"typedef:entitydef"
,
typeDefinitionMap
.
getEntityDefs
().
size
());
result
.
incrementMeticsCounter
(
"typedef:struct"
,
typeDefinitionMap
.
getStructDefs
().
size
());
result
.
incrementMeticsCounter
(
"typedef:relationship"
,
typeDefinitionMap
.
getRelationshipDefs
().
size
());
}
}
This diff is collapsed.
Click to expand it.
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