Repository: syncope
Updated Branches:
  refs/heads/2_0_X 4810fb796 -> 95123f8e5
  refs/heads/2_1_X b70bbb37e -> f1c83e548
  refs/heads/master 842a0fb9d -> ae8fef040


[SYNCOPE-1358] BooleanUtils to the resce


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/95123f8e
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/95123f8e
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/95123f8e

Branch: refs/heads/2_0_X
Commit: 95123f8e577948cc101d3718532413abff1c22a6
Parents: 4810fb7
Author: Francesco Chicchiriccò <ilgro...@apache.org>
Authored: Thu Aug 16 15:11:19 2018 +0200
Committer: Francesco Chicchiriccò <ilgro...@apache.org>
Committed: Thu Aug 16 15:11:19 2018 +0200

----------------------------------------------------------------------
 .../console/panels/search/SearchUtils.java      | 37 ++++++++++++++++----
 1 file changed, 30 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/95123f8e/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
index eaecc2f..32f491c 100644
--- 
a/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/panels/search/SearchUtils.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
+import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.math.NumberUtils;
 import org.apache.cxf.jaxrs.ext.search.ConditionType;
@@ -40,7 +41,6 @@ import 
org.apache.syncope.common.lib.search.SyncopeFiqlSearchCondition;
 import org.apache.syncope.common.lib.search.SyncopeProperty;
 import org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder;
 import org.apache.syncope.common.lib.to.PlainSchemaTO;
-import org.apache.syncope.common.lib.types.AttrSchemaType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -261,11 +261,23 @@ public final class SearchUtils implements Serializable {
                         if (StringUtils.isNotBlank(clause.getProperty())) {
                             boolean isLong = false;
                             boolean isDouble = false;
+                            boolean isBoolean = false;
                             if (availableSchemaTypes.get(clause.getProperty()) 
!= null) {
-                                isLong = 
availableSchemaTypes.get(clause.getProperty()).getType()
-                                        == AttrSchemaType.Long;
-                                isDouble = 
availableSchemaTypes.get(clause.getProperty()).getType()
-                                        == AttrSchemaType.Double;
+                                switch 
(availableSchemaTypes.get(clause.getProperty()).getType()) {
+                                    case Long:
+                                        isLong = true;
+                                        break;
+
+                                    case Double:
+                                        isDouble = true;
+                                        break;
+
+                                    case Boolean:
+                                        isBoolean = true;
+                                        break;
+
+                                    default:
+                                }
                             }
 
                             SyncopeProperty property = 
builder.is(clause.getProperty());
@@ -311,7 +323,14 @@ public final class SearchUtils implements Serializable {
                                     break;
 
                                 case NOT_EQUALS:
-                                    condition = 
property.notEqualTolIgnoreCase(value);
+                                    condition = isLong
+                                            ? 
property.notEqualTo(NumberUtils.toLong(value))
+                                            : isDouble
+                                                    ? 
property.notEqualTo(NumberUtils.toDouble(value))
+                                                    : isBoolean
+                                                            ? 
property.notEqualTo(BooleanUtils.toStringTrueFalse(
+                                                                    
BooleanUtils.toBoolean(value)))
+                                                            : 
property.notEqualTolIgnoreCase(value);
                                     break;
 
                                 case EQUALS:
@@ -319,8 +338,12 @@ public final class SearchUtils implements Serializable {
                                             ? 
property.equalTo(NumberUtils.toLong(value))
                                             : isDouble
                                                     ? 
property.equalTo(NumberUtils.toDouble(value))
-                                                    : 
property.equalToIgnoreCase(value);
+                                                    : isBoolean
+                                                            ? 
property.equalTo(BooleanUtils.toStringTrueFalse(
+                                                                    
BooleanUtils.toBoolean(value)))
+                                                            : 
property.equalToIgnoreCase(value);
                                     break;
+
                                 default:
                                     condition = 
property.equalToIgnoreCase(value);
                                     break;

Reply via email to