Skip to content

Commit

Permalink
Merge branch 'exclude-classification-names' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
sumandas0 committed Apr 9, 2024
2 parents 9a9db66 + 67a1895 commit 3ad0a77
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class SearchParams {
boolean excludeClassifications;
boolean enableFullRestriction;

boolean includeClassificationNames = false;

RequestMetadata requestMetadata = new RequestMetadata();

Async async = new Async();
Expand Down Expand Up @@ -109,6 +111,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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,18 @@ public static List<String> getTraitNames(AtlasVertex entityVertex) {
public static List<String> getPropagatedTraitNames(AtlasVertex entityVertex) {
return getTraitNames(entityVertex, true);
}

public static List<String> getAllTraitNamesFromAttribute(AtlasVertex entityVertex) {
List<String> ret = new ArrayList<>();
List<String> traitNames = entityVertex.getMultiValuedProperty(TRAIT_NAMES_PROPERTY_KEY, String.class);
if (traitNames != null) {
ret.addAll(traitNames);
}
List<String> propagatedTraitNames = entityVertex.getMultiValuedProperty(PROPAGATED_TRAIT_NAMES_PROPERTY_KEY, String.class);
if (propagatedTraitNames != null) {
ret.addAll(propagatedTraitNames);
}
return ret;
}
public static List<String> getAllTraitNames(AtlasVertex entityVertex) {
return getTraitNames(entityVertex, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.setClassifications(getAllClassifications(entityVertex));
}
ret.setIsIncomplete(isIncomplete);
ret.setLabels(getLabels(entityVertex));
Expand Down
10 changes: 10 additions & 0 deletions server-api/src/main/java/org/apache/atlas/RequestContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -710,6 +712,14 @@ public String getRequestUri() {
return this.requestUri;
}

public boolean isIncludeClassificationNames() {
return includeClassificationNames;
}

public void setIncludeClassificationNames(boolean includeClassificationNames) {
this.includeClassificationNames = includeClassificationNames;
}

public class EntityGuidPair {
private final Object entity;
private final String guid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ")");
Expand Down

0 comments on commit 3ad0a77

Please sign in to comment.