dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25116
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12376: Event analytics, fixed issue with relative periods
------------------------------------------------------------
revno: 12376
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-02 11:13:04 +0200
message:
Event analytics, fixed issue with relative periods
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.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/period/PeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2013-09-27 12:55:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2013-10-02 09:13:04 +0000
@@ -349,26 +349,6 @@
}
/**
- * Creates a period based on the given external identifier, which is on the
- * format [PeriodType]_[StartDate]. The start date is on the form yyyy-MM-dd.
- *
- * @param externalId the external identifier.
- * @return the period.
- */
- @Deprecated
- public static Period createPeriodExternalId( String externalId )
- {
- if ( externalId == null || externalId.split( "_" ).length <= 1 )
- {
- return null;
- }
-
- final String[] id = externalId.split( "_" );
- final PeriodType periodType = getPeriodTypeByName( id[0] );
- return periodType.createPeriod( getMediumDate( id[1] ) );
- }
-
- /**
* Return the potential number of periods of the given period type which is
* spanned by this period.
*
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java 2013-09-29 17:43:01 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java 2013-10-02 09:13:04 +0000
@@ -31,6 +31,7 @@
import java.util.Set;
import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.i18n.I18nFormat;
/**
* @author Lars Helge Overland
@@ -42,8 +43,8 @@
Grid getEvents( EventQueryParams params );
EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
- Set<String> dimension, Set<String> filter, String ouMode );
+ Set<String> dimension, Set<String> filter, String ouMode, I18nFormat format );
EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
- Set<String> dimension, Set<String> filter, String ouMode, Set<String> asc, Set<String> desc, Integer page, Integer pageSize );
+ Set<String> dimension, Set<String> filter, String ouMode, Set<String> asc, Set<String> desc, Integer page, Integer pageSize, I18nFormat format );
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2013-10-01 07:04:49 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2013-10-02 09:13:04 +0000
@@ -56,6 +56,7 @@
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.patient.PatientAttribute;
@@ -233,16 +234,18 @@
}
public EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
- Set<String> dimension, Set<String> filter, String ouMode )
+ Set<String> dimension, Set<String> filter, String ouMode, I18nFormat format )
{
- return getFromUrl( program, stage, startDate, endDate, dimension, filter, ouMode, null, null, null, null );
+ return getFromUrl( program, stage, startDate, endDate, dimension, filter, ouMode, null, null, null, null, format );
}
public EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
- Set<String> dimension, Set<String> filter, String ouMode, Set<String> asc, Set<String> desc, Integer page, Integer pageSize )
+ Set<String> dimension, Set<String> filter, String ouMode, Set<String> asc, Set<String> desc, Integer page, Integer pageSize, I18nFormat format )
{
EventQueryParams params = new EventQueryParams();
+ Date date = new Date();
+
Program pr = programService.getProgram( program );
if ( pr == null )
@@ -282,7 +285,7 @@
if ( ORGUNIT_DIM_ID.equals( dimensionId ) || PERIOD_DIM_ID.equals( dimensionId ) )
{
List<String> items = DataQueryParams.getDimensionItemsFromParam( dim );
- params.getDimensions().addAll( analyticsService.getDimension( dimensionId, items, null, null ) );
+ params.getDimensions().addAll( analyticsService.getDimension( dimensionId, items, date, format ) );
}
else
{
@@ -300,7 +303,7 @@
if ( ORGUNIT_DIM_ID.equals( dimensionId ) || PERIOD_DIM_ID.equals( dimensionId ) )
{
List<String> items = DataQueryParams.getDimensionItemsFromParam( dim );
- params.getFilters().addAll( analyticsService.getDimension( dimensionId, items, null, null ) );
+ params.getFilters().addAll( analyticsService.getDimension( dimensionId, items, date, format ) );
}
else
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java 2013-09-29 17:43:01 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java 2013-10-02 09:13:04 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.api.utils.ContextUtils;
import org.hisp.dhis.api.utils.ContextUtils.CacheStrategy;
import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.i18n.I18nManager;
import org.hisp.dhis.system.grid.GridUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -62,6 +63,9 @@
@Autowired
private ContextUtils contextUtils;
+ @Autowired
+ private I18nManager i18nManager;
+
// -------------------------------------------------------------------------
// Aggregate
// -------------------------------------------------------------------------
@@ -78,7 +82,7 @@
Model model,
HttpServletResponse response ) throws Exception
{
- EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, ouMode );
+ EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, ouMode, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.RESPECT_SYSTEM_SETTING );
Grid grid = analyticsService.getAggregatedEventData( params );
@@ -99,7 +103,7 @@
Model model,
HttpServletResponse response ) throws Exception
{
- EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, ouMode );
+ EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, ouMode, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.xls", true );
Grid grid = analyticsService.getAggregatedEventData( params );
@@ -126,7 +130,8 @@
Model model,
HttpServletResponse response ) throws Exception
{
- EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, ouMode, asc, desc, page, pageSize );
+ EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, ouMode,
+ asc, desc, page, pageSize, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.RESPECT_SYSTEM_SETTING );
Grid grid = analyticsService.getEvents( params );
@@ -151,7 +156,8 @@
Model model,
HttpServletResponse response ) throws Exception
{
- EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, ouMode, asc, desc, page, pageSize );
+ EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter,
+ ouMode, asc, desc, page, pageSize, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.xls", true );
Grid grid = analyticsService.getEvents( params );