dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25238
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12464: PNG maps, support for dynamic org unit
------------------------------------------------------------
revno: 12464
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-10-07 12:19:08 +0200
message:
PNG maps, support for dynamic org unit
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapgeneration/MapGenerationService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.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/mapgeneration/MapGenerationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapgeneration/MapGenerationService.java 2013-10-07 10:01:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapgeneration/MapGenerationService.java 2013-10-07 10:19:08 +0000
@@ -33,6 +33,7 @@
import org.hisp.dhis.mapping.Map;
import org.hisp.dhis.mapping.MapView;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
/**
* The MapGenerationService interface generates map images from Map objects.
@@ -71,9 +72,10 @@
*
* @param map the map that will be rendered.
* @param date the date for relative periods.
+ * @param unit the organisation unit.
* @param width the maximum width of the map image.
* @param height the maxium height of the map image.
* @return the rendered map image or null if there is no data for the map view.
*/
- BufferedImage generateMapImage( Map map, Date date, Integer width, Integer height );
+ BufferedImage generateMapImage( Map map, Date date, OrganisationUnit unit, Integer width, Integer height );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2013-09-13 11:22:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2013-10-07 10:19:08 +0000
@@ -106,6 +106,8 @@
Map getMap( String uid );
+ Map getMapNoAcl( String uid );
+
void deleteMap( Map map );
List<Map> getMapsBetweenLikeName( String name, int first, int max );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2013-09-17 16:22:09 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2013-10-07 10:19:08 +0000
@@ -259,6 +259,11 @@
return mapStore.getByUid( uid );
}
+ public Map getMapNoAcl( String uid )
+ {
+ return mapStore.getByUidNoAcl( uid );
+ }
+
public void deleteMap( Map map )
{
mapStore.delete( map );
=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java 2013-10-07 10:01:43 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java 2013-10-07 10:19:08 +0000
@@ -97,10 +97,10 @@
public BufferedImage generateMapImage( Map map )
{
- return generateMapImage( map, new Date(), 512, null );
+ return generateMapImage( map, new Date(), null, 512, null );
}
- public BufferedImage generateMapImage( Map map, Date date, Integer width, Integer height )
+ public BufferedImage generateMapImage( Map map, Date date, OrganisationUnit unit, Integer width, Integer height )
{
Assert.isTrue( map != null );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2013-10-07 10:01:43 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2013-10-07 10:19:08 +0000
@@ -229,13 +229,22 @@
public void getMapData(
@PathVariable String uid,
@RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date date,
+ @RequestParam( value = "ou", required = false ) String ou,
@RequestParam( required = false ) Integer width,
@RequestParam( required = false ) Integer height,
HttpServletResponse response ) throws Exception
{
- Map map = mappingService.getMap( uid );
-
- renderMapViewPng( map, date, width, height, response );
+ Map map = mappingService.getMapNoAcl( uid );
+
+ if ( map == null )
+ {
+ ContextUtils.notFoundResponse( response, "Map does not exist: " + uid );
+ return;
+ }
+
+ OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit( ou ) : null;
+
+ renderMapViewPng( map, date, unit, width, height, response );
}
//--------------------------------------------------------------------------
@@ -269,10 +278,10 @@
}
}
- private void renderMapViewPng( Map map, Date date, Integer width, Integer height, HttpServletResponse response )
+ private void renderMapViewPng( Map map, Date date, OrganisationUnit unit, Integer width, Integer height, HttpServletResponse response )
throws Exception
{
- BufferedImage image = mapGenerationService.generateMapImage( map, date, width, height );
+ BufferedImage image = mapGenerationService.generateMapImage( map, date, unit, width, height );
if ( image != null )
{