dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29211
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14733: TEI query, impl OR logic for tokens in query
------------------------------------------------------------
revno: 14733
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-07 19:25:25 +0200
message:
TEI query, impl OR logic for tokens in query
modified:
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-04-04 17:20:41 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-04-07 17:25:25 +0000
@@ -320,14 +320,24 @@
if ( params.isOrQuery() && params.hasAttributesOrFilters() )
{
+ String regexp = statementBuilder.getRegexpMatch();
+ String wordStart = statementBuilder.getRegexpWordStart();
+ String wordEnd = statementBuilder.getRegexpWordEnd();
+
sql += hlp.whereAnd() + " (";
for ( QueryItem item : params.getAttributesAndFilters() )
{
String col = statementBuilder.columnQuote( item.getItemId() );
- String query = statementBuilder.encode( params.getQuery(), false );
- sql += "lower(" + col + ".value) = '" + StringUtils.lowerCase( query ) + "' or ";
+ List<String> queryTokens = TextUtils.getTokens( params.getQuery() );
+
+ for ( String queryToken : queryTokens )
+ {
+ String query = statementBuilder.encode( queryToken, false );
+
+ sql += "lower(" + col + ".value) " + regexp + " '" + wordStart + StringUtils.lowerCase( query ) + wordEnd + "' or ";
+ }
}
sql = sql.substring( 0, sql.length() - 3 ) + ") "; // Remove last or