Commit d1f34186 by Sarath Subramanian

ATLAS-3530: Retrieve entityDefinition for '_ALL_ENTITY_TYPES' in…

ATLAS-3530: Retrieve entityDefinition for '_ALL_ENTITY_TYPES' in /api/atlas/v2/types/entitydef/name/{name}
parent bdd110df
......@@ -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);
}
......
......@@ -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;
......
......@@ -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());
}
}
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