← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14838: Analytics, using convenience methods

 

------------------------------------------------------------
revno: 14838
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-14 11:15:35 +0200
message:
  Analytics, using convenience methods
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.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-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java	2014-03-31 08:21:01 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java	2014-04-14 09:15:35 +0000
@@ -43,6 +43,7 @@
 import static org.hisp.dhis.common.DimensionalObject.DIMENSION_SEP;
 import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
 import static org.hisp.dhis.system.util.TextUtils.getQuotedCommaDelimitedString;
+import static org.hisp.dhis.system.util.TextUtils.removeLastOr;
 import static org.hisp.dhis.system.util.TextUtils.trimEnd;
 
 import java.util.Collection;
@@ -296,7 +297,7 @@
                 }
             }
             
-            sql = trimEnd( sql, " or ".length() ) + ") ";
+            sql = removeLastOr( sql ) + ") ";
         }
         
         return sql;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2014-04-07 13:58:32 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2014-04-14 09:15:35 +0000
@@ -33,7 +33,8 @@
 import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
 import static org.hisp.dhis.system.util.DateUtils.getMediumDateString;
 import static org.hisp.dhis.system.util.TextUtils.getQuotedCommaDelimitedString;
-import static org.hisp.dhis.system.util.TextUtils.removeLast;
+import static org.hisp.dhis.system.util.TextUtils.removeLastComma;
+import static org.hisp.dhis.system.util.TextUtils.removeLastOr;
 import static org.hisp.dhis.system.util.TextUtils.trimEnd;
 
 import java.util.Arrays;
@@ -54,7 +55,6 @@
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.Program;
-import org.hisp.dhis.system.util.TextUtils;
 import org.hisp.dhis.system.util.Timer;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.BadSqlGrammarException;
@@ -211,7 +211,7 @@
                 sql += statementBuilder.columnQuote( item ) + " desc,";
             }
             
-            sql = removeLast( sql, 1 ) + " ";
+            sql = removeLastComma( sql ) + " ";
         }
         
         // ---------------------------------------------------------------------
@@ -333,7 +333,7 @@
             sql += statementBuilder.columnQuote( item.getUid() ) + ",";
         }
         
-        return removeLast( sql, 1 );
+        return removeLastComma( sql );
     }
 
     private String getFromWhereMultiplePartitionsClause( EventQueryParams params, List<String> fixedColumns )
@@ -388,7 +388,7 @@
                 sql += "uidlevel" + unit.getLevel() + " = '" + unit.getUid() + "' or ";
             }
             
-            sql = TextUtils.removeLast( sql, 3 ) + ") ";
+            sql = removeLastOr( sql ) + ") ";
         }
         
         if ( params.getProgramStage() != null )