dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29227
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14734: TEI query, minor
------------------------------------------------------------
revno: 14734
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-04-08 10:47:49 +0200
message:
TEI query, minor
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-07 17:25:25 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-04-08 08:47:49 +0000
@@ -325,22 +325,26 @@
String wordEnd = statementBuilder.getRegexpWordEnd();
sql += hlp.whereAnd() + " (";
-
- for ( QueryItem item : params.getAttributesAndFilters() )
+
+ List<String> queryTokens = TextUtils.getTokens( params.getQuery() );
+
+ for ( String queryToken : queryTokens )
{
- String col = statementBuilder.columnQuote( item.getItemId() );
+ sql += "(";
- List<String> queryTokens = TextUtils.getTokens( params.getQuery() );
+ for ( QueryItem item : params.getAttributesAndFilters() )
+ {
+ String col = statementBuilder.columnQuote( item.getItemId() );
- for ( String queryToken : queryTokens )
- {
String query = statementBuilder.encode( queryToken, false );
-
- sql += "lower(" + col + ".value) " + regexp + " '" + wordStart + StringUtils.lowerCase( query ) + wordEnd + "' or ";
+
+ sql += "lower(" + col + ".value) " + regexp + " '" + wordStart + StringUtils.lowerCase( query ) + wordEnd + "' or ";
}
+
+ sql = sql.substring( 0, sql.length() - 3 ) + ") and "; // Remove last or
}
- sql = sql.substring( 0, sql.length() - 3 ) + ") "; // Remove last or
+ sql = sql.substring( 0, sql.length() - 4 ) + ") "; // Remove last and
}
return sql;