From 55643b4d158ac8ba1453931abb005d1793dee3ff Mon Sep 17 00:00:00 2001 From: matthewjrose87 Date: Mon, 25 Jan 2016 11:21:40 -0500 Subject: [PATCH 1/2] Add support for boolean types to Filter --- src/groovy/net/hedtech/restfulapi/query/Filter.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/groovy/net/hedtech/restfulapi/query/Filter.groovy b/src/groovy/net/hedtech/restfulapi/query/Filter.groovy index db70133..eb8e414 100644 --- a/src/groovy/net/hedtech/restfulapi/query/Filter.groovy +++ b/src/groovy/net/hedtech/restfulapi/query/Filter.groovy @@ -52,7 +52,8 @@ class Filter { private static List NUMERIC_TYPES = ['num', 'number'] private static List STRING_TYPES = ['string'] private static List DATE_TYPES = ['date'] - private static List SUPPORTED_TYPES = STRING_TYPES + NUMERIC_TYPES + DATE_TYPES + private static List BOOL_TYPES = ['bool', 'boolean'] + private static List SUPPORTED_TYPES = STRING_TYPES + NUMERIC_TYPES + DATE_TYPES + BOOL_TYPES protected static final Log log = LogFactory.getLog(Filter.class) @@ -81,6 +82,7 @@ class Filter { public boolean isNumeric() { NUMERIC_TYPES.contains(type) } public boolean isDate() { DATE_TYPES.contains(type) } + public boolean isBoolean() { BOOL_TYPES.contains(type) } public String toString() { "Filter[field=$field,operator=$operator,value=$value,type=${persistentProperty?.type},isAssociation=$isAssociation,isMany=$isMany]" From 5d346740ba82ad6432dbfd61283fac5c5fe732de Mon Sep 17 00:00:00 2001 From: matthewjrose87 Date: Mon, 25 Jan 2016 11:22:50 -0500 Subject: [PATCH 2/2] Add support for boolean types to HQLBuilder --- src/groovy/net/hedtech/restfulapi/query/HQLBuilder.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/src/groovy/net/hedtech/restfulapi/query/HQLBuilder.groovy b/src/groovy/net/hedtech/restfulapi/query/HQLBuilder.groovy index dcdc219..70a12a6 100644 --- a/src/groovy/net/hedtech/restfulapi/query/HQLBuilder.groovy +++ b/src/groovy/net/hedtech/restfulapi/query/HQLBuilder.groovy @@ -112,6 +112,7 @@ class HQLBuilder { else { if (it.isNumeric()) namedParameters."${it.field}" = "${it.value}".toLong() else if (it.isDate()) namedParameters."${it.field}" = parseDate( params, it ) + else if (it.isBoolean()) namedParameters."${it.field}" = "${it.value}".toBoolean() else namedParameters."${it.field}" = "${it.value}" whereFragment += "${firstAlias}.${it.field} "