Repository: incubator-atlas
Updated Branches:
  refs/heads/master abc4856e9 -> d7ce0a535


ATLAS-1956: AtlasSearchResult should include attributes present in filter 
criteria

Signed-off-by: Madhan Neethiraj <mad...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/d7ce0a53
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/d7ce0a53
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/d7ce0a53

Branch: refs/heads/master
Commit: d7ce0a535621e2cd1176ff3e069ce60b27b04c17
Parents: abc4856
Author: apoorvnaik <apoorvn...@apache.org>
Authored: Mon Jul 17 18:07:15 2017 -0700
Committer: Madhan Neethiraj <mad...@apache.org>
Committed: Mon Jul 17 18:07:15 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/atlas/discovery/EntityDiscoveryService.java | 4 ++++
 .../src/main/java/org/apache/atlas/discovery/SearchContext.java | 5 +++++
 .../main/java/org/apache/atlas/discovery/SearchProcessor.java   | 5 +++++
 3 files changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d7ce0a53/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
 
b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
index c7a624f..dbe11a6 100644
--- 
a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
+++ 
b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
@@ -420,6 +420,10 @@ public class EntityDiscoveryService implements 
AtlasDiscoveryService {
                 resultAttributes.addAll(searchParameters.getAttributes());
             }
 
+            if (CollectionUtils.isNotEmpty(context.getEntityAttributes())) {
+                resultAttributes.addAll(context.getEntityAttributes());
+            }
+
             for (String resultAttribute : resultAttributes) {
                 AtlasAttribute attribute = 
context.getEntityType().getAttribute(resultAttribute);
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d7ce0a53/repository/src/main/java/org/apache/atlas/discovery/SearchContext.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/discovery/SearchContext.java 
b/repository/src/main/java/org/apache/atlas/discovery/SearchContext.java
index 2125d61..55a07f3 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/SearchContext.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/SearchContext.java
@@ -27,6 +27,7 @@ import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 
+import java.util.HashSet;
 import java.util.Set;
 
 
@@ -35,6 +36,7 @@ public class SearchContext {
     private final AtlasTypeRegistry       typeRegistry;
     private final AtlasGraph              graph;
     private final Set<String>             indexedKeys;
+    private final Set<String>             entityAttributes;
     private final AtlasEntityType         entityType;
     private final AtlasClassificationType classificationType;
     private       SearchProcessor         searchProcessor;
@@ -45,6 +47,7 @@ public class SearchContext {
         this.typeRegistry       = typeRegistry;
         this.graph              = graph;
         this.indexedKeys        = indexedKeys;
+        this.entityAttributes   = new HashSet<>();
         this.entityType         = 
typeRegistry.getEntityTypeByName(searchParameters.getTypeName());
         this.classificationType = 
typeRegistry.getClassificationTypeByName(searchParameters.getClassification());
 
@@ -70,6 +73,8 @@ public class SearchContext {
 
     public Set<String> getIndexedKeys() { return indexedKeys; }
 
+    public Set<String> getEntityAttributes() { return entityAttributes; }
+
     public AtlasEntityType getEntityType() { return entityType; }
 
     public AtlasClassificationType getClassificationType() { return 
classificationType; }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/d7ce0a53/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java 
b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
index 29430ef..1481809 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
@@ -118,6 +118,11 @@ public abstract class SearchProcessor {
                     gremlinFiltered.add(attributeName);
                 }
 
+                if (structType instanceof AtlasEntityType) {
+                    // Capture the entity attributes
+                    context.getEntityAttributes().add(attributeName);
+                }
+
                 allAttributes.add(attributeName);
             } catch (AtlasBaseException e) {
                 LOG.warn(e.getMessage());

Reply via email to