Adhoc Filters Case insensitive for Ends With Condition

Hello Champs,

We have a requirement where we need to make adhoc filters as Case insensitive and we are on Oracle, so we mofidied applicationContext-semanticLayer.xml

As per this article - http://community.jaspersoft.com/wiki/how-enable-case-insensitive-search-...

And I am able to make it work for Starts with by adding ^ in the regular expression and it worked with no issues

return " regexp_like(" + sqlArgs[0] + "," + "'^" + search.replace("'","''") + "', 'i')"

But I am trying to change it for Ends with so it should be $ so I tried with below line but ended up with no luck and Ends with stopped working.

return " regexp_like(" + sqlArgs[0] + "," + "'" + search.replace("'","''") + "$', 'i')"

 

 

 

 

karthik.clarity's picture
Joined: Jul 4 2016 - 8:28pm
Last seen: 4 years 4 months ago

1 Answer:

It is fixed now. For other readers benefit, here is the solution

$ in grovvy needs to be escaped by \

So here is the xml snippet 

 

 <entry key="EndsWith">
                    <value>
                        def search = args[1].value;
                        if (search == null)
                        return sqlArgs[0] + " like '%' || " + sqlArgs[1]
                        if (! (search instanceof String)) { search = search.value }
                        return " regexp_like(" + sqlArgs[0] + "," + "'" + search.replace("'","''") + "\$', 'i')"
                    </value>
                </entry>
karthik.clarity's picture
Joined: Jul 4 2016 - 8:28pm
Last seen: 4 years 4 months ago
Feedback
randomness