This is an automated email from the ASF dual-hosted git repository.
sarath pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new d1f3418 ATLAS-3530: Retrieve entityDefinition for '_ALL_ENTITY_TYPES'
in /api/atlas/v2/types/entitydef/name/{name}
d1f3418 is described below
commit d1f341864ee026c0ea30c7f76f1fa5acad25dc09
Author: Sarath Subramanian <[email protected]>
AuthorDate: Thu Nov 21 14:59:01 2019 -0800
ATLAS-3530: Retrieve entityDefinition for '_ALL_ENTITY_TYPES' in
/api/atlas/v2/types/entitydef/name/{name}
---
intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java | 2 +-
.../atlas/repository/store/graph/AtlasTypeDefGraphStore.java | 7 ++++++-
.../repository/store/graph/AtlasTypeDefGraphStoreTest.java | 10 +++++++++-
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
index 557ef74..561a4a2 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
@@ -643,7 +643,7 @@ public class AtlasEntityType extends AtlasStructType {
add(new AtlasAttributeDef(CUSTOM_ATTRIBUTES_PROPERTY_KEY,
ATLAS_TYPE_STRING, false, true));
}};
- AtlasEntityDef entityDef = new AtlasEntityDef(ENTITY_ROOT_NAME, "",
"", attributeDefs);
+ AtlasEntityDef entityDef = new AtlasEntityDef(ENTITY_ROOT_NAME, "Root
entity for system attributes", "1.0", attributeDefs);
return new AtlasEntityType(entityDef);
}
diff --git
a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
index 2e2ab1a..0c2c2eb 100644
---
a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+++
b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
@@ -45,6 +45,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import static
org.apache.atlas.model.discovery.SearchParameters.ALL_ENTITY_TYPES;
import static
org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer.getTypesToCreate;
import static
org.apache.atlas.repository.store.bootstrap.AtlasTypeDefStoreInitializer.getTypesToUpdate;
@@ -260,7 +261,11 @@ public abstract class AtlasTypeDefGraphStore implements
AtlasTypeDefStore {
AtlasEntityDef ret = typeRegistry.getEntityDefByName(name);
if (ret == null) {
- throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND,
name);
+ ret = StringUtils.equals(name, ALL_ENTITY_TYPES) ?
AtlasEntityType.getEntityRoot().getEntityDef() : null;
+
+ if (ret == null) {
+ throw new
AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
+ }
}
return ret;
diff --git
a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
index 51dd16b..10568e9 100644
---
a/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
+++
b/repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
@@ -24,7 +24,6 @@ import org.apache.atlas.TestUtilsV2;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.SearchFilter;
import org.apache.atlas.model.typedef.*;
-import org.apache.atlas.model.impexp.AtlasExportRequest;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef;
@@ -32,6 +31,7 @@ import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
import org.apache.atlas.runner.LocalSolrRunner;
import org.apache.atlas.store.AtlasTypeDefStore;
+import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.utils.TestResourceFileUtils;
import org.slf4j.Logger;
@@ -693,4 +693,12 @@ public class AtlasTypeDefGraphStoreTest {
assertEquals(guid, getBackFromCache.getGuid());
assertEquals(createdTime, getBackFromCache.getCreateTime());
}
+
+ @Test
+ public void testGetOnAllEntityTypes() throws AtlasBaseException {
+ AtlasEntityDef entityDefByName =
typeDefStore.getEntityDefByName("_ALL_ENTITY_TYPES");
+
+ assertNotNull(entityDefByName);
+ assertEquals(entityDefByName,
AtlasEntityType.getEntityRoot().getEntityDef());
+ }
}