=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2012-10-25 16:59:25 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2012-10-25 17:18:52 +0000 @@ -147,6 +147,12 @@ // Getters and setters // ------------------------------------------------------------------------- + @Override + public String getName() + { + return uid; + } + @JsonProperty @JsonView( {DetailedView.class, ExportView.class} ) @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) === 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 2012-10-25 16:59:25 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2012-10-25 17:18:52 +0000 @@ -29,25 +29,20 @@ import static org.hisp.dhis.period.PeriodType.getPeriodFromIsoString; -import java.awt.image.BufferedImage; import java.io.InputStream; import java.util.Iterator; -import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.hisp.dhis.api.controller.AbstractCrudController; import org.hisp.dhis.api.utils.ContextUtils; -import org.hisp.dhis.api.utils.ContextUtils.CacheStrategy; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dxf2.utils.JacksonUtils; import org.hisp.dhis.indicator.IndicatorService; -import org.hisp.dhis.mapgeneration.MapGenerationService; import org.hisp.dhis.mapping.Map; import org.hisp.dhis.mapping.MapView; import org.hisp.dhis.mapping.MappingService; -import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.PeriodService; @@ -56,11 +51,9 @@ import org.springframework.http.HttpStatus; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; /** @@ -94,13 +87,7 @@ @Autowired private PeriodService periodService; - - @Autowired - private MapGenerationService mapGenerationService; - - @Autowired - private ContextUtils contextUtils; - + //-------------------------------------------------------------------------- // CRUD //-------------------------------------------------------------------------- @@ -189,58 +176,9 @@ } //-------------------------------------------------------------------------- - // Data - //-------------------------------------------------------------------------- - - @RequestMapping( value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET ) - public void getMap( @PathVariable String uid, HttpServletResponse response ) throws Exception - { - MapView mapView = mappingService.getMapView( uid ); - - renderMapViewPng( mapView, response ); - } - - @RequestMapping( value = { "/data", "/data.png" }, method = RequestMethod.GET ) - public void getMap( Model model, - @RequestParam( value = "in" ) String indicatorUid, - @RequestParam( value = "ou" ) String organisationUnitUid, - @RequestParam( value = "level", required = false ) Integer level, - HttpServletResponse response ) throws Exception - { - if ( level == null ) - { - OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitUid ); - - level = organisationUnitService.getLevelOfOrganisationUnit( unit.getId() ); - level++; - } - - MapView mapView = mappingService.getIndicatorLastYearMapView( indicatorUid, organisationUnitUid, level ); - - renderMapViewPng( mapView, response ); - } - - //-------------------------------------------------------------------------- // Supportive methods //-------------------------------------------------------------------------- - private void renderMapViewPng( MapView mapView, HttpServletResponse response ) - throws Exception - { - BufferedImage image = mapGenerationService.generateMapImage( mapView ); - - if ( image != null ) - { - contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, "mapview.png", false ); - - ImageIO.write( image, "PNG", response.getOutputStream() ); - } - else - { - response.setStatus( HttpServletResponse.SC_NO_CONTENT ); - } - } - // TODO use the import service instead private void mergeMap( Map map ) === added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapViewController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapViewController.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapViewController.java 2012-10-25 17:18:52 +0000 @@ -0,0 +1,121 @@ +package org.hisp.dhis.api.controller.mapping; + +/* + * Copyright (c) 2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.awt.image.BufferedImage; + +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletResponse; + +import org.hisp.dhis.api.controller.AbstractCrudController; +import org.hisp.dhis.api.utils.ContextUtils; +import org.hisp.dhis.api.utils.ContextUtils.CacheStrategy; +import org.hisp.dhis.mapgeneration.MapGenerationService; +import org.hisp.dhis.mapping.MapView; +import org.hisp.dhis.mapping.MappingService; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author Lars Helge Overland + */ +@Controller +@RequestMapping( value = MapViewController.RESOURCE_PATH ) +public class MapViewController + extends AbstractCrudController +{ + public static final String RESOURCE_PATH = "/mapViews"; + + @Autowired + private MappingService mappingService; + + @Autowired + private OrganisationUnitService organisationUnitService; + + @Autowired + private ContextUtils contextUtils; + + @Autowired + private MapGenerationService mapGenerationService; + + @RequestMapping( value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET ) + public void getMap( @PathVariable String uid, HttpServletResponse response ) throws Exception + { + MapView mapView = mappingService.getMapView( uid ); + + renderMapViewPng( mapView, response ); + } + + @RequestMapping( value = { "/data", "/data.png" }, method = RequestMethod.GET ) + public void getMap( Model model, + @RequestParam( value = "in" ) String indicatorUid, + @RequestParam( value = "ou" ) String organisationUnitUid, + @RequestParam( value = "level", required = false ) Integer level, + HttpServletResponse response ) throws Exception + { + if ( level == null ) + { + OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitUid ); + + level = organisationUnitService.getLevelOfOrganisationUnit( unit.getId() ); + level++; + } + + MapView mapView = mappingService.getIndicatorLastYearMapView( indicatorUid, organisationUnitUid, level ); + + renderMapViewPng( mapView, response ); + } + + //-------------------------------------------------------------------------- + // Supportive methods + //-------------------------------------------------------------------------- + + private void renderMapViewPng( MapView mapView, HttpServletResponse response ) + throws Exception + { + BufferedImage image = mapGenerationService.generateMapImage( mapView ); + + if ( image != null ) + { + contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, "mapview.png", false ); + + ImageIO.write( image, "PNG", response.getOutputStream() ); + } + else + { + response.setStatus( HttpServletResponse.SC_NO_CONTENT ); + } + } +} === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl 2012-10-23 13:24:16 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl 2012-10-25 17:18:52 +0000 @@ -12,7 +12,7 @@ -
-

- - - - - - -
Resource Datapng

- - - - - - - - - - - - - - - - - - -
Dynamic Datapng
inindicator uid (req)
ouorganisation unit uid (req)
levelorganisation unit level (opt)

- - - -

Details

+

- - - - - - + + + + + + + + + + + +
- - - - - -
ID
Last Updated
Code
+
- - - - - - - html - - - - - - png - - - - - - xml - - - - - - json - - - - - - jsonp - - - - - === added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/mapView.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/mapView.xsl 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/mapView.xsl 2012-10-25 17:18:52 +0000 @@ -0,0 +1,92 @@ + + + + +
+

+ + + + + + +
Resource Datapng

+ + + + + + + + + + + + + + + + + + +
Dynamic Datapng
inindicator uid (req)
ouorganisation unit uid (req)
levelorganisation unit level (opt)

+ + + +

Details

+ + + + + + + + +
+ + + + + +
+
+
+ + + + + + + + html + + + + + + png + + + + + + xml + + + + + + json + + + + + + jsonp + + + + + +
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl' --- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl 2012-10-17 12:39:02 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl 2012-10-25 17:18:52 +0000 @@ -17,6 +17,7 @@ +