diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/SearchParams.java b/intg/src/main/java/org/apache/atlas/model/discovery/SearchParams.java index 57000cc84f..93e6ea6b88 100644 --- a/intg/src/main/java/org/apache/atlas/model/discovery/SearchParams.java +++ b/intg/src/main/java/org/apache/atlas/model/discovery/SearchParams.java @@ -19,6 +19,8 @@ public class SearchParams { boolean excludeMeanings; boolean excludeClassifications; + boolean includeClassificationNames = false; + RequestMetadata requestMetadata = new RequestMetadata(); Async async = new Async(); @@ -100,6 +102,14 @@ public void setExcludeMeanings(boolean excludeMeanings) { this.excludeMeanings = excludeMeanings; } + public boolean isIncludeClassificationNames() { + return includeClassificationNames; + } + + public void setIncludeClassificationNames(boolean includeClassificationNames) { + this.includeClassificationNames = includeClassificationNames; + } + public boolean isSaveSearchLog() { return requestMetadata.saveSearchLog; } diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java index 987ceec296..8844d2d87b 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java @@ -785,7 +785,18 @@ public static List getTraitNames(AtlasVertex entityVertex) { public static List getPropagatedTraitNames(AtlasVertex entityVertex) { return getTraitNames(entityVertex, true); } - + public static List getAllTraitNamesFromAttribute(AtlasVertex entityVertex) { + List ret = new ArrayList<>(); + List traitNames = entityVertex.getMultiValuedProperty(TRAIT_NAMES_PROPERTY_KEY, String.class); + if (traitNames != null) { + ret.addAll(traitNames); + } + List propagatedTraitNames = entityVertex.getMultiValuedProperty(PROPAGATED_TRAIT_NAMES_PROPERTY_KEY, String.class); + if (propagatedTraitNames != null) { + ret.addAll(propagatedTraitNames); + } + return ret; + } public static List getAllTraitNames(AtlasVertex entityVertex) { return getTraitNames(entityVertex, null); } diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java index 691b5ab75f..90e041b473 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java @@ -1019,8 +1019,13 @@ private AtlasEntityHeader mapVertexToAtlasEntityHeader(AtlasVertex entityVertex, ret.setTypeName(typeName); ret.setGuid(guid); ret.setStatus(GraphHelper.getStatus(entityVertex)); - if(RequestContext.get().includeClassifications()){ - ret.setClassificationNames(getAllTraitNames(entityVertex)); + RequestContext context = RequestContext.get(); + boolean includeClassifications = context.includeClassifications(); + boolean includeClassificationNames = context.isIncludeClassificationNames(); + if(includeClassifications){ + ret.setClassificationNames(getAllTraitNamesFromAttribute(entityVertex)); + } else if (!includeClassifications && includeClassificationNames) { + ret.setClassificationNames(getAllTraitNamesFromAttribute(entityVertex)); } ret.setIsIncomplete(isIncomplete); ret.setLabels(getLabels(entityVertex)); diff --git a/server-api/src/main/java/org/apache/atlas/RequestContext.java b/server-api/src/main/java/org/apache/atlas/RequestContext.java index 1c7ccababb..d27be16759 100644 --- a/server-api/src/main/java/org/apache/atlas/RequestContext.java +++ b/server-api/src/main/java/org/apache/atlas/RequestContext.java @@ -88,6 +88,8 @@ public class RequestContext { private boolean allowDeletedRelationsIndexsearch = false; private boolean includeMeanings = true; private boolean includeClassifications = true; + + private boolean includeClassificationNames = false; private String currentTypePatchAction = ""; private AtlasTask currentTask; private String traceId; @@ -719,6 +721,14 @@ public boolean isCacheEnabled() { return this.cacheEnabled; } + public boolean isIncludeClassificationNames() { + return includeClassificationNames; + } + + public void setIncludeClassificationNames(boolean includeClassificationNames) { + this.includeClassificationNames = includeClassificationNames; + } + public class EntityGuidPair { private final Object entity; private final String guid; diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java index 7717baa49a..70c1f57cc3 100644 --- a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java +++ b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java @@ -393,6 +393,7 @@ public AtlasSearchResult indexSearch(@Context HttpServletRequest servletRequest, RequestContext.get().setIncludeMeanings(!parameters.isExcludeMeanings()); RequestContext.get().setIncludeClassifications(!parameters.isExcludeClassifications()); + RequestContext.get().setIncludeClassificationNames(parameters.isIncludeClassificationNames()); try { if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.indexSearch(" + parameters + ")");