Commit eaf067bc by apoorvnaik

ATLAS-2705: Search using term shouldn't show deleted entities by default

Change-Id: I23b53086b2bb2380f451e7d85b59096edc610181
parent 0b9d7113
......@@ -27,16 +27,15 @@ import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graph.GraphHelper;
import org.apache.atlas.repository.graphdb.AtlasEdge;
import org.apache.atlas.repository.graphdb.AtlasEdgeDirection;
import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasGraphQuery;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1;
import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.v1.model.instance.Id;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -233,11 +232,16 @@ public class SearchContext {
AtlasAttribute attr = termType.getRelationshipAttribute(TermSearchProcessor.ATLAS_GLOSSARY_TERM_ATTR_ASSIGNED_ENTITIES);
Iterator<AtlasEdge> edges = GraphHelper.getEdgesForLabel(glossaryTerm, attr.getRelationshipEdgeLabel(), attr.getRelationshipEdgeDirection());
boolean excludeDeletedEntities = searchParameters.getExcludeDeletedEntities();
if (edges != null) {
while (edges.hasNext()) {
AtlasEdge edge = edges.next();
ret.add(edge.getInVertex());
AtlasVertex inVertex = edge.getInVertex();
if (excludeDeletedEntities && AtlasGraphUtilsV1.getState(inVertex) == AtlasEntity.Status.DELETED) {
continue;
}
ret.add(inVertex);
}
}
......
......@@ -20,7 +20,6 @@ package org.apache.atlas.discovery;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.utils.AtlasPerfTracer;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -89,9 +88,7 @@ public class TermSearchProcessor extends SearchProcessor {
if (CollectionUtils.isEmpty(assignedEntities)) {
entityVertices.clear();
} else {
CollectionUtils.filter(entityVertices, new Predicate() {
@Override
public boolean evaluate(Object o) {
CollectionUtils.filter(entityVertices, o -> {
if (o instanceof AtlasVertex) {
AtlasVertex entityVertex = (AtlasVertex) o;
......@@ -103,7 +100,6 @@ public class TermSearchProcessor extends SearchProcessor {
}
return false;
}
});
}
}
......
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