dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15249
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5438: Map generation: removed Map wrapper class
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 5438 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-12-15 17:57:22 +0100
message:
Map generation: removed Map wrapper class
removed:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapgeneration/Map.java
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-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/MapController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/MapGenerationView.java
dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/chart.xsl
dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl
--
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
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapgeneration/Map.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapgeneration/Map.java 2011-12-13 09:43:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapgeneration/Map.java 1970-01-01 00:00:00 +0000
@@ -1,102 +0,0 @@
-package org.hisp.dhis.mapgeneration;
-
-/*
- * Copyright (c) 2004-2010, 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.util.ArrayList;
-import java.util.List;
-
-import org.hisp.dhis.mapping.MapView;
-
-/**
- * The Map class represents a single map that may contain several layers.
- *
- * @author Kjetil Andresen <kjetand@xxxxxxxxxx>
- */
-public class Map
-{
- private List<MapView> mapViews;
-
- /**
- * Construct an initially empty map.
- */
- public Map()
- {
- mapViews = new ArrayList<MapView>();
- }
-
- /**
- * Construct a map with a single initial layer.
- *
- * @param mapView the initial layer
- */
- public Map( MapView mapView )
- {
- mapViews = new ArrayList<MapView>();
- mapViews.add( mapView );
- }
-
- /**
- * Construct a map with a given list of predefined layers.
- *
- * @param mapViews the list of layers
- */
- public Map( List<MapView> mapViews )
- {
- this.mapViews = mapViews;
- }
-
- /**
- * Add a layer to this map.
- *
- * @param mapView the layer
- */
- public void addMapView( MapView mapView )
- {
- mapViews.add( mapView );
- }
-
- /**
- * Add a list of layers to this map.
- *
- * @param mapViews the list of layers
- */
- public void addMapViews( List<MapView> mapViews )
- {
- this.mapViews.addAll( mapViews );
- }
-
- /**
- * Gets all the layers currently associated with this map.
- *
- * @return the list of layers
- */
- public List<MapView> getMapViews()
- {
- return mapViews;
- }
-}
=== 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 2011-12-13 09:43:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapgeneration/MapGenerationService.java 2011-12-15 16:57:22 +0000
@@ -29,6 +29,8 @@
import java.awt.image.BufferedImage;
+import org.hisp.dhis.mapping.MapView;
+
/**
* The MapGenerationService interface generates map images from Map objects.
*
@@ -48,8 +50,8 @@
/**
* Generate an image that represents this map.
*
- * @param map the map that will be rendered
+ * @param mapView the map view that will be rendered
* @return the rendered map image
*/
- public BufferedImage generateMapImage( Map map );
+ public BufferedImage generateMapImage( MapView mapView );
}
=== 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 2011-12-06 17:41:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2011-12-15 16:57:22 +0000
@@ -44,29 +44,23 @@
final String GEOJSON_DIR = "geojson";
final String MAP_VALUE_TYPE_INDICATOR = "indicator";
-
final String MAP_VALUE_TYPE_DATAELEMENT = "dataelement";
final String MAP_LEGEND_SYMBOLIZER_COLOR = "color";
-
final String MAP_LEGEND_SYMBOLIZER_IMAGE = "image";
final String MAPLEGENDSET_TYPE_AUTOMATIC = "automatic";
-
final String MAPLEGENDSET_TYPE_PREDEFINED = "predefined";
final String KEY_MAP_DATE_TYPE = "dateType";
final String MAP_DATE_TYPE_FIXED = "fixed";
-
final String MAP_DATE_TYPE_START_END = "start-end";
final String ORGANISATION_UNIT_SELECTION_TYPE_PARENT = "parent";
-
final String ORGANISATION_UNIT_SELECTION_TYPE_LEVEL = "level";
final String MAP_LAYER_TYPE_BASELAYER = "baselayer";
-
final String MAP_LAYER_TYPE_OVERLAY = "overlay";
// -------------------------------------------------------------------------
=== 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 2011-12-13 10:24:33 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java 2011-12-15 16:57:22 +0000
@@ -78,24 +78,22 @@
// MapGenerationService implementation
// -------------------------------------------------------------------------
- public BufferedImage generateMapImage( Map map )
+ public BufferedImage generateMapImage( MapView mapView )
{
- Assert.isTrue( map != null );
- Assert.isTrue( map.getMapViews() != null );
- Assert.isTrue( map.getMapViews().size() > 0 );
+ Assert.isTrue( mapView != null );
int height = 512;
// Build internal map layer representation
- List<InternalMapLayer> mapLayers = buildInternalMapLayers( map.getMapViews() );
+ InternalMapLayer mapLayer = buildSingleInternalMapLayer( mapView );
// Build internal representation of a map using GeoTools, then render it
// to an image
- GeoToolsMap gtMap = new GeoToolsMap( mapLayers );
+ GeoToolsMap gtMap = new GeoToolsMap( mapLayer );
BufferedImage mapImage = gtMap.render( height );
// Build the legend set, then render it to an image
- LegendSet legendSet = new LegendSet( mapLayers );
+ LegendSet legendSet = new LegendSet( mapLayer );
BufferedImage legendImage = legendSet.render( height );
// Combine the legend image and the map image into one image
@@ -122,26 +120,12 @@
private static final int DEFAULT_RADIUS_LOW = 15;
- private List<InternalMapLayer> buildInternalMapLayers( List<MapView> mapViews )
- {
- // Create the list of internal map layers
- List<InternalMapLayer> mapLayers = new LinkedList<InternalMapLayer>();
-
- // Build internal layers for each external layer
- for ( MapView mapView : mapViews )
- {
- mapLayers.add( buildSingleInternalMapLayer( mapView ) );
- }
-
- return mapLayers;
- }
-
private InternalMapLayer buildSingleInternalMapLayer( MapView mapView )
{
Assert.isTrue( mapView != null );
Assert.isTrue( mapView.getMapValueType() != null );
- boolean isIndicator = "indicator".equals( mapView.getMapValueType() );
+ boolean isIndicator = MappingService.MAP_VALUE_TYPE_INDICATOR.equals( mapView.getMapValueType() );
// Get the name from the external layer
String name = mapView.getName();
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java 2011-12-15 15:58:31 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java 2011-12-15 16:24:21 +0000
@@ -50,9 +50,11 @@
import org.springframework.web.bind.annotation.ResponseStatus;
@Controller
-@RequestMapping( value = "/maps" )
+@RequestMapping( value = MapController.RESOURCE_PATH )
public class MapController
{
+ public static final String RESOURCE_PATH = "/maps";
+
@Autowired
private MappingService mappingService;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java 2011-12-15 10:32:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java 2011-12-15 16:24:21 +0000
@@ -111,10 +111,10 @@
return "report";
}
- @RequestMapping( value = {"/{uid}/data", "/{uid}/data.pdf"}, method = RequestMethod.GET )
+ @RequestMapping( value = {"/{uid}/data","/{uid}/data.pdf"}, method = RequestMethod.GET )
public void getReportAsPdf( @PathVariable( "uid" ) String uid,
- @RequestParam( value = "organisationUnit", required = false ) String organisationUnitUid,
- @RequestParam( value = "period", required = false ) String period, HttpServletResponse response )
+ @RequestParam( value = "ou", required = false ) String organisationUnitUid,
+ @RequestParam( value = "pe", required = false ) String period, HttpServletResponse response )
throws Exception
{
getReport( uid, organisationUnitUid, period, response, "pdf", ContextUtils.CONTENT_TYPE_PDF, false );
@@ -122,8 +122,8 @@
@RequestMapping( value = "/{uid}/data.xls", method = RequestMethod.GET )
public void getReportAsXls( @PathVariable( "uid" ) String uid,
- @RequestParam( value = "organisationUnit", required = false ) String organisationUnitUid,
- @RequestParam( value = "period", required = false ) String period, HttpServletResponse response )
+ @RequestParam( value = "ou", required = false ) String organisationUnitUid,
+ @RequestParam( value = "pe", required = false ) String period, HttpServletResponse response )
throws Exception
{
getReport( uid, organisationUnitUid, period, response, "xls", ContextUtils.CONTENT_TYPE_EXCEL, true );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java 2011-12-15 10:32:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java 2011-12-15 16:24:21 +0000
@@ -115,8 +115,8 @@
@RequestMapping( value = "/{uid}/data", method = RequestMethod.GET )
public String getReportTableData( @PathVariable( "uid" ) String uid, Model model,
- @RequestParam( value = "organisationUnit", required = false ) String organisationUnitUid,
- @RequestParam( value = "period", required = false ) String period,
+ @RequestParam( value = "ou", required = false ) String organisationUnitUid,
+ @RequestParam( value = "pe", required = false ) String period,
HttpServletResponse response ) throws Exception
{
ReportTable reportTable = reportTableService.getReportTable( uid );
@@ -137,8 +137,8 @@
@RequestMapping( value = "/{uid}/data.pdf", method = RequestMethod.GET )
public void getReportTablePdf( @PathVariable( "uid" ) String uid,
- @RequestParam( value = "organisationUnit", required = false ) String organisationUnitUid,
- @RequestParam( value = "period", required = false ) String period,
+ @RequestParam( value = "ou", required = false ) String organisationUnitUid,
+ @RequestParam( value = "pe", required = false ) String period,
HttpServletResponse response ) throws Exception
{
ReportTable reportTable = reportTableService.getReportTable( uid );
@@ -160,8 +160,8 @@
@RequestMapping( value = "/{uid}/data.xls", method = RequestMethod.GET )
public void getReportTableXls( @PathVariable( "uid" ) String uid,
- @RequestParam( value = "organisationUnit", required = false ) String organisationUnitUid,
- @RequestParam( value = "period", required = false ) String period,
+ @RequestParam( value = "ou", required = false ) String organisationUnitUid,
+ @RequestParam( value = "pe", required = false ) String period,
HttpServletResponse response ) throws Exception
{
ReportTable reportTable = reportTableService.getReportTable( uid );
@@ -183,8 +183,8 @@
@RequestMapping( value = "/{uid}/data.csv", method = RequestMethod.GET )
public void getReportTableCsv( @PathVariable( "uid" ) String uid,
- @RequestParam( value = "organisationUnit", required = false ) String organisationUnitUid,
- @RequestParam( value = "period", required = false ) String period,
+ @RequestParam( value = "ou", required = false ) String organisationUnitUid,
+ @RequestParam( value = "pe", required = false ) String period,
HttpServletResponse response ) throws Exception
{
ReportTable reportTable = reportTableService.getReportTable( uid );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/MapGenerationView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/MapGenerationView.java 2011-12-06 08:39:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/MapGenerationView.java 2011-12-15 16:57:22 +0000
@@ -43,7 +43,7 @@
extends AbstractView
{
@Autowired
- MapGenerationService mapGenerationService;
+ private MapGenerationService mapGenerationService;
public MapGenerationView()
{
@@ -56,7 +56,7 @@
throws Exception
{
MapView mapView = (MapView) model.get( "model" );
- BufferedImage image = mapGenerationService.generateMapImage( new org.hisp.dhis.mapgeneration.Map( mapView ) );
+ BufferedImage image = mapGenerationService.generateMapImage( mapView );
response.setContentType( MediaType.IMAGE_PNG.toString() );
ImageIO.write( image, "PNG", response.getOutputStream() );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/chart.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/chart.xsl 2011-12-14 10:03:38 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/chart.xsl 2011-12-15 16:24:21 +0000
@@ -7,7 +7,7 @@
<xsl:template match="d:chart">
<div class="chart">
<h2>Chart: <xsl:value-of select="@name"/> </h2>
- <a href="{@link}.png"><img src="{@link}.png" style="border-style:solid; border-width: 1px; padding: 5px;" /></a>
+ <a href="{@link}/data"><img src="{@link}/data" style="border-style:solid; border-width: 1px; padding: 5px;" /></a>
<h3>Details</h3>
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl 2011-12-07 14:04:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl 2011-12-15 16:24:21 +0000
@@ -9,32 +9,8 @@
<td> <a href="{@link}.xml">xml</a> </td>
<td> <a href="{@link}.json">json</a> </td>
<td> <a href="{@link}.jsonp">jsonp</a> </td>
- <td><a href="{@link}.pdf">pdf</a> </td>
+ <td> <a href="{@link}.pdf">pdf</a> </td>
</tr>
</xsl:template>
- <!-- special case - TODO handle this better -->
- <!-- <xsl:template match="d:parent" mode="row">
- <tr>
- <td>
- <xsl:value-of select="@name"/>
- </td>
- <td>
- <a href="{@link}">html</a>
- </td>
- <td>
- <a href="{@link}.xml">xml</a>
- </td>
- <td>
- <a href="{@link}.json">json</a>
- </td>
- <td>
- <a href="{@link}.jsonp">jsonp</a>
- </td>
- <td>
- <a href="{@link}.pdf">pdf</a>
- </td>
- </tr>
- </xsl:template>-->
-
</xsl:stylesheet>