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; ...@@ -27,16 +27,15 @@ import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graph.GraphHelper; import org.apache.atlas.repository.graph.GraphHelper;
import org.apache.atlas.repository.graphdb.AtlasEdge; 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.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasGraphQuery; import org.apache.atlas.repository.graphdb.AtlasGraphQuery;
import org.apache.atlas.repository.graphdb.AtlasVertex; 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.AtlasClassificationType;
import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasStructType; import org.apache.atlas.type.AtlasStructType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute; import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.v1.model.instance.Id;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -233,11 +232,16 @@ public class SearchContext { ...@@ -233,11 +232,16 @@ public class SearchContext {
AtlasAttribute attr = termType.getRelationshipAttribute(TermSearchProcessor.ATLAS_GLOSSARY_TERM_ATTR_ASSIGNED_ENTITIES); AtlasAttribute attr = termType.getRelationshipAttribute(TermSearchProcessor.ATLAS_GLOSSARY_TERM_ATTR_ASSIGNED_ENTITIES);
Iterator<AtlasEdge> edges = GraphHelper.getEdgesForLabel(glossaryTerm, attr.getRelationshipEdgeLabel(), attr.getRelationshipEdgeDirection()); Iterator<AtlasEdge> edges = GraphHelper.getEdgesForLabel(glossaryTerm, attr.getRelationshipEdgeLabel(), attr.getRelationshipEdgeDirection());
boolean excludeDeletedEntities = searchParameters.getExcludeDeletedEntities();
if (edges != null) { if (edges != null) {
while (edges.hasNext()) { while (edges.hasNext()) {
AtlasEdge edge = edges.next(); 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; ...@@ -20,7 +20,6 @@ package org.apache.atlas.discovery;
import org.apache.atlas.repository.graphdb.AtlasVertex; import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.utils.AtlasPerfTracer; import org.apache.atlas.utils.AtlasPerfTracer;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -89,21 +88,18 @@ public class TermSearchProcessor extends SearchProcessor { ...@@ -89,21 +88,18 @@ public class TermSearchProcessor extends SearchProcessor {
if (CollectionUtils.isEmpty(assignedEntities)) { if (CollectionUtils.isEmpty(assignedEntities)) {
entityVertices.clear(); entityVertices.clear();
} else { } else {
CollectionUtils.filter(entityVertices, new Predicate() { CollectionUtils.filter(entityVertices, o -> {
@Override if (o instanceof AtlasVertex) {
public boolean evaluate(Object o) { AtlasVertex entityVertex = (AtlasVertex) o;
if (o instanceof AtlasVertex) {
AtlasVertex entityVertex = (AtlasVertex) o; for (AtlasVertex assignedEntity : assignedEntities) {
if (assignedEntity.getId().equals(entityVertex.getId())) {
for (AtlasVertex assignedEntity : assignedEntities) { return true;
if (assignedEntity.getId().equals(entityVertex.getId())) {
return true;
}
} }
} }
return false;
} }
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