[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/f1c83e54 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/f1c83e54 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/f1c83e54 Branch: refs/heads/2_1_X Commit: f1c83e5487b1f497025658b88f2f3a11abd84105 Parents: b70bbb3 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:27 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/f1c83e54/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 9bef61c..1c8f577 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; @@ -264,11 +264,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()); @@ -314,7 +326,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: @@ -322,8 +341,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;