← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5437: Cleanup

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 5437 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-12-15 16:58:53 +0100
message:
  Cleanup
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java	2011-12-15 10:32:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java	2011-12-15 15:58:31 +0000
@@ -27,34 +27,33 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.aggregation.AggregatedDataValueService;
-import org.hisp.dhis.aggregation.AggregationService;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.hisp.dhis.api.utils.IdentifiableObjectParams;
 import org.hisp.dhis.api.utils.WebLinkPopulator;
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.chart.ChartService;
 import org.hisp.dhis.chart.Charts;
-import org.hisp.dhis.completeness.DataSetCompletenessService;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.i18n.I18nManagerException;
-import org.hisp.dhis.options.SystemSettingManager;
-import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.util.ContextUtils;
 import org.jfree.chart.ChartUtilities;
 import org.jfree.chart.JFreeChart;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.HttpRequestMethodNotSupportedException;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
+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;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -69,25 +68,6 @@
     private ChartService chartService;
 
     @Autowired
-    private AggregatedDataValueService aggregatedDataValueService;
-
-    @Autowired
-    private AggregationService aggregationService;
-
-    @Autowired
-    private DataValueService dataValueService;
-
-    @Autowired
-    private PeriodService periodService;
-
-    @Autowired
-    @Qualifier( "registrationDataCompletenessService" )
-    private DataSetCompletenessService dataSetCompletenessService;
-
-    @Autowired
-    private SystemSettingManager systemSettingManager;
-
-    @Autowired
     private I18nManager i18nManager;
 
     //-------------------------------------------------------------------------------------------------------
@@ -127,13 +107,7 @@
         return "chart";
     }
 
-    @RequestMapping( value = "/{uid}/data", method = RequestMethod.GET )
-    public void getChartData( @PathVariable( "uid" ) String uid, HttpServletResponse response ) throws IOException, I18nManagerException
-    {
-        Chart chart = chartService.getChart( uid );
-    }
-
-    @RequestMapping( value = "/{uid}/data.png", method = RequestMethod.GET )
+    @RequestMapping( value = {"/{uid}/data","/{uid}/data.png"}, method = RequestMethod.GET )
     public void getChartPng( @PathVariable( "uid" ) String uid,
                              @RequestParam( value = "width", defaultValue = "700", required = false ) int width,
                              @RequestParam( value = "height", defaultValue = "500", required = false ) int height,
@@ -141,7 +115,7 @@
     {
         JFreeChart chart = chartService.getJFreeChart( uid, i18nManager.getI18nFormat() );
 
-        response.setContentType( "image/png" );
+        response.setContentType( ContextUtils.CONTENT_TYPE_PNG );
         ChartUtilities.writeChartAsPNG( response.getOutputStream(), chart, width, height );
     }
 
@@ -153,7 +127,7 @@
     {
         JFreeChart chart = chartService.getJFreeChart( uid, i18nManager.getI18nFormat() );
 
-        response.setContentType( "image/jpg" );
+        response.setContentType( ContextUtils.CONTENT_TYPE_JPG );
         ChartUtilities.writeChartAsJPEG( response.getOutputStream(), chart, width, height );
     }
 

=== 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-12 11:37:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MapController.java	2011-12-15 15:58:31 +0000
@@ -36,7 +36,6 @@
 
 import org.hisp.dhis.api.utils.IdentifiableObjectParams;
 import org.hisp.dhis.api.utils.WebLinkPopulator;
-import org.hisp.dhis.mapgeneration.MapGenerationService;
 import org.hisp.dhis.mapping.MapView;
 import org.hisp.dhis.mapping.MappingService;
 import org.hisp.dhis.mapping.Maps;
@@ -55,10 +54,7 @@
 public class MapController
 {
     @Autowired
-    MapGenerationService mapGenerationService;
-
-    @Autowired
-    MappingService mappingService;
+    private MappingService mappingService;
 
     //-------------------------------------------------------------------------------------------------------
     // GET
@@ -85,10 +81,6 @@
     public String getMap( @PathVariable String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
     {
         MapView mapView = mappingService.getMapView( uid );
-
-        if (mapView == null) {
-            throw new IllegalArgumentException("No map with id " + uid);
-        }
         
         if ( params.hasLinks() )
         {
@@ -101,7 +93,6 @@
         return "map";
     }
 
-
     //-------------------------------------------------------------------------------------------------------
     // POST
     //-------------------------------------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java	2011-12-14 13:18:25 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java	2011-12-15 15:52:19 +0000
@@ -54,6 +54,7 @@
     public static final String CONTENT_TYPE_XML = "application/xml";
     public static final String CONTENT_TYPE_CSV = "application/csv";
     public static final String CONTENT_TYPE_PNG = "image/png";
+    public static final String CONTENT_TYPE_JPG = "image/jpg";
     public static final String CONTENT_TYPE_EXCEL = "application/vnd.ms-excel";
     public static final String CONTENT_TYPE_JAVASCRIPT = "application/javascript";