Commit 7b0a0e12 by Ashutosh Mestry

ATLAS-3232: Import Service: Handling RelationshipAttributes during import.

parent 6598c749
......@@ -22,6 +22,7 @@ import org.apache.atlas.model.impexp.AtlasImportResult;
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.AtlasTypesDef;
import org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer;
......@@ -68,6 +69,10 @@ public class ImportTypeDefProcessor {
for (AtlasStructDef def : typesDef.getStructDefs()) {
def.setGuid(null);
}
for (AtlasRelationshipDef def : typesDef.getRelationshipDefs()) {
def.setGuid(null);
}
}
private void updateMetricsForTypesDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) {
......
......@@ -24,6 +24,7 @@ import org.apache.atlas.model.impexp.AtlasImportResult;
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.AtlasTypesDef;
import org.apache.atlas.store.AtlasTypeDefStore;
......@@ -53,6 +54,7 @@ public class TypeAttributeDifference {
updateClassificationDef(typeDefinitionMap, result);
updateEnumDef(typeDefinitionMap, result);
updateStructDef(typeDefinitionMap, result);
updateRelationshipDefs(typeDefinitionMap, result);
}
private void updateEntityDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException {
......@@ -95,6 +97,16 @@ public class TypeAttributeDifference {
}
}
private void updateRelationshipDefs(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException {
for (AtlasRelationshipDef def : typeDefinitionMap.getRelationshipDefs()) {
AtlasRelationshipDef existing = typeRegistry.getRelationshipDefByName(def.getName());
if (existing != null && addAttributes(existing, def)) {
typeDefStore.updateRelationshipDefByName(existing.getName(), existing);
result.incrementMeticsCounter("typedef:relationshipdef:update");
}
}
}
@VisibleForTesting
boolean addElements(AtlasEnumDef existing, AtlasEnumDef incoming) throws AtlasBaseException {
return addElements(existing, getElementsAbsentInExisting(existing, incoming));
......
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