← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19810: Event analytics, custom aggregation type

 

------------------------------------------------------------
revno: 19810
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-08-20 23:35:34 -0400
message:
  Event analytics, custom aggregation type
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java
  dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/TextUtils.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/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2015-08-21 02:55:35 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2015-08-21 03:35:34 +0000
@@ -42,6 +42,7 @@
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.analytics.EventOutputType;
 import org.hisp.dhis.analytics.event.EventAnalyticsManager;
 import org.hisp.dhis.analytics.event.EventQueryParams;
@@ -52,6 +53,7 @@
 import org.hisp.dhis.common.QueryFilter;
 import org.hisp.dhis.common.QueryItem;
 import org.hisp.dhis.commons.util.ExpressionUtils;
+import org.hisp.dhis.commons.util.TextUtils;
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.legend.Legend;
 import org.hisp.dhis.option.Option;
@@ -336,6 +338,8 @@
         {
             String function = params.getProgramIndicator().getAggregationTypeFallback().getValue();
             
+            function = TextUtils.emptyIfEqual( function, AggregationType.CUSTOM.getValue() );
+            
             String expression = programIndicatorService.getAnalyticsSQl( params.getProgramIndicator().getExpression() );
             
             return function + "(" + expression + ")";

=== modified file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/TextUtils.java'
--- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/TextUtils.java	2015-07-12 10:22:46 +0000
+++ dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/TextUtils.java	2015-08-21 03:35:34 +0000
@@ -457,6 +457,19 @@
     }
 
     /**
+     * Returns the empty string if the given string is equal to the given test,
+     * the string if not.
+     * 
+     * @param string the string.
+     * @param test the test to check the string for equality.
+     * @return a string.
+     */
+    public static String emptyIfEqual( String string, String test )
+    {
+        return test != null && test.equals( string ) ? EMPTY : string;
+    }
+    
+    /**
      * Invokes append tail on matcher with the given string buffer, and returns
      * the string buffer as a string.
      *