Commit 8a3795b8 by Ashutosh Mestry

ATLAS-2560: Addresses relationship handling during import.

parent 19abdf68
...@@ -695,6 +695,10 @@ public class EntityGraphMapper { ...@@ -695,6 +695,10 @@ public class EntityGraphMapper {
} }
if (attributeVertex == null) { if (attributeVertex == null) {
if(context.isImport()) {
return null;
}
throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, (ctx.getValue() == null ? null : ctx.getValue().toString())); throw new AtlasBaseException(AtlasErrorCode.INVALID_OBJECT_ID, (ctx.getValue() == null ? null : ctx.getValue().toString()));
} }
...@@ -733,7 +737,7 @@ public class EntityGraphMapper { ...@@ -733,7 +737,7 @@ public class EntityGraphMapper {
// for import use the relationship guid provided // for import use the relationship guid provided
if (context.isImport()) { 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 // if relationship did not exist before and new relationship was created
...@@ -869,14 +873,16 @@ public class EntityGraphMapper { ...@@ -869,14 +873,16 @@ public class EntityGraphMapper {
Object newEntry = mapCollectionElementsToVertex(arrCtx, context); 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. // Update the inverse reference value.
AtlasEdge newEdge = (AtlasEdge) newEntry; AtlasEdge newEdge = (AtlasEdge) newEntry;
addInverseReference(inverseRefAttribute, newEdge, getRelationshipAttributes(ctx.getValue())); addInverseReference(inverseRefAttribute, newEdge, getRelationshipAttributes(ctx.getValue()));
} }
newElementsCreated.add(newEntry); if(newEntry != null) {
newElementsCreated.add(newEntry);
}
} }
} }
......
...@@ -202,8 +202,21 @@ public class ImportServiceTest { ...@@ -202,8 +202,21 @@ public class ImportServiceTest {
} }
} }
@DataProvider(name = "relationship") @DataProvider(name = "relationshipLineage")
public static Object[][] getImportWithRelationships(ITestContext context) throws IOException { 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"); return getZipSource("stocks-rel-2.zip");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment