dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26594
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13153: Event analytics, extended meta-data
------------------------------------------------------------
revno: 13153
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-12-05 12:51:31 +0100
message:
Event analytics, extended meta-data
modified:
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-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-12-04 14:25:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2013-12-05 11:51:31 +0000
@@ -422,7 +422,14 @@
{
map.put( stage.getUid(), stage.getName() );
}
-
+ else
+ {
+ for ( ProgramStage st : program.getProgramStages() )
+ {
+ map.put( st.getUid(), st.getName() );
+ }
+ }
+
for ( QueryItem item : params.getItems() )
{
map.put( item.getItem().getUid(), item.getItem().getDisplayName() );
=== 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-12-05 10:29:15 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java 2013-12-05 11:51:31 +0000
@@ -28,6 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.analytics.AnalyticsService.NAMES_META_KEY;
+
+import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletResponse;
@@ -112,7 +115,7 @@
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.xls", true );
Grid grid = analyticsService.getAggregatedEventData( params );
- GridUtils.toXls( grid, response.getOutputStream() );
+ GridUtils.toXls( substituteMetaData( grid ), response.getOutputStream() );
}
@RequestMapping( value = RESOURCE_PATH + "/aggregate/{program}.csv", method = RequestMethod.GET )
@@ -133,7 +136,7 @@
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.csv", true );
Grid grid = analyticsService.getAggregatedEventData( params );
- GridUtils.toCsv( grid, response.getOutputStream() );
+ GridUtils.toCsv( substituteMetaData( grid ), response.getOutputStream() );
}
// -------------------------------------------------------------------------
@@ -189,7 +192,7 @@
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.xls", true );
Grid grid = analyticsService.getEvents( params );
- GridUtils.toXls( grid, response.getOutputStream() );
+ GridUtils.toXls( substituteMetaData( grid ), response.getOutputStream() );
}
@RequestMapping( value = RESOURCE_PATH + "/query/{program}.csv", method = RequestMethod.GET )
@@ -214,7 +217,7 @@
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.csv", true );
Grid grid = analyticsService.getEvents( params );
- GridUtils.toCsv( grid, response.getOutputStream() );
+ GridUtils.toCsv( substituteMetaData( grid ), response.getOutputStream() );
}
// -------------------------------------------------------------------------
@@ -226,4 +229,25 @@
{
ContextUtils.conflictResponse( response, ex.getMessage() );
}
+
+ @ExceptionHandler(IllegalArgumentException.class)
+ public void handleError( IllegalArgumentException ex, HttpServletResponse response )
+ {
+ ContextUtils.conflictResponse( response, ex.getMessage() );
+ }
+
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
+ @SuppressWarnings("unchecked")
+ private Grid substituteMetaData( Grid grid )
+ {
+ if ( grid.getMetaData() != null && grid.getMetaData().containsKey( NAMES_META_KEY ) )
+ {
+ grid.substituteMetaData( (Map<Object, Object>) grid.getMetaData().get( NAMES_META_KEY ) );
+ }
+
+ return grid;
+ }
}