You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by am...@apache.org on 2019/07/31 23:10:57 UTC
[atlas] 01/02: ATLAS-3232: Import Service: Handling
RelationshipAttributes during import.
This is an automated email from the ASF dual-hosted git repository.
amestry pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
commit 7b0a0e1294f9ee91e269aa4bd970e54ab42df779
Author: Ashutosh Mestry <am...@hortonworks.com>
AuthorDate: Wed Jul 31 15:59:16 2019 -0700
ATLAS-3232: Import Service: Handling RelationshipAttributes during import.
---
.../atlas/repository/impexp/ImportTypeDefProcessor.java | 5 +++++
.../atlas/repository/impexp/TypeAttributeDifference.java | 12 ++++++++++++
2 files changed, 17 insertions(+)
diff --git a/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTypeDefProcessor.java b/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTypeDefProcessor.java
index c217937..4fc70bc 100644
--- a/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTypeDefProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTypeDefProcessor.java
@@ -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) {
diff --git a/repository/src/main/java/org/apache/atlas/repository/impexp/TypeAttributeDifference.java b/repository/src/main/java/org/apache/atlas/repository/impexp/TypeAttributeDifference.java
index e3d86c8..b811b5a 100644
--- a/repository/src/main/java/org/apache/atlas/repository/impexp/TypeAttributeDifference.java
+++ b/repository/src/main/java/org/apache/atlas/repository/impexp/TypeAttributeDifference.java
@@ -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));