dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39013
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19807: Event analytics, code simplification
------------------------------------------------------------
revno: 19807
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-08-20 16:05:43 -0400
message:
Event analytics, code simplification
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/analytics/AggregationType.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.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-api/src/main/java/org/hisp/dhis/analytics/AggregationType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/analytics/AggregationType.java 2015-08-02 13:30:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/analytics/AggregationType.java 2015-08-20 20:05:43 +0000
@@ -59,6 +59,11 @@
this.value = value;
}
+ public String getValue()
+ {
+ return value;
+ }
+
public static AggregationType fromValue( String value )
{
for ( AggregationType type : AggregationType.values() )
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2015-08-20 16:24:05 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2015-08-20 20:05:43 +0000
@@ -287,7 +287,7 @@
/**
* Returns the aggregation type for this query, first by looking at the
* aggregation type of the query, second by looking at the aggregation type
- * of the value dimension.
+ * of the value dimension, third by returning AVERAGE;
*/
public AggregationType getAggregationTypeFallback()
{
@@ -300,7 +300,7 @@
return value.getAggregationType();
}
- return null;
+ return AggregationType.AVERAGE;
}
/**
=== 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-09 19:05:08 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2015-08-20 20:05:43 +0000
@@ -28,12 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.analytics.AggregationType.COUNT;
-import static org.hisp.dhis.analytics.AggregationType.MAX;
-import static org.hisp.dhis.analytics.AggregationType.MIN;
-import static org.hisp.dhis.analytics.AggregationType.STDDEV;
-import static org.hisp.dhis.analytics.AggregationType.SUM;
-import static org.hisp.dhis.analytics.AggregationType.VARIANCE;
import static org.hisp.dhis.common.DimensionalObject.ORGUNIT_DIM_ID;
import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID;
import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
@@ -324,34 +318,9 @@
{
String column = statementBuilder.columnQuote( params.getValue().getUid() );
- if ( params.isAggregationType( SUM ) )
- {
- return "sum(" + column + ")";
- }
- else if ( params.isAggregationType( COUNT ) )
- {
- return "count(" + column + ")";
- }
- else if ( params.isAggregationType( STDDEV ) )
- {
- return "stddev(" + column + ")";
- }
- else if ( params.isAggregationType( VARIANCE ) )
- {
- return "variance(" + column + ")";
- }
- else if ( params.isAggregationType( MIN ) )
- {
- return "min(" + column + ")";
- }
- else if ( params.isAggregationType( MAX ) )
- {
- return "max(" + column + ")";
- }
- else // AVERAGE
- {
- return "avg(" + column + ")";
- }
+ String function = params.getAggregationTypeFallback().getValue();
+
+ return function + "(" + column + ")";
}
else
{