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
4c2f7bf2
Commit
4c2f7bf2
authored
7 years ago
by
Ashutosh Mestry
Committed by
Sarath Subramanian
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2372: Export-Import: Support for Relationship Attributes Missing
Signed-off-by:
Sarath Subramanian
<
ssubramanian@hortonworks.com
>
parent
5c2f7a0c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
26 deletions
+37
-26
ExportService.java
...ava/org/apache/atlas/repository/impexp/ExportService.java
+0
-14
AtlasEntityGraphDiscoveryV1.java
...epository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java
+15
-9
EntityGraphMapper.java
...he/atlas/repository/store/graph/v1/EntityGraphMapper.java
+6
-1
EntityMutationContext.java
...tlas/repository/store/graph/v1/EntityMutationContext.java
+3
-0
ImportServiceTest.java
...org/apache/atlas/repository/impexp/ImportServiceTest.java
+13
-2
No files found.
repository/src/main/java/org/apache/atlas/repository/impexp/ExportService.java
View file @
4c2f7bf2
...
...
@@ -442,7 +442,6 @@ public class ExportService {
return
;
}
removeRelationshipAttributes
(
entity
);
context
.
sink
.
add
(
entity
);
context
.
result
.
incrementMeticsCounter
(
String
.
format
(
"entity:%s"
,
entity
.
getEntity
().
getTypeName
()));
...
...
@@ -456,19 +455,6 @@ public class ExportService {
context
.
reportProgress
();
}
private
void
removeRelationshipAttributes
(
AtlasEntityWithExtInfo
entity
)
{
if
(
entity
.
getEntity
().
getRelationshipAttributes
()
!=
null
)
{
entity
.
getEntity
().
getRelationshipAttributes
().
clear
();
}
if
(
entity
.
getReferredEntities
()
!=
null
)
{
for
(
AtlasEntity
e
:
entity
.
getReferredEntities
().
values
())
{
if
(
e
.
getRelationshipAttributes
()
!=
null
)
{
e
.
getRelationshipAttributes
().
clear
();
}
}
}
}
private
void
addTypes
(
AtlasEntity
entity
,
ExportContext
context
)
{
addEntityType
(
entity
.
getTypeName
(),
context
);
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityGraphDiscoveryV1.java
View file @
4c2f7bf2
...
...
@@ -305,26 +305,32 @@ public class AtlasEntityGraphDiscoveryV1 implements EntityGraphDiscovery {
List
<
String
>
visitedAttributes
=
new
ArrayList
<>();
// visit relationship attributes
for
(
AtlasAttribute
attribute
:
entityType
.
getRelationshipAttributes
().
values
())
{
if
(!(
this
.
discoveryContext
.
getEntityStream
()
instanceof
EntityImportStream
))
{
visitRelationships
(
entityType
,
entity
,
visitedAttributes
);
}
// visit struct attributes
for
(
AtlasAttribute
attribute
:
entityType
.
getAllAttributes
().
values
())
{
AtlasType
attrType
=
attribute
.
getAttributeType
();
String
attrName
=
attribute
.
getName
();
Object
attrVal
=
entity
.
get
Relationship
Attribute
(
attrName
);
Object
attrVal
=
entity
.
getAttribute
(
attrName
);
if
(
entity
.
has
RelationshipAttribute
(
attrName
))
{
if
(
entity
.
has
Attribute
(
attrName
)
&&
!
visitedAttributes
.
contains
(
attrName
))
{
visitAttribute
(
attrType
,
attrVal
);
visitedAttributes
.
add
(
attrName
);
}
}
}
// visit struct attributes
for
(
AtlasAttribute
attribute
:
entityType
.
get
All
Attributes
().
values
())
{
private
void
visitRelationships
(
AtlasEntityType
entityType
,
AtlasEntity
entity
,
List
<
String
>
visitedAttributes
)
throws
AtlasBaseException
{
for
(
AtlasAttribute
attribute
:
entityType
.
get
Relationship
Attributes
().
values
())
{
AtlasType
attrType
=
attribute
.
getAttributeType
();
String
attrName
=
attribute
.
getName
();
Object
attrVal
=
entity
.
get
Attribute
(
attrName
);
Object
attrVal
=
entity
.
getRelationship
Attribute
(
attrName
);
if
(
entity
.
has
Attribute
(
attrName
)
&&
!
visitedAttributes
.
contains
(
attrName
))
{
if
(
entity
.
has
RelationshipAttribute
(
attrName
))
{
visitAttribute
(
attrType
,
attrVal
);
visitedAttributes
.
add
(
attrName
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
View file @
4c2f7bf2
...
...
@@ -377,7 +377,7 @@ public class EntityGraphMapper {
AtlasEdge
currentEdge
;
// if relationshipGuid is assigned in AtlasRelatedObjectId use it to fetch existing AtlasEdge
if
(
StringUtils
.
isNotEmpty
(
relationshipGuid
))
{
if
(
StringUtils
.
isNotEmpty
(
relationshipGuid
)
&&
!
context
.
isImport
()
)
{
currentEdge
=
graphHelper
.
getEdgeForGUID
(
relationshipGuid
);
}
else
{
currentEdge
=
graphHelper
.
getEdgeForLabel
(
ctx
.
getReferringVertex
(),
edgeLabel
,
edgeDirection
);
...
...
@@ -699,6 +699,11 @@ public class EntityGraphMapper {
ret
=
getOrCreateRelationship
(
fromVertex
,
toVertex
,
relationshipName
,
relationshipAttributes
);
// for import use the relationship guid provided
if
(
context
.
isImport
())
{
AtlasGraphUtilsV1
.
setProperty
(
ret
,
Constants
.
GUID_PROPERTY_KEY
,
getRelationshipGuid
(
ctx
.
getValue
()));
}
// if relationship did not exist before and new relationship was created
// record entity update on both relationship vertices
if
(!
relationshipExists
)
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityMutationContext.java
View file @
4c2f7bf2
...
...
@@ -87,6 +87,9 @@ public class EntityMutationContext {
public
AtlasVertex
getVertex
(
String
guid
)
{
return
entityVsVertex
.
get
(
guid
);
}
public
boolean
isImport
()
{
return
(
context
!=
null
)
&&
context
.
getEntityStream
()
instanceof
EntityImportStream
;
}
@Override
public
boolean
equals
(
final
Object
o
)
{
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
View file @
4c2f7bf2
...
...
@@ -135,7 +135,6 @@ public class ImportServiceTest {
return
getZipSource
(
"salesNewTypeAttrs-next.zip"
);
}
@Test
(
dataProvider
=
"salesNewTypeAttrs-next"
,
dependsOnMethods
=
"importDB4"
)
public
void
importDB5
(
ZipSource
zipSource
)
throws
AtlasBaseException
,
IOException
{
final
String
newEnumDefName
=
"database_action"
;
...
...
@@ -186,7 +185,6 @@ public class ImportServiceTest {
return
getZipSource
(
"hdfs_path1.zip"
);
}
@Test
(
dataProvider
=
"hdfs_path1"
,
expectedExceptions
=
AtlasBaseException
.
class
)
public
void
importHdfs_path1
(
ZipSource
zipSource
)
throws
IOException
,
AtlasBaseException
{
loadBaseModel
();
...
...
@@ -204,6 +202,19 @@ public class ImportServiceTest {
}
}
@DataProvider
(
name
=
"relationship"
)
public
static
Object
[][]
getImportWithRelationships
(
ITestContext
context
)
throws
IOException
{
return
getZipSource
(
"stocks-rel-2.zip"
);
}
@Test
(
dataProvider
=
"relationship"
)
public
void
importDB7
(
ZipSource
zipSource
)
throws
AtlasBaseException
,
IOException
{
loadBaseModel
();
loadHiveModel
();
AtlasImportRequest
request
=
getDefaultImportRequest
();
runImportWithParameters
(
importService
,
request
,
zipSource
);
}
@Test
public
void
importServiceProcessesIOException
()
{
ImportService
importService
=
new
ImportService
(
typeDefStore
,
typeRegistry
,
null
);
...
...
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