You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2020/03/31 18:47:16 UTC
[atlas] 01/02: ATLAS-3708: fix to persist displayName field in
AtlasAttributeDef
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
commit 521118c82585d959cd22262d0012eb8c6b17c05a
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Mon Mar 30 18:47:18 2020 -0700
ATLAS-3708: fix to persist displayName field in AtlasAttributeDef
---
.../repository/store/graph/v2/AtlasStructDefStoreV2.java | 4 ++++
.../graph/v2/AtlasBusinessMetadataDefStoreV2Test.java | 15 ++++++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasStructDefStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasStructDefStoreV2.java
index 57c30f4..9a45f00 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasStructDefStoreV2.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasStructDefStoreV2.java
@@ -546,6 +546,8 @@ public class AtlasStructDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasStructDe
attribInfo.put("options", AtlasType.toJson(attributeDef.getOptions()));
}
+ attribInfo.put("displayName", attributeDef.getDisplayName());
+
final int lower;
final int upper;
@@ -591,6 +593,8 @@ public class AtlasStructDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasStructDe
ret.setOptions(AtlasType.fromJson((String) attribInfo.get("options"), Map.class));
}
+ ret.setDisplayName((String) attribInfo.get("displayName"));
+
if ((Boolean)attribInfo.get("isComposite")) {
ret.addConstraint(new AtlasConstraintDef(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF));
}
diff --git a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasBusinessMetadataDefStoreV2Test.java b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasBusinessMetadataDefStoreV2Test.java
index dd1a566..eaffac1 100644
--- a/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasBusinessMetadataDefStoreV2Test.java
+++ b/repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasBusinessMetadataDefStoreV2Test.java
@@ -19,7 +19,9 @@ package org.apache.atlas.repository.store.graph.v2;
import com.google.inject.Inject;
import org.apache.atlas.AtlasErrorCode;
+import org.apache.atlas.RequestContext;
import org.apache.atlas.TestModules;
+import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasBusinessMetadataDef;
@@ -69,6 +71,9 @@ public class AtlasBusinessMetadataDefStoreV2Test {
private String businessMetadataName;
@BeforeClass
public void setup() throws IOException, AtlasBaseException {
+ RequestContext.clear();
+ RequestContext.get().setUser(TestUtilsV2.TEST_USER, null);
+
loadBaseModel(typeDefStore, typeRegistry);
loadFsModel(typeDefStore, typeRegistry);
loadHiveModel(typeDefStore, typeRegistry);
@@ -402,6 +407,9 @@ public class AtlasBusinessMetadataDefStoreV2Test {
AtlasStructDef.AtlasAttributeDef.Cardinality.SINGLE);
addBusinessAttribute(businessMetadataDef1, "test_businessMetadata_attribute2", Collections.singleton("hive_table"), "int",
AtlasStructDef.AtlasAttributeDef.Cardinality.SINGLE);
+
+ TestUtilsV2.populateSystemAttributes(businessMetadataDef1);
+
return businessMetadataDef1;
}
@@ -418,7 +426,9 @@ public class AtlasBusinessMetadataDefStoreV2Test {
List<AtlasBusinessMetadataDef> businessMetadataDefs = new ArrayList(typesDefs.getBusinessMetadataDefs());
businessMetadataDefs.add(createBusinessMetadataDef(businessMetadataName));
typesDefs.setBusinessMetadataDefs(businessMetadataDefs);
- typeDefStore.createTypesDef(typesDefs);
+ AtlasTypesDef createdTypesDef = typeDefStore.createTypesDef(typesDefs);
+
+ Assert.assertEquals(createdTypesDef.getBusinessMetadataDefs(), businessMetadataDefs, "Data integrity issue while persisting");
}
private void addBusinessAttribute(AtlasBusinessMetadataDef businessMetadataDef, String name, Set<String> applicableEntityTypes,
@@ -431,7 +441,10 @@ public class AtlasBusinessMetadataDefStoreV2Test {
attributeDef.setOption(ATTR_MAX_STRING_LENGTH, "20");
}
attributeDef.setIsOptional(true);
+ attributeDef.setValuesMinCount(0);
+ attributeDef.setValuesMaxCount(1);
attributeDef.setIsUnique(false);
+ attributeDef.setDisplayName(name);
businessMetadataDef.addAttribute(attributeDef);
}