Repository: atlas
Updated Branches:
  refs/heads/master 19abdf68e -> 8a3795b82


ATLAS-2560: Addresses relationship handling during import.

Signed-off-by: Ashutosh Mestry <ames...@hortonworks.com>


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/8a3795b8
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/8a3795b8
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/8a3795b8

Branch: refs/heads/master
Commit: 8a3795b8297566fd4429a6522379b0a92aae0a90
Parents: 19abdf6
Author: Ashutosh Mestry <ames...@hortonworks.com>
Authored: Mon Apr 16 15:01:32 2018 -0700
Committer: Ashutosh Mestry <ames...@hortonworks.com>
Committed: Mon Apr 16 15:41:04 2018 -0700

----------------------------------------------------------------------
 .../store/graph/v1/EntityGraphMapper.java           |  12 +++++++++---
 .../atlas/repository/impexp/ImportServiceTest.java  |  15 ++++++++++++++-
 repository/src/test/resources/rel-lineage.zip       | Bin 0 -> 8965 bytes
 3 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/8a3795b8/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
index 564567d..33b5896 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
@@ -695,6 +695,10 @@ public class EntityGraphMapper {
         }
 
         if (attributeVertex == null) {
+            if(context.isImport()) {
+                return null;
+            }
+
             throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, 
(ctx.getValue() == null ? null : ctx.getValue().toString()));
         }
 
@@ -733,7 +737,7 @@ public class EntityGraphMapper {
 
                     // for import use the relationship guid provided
                     if (context.isImport()) {
-                        AtlasGraphUtilsV1.setProperty(ret, 
Constants.GUID_PROPERTY_KEY, getRelationshipGuid(ctx.getValue()));
+                        AtlasGraphUtilsV1.setProperty(ret, 
Constants.RELATIONSHIP_GUID_PROPERTY_KEY, getRelationshipGuid(ctx.getValue()));
                     }
 
                     // if relationship did not exist before and new 
relationship was created
@@ -869,14 +873,16 @@ public class EntityGraphMapper {
 
                 Object newEntry = mapCollectionElementsToVertex(arrCtx, 
context);
 
-                if (isReference && newEntry instanceof AtlasEdge && 
inverseRefAttribute != null) {
+                if (isReference && newEntry != null && newEntry instanceof 
AtlasEdge && inverseRefAttribute != null) {
                     // Update the inverse reference value.
                     AtlasEdge newEdge = (AtlasEdge) newEntry;
 
                     addInverseReference(inverseRefAttribute, newEdge, 
getRelationshipAttributes(ctx.getValue()));
                 }
 
-                newElementsCreated.add(newEntry);
+                if(newEntry != null) {
+                    newElementsCreated.add(newEntry);
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/atlas/blob/8a3795b8/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
----------------------------------------------------------------------
diff --git 
a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
 
b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
index 080a96a..91d56ab 100644
--- 
a/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
+++ 
b/repository/src/test/java/org/apache/atlas/repository/impexp/ImportServiceTest.java
@@ -202,8 +202,21 @@ public class ImportServiceTest {
         }
     }
 
-    @DataProvider(name = "relationship")
+    @DataProvider(name = "relationshipLineage")
     public static Object[][] getImportWithRelationships(ITestContext context) 
throws IOException {
+        return getZipSource("rel-lineage.zip");
+    }
+
+    @Test(dataProvider = "relationshipLineage")
+    public void importDB8(ZipSource zipSource) throws AtlasBaseException, 
IOException {
+        loadBaseModel();
+        loadHiveModel();
+        AtlasImportRequest request = getDefaultImportRequest();
+        runImportWithParameters(importService, request, zipSource);
+    }
+
+    @DataProvider(name = "relationship")
+    public static Object[][] 
getImportWithRelationshipsWithLineage(ITestContext context) throws IOException {
         return getZipSource("stocks-rel-2.zip");
     }
 

http://git-wip-us.apache.org/repos/asf/atlas/blob/8a3795b8/repository/src/test/resources/rel-lineage.zip
----------------------------------------------------------------------
diff --git a/repository/src/test/resources/rel-lineage.zip 
b/repository/src/test/resources/rel-lineage.zip
new file mode 100644
index 0000000..de4da08
Binary files /dev/null and b/repository/src/test/resources/rel-lineage.zip 
differ

Reply via email to