dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29228
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14735: Minor
------------------------------------------------------------
revno: 14735
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-04-08 11:18:14 +0200
message:
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-08 08:47:49 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-04-08 09:18:14 +0000
@@ -237,6 +237,10 @@
*/
private String getFromWhereClause( TrackedEntityInstanceQueryParams params, SqlHelper hlp )
{
+ final String regexp = statementBuilder.getRegexpMatch();
+ final String wordStart = statementBuilder.getRegexpWordStart();
+ final String wordEnd = statementBuilder.getRegexpWordEnd();
+
String sql =
"from trackedentityinstance tei " +
"inner join trackedentity te on tei.trackedentityid = te.trackedentityid " +
@@ -244,20 +248,20 @@
for ( QueryItem item : params.getAttributesAndFilters() )
{
- String col = statementBuilder.columnQuote( item.getItemId() );
+ final String col = statementBuilder.columnQuote( item.getItemId() );
- String joinClause = item.hasFilter() ? "inner join" : "left join";
+ final String joinClause = item.hasFilter() ? "inner join" : "left join";
sql +=
joinClause + " trackedentityattributevalue as " + col + " " +
"on " + col + ".trackedentityinstanceid = tei.trackedentityinstanceid " +
"and " + col + ".trackedentityattributeid = " + item.getItem().getId() + " ";
- String filter = statementBuilder.encode( item.getFilter(), false );
+ final String filter = statementBuilder.encode( item.getFilter(), false );
if ( !params.isOrQuery() && item.hasFilter() )
{
- String queryCol = item.isNumeric() ? ( col + ".value" ) : "lower(" + col + ".value)";
+ final String queryCol = item.isNumeric() ? ( col + ".value" ) : "lower(" + col + ".value)";
sql += "and " + queryCol + " " + item.getSqlOperator() + " " + StringUtils.lowerCase( item.getSqlFilter( filter ) ) + " ";
}
@@ -320,24 +324,20 @@
if ( params.isOrQuery() && params.hasAttributesOrFilters() )
{
- String regexp = statementBuilder.getRegexpMatch();
- String wordStart = statementBuilder.getRegexpWordStart();
- String wordEnd = statementBuilder.getRegexpWordEnd();
-
sql += hlp.whereAnd() + " (";
List<String> queryTokens = TextUtils.getTokens( params.getQuery() );
for ( String queryToken : queryTokens )
- {
+ {
+ final String query = statementBuilder.encode( queryToken, false );
+
sql += "(";
for ( QueryItem item : params.getAttributesAndFilters() )
{
- String col = statementBuilder.columnQuote( item.getItemId() );
-
- String query = statementBuilder.encode( queryToken, false );
-
+ final String col = statementBuilder.columnQuote( item.getItemId() );
+
sql += "lower(" + col + ".value) " + regexp + " '" + wordStart + StringUtils.lowerCase( query ) + wordEnd + "' or ";
}