This is an automated email from the ASF dual-hosted git repository.

nixon pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit d1f6585f1279f0574902dd559eb0f844f9a56488
Author: mayanknj <mayank.j...@freestoneinfotech.com>
AuthorDate: Mon Mar 2 16:55:08 2020 +0530

    ATLAS-3647: Fix System attribute search when IsIncomplete Attribute has 
1,null as values.
    
    Signed-off-by: nixonrodrigues <ni...@apache.org>
    (cherry picked from commit c6cac0301707e0d5ac983902a0c2aeefb148c872)
---
 .../apache/atlas/discovery/SearchProcessor.java    | 38 ++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

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 cd01443..ddd3e60 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
@@ -222,9 +222,43 @@ public abstract class SearchProcessor {
                 processSearchAttributes(structType, criteria, indexFiltered, 
graphFiltered, allAttributes);
             }
         } else if (StringUtils.isNotEmpty(filterCriteria.getAttributeName())) {
-            try {
-                String attributeName = filterCriteria.getAttributeName();
+            String attributeName = filterCriteria.getAttributeName();
+
+            if (StringUtils.equals(attributeName, 
Constants.IS_INCOMPLETE_PROPERTY_KEY)) {
+                // when entity is incomplete (i.e. shell entity):
+                //   vertex property IS_INCOMPLETE_PROPERTY_KEY will be set to 
INCOMPLETE_ENTITY_VALUE
+                // when entity is not incomplete (i.e. not a shell entity):
+                //   vertex property IS_INCOMPLETE_PROPERTY_KEY will not be set
+
+                String attributeValue = filterCriteria.getAttributeValue();
+
+                switch (filterCriteria.getOperator()) {
+                    case EQ:
+                        if (attributeValue == null || 
StringUtils.equals(attributeValue, "0") || 
StringUtils.equalsIgnoreCase(attributeValue, "false")) {
+                            
filterCriteria.setOperator(SearchParameters.Operator.IS_NULL);
+                        } else {
+                            
filterCriteria.setOperator(SearchParameters.Operator.EQ);
+                            
filterCriteria.setAttributeValue(Constants.INCOMPLETE_ENTITY_VALUE.toString());
+                        }
+                    break;
 
+                    case NEQ:
+                        if (attributeValue == null || 
StringUtils.equals(attributeValue, "0") || 
StringUtils.equalsIgnoreCase(attributeValue, "false")) {
+                            
filterCriteria.setOperator(SearchParameters.Operator.EQ);
+                            
filterCriteria.setAttributeValue(Constants.INCOMPLETE_ENTITY_VALUE.toString());
+                        } else {
+                            
filterCriteria.setOperator(SearchParameters.Operator.IS_NULL);
+                        }
+                    break;
+
+                    case NOT_NULL:
+                        
filterCriteria.setOperator(SearchParameters.Operator.EQ);
+                        
filterCriteria.setAttributeValue(Constants.INCOMPLETE_ENTITY_VALUE.toString());
+                    break;
+                }
+            }
+
+            try {
                 if (isIndexSearchable(filterCriteria, structType)) {
                     indexFiltered.add(attributeName);
                 } else {

Reply via email to