Repository: atlas Updated Branches: refs/heads/branch-0.8 a5254b551 -> 64999fdc0
ATLAS-2815: UI Slow loading enhancements 1. Updated REST APIs that read entities with an option to include only minimum attributes for referred entities 2. UI changes for minExtInfo Signed-off-by: apoorvnaik <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/64999fdc Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/64999fdc Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/64999fdc Branch: refs/heads/branch-0.8 Commit: 64999fdc0b488f57445f52f2e77d9507fd660f57 Parents: a5254b5 Author: apoorvnaik <[email protected]> Authored: Tue Jul 31 07:06:17 2018 -0700 Committer: apoorvnaik <[email protected]> Committed: Tue Aug 7 11:53:07 2018 -0700 ---------------------------------------------------------------------- dashboardv2/public/js/models/VEntity.js | 14 +- dashboardv2/public/js/models/VSearch.js | 2 +- dashboardv2/public/js/models/VTag.js | 4 +- dashboardv2/public/js/router/Router.js | 2 +- .../public/js/utils/CommonViewFunction.js | 4 +- dashboardv2/public/js/utils/UrlLinks.js | 27 +++- .../js/views/entity/CreateEntityLayoutView.js | 4 +- .../atlas/model/discovery/SearchParameters.java | 14 ++ .../org/apache/atlas/type/AtlasEntityType.java | 54 +++++++- .../impexp/ExportImportAuditService.java | 42 ++---- .../store/graph/AtlasEntityStore.java | 38 ++++++ .../store/graph/v1/AtlasEntityStoreV1.java | 56 ++++++-- .../store/graph/v1/EntityGraphRetriever.java | 132 +++++++++++++------ .../org/apache/atlas/web/rest/EntityREST.java | 52 +++++--- .../atlas/web/adapters/TestEntitiesREST.java | 2 +- .../atlas/web/adapters/TestEntityREST.java | 8 +- 16 files changed, 330 insertions(+), 125 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/dashboardv2/public/js/models/VEntity.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/models/VEntity.js b/dashboardv2/public/js/models/VEntity.js index aa8dbc4..deeb6b0 100644 --- a/dashboardv2/public/js/models/VEntity.js +++ b/dashboardv2/public/js/models/VEntity.js @@ -43,7 +43,17 @@ define(['require', *************************/ getEntity: function(token, options) { - var url = UrlLinks.entitiesApiUrl(token); + var url = UrlLinks.entitiesApiUrl({ guid: token }); + + options = _.extend({ + contentType: 'application/json', + dataType: 'json' + }, options); + + return this.constructor.nonCrudOperation.call(this, url, 'GET', options); + }, + getEntityHeader: function(token, options) { + var url = UrlLinks.entityHeaderApiUrl(token); options = _.extend({ contentType: 'application/json', @@ -80,4 +90,4 @@ define(['require', } }, {}); return VEntity; -}); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/dashboardv2/public/js/models/VSearch.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/models/VSearch.js b/dashboardv2/public/js/models/VSearch.js index 700a909..32d4278 100644 --- a/dashboardv2/public/js/models/VSearch.js +++ b/dashboardv2/public/js/models/VSearch.js @@ -41,7 +41,7 @@ define(['require', * Non - CRUD operations *************************/ getEntity: function(id, options) { - var url = UrlLinks.entitiesApiUrl(id); + var url = UrlLinks.entitiesApiUrl({guid: id}); options = _.extend({ contentType: 'application/json', http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/dashboardv2/public/js/models/VTag.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/models/VTag.js b/dashboardv2/public/js/models/VTag.js index 65010cf..fc5a97f 100644 --- a/dashboardv2/public/js/models/VTag.js +++ b/dashboardv2/public/js/models/VTag.js @@ -41,7 +41,7 @@ define(['require', * Non - CRUD operations *************************/ deleteAssociation: function(guid, name, options) { - var url = UrlLinks.entitiesApiUrl(guid, name); + var url = UrlLinks.entitiesApiUrl({ guid: guid, name: name }); options = _.extend({ contentType: 'application/json', dataType: 'json' @@ -66,4 +66,4 @@ define(['require', } }, {}); return VTag; -}); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/dashboardv2/public/js/router/Router.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/router/Router.js b/dashboardv2/public/js/router/Router.js index 5ef3b49..d90c901 100644 --- a/dashboardv2/public/js/router/Router.js +++ b/dashboardv2/public/js/router/Router.js @@ -174,7 +174,7 @@ define([ 'id': id, 'value': paramObj }, that.preFetchedCollectionLists, that.sharedObj))); - this.entityCollection.url = UrlLinks.entitiesApiUrl(id); + this.entityCollection.url = UrlLinks.entitiesApiUrl({ guid: id, minExtInfo: true }); this.entityCollection.fetch({ reset: true }); }); } http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/dashboardv2/public/js/utils/CommonViewFunction.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js b/dashboardv2/public/js/utils/CommonViewFunction.js index 1b81c75..5f7e024 100644 --- a/dashboardv2/public/js/utils/CommonViewFunction.js +++ b/dashboardv2/public/js/utils/CommonViewFunction.js @@ -85,11 +85,11 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum var table = "", fetchInputOutputValue = function(id) { var that = this; - scope.entityModel.getEntity(id, { + scope.entityModel.getEntityHeader(id, { success: function(serverData) { var value = "", deleteButton = "", - data = serverData.entity; + data = serverData; value = Utils.getName(data); var id = ""; if (data.guid) { http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/dashboardv2/public/js/utils/UrlLinks.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/utils/UrlLinks.js b/dashboardv2/public/js/utils/UrlLinks.js index 1ab7061..c6335b9 100644 --- a/dashboardv2/public/js/utils/UrlLinks.js +++ b/dashboardv2/public/js/utils/UrlLinks.js @@ -54,16 +54,28 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require taxonomiesTermsApiUrl: function(name) { return this.baseUrl + '/v1/taxonomies' + '/' + name + '/terms'; }, - entitiesApiUrl: function(guid, name) { + entitiesApiUrl: function(options) { var entitiesUrl = this.baseUrlV2 + '/entity'; - if (guid && name) { - return entitiesUrl + '/guid/' + guid + '/classification/' + name; - } else if (guid && !name) { - return entitiesUrl + '/guid/' + guid; - } else { + if (options) { + var guid = options.guid, + name = options.name, + minExtInfo = options.minExtInfo; + if (guid && name) { + entitiesUrl += '/guid/' + guid + '/classification/' + name; + } else if (guid && !name) { + entitiesUrl += '/guid/' + guid; + } + } + + if (!minExtInfo) { return entitiesUrl; + } else { + return entitiesUrl += '?minExtInfo=' + (minExtInfo); } }, + entityHeaderApiUrl: function(guid) { + return this.entitiesApiUrl({ guid: guid }) + "/header" + }, entitiesTraitsApiUrl: function(token) { if (token) { return this.baseUrlV2 + '/entity/guid/' + token + '/classifications'; @@ -75,6 +87,9 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require entityCollectionaudit: function(guid) { return this.baseUrl + '/entities/' + guid + '/audit'; }, + replicationCollectionaudit: function(name) { + return this.baseUrl + '/admin/cluster/audit/' + name; + }, classicationApiUrl: function(name, guid) { var typeUrl = this.typedefsUrl(); if (name) { http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js ---------------------------------------------------------------------- diff --git a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js index a645237..6df1af0 100644 --- a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js +++ b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js @@ -184,7 +184,7 @@ define(['require', }, fetchCollections: function() { if (this.guid) { - this.collection.url = UrlLinks.entitiesApiUrl(this.guid); + this.collection.url = UrlLinks.entitiesApiUrl({ guid: this.guid }); this.collection.fetch({ reset: true }); } else { this.entityCollectionList(); @@ -212,7 +212,7 @@ define(['require', _.each(attrObj, function(obj) { if (obj.guid && !referredEntities[obj.guid]) { ++that.asyncReferEntityCounter; - that.collection.url = UrlLinks.entitiesApiUrl(obj.guid); + that.collection.url = UrlLinks.entitiesApiUrl({ guid: obj.guid }); that.collection.fetch({ success: function(data, response) { referredEntities[obj.guid] = response.entity; http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/intg/src/main/java/org/apache/atlas/model/discovery/SearchParameters.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/SearchParameters.java b/intg/src/main/java/org/apache/atlas/model/discovery/SearchParameters.java index 328c46b..fddf802 100644 --- a/intg/src/main/java/org/apache/atlas/model/discovery/SearchParameters.java +++ b/intg/src/main/java/org/apache/atlas/model/discovery/SearchParameters.java @@ -303,6 +303,20 @@ public class SearchParameters implements Serializable { private Condition condition; private List<FilterCriteria> criterion; + public FilterCriteria() { + } + + public FilterCriteria(String attributeName, Operator operator, String attributeValue) { + this.attributeName = attributeName; + this.operator = operator; + this.attributeValue = attributeValue; + } + + public FilterCriteria(Condition condition, List<FilterCriteria> criterion) { + this.condition = condition; + this.criterion = criterion; + } + public String getAttributeName() { return attributeName; } http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java ---------------------------------------------------------------------- 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 8b3d78a..e29f3a4 100644 --- a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java +++ b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java @@ -45,15 +45,25 @@ import java.util.Set; public class AtlasEntityType extends AtlasStructType { private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityType.class); + private static final String NAME = "name"; + private static final String DESCRIPTION = "description"; + private static final String OWNER = "owner"; + private static final String CREATE_TIME = "createTime"; + + private static final String[] ENTITY_HEADER_ATTRIBUTES = new String[] { NAME, DESCRIPTION, OWNER, CREATE_TIME }; + private static final String OPTION_SCHEMA_ATTRIBUTES = "schemaAttributes"; + private final AtlasEntityDef entityDef; private final String typeQryStr; - private List<AtlasEntityType> superTypes = Collections.emptyList(); - private Set<String> allSuperTypes = Collections.emptySet(); - private Set<String> subTypes = Collections.emptySet(); - private Set<String> allSubTypes = Collections.emptySet(); - private Set<String> typeAndAllSubTypes = Collections.emptySet(); - private String typeAndAllSubTypesQryStr = ""; + private List<AtlasEntityType> superTypes = Collections.emptyList(); + private Set<String> allSuperTypes = Collections.emptySet(); + private Set<String> subTypes = Collections.emptySet(); + private Set<String> allSubTypes = Collections.emptySet(); + private Set<String> typeAndAllSubTypes = Collections.emptySet(); + private String typeAndAllSubTypesQryStr = ""; + private Map<String, AtlasAttribute> headerAttributes = Collections.emptyMap(); + private Map<String, AtlasAttribute> minInfoAttributes = Collections.emptyMap(); public AtlasEntityType(AtlasEntityDef entityDef) { super(entityDef); @@ -102,6 +112,34 @@ public class AtlasEntityType extends AtlasStructType { this.typeAndAllSubTypes = new HashSet<>(); // this will be populated in resolveReferencesPhase2() this.typeAndAllSubTypes.add(this.getTypeName()); + + // headerAttributes includes uniqAttributes & ENTITY_HEADER_ATTRIBUTES + this.headerAttributes = new HashMap<>(this.uniqAttributes); + + for (String headerAttributeName : ENTITY_HEADER_ATTRIBUTES) { + AtlasAttribute headerAttribute = getAttribute(headerAttributeName); + + if (headerAttribute != null) { + this.headerAttributes.put(headerAttributeName, headerAttribute); + } + } + + // minInfoAttributes includes all headerAttributes & schema-attributes + this.minInfoAttributes = new HashMap<>(this.headerAttributes); + + Map<String, String> typeDefOptions = entityDef.getOptions(); + String jsonList = typeDefOptions != null ? typeDefOptions.get(OPTION_SCHEMA_ATTRIBUTES) : null; + List<String> schemaAttributeNames = StringUtils.isNotEmpty(jsonList) ? AtlasType.fromJson(jsonList, List.class) : null; + + if (CollectionUtils.isNotEmpty(schemaAttributeNames)) { + for (String schemaAttributeName : schemaAttributeNames) { + AtlasAttribute schemaAttribute = getAttribute(schemaAttributeName); + + if (schemaAttribute != null) { + this.minInfoAttributes.put(schemaAttributeName, schemaAttribute); + } + } + } } @Override @@ -142,6 +180,10 @@ public class AtlasEntityType extends AtlasStructType { public Set<String> getTypeAndAllSubTypes() { return typeAndAllSubTypes; } + public Map<String, AtlasAttribute> getHeaderAttributes() { return headerAttributes; } + + public Map<String, AtlasAttribute> getMinInfoAttributes() { return minInfoAttributes; } + public boolean isSuperTypeOf(AtlasEntityType entityType) { return entityType != null && allSubTypes.contains(entityType.getTypeName()); } http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/repository/src/main/java/org/apache/atlas/repository/impexp/ExportImportAuditService.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/impexp/ExportImportAuditService.java b/repository/src/main/java/org/apache/atlas/repository/impexp/ExportImportAuditService.java index f7e32dc..e90b6b9 100644 --- a/repository/src/main/java/org/apache/atlas/repository/impexp/ExportImportAuditService.java +++ b/repository/src/main/java/org/apache/atlas/repository/impexp/ExportImportAuditService.java @@ -24,6 +24,8 @@ import org.apache.atlas.discovery.AtlasDiscoveryService; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.discovery.AtlasSearchResult; import org.apache.atlas.model.discovery.SearchParameters; +import org.apache.atlas.model.discovery.SearchParameters.FilterCriteria; +import org.apache.atlas.model.discovery.SearchParameters.Operator; import org.apache.atlas.model.impexp.ExportImportAuditEntry; import org.apache.atlas.repository.ogm.DataAccess; import org.apache.atlas.repository.ogm.ExportImportAuditEntryDTO; @@ -62,8 +64,7 @@ public class ExportImportAuditService { public AtlasSearchResult get(String userName, String operation, String sourceCluster, String targetCluster, String startTime, String endTime, int limit, int offset) throws AtlasBaseException { - SearchParameters.FilterCriteria criteria = new SearchParameters.FilterCriteria(); - criteria.setCriterion(new ArrayList<SearchParameters.FilterCriteria>()); + FilterCriteria criteria = new FilterCriteria(FilterCriteria.Condition.AND, new ArrayList<FilterCriteria>()); addSearchParameters(criteria, userName, operation, sourceCluster, targetCluster, startTime, endTime); @@ -72,19 +73,18 @@ public class ExportImportAuditService { return discoveryService.searchWithParameters(searchParameters); } - private SearchParameters getSearchParameters(int limit, int offset, SearchParameters.FilterCriteria criteria) { + private SearchParameters getSearchParameters(int limit, int offset, FilterCriteria criteria) { SearchParameters searchParameters = new SearchParameters(); searchParameters.setTypeName(ENTITY_TYPE_NAME); searchParameters.setEntityFilters(criteria); searchParameters.setLimit(limit); searchParameters.setOffset(offset); + return searchParameters; } - private void addSearchParameters(SearchParameters.FilterCriteria criteria, - String userName, String operation, String sourceCluster, String targetCluster, - String startTime, String endTime) { - + private void addSearchParameters(FilterCriteria criteria, String userName, String operation, + String sourceCluster, String targetCluster, String startTime, String endTime) { addParameterIfValueNotEmpty(criteria, ExportImportAuditEntryDTO.PROPERTY_USER_NAME, userName); addParameterIfValueNotEmpty(criteria, ExportImportAuditEntryDTO.PROPERTY_OPERATION, operation); addParameterIfValueNotEmpty(criteria, ExportImportAuditEntryDTO.PROPERTY_SOURCE_CLUSTER_NAME, sourceCluster); @@ -93,31 +93,11 @@ public class ExportImportAuditService { addParameterIfValueNotEmpty(criteria, ExportImportAuditEntryDTO.PROPERTY_END_TIME, endTime); } - private void addParameterIfValueNotEmpty(SearchParameters.FilterCriteria criteria, - String attributeName, String value) { - if(StringUtils.isEmpty(value)) return; - - boolean isFirstCriteria = criteria.getAttributeName() == null; - SearchParameters.FilterCriteria cx = isFirstCriteria - ? criteria - : new SearchParameters.FilterCriteria(); - - setCriteria(cx, attributeName, value); - - if(isFirstCriteria) { - cx.setCondition(SearchParameters.FilterCriteria.Condition.AND); + private void addParameterIfValueNotEmpty(FilterCriteria criteria, String attributeName, String value) { + if(StringUtils.isEmpty(value)) { + return; } - if(!isFirstCriteria) { - criteria.getCriterion().add(cx); - } - } - - private SearchParameters.FilterCriteria setCriteria(SearchParameters.FilterCriteria criteria, String attributeName, String value) { - criteria.setAttributeName(attributeName); - criteria.setAttributeValue(value); - criteria.setOperator(SearchParameters.Operator.EQ); - - return criteria; + criteria.getCriterion().add(new FilterCriteria(attributeName, Operator.EQ, value)); } } http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java index 06208be..6a1a88f 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java @@ -21,6 +21,7 @@ import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; +import org.apache.atlas.model.instance.AtlasEntityHeader; import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.repository.store.graph.v1.EntityStream; @@ -42,6 +43,23 @@ public interface AtlasEntityStore { AtlasEntityWithExtInfo getById(String guid) throws AtlasBaseException; /** + * + * Get entity definition by its guid + * @param guid + * @param isMinExtInfo + * @return AtlasEntity + */ + AtlasEntityWithExtInfo getById(String guid, boolean isMinExtInfo) throws AtlasBaseException; + + /** + * Get entity header for the given GUID + * @param guid + * @return + * @throws AtlasBaseException + */ + AtlasEntityHeader getHeaderById(String guid) throws AtlasBaseException; + + /** * Batch GET to retrieve entities by their ID * @param guid * @return @@ -50,6 +68,15 @@ public interface AtlasEntityStore { AtlasEntitiesWithExtInfo getByIds(List<String> guid) throws AtlasBaseException; /** + * Batch GET to retrieve entities by their ID + * @param guid + * @param isMinExtInfo + * @return + * @throws AtlasBaseException + */ + AtlasEntitiesWithExtInfo getByIds(List<String> guid, boolean isMinExtInfo) throws AtlasBaseException; + + /** * * Get an eneity by its unique attribute * @param entityType type of the entity @@ -60,6 +87,17 @@ public interface AtlasEntityStore { throws AtlasBaseException; /** + * + * Get an eneity by its unique attribute + * @param entityType type of the entity + * @param uniqAttributes Attributes that uniquely identify the entity + * @param isMinExtInfo + * @return EntityMutationResponse details of the updates performed by this call + */ + AtlasEntityWithExtInfo getByUniqueAttributes(AtlasEntityType entityType, Map<String, Object> uniqAttributes, boolean isMinExtInfo) + throws AtlasBaseException; + + /** * Create or update entities in the stream * @param entityStream AtlasEntityStream * @return EntityMutationResponse Entity mutations operations with the corresponding set of entities on which these operations were performed http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java index 53f29d0..1f48d1c 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java @@ -27,6 +27,7 @@ import org.apache.atlas.model.instance.AtlasClassification; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; +import org.apache.atlas.model.instance.AtlasEntityHeader; import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.repository.graphdb.AtlasVertex; @@ -76,22 +77,27 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { } @Override - @GraphTransaction public AtlasEntityWithExtInfo getById(String guid) throws AtlasBaseException { + return getById(guid, false); + } + + @Override + @GraphTransaction + public AtlasEntityWithExtInfo getById(String guid, boolean isMinExtInfo) throws AtlasBaseException { if (LOG.isDebugEnabled()) { - LOG.debug("==> getById({})", guid); + LOG.debug("==> getById({}, {})", guid, isMinExtInfo); } EntityGraphRetriever entityRetriever = new EntityGraphRetriever(typeRegistry); - AtlasEntityWithExtInfo ret = entityRetriever.toAtlasEntityWithExtInfo(guid); + AtlasEntityWithExtInfo ret = entityRetriever.toAtlasEntityWithExtInfo(guid, isMinExtInfo); if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid); } if (LOG.isDebugEnabled()) { - LOG.debug("<== getById({}): {}", guid, ret); + LOG.debug("<== getById({}, {}): {}", guid, isMinExtInfo, ret); } return ret; @@ -99,26 +105,58 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { @Override @GraphTransaction - public AtlasEntitiesWithExtInfo getByIds(List<String> guids) throws AtlasBaseException { + public AtlasEntityHeader getHeaderById(String guid) throws AtlasBaseException { if (LOG.isDebugEnabled()) { - LOG.debug("==> getByIds({})", guids); + LOG.debug("==> getHeaderById({})", guid); } EntityGraphRetriever entityRetriever = new EntityGraphRetriever(typeRegistry); - AtlasEntitiesWithExtInfo ret = entityRetriever.toAtlasEntitiesWithExtInfo(guids); + AtlasEntityHeader ret = entityRetriever.toAtlasEntityHeader(guid); + + if (ret == null) { + throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid); + } if (LOG.isDebugEnabled()) { - LOG.debug("<== getByIds({}): {}", guids, ret); + LOG.debug("<== getHeaderById({}): {}", guid, ret); } return ret; } + @Override + public AtlasEntitiesWithExtInfo getByIds(List<String> guids) throws AtlasBaseException { + return getByIds(guids, false); + } @Override @GraphTransaction + public AtlasEntitiesWithExtInfo getByIds(List<String> guids, boolean isMinExtInfo) throws AtlasBaseException { + if (LOG.isDebugEnabled()) { + LOG.debug("==> getByIds({}, {})", guids, isMinExtInfo); + } + + EntityGraphRetriever entityRetriever = new EntityGraphRetriever(typeRegistry); + + AtlasEntitiesWithExtInfo ret = entityRetriever.toAtlasEntitiesWithExtInfo(guids, isMinExtInfo); + + if (LOG.isDebugEnabled()) { + LOG.debug("<== getByIds({}, {}): {}", guids, isMinExtInfo, ret); + } + + return ret; + } + + @Override public AtlasEntityWithExtInfo getByUniqueAttributes(AtlasEntityType entityType, Map<String, Object> uniqAttributes) throws AtlasBaseException { + return getByUniqueAttributes(entityType, uniqAttributes, false); + } + + @Override + @GraphTransaction + public AtlasEntityWithExtInfo getByUniqueAttributes(AtlasEntityType entityType, Map<String, Object> uniqAttributes, boolean isMinExtInfo) + throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> getByUniqueAttribute({}, {})", entityType.getTypeName(), uniqAttributes); } @@ -127,7 +165,7 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { EntityGraphRetriever entityRetriever = new EntityGraphRetriever(typeRegistry); - AtlasEntityWithExtInfo ret = entityRetriever.toAtlasEntityWithExtInfo(entityVertex); + AtlasEntityWithExtInfo ret = entityRetriever.toAtlasEntityWithExtInfo(entityVertex, isMinExtInfo); if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, entityType.getTypeName(), http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java index b972946..f2241b5 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java @@ -66,11 +66,8 @@ import static org.apache.atlas.repository.graph.GraphHelper.EDGE_LABEL_PREFIX; public final class EntityGraphRetriever { private static final Logger LOG = LoggerFactory.getLogger(EntityGraphRetriever.class); - private final String NAME = "name"; - private final String DESCRIPTION = "description"; - private final String OWNER = "owner"; - private final String CREATE_TIME = "createTime"; - private final String QUALIFIED_NAME = "qualifiedName"; + private static final String NAME = "name"; + private static final String QUALIFIED_NAME = "qualifiedName"; private static final GraphHelper graphHelper = GraphHelper.getInstance(); @@ -94,7 +91,11 @@ public final class EntityGraphRetriever { } public AtlasEntityWithExtInfo toAtlasEntityWithExtInfo(String guid) throws AtlasBaseException { - return toAtlasEntityWithExtInfo(getEntityVertex(guid)); + return toAtlasEntityWithExtInfo(guid, false); + } + + public AtlasEntityWithExtInfo toAtlasEntityWithExtInfo(String guid, boolean isMinExtInfo) throws AtlasBaseException { + return toAtlasEntityWithExtInfo(getEntityVertex(guid), isMinExtInfo); } public AtlasEntityWithExtInfo toAtlasEntityWithExtInfo(AtlasObjectId objId) throws AtlasBaseException { @@ -102,8 +103,12 @@ public final class EntityGraphRetriever { } public AtlasEntityWithExtInfo toAtlasEntityWithExtInfo(AtlasVertex entityVertex) throws AtlasBaseException { + return toAtlasEntityWithExtInfo(entityVertex, false); + } + + public AtlasEntityWithExtInfo toAtlasEntityWithExtInfo(AtlasVertex entityVertex, boolean isMinExtInfo) throws AtlasBaseException { AtlasEntityExtInfo entityExtInfo = new AtlasEntityExtInfo(); - AtlasEntity entity = mapVertexToAtlasEntity(entityVertex, entityExtInfo); + AtlasEntity entity = mapVertexToAtlasEntity(entityVertex, entityExtInfo, isMinExtInfo); AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(entity, entityExtInfo); ret.compact(); @@ -112,12 +117,16 @@ public final class EntityGraphRetriever { } public AtlasEntitiesWithExtInfo toAtlasEntitiesWithExtInfo(List<String> guids) throws AtlasBaseException { + return toAtlasEntitiesWithExtInfo(guids, false); + } + + public AtlasEntitiesWithExtInfo toAtlasEntitiesWithExtInfo(List<String> guids, boolean isMinExtInfo) throws AtlasBaseException { AtlasEntitiesWithExtInfo ret = new AtlasEntitiesWithExtInfo(); for (String guid : guids) { AtlasVertex vertex = getEntityVertex(guid); - AtlasEntity entity = mapVertexToAtlasEntity(vertex, ret); + AtlasEntity entity = mapVertexToAtlasEntity(vertex, ret, isMinExtInfo); ret.addEntity(entity); } @@ -169,6 +178,10 @@ public final class EntityGraphRetriever { } private AtlasEntity mapVertexToAtlasEntity(AtlasVertex entityVertex, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException { + return mapVertexToAtlasEntity(entityVertex, entityExtInfo, false); + } + + private AtlasEntity mapVertexToAtlasEntity(AtlasVertex entityVertex, AtlasEntityExtInfo entityExtInfo, boolean isMinExtInfo) throws AtlasBaseException { String guid = GraphHelper.getGuid(entityVertex); AtlasEntity entity = entityExtInfo != null ? entityExtInfo.getEntity(guid) : null; @@ -185,9 +198,44 @@ public final class EntityGraphRetriever { mapSystemAttributes(entityVertex, entity); - mapAttributes(entityVertex, entity, entityExtInfo); + mapAttributes(entityVertex, entity, entityExtInfo, isMinExtInfo); - mapClassifications(entityVertex, entity, entityExtInfo); + mapClassifications(entityVertex, entity); + } + + return entity; + } + + private AtlasEntity mapVertexToAtlasEntityMin(AtlasVertex entityVertex, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException { + return mapVertexToAtlasEntityMin(entityVertex, entityExtInfo, null); + } + + private AtlasEntity mapVertexToAtlasEntityMin(AtlasVertex entityVertex, AtlasEntityExtInfo entityExtInfo, Set<String> attributes) throws AtlasBaseException { + String guid = GraphHelper.getGuid(entityVertex); + AtlasEntity entity = entityExtInfo != null ? entityExtInfo.getEntity(guid) : null; + + if (entity == null) { + entity = new AtlasEntity(); + + if (entityExtInfo != null) { + entityExtInfo.addReferredEntity(guid, entity); + } + + mapSystemAttributes(entityVertex, entity); + + mapClassifications(entityVertex, entity); + + AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); + + if (entityType != null) { + for (AtlasAttribute attribute : entityType.getMinInfoAttributes().values()) { + Object attrValue = getVertexAttribute(entityVertex, attribute); + + if (attrValue != null) { + entity.setAttribute(attribute.getName(), attrValue); + } + } + } } return entity; @@ -211,25 +259,17 @@ public final class EntityGraphRetriever { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName); if (entityType != null) { - for (AtlasAttribute uniqueAttribute : entityType.getUniqAttributes().values()) { - Object attrValue = getVertexAttribute(entityVertex, uniqueAttribute); + for (AtlasAttribute headerAttribute : entityType.getHeaderAttributes().values()) { + Object attrValue = getVertexAttribute(entityVertex, headerAttribute); if (attrValue != null) { - ret.setAttribute(uniqueAttribute.getName(), attrValue); + ret.setAttribute(headerAttribute.getName(), attrValue); } } - Object name = getVertexAttribute(entityVertex, entityType.getAttribute(NAME)); - Object description = getVertexAttribute(entityVertex, entityType.getAttribute(DESCRIPTION)); - Object owner = getVertexAttribute(entityVertex, entityType.getAttribute(OWNER)); - Object createTime = getVertexAttribute(entityVertex, entityType.getAttribute(CREATE_TIME)); + Object name = ret.getAttribute(NAME); Object displayText = name != null ? name : ret.getAttribute(QUALIFIED_NAME); - ret.setAttribute(NAME, name); - ret.setAttribute(DESCRIPTION, description); - ret.setAttribute(OWNER, owner); - ret.setAttribute(CREATE_TIME, createTime); - if (displayText != null) { ret.setDisplayText(displayText.toString()); } @@ -284,6 +324,10 @@ public final class EntityGraphRetriever { } private void mapAttributes(AtlasVertex entityVertex, AtlasStruct struct, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException { + mapAttributes(entityVertex, struct, entityExtInfo, false); + } + + private void mapAttributes(AtlasVertex entityVertex, AtlasStruct struct, AtlasEntityExtInfo entityExtInfo, boolean isMinExtInfo) throws AtlasBaseException { AtlasType objType = typeRegistry.getType(struct.getTypeName()); if (!(objType instanceof AtlasStructType)) { @@ -293,7 +337,7 @@ public final class EntityGraphRetriever { AtlasStructType structType = (AtlasStructType) objType; for (AtlasAttribute attribute : structType.getAllAttributes().values()) { - Object attrValue = mapVertexToAttribute(entityVertex, attribute, entityExtInfo); + Object attrValue = mapVertexToAttribute(entityVertex, attribute, entityExtInfo, isMinExtInfo); struct.setAttribute(attribute.getName(), attrValue); } @@ -376,12 +420,12 @@ public final class EntityGraphRetriever { return ret; } - private void mapClassifications(AtlasVertex entityVertex, AtlasEntity entity, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException { + private void mapClassifications(AtlasVertex entityVertex, AtlasEntity entity) throws AtlasBaseException { final List<AtlasClassification> classifications = getClassifications(entityVertex, null); entity.setClassifications(classifications); } - private Object mapVertexToAttribute(AtlasVertex entityVertex, AtlasAttribute attribute, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException { + private Object mapVertexToAttribute(AtlasVertex entityVertex, AtlasAttribute attribute, AtlasEntityExtInfo entityExtInfo, boolean isMinExtInfo) throws AtlasBaseException { Object ret = null; AtlasType attrType = attribute.getAttributeType(); String vertexPropertyName = attribute.getQualifiedName(); @@ -400,16 +444,16 @@ public final class EntityGraphRetriever { ret = GraphHelper.getProperty(entityVertex, vertexPropertyName); break; case STRUCT: - ret = mapVertexToStruct(entityVertex, edgeLabel, null, entityExtInfo); + ret = mapVertexToStruct(entityVertex, edgeLabel, null, entityExtInfo, isMinExtInfo); break; case OBJECT_ID_TYPE: - ret = mapVertexToObjectId(entityVertex, edgeLabel, null, entityExtInfo, isOwnedAttribute); + ret = mapVertexToObjectId(entityVertex, edgeLabel, null, entityExtInfo, isOwnedAttribute, isMinExtInfo); break; case ARRAY: - ret = mapVertexToArray(entityVertex, (AtlasArrayType) attrType, vertexPropertyName, entityExtInfo, isOwnedAttribute); + ret = mapVertexToArray(entityVertex, (AtlasArrayType) attrType, vertexPropertyName, entityExtInfo, isOwnedAttribute, isMinExtInfo); break; case MAP: - ret = mapVertexToMap(entityVertex, (AtlasMapType) attrType, vertexPropertyName, entityExtInfo, isOwnedAttribute); + ret = mapVertexToMap(entityVertex, (AtlasMapType) attrType, vertexPropertyName, entityExtInfo, isOwnedAttribute, isMinExtInfo); break; case CLASSIFICATION: // do nothing @@ -420,7 +464,7 @@ public final class EntityGraphRetriever { } private Map<String, Object> mapVertexToMap(AtlasVertex entityVertex, AtlasMapType atlasMapType, final String propertyName, - AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute) throws AtlasBaseException { + AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute, boolean isMinExtInfo) throws AtlasBaseException { List<String> mapKeys = GraphHelper.getListProperty(entityVertex, propertyName); if (CollectionUtils.isEmpty(mapKeys)) { @@ -439,7 +483,7 @@ public final class EntityGraphRetriever { final String edgeLabel = EDGE_LABEL_PREFIX + keyPropertyName; final Object keyValue = GraphHelper.getMapValueProperty(mapValueType, entityVertex, keyPropertyName); - Object mapValue = mapVertexToCollectionEntry(entityVertex, mapValueType, keyValue, edgeLabel, entityExtInfo, isOwnedAttribute); + Object mapValue = mapVertexToCollectionEntry(entityVertex, mapValueType, keyValue, edgeLabel, entityExtInfo, isOwnedAttribute, isMinExtInfo); if (mapValue != null) { ret.put(mapKey, mapValue); } @@ -449,7 +493,7 @@ public final class EntityGraphRetriever { } private List<Object> mapVertexToArray(AtlasVertex entityVertex, AtlasArrayType arrayType, String propertyName, - AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute) throws AtlasBaseException { + AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute, boolean isMinExtInfo) throws AtlasBaseException { AtlasType arrayElementType = arrayType.getElementType(); List<Object> arrayElements = GraphHelper.getArrayElementsProperty(arrayElementType, entityVertex, propertyName); @@ -466,7 +510,7 @@ public final class EntityGraphRetriever { for (Object element : arrayElements) { Object arrValue = mapVertexToCollectionEntry(entityVertex, arrayElementType, element, - edgeLabel, entityExtInfo, isOwnedAttribute); + edgeLabel, entityExtInfo, isOwnedAttribute, isMinExtInfo); if (arrValue != null) { arrValues.add(arrValue); @@ -477,7 +521,7 @@ public final class EntityGraphRetriever { } private Object mapVertexToCollectionEntry(AtlasVertex entityVertex, AtlasType arrayElement, Object value, String edgeLabel, - AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute) throws AtlasBaseException { + AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute, boolean isMinExtInfo) throws AtlasBaseException { Object ret = null; switch (arrayElement.getTypeCategory()) { @@ -492,11 +536,11 @@ public final class EntityGraphRetriever { break; case STRUCT: - ret = mapVertexToStruct(entityVertex, edgeLabel, (AtlasEdge) value, entityExtInfo); + ret = mapVertexToStruct(entityVertex, edgeLabel, (AtlasEdge) value, entityExtInfo, isMinExtInfo); break; case OBJECT_ID_TYPE: - ret = mapVertexToObjectId(entityVertex, edgeLabel, (AtlasEdge) value, entityExtInfo, isOwnedAttribute); + ret = mapVertexToObjectId(entityVertex, edgeLabel, (AtlasEdge) value, entityExtInfo, isOwnedAttribute, isMinExtInfo); break; default: @@ -555,7 +599,7 @@ public final class EntityGraphRetriever { } private AtlasObjectId mapVertexToObjectId(AtlasVertex entityVertex, String edgeLabel, AtlasEdge edge, - AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute) throws AtlasBaseException { + AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute, boolean isMinExtInfo) throws AtlasBaseException { AtlasObjectId ret = null; if (edge == null) { @@ -567,7 +611,13 @@ public final class EntityGraphRetriever { if (referenceVertex != null) { if (entityExtInfo != null && isOwnedAttribute) { - AtlasEntity entity = mapVertexToAtlasEntity(referenceVertex, entityExtInfo); + final AtlasEntity entity; + + if (isMinExtInfo) { + entity = mapVertexToAtlasEntityMin(referenceVertex, entityExtInfo); + } else { + entity = mapVertexToAtlasEntity(referenceVertex, entityExtInfo); + } if (entity != null) { ret = AtlasTypeUtil.getAtlasObjectId(entity); @@ -581,7 +631,7 @@ public final class EntityGraphRetriever { return ret; } - private AtlasStruct mapVertexToStruct(AtlasVertex entityVertex, String edgeLabel, AtlasEdge edge, AtlasEntityExtInfo entityExtInfo) throws AtlasBaseException { + private AtlasStruct mapVertexToStruct(AtlasVertex entityVertex, String edgeLabel, AtlasEdge edge, AtlasEntityExtInfo entityExtInfo, boolean isMinExtInfo) throws AtlasBaseException { AtlasStruct ret = null; if (edge == null) { @@ -592,14 +642,14 @@ public final class EntityGraphRetriever { final AtlasVertex referenceVertex = edge.getInVertex(); ret = new AtlasStruct(GraphHelper.getTypeName(referenceVertex)); - mapAttributes(referenceVertex, ret, entityExtInfo); + mapAttributes(referenceVertex, ret, entityExtInfo, isMinExtInfo); } return ret; } private Object getVertexAttribute(AtlasVertex vertex, AtlasAttribute attribute) throws AtlasBaseException { - return vertex != null && attribute != null ? mapVertexToAttribute(vertex, attribute, null) : null; + return vertex != null && attribute != null ? mapVertexToAttribute(vertex, attribute, null, false) : null; } public AtlasEntityHeader toAtlasEntityHeader(AtlasVertex atlasVertex, Set<String> attributes) throws AtlasBaseException { http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java index f4eafa4..b9956f6 100644 --- a/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java +++ b/webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java @@ -21,9 +21,9 @@ import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.instance.AtlasClassification; -import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo; +import org.apache.atlas.model.instance.AtlasEntityHeader; import org.apache.atlas.model.instance.ClassificationAssociateRequest; import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; @@ -44,15 +44,7 @@ import org.springframework.stereotype.Service; import javax.inject.Inject; import javax.inject.Singleton; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import java.util.ArrayList; @@ -92,17 +84,43 @@ public class EntityREST { @Path("/guid/{guid}") @Consumes(Servlets.JSON_MEDIA_TYPE) @Produces(Servlets.JSON_MEDIA_TYPE) - public AtlasEntityWithExtInfo getById(@PathParam("guid") String guid) throws AtlasBaseException { + public AtlasEntityWithExtInfo getById(@PathParam("guid") String guid, @QueryParam("minExtInfo") @DefaultValue("false") boolean minExtInfo) throws AtlasBaseException { Servlets.validateQueryParamLength("guid", guid); AtlasPerfTracer perf = null; try { if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { - perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getById(" + guid + ")"); + perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getById(" + guid + ", " + minExtInfo + " )"); } - return entitiesStore.getById(guid); + return entitiesStore.getById(guid, minExtInfo); + } finally { + AtlasPerfTracer.log(perf); + } + } + + /** + * Get entity header given its GUID. + * @param guid GUID for the entity + * @return AtlasEntity + * @throws AtlasBaseException + */ + @GET + @Path("/guid/{guid}/header") + @Consumes(Servlets.JSON_MEDIA_TYPE) + @Produces(Servlets.JSON_MEDIA_TYPE) + public AtlasEntityHeader getHeaderById(@PathParam("guid") String guid) throws AtlasBaseException { + Servlets.validateQueryParamLength("guid", guid); + + AtlasPerfTracer perf = null; + + try { + if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { + perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getHeaderById(" + guid + ")"); + } + + return entitiesStore.getHeaderById(guid); } finally { AtlasPerfTracer.log(perf); } @@ -129,7 +147,7 @@ public class EntityREST { @Path("/uniqueAttribute/type/{typeName}") @Consumes(Servlets.JSON_MEDIA_TYPE) @Produces(Servlets.JSON_MEDIA_TYPE) - public AtlasEntityWithExtInfo getByUniqueAttributes(@PathParam("typeName") String typeName, + public AtlasEntityWithExtInfo getByUniqueAttributes(@PathParam("typeName") String typeName, @QueryParam("minExtInfo") @DefaultValue("false") boolean minExtInfo, @Context HttpServletRequest servletRequest) throws AtlasBaseException { Servlets.validateQueryParamLength("typeName", typeName); @@ -146,7 +164,7 @@ public class EntityREST { validateUniqueAttribute(entityType, attributes); - return entitiesStore.getByUniqueAttributes(entityType, attributes); + return entitiesStore.getByUniqueAttributes(entityType, attributes, minExtInfo); } finally { AtlasPerfTracer.log(perf); } @@ -573,7 +591,7 @@ public class EntityREST { @Path("/bulk") @Consumes(Servlets.JSON_MEDIA_TYPE) @Produces(Servlets.JSON_MEDIA_TYPE) - public AtlasEntitiesWithExtInfo getByGuids(@QueryParam("guid") List<String> guids) throws AtlasBaseException { + public AtlasEntitiesWithExtInfo getByGuids(@QueryParam("guid") List<String> guids, @QueryParam("minExtInfo") @DefaultValue("false") boolean minExtInfo) throws AtlasBaseException { if (CollectionUtils.isNotEmpty(guids)) { for (String guid : guids) { Servlets.validateQueryParamLength("guid", guid); @@ -591,7 +609,7 @@ public class EntityREST { throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guids); } - return entitiesStore.getByIds(guids); + return entitiesStore.getByIds(guids, minExtInfo); } finally { AtlasPerfTracer.log(perf); } http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java index e753881..673d698 100644 --- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java +++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java @@ -167,7 +167,7 @@ public class TestEntitiesREST { @Test(dependsOnMethods = "testCreateOrUpdateEntities") public void testGetEntities() throws Exception { - final AtlasEntitiesWithExtInfo response = entityREST.getByGuids(createdGuids); + final AtlasEntitiesWithExtInfo response = entityREST.getByGuids(createdGuids, false); final List<AtlasEntity> entities = response.getEntities(); Assert.assertNotNull(entities); http://git-wip-us.apache.org/repos/asf/atlas/blob/64999fdc/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java ---------------------------------------------------------------------- diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java index 842ab39..a470c3f 100644 --- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java +++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntityREST.java @@ -101,7 +101,7 @@ public class TestEntityREST { @Test public void testGetEntityById() throws Exception { createTestEntity(); - AtlasEntityWithExtInfo response = entityREST.getById(dbEntity.getGuid()); + AtlasEntityWithExtInfo response = entityREST.getById(dbEntity.getGuid(), false); Assert.assertNotNull(response); Assert.assertNotNull(response.getEntity()); @@ -185,7 +185,7 @@ public class TestEntityREST { @Test(dependsOnMethods = "testAddAndGetClassification") public void testGetEntityWithAssociations() throws Exception { - AtlasEntityWithExtInfo entity = entityREST.getById(dbEntity.getGuid()); + AtlasEntityWithExtInfo entity = entityREST.getById(dbEntity.getGuid(), false); final List<AtlasClassification> retrievedClassifications = entity.getEntity().getClassifications(); Assert.assertNotNull(retrievedClassifications); @@ -317,7 +317,7 @@ public class TestEntityREST { Assert.assertEquals(response.getEntitiesByOperation(EntityMutations.EntityOperation.PARTIAL_UPDATE).get(0).getGuid(), dbGuid); //Get By unique attribute - AtlasEntityWithExtInfo entity = entityREST.getByUniqueAttributes(TestUtilsV2.DATABASE_TYPE, toHttpServletRequest(TestUtilsV2.NAME, updatedDBName)); + AtlasEntityWithExtInfo entity = entityREST.getByUniqueAttributes(TestUtilsV2.DATABASE_TYPE, false, toHttpServletRequest(TestUtilsV2.NAME, updatedDBName)); Assert.assertNotNull(entity); Assert.assertNotNull(entity.getEntity().getGuid()); Assert.assertEquals(entity.getEntity().getGuid(), dbGuid); @@ -342,7 +342,7 @@ public class TestEntityREST { Assert.assertEquals(response.getEntitiesByOperation(EntityMutations.EntityOperation.PARTIAL_UPDATE).get(0).getGuid(), dbGuid); //Get By unique attribute - AtlasEntityWithExtInfo entity = entityREST.getByUniqueAttributes(TestUtilsV2.DATABASE_TYPE, toHttpServletRequest(TestUtilsV2.NAME, updatedDBName)); + AtlasEntityWithExtInfo entity = entityREST.getByUniqueAttributes(TestUtilsV2.DATABASE_TYPE, false, toHttpServletRequest(TestUtilsV2.NAME, updatedDBName)); Assert.assertNotNull(entity); Assert.assertNotNull(entity.getEntity().getGuid()); Assert.assertEquals(entity.getEntity().getGuid(), dbGuid);
