=== modified file 'dhis-2/dhis-web/dhis-web-api/pom.xml'
--- dhis-2/dhis-web/dhis-web-api/pom.xml 2011-09-02 10:40:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/pom.xml 2011-09-16 15:59:35 +0000
@@ -72,6 +72,10 @@
org.hisp.dhis
+ dhis-service-reporting
+
+
+ org.hisp.dhis
dhis-support-test
test
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ChartResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ChartResource.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ChartResource.java 2011-09-16 15:59:35 +0000
@@ -0,0 +1,53 @@
+package org.hisp.dhis.web.api.resources;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.StreamingOutput;
+
+import org.hisp.dhis.chart.ChartService;
+import org.hisp.dhis.i18n.I18nManager;
+import org.hisp.dhis.util.ContextUtils;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+
+@Path( "/chart/{id}" )
+public class ChartResource
+{
+ private ChartService chartService;
+
+ public void setChartService( ChartService chartService )
+ {
+ this.chartService = chartService;
+ }
+
+ private I18nManager i18nManager;
+
+ public void setI18nManager( I18nManager manager )
+ {
+ i18nManager = manager;
+ }
+
+ @GET
+ @Produces( ContextUtils.CONTENT_TYPE_PNG )
+ public StreamingOutput getChart( @PathParam("id") Integer id )
+ throws Exception
+ {
+ final JFreeChart chart = chartService.getJFreeChart( id, i18nManager.getI18nFormat() );
+
+ return new StreamingOutput()
+ {
+ @Override
+ public void write( OutputStream out )
+ throws IOException, WebApplicationException
+ {
+ ChartUtilities.writeChartAsPNG( out, chart, 600, 400 );
+ }
+ };
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java 2011-09-16 10:44:02 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java 2011-09-16 15:59:35 +0000
@@ -20,6 +20,7 @@
import org.hisp.dhis.importexport.dxf2.model.DataSetLinks;
import org.hisp.dhis.importexport.dxf2.service.LinkBuilder;
import org.hisp.dhis.importexport.dxf2.service.LinkBuilderImpl;
+import org.hisp.dhis.util.ContextUtils;
import org.hisp.dhis.web.api.UrlResourceListener;
import org.springframework.beans.factory.annotation.Required;
@@ -40,14 +41,14 @@
this.dataSetService = dataSetService;
}
+ private VelocityManager velocityManager;
+
@Required
public void setVelocityManager( VelocityManager velocityManager )
{
this.velocityManager = velocityManager;
}
- private VelocityManager velocityManager;
-
private LinkBuilder linkBuilder = new LinkBuilderImpl();
@Context
@@ -67,7 +68,7 @@
}
@GET
- @Produces( { "application/javascript" } )
+ @Produces( ContextUtils.CONTENT_TYPE_JAVASCRIPT )
public JSONWithPadding getDataSets( @QueryParam( "callback" ) @DefaultValue( "callback" )
String callback )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2011-09-16 13:47:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2011-09-16 16:05:52 +0000
@@ -37,6 +37,14 @@
+
+
+
+
+
+
+
=== 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-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/util/ContextUtils.java 2011-09-16 15:59:35 +0000
@@ -52,6 +52,7 @@
public static final String CONTENT_TYPE_CSV = "application/csv";
public static final String CONTENT_TYPE_PNG = "image/png";
public static final String CONTENT_TYPE_EXCEL = "application/vnd.ms-excel";
+ public static final String CONTENT_TYPE_JAVASCRIPT = "application/javascript";
private static final String SEPARATOR = "/";
private static final String PORT_SEPARATOR = ":";