dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13918
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4574: Web API, moved HTML to velocity templates and reused LinkBuilder for HTML representations
------------------------------------------------------------
revno: 4574
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-09-13 13:10:12 +0200
message:
Web API, moved HTML to velocity templates and reused LinkBuilder for HTML representations
removed:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/Html.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityProcessor.java
added:
dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataSet.vm
dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataSets.vm
dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataValueSets.vm
dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/orgUnits.vm
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java
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/DataValueSetsResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityManager.java
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/dhis-web-api/index.vm
--
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/web/api/resources/ApiResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java 2011-09-12 14:39:31 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java 2011-09-13 11:10:12 +0000
@@ -1,7 +1,6 @@
package org.hisp.dhis.web.api.resources;
import java.io.IOException;
-import java.io.StringWriter;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -11,6 +10,7 @@
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
+import org.springframework.beans.factory.annotation.Required;
import com.sun.jersey.api.view.ImplicitProduces;
@@ -20,20 +20,17 @@
{
private VelocityManager velocityManager;
- public void setVelocityManager( VelocityManager velocityManager )
- {
- this.velocityManager = velocityManager;
- }
-
@GET
@Produces( MediaType.TEXT_HTML )
public String getDescription()
throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, IOException, Exception
{
- StringWriter writer = new StringWriter();
-
- velocityManager.render( null, "index", writer );
-
- return writer.toString();
+ return velocityManager.render( null, "index" );
+ }
+
+ @Required
+ public void setVelocityManager( VelocityManager velocityManager )
+ {
+ this.velocityManager = velocityManager;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java 2011-09-12 08:29:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java 2011-09-13 11:10:12 +0000
@@ -1,7 +1,5 @@
package org.hisp.dhis.web.api.resources;
-import java.util.Set;
-
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -10,13 +8,9 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.importexport.dxf2.service.DataSetMapper;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.web.api.UrlResourceListener;
import org.springframework.beans.factory.annotation.Required;
@@ -25,8 +19,10 @@
{
private DataSetService dataSetService;
+ private VelocityManager velocityManager;
+
@Context
- UriInfo uriInfo;
+ private UriInfo uriInfo;
@GET
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } )
@@ -38,6 +34,7 @@
{
throw new IllegalArgumentException( "No dataset with uuid " + uuid );
}
+
org.hisp.dhis.importexport.dxf2.model.DataSet dxfDataSet = new DataSetMapper().convert( dataSet );
new UrlResourceListener( uriInfo ).beforeMarshal( dxfDataSet );
return dxfDataSet;
@@ -53,49 +50,8 @@
{
throw new IllegalArgumentException( "No dataset with uuid " + uuid );
}
-
- StringBuilder t = Html.head( "Data set " + dataSet.getName() );
- t.append( "<p>See the <a href=\"" + uuid + ".xml\">xml version</a></p>\n" );
- t.append( "<p>Uuid: " ).append( dataSet.getUuid() ).append( "<br>\n" );
- PeriodType periodType = dataSet.getPeriodType();
- t.append( "Period type: " ).append( dataSet.getPeriodType().getName() ).append( " - " )
- .append( periodType.getIsoFormat() );
- t.append( "</p>\n" );
-
- t.append( "<h2>Org units reporting data set</h2>\n<ul>" );
- for ( OrganisationUnit unit : dataSet.getSources() )
- {
- t.append( "<li><b>" ).append( unit.getName() ).append( "</b> - " ).append( unit.getUuid() )
- .append( "</li>" );
- }
- t.append( "</ul>\n" );
-
- t.append( "<h2>Data elements in data set</h2>\n<ul>" );
- for ( DataElement element : dataSet.getDataElements() )
- {
- t.append( "<li><b>" ).append( element.getName() ).append( "</b> (" ).append( element.getType() )
- .append( ") - " ).append( element.getUuid() );
-
- Set<DataElementCategoryOptionCombo> optionCombos = element.getCategoryCombo().getOptionCombos();
- if ( optionCombos.size() > 1 )
- {
- t.append( "<br>CategoryOptionCombos\n<ul>\n" );
- for ( DataElementCategoryOptionCombo optionCombo : optionCombos )
- {
- t.append( "<li><b>" ).append( optionCombo.getName() ).append( "</b> - " )
- .append( optionCombo.getUuid() ).append( "</li>" );
- }
- t.append( "</ul>\n" );
- }
- t.append( "</li>\n" );
- }
- t.append( "</ul>" );
- t.append( "<h2>Xml template</h2>\n" );
-
- Html.xmlTemplate( t, uriInfo );
- t.append( Html.tail() );
-
- return t.toString();
+
+ return velocityManager.render( dataSet, "dataSet" );
}
@Required
@@ -103,4 +59,10 @@
{
this.dataSetService = dataSetService;
}
+
+ @Required
+ public void setVelocityManager( VelocityManager velocityManager )
+ {
+ this.velocityManager = velocityManager;
+ }
}
=== 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-12 08:29:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java 2011-09-13 11:10:12 +0000
@@ -1,7 +1,5 @@
package org.hisp.dhis.web.api.resources;
-import java.net.URI;
-
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@@ -9,7 +7,6 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
-import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.importexport.dxf2.model.DataSetLinks;
import org.hisp.dhis.importexport.dxf2.service.LinkBuilder;
@@ -24,6 +21,8 @@
private DataSetService dataSetService;
+ private VelocityManager velocityManager;
+
@Context
private UriInfo uriInfo;
@@ -40,25 +39,20 @@
@Produces( MediaType.TEXT_HTML )
public String getDataSetList()
{
- StringBuilder t = Html.head( "Data sets available for reporting" );
-
- t.append( "<p>See the <a href=\"dataSets.xml\">xml version</a></p>\n" );
- for ( DataSet dataSet : dataSetService.getAllDataSets() )
- {
- URI uri = uriInfo.getAbsolutePathBuilder().path( "{uuid}" ).build( dataSet.getUuid() );
- t.append( "<li>" ).append( "<a href=\"" ).append( uri ).append( "\">" ).append( dataSet.getName() )
- .append( "</a></li>\n" );
- }
- t.append( "</ul>" );
- Html.xmlTemplate( t, uriInfo );
- t.append( Html.tail() );
-
- return t.toString();
- }
+ DataSetLinks dataSetLinks = new DataSetLinks( linkBuilder.getLinks( dataSetService.getAllDataSets() ) );
+ new UrlResourceListener( uriInfo ).beforeMarshal( dataSetLinks );
+ return velocityManager.render( dataSetLinks.getDataSet(), "dataSets" );
+ }
@Required
public void setDataSetService( DataSetService dataSetService )
{
this.dataSetService = dataSetService;
}
+
+ @Required
+ public void setVelocityManager( VelocityManager velocityManager )
+ {
+ this.velocityManager = velocityManager;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java 2011-09-12 08:29:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java 2011-09-13 11:10:12 +0000
@@ -20,11 +20,18 @@
{
private DataValueSetService dataValueSetService;
- @Context UriInfo uriInfo;
+ private VelocityManager velocityManager;
+
+ @Context
+ private UriInfo uriInfo;
@GET
@Produces( MediaType.TEXT_HTML )
- public String getDescription() {
+ public String getDescription()
+ {
+ URI uri = uriInfo.getBaseUriBuilder().path( DataSetsResource.class ).build( );
+ return velocityManager.render( uri, "dataValueSets" );
+ /*
StringBuilder sb = Html.head( "Data value sets" );
URI uri = uriInfo.getBaseUriBuilder().path( DataSetsResource.class ).build( );
sb.append( "<p>This resource is the place to post data value sets. Take a look at the <a href=\"" );
@@ -33,7 +40,7 @@
sb.append( Html.tail() );
- return sb.toString();
+ return sb.toString();*/
}
@POST
@@ -48,4 +55,10 @@
{
this.dataValueSetService = dataValueSetService;
}
+
+ @Required
+ public void setVelocityManager( VelocityManager velocityManager )
+ {
+ this.velocityManager = velocityManager;
+ }
}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/Html.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/Html.java 2011-09-12 08:29:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/Html.java 1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
-package org.hisp.dhis.web.api.resources;
-
-import java.net.URI;
-
-import javax.ws.rs.core.UriInfo;
-
-public class Html
-{
- public static StringBuilder head( String title )
- {
- StringBuilder sb = new StringBuilder(
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"> \n<html><head><title>DHIS2 Web API" );
-
- if ( title != null )
- {
- sb.append( " - " ).append( title );
- }
-
- sb.append( "</title></head>\n<body>\n<h1>" );
- if ( title == null )
- {
- sb.append( "DHIS2 Web API" );
- }
- else
- {
- sb.append( title );
- }
- sb.append( "</h1>\n" );
-
- return sb;
-
- }
-
- public static String tail()
- {
- return "</body>\n</html>\n";
- }
-
- public static void xmlTemplate( StringBuilder t, UriInfo uriInfo )
- {
-
- t.append( "<p>Post according to the following template" );
- if ( uriInfo != null )
- {
- URI uri = uriInfo.getBaseUriBuilder().path( DataValueSetsResource.class ).build();
- t.append( " to <a href=\"" ).append( uri ).append( "\">" ).append( uri ).append( "</a>" );
- }
- t.append( ":</p>" );
-
- t.append( "<pre>" ).append( "<dataValueSet xmlns=\"http://dhis2.org/schema/dxf/2.0-SNAPSHOT\"\n" );
- t.append( " dataSet=\"dataSet UUID\" \n period=\"periodInIsoFormat\"\n orgUnit=\"unit UUID\">" );
-
- t.append( "\n <dataValue dataElement=\"data element UUID\" categoryOptionCombo=\"UUID, only specify if used\" storedBy=\"string\" value=\"value\"/>" );
- t.append( "\n</dataValueSet>" );
- t.append( "</pre>" );
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java 2011-09-12 08:29:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitResource.java 2011-09-13 11:10:12 +0000
@@ -41,7 +41,6 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.web.api.UrlResourceListener;
-import org.springframework.beans.factory.annotation.Required;
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } )
@Consumes( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON } )
@@ -50,6 +49,11 @@
{
private OrganisationUnitService organisationUnitService;
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
@PathParam( "id" )
private String id;
@@ -71,10 +75,4 @@
new UrlResourceListener( uriInfo ).beforeMarshal( orgUnit );
return orgUnit;
}
-
- @Required
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java 2011-09-12 08:29:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java 2011-09-13 11:10:12 +0000
@@ -10,16 +10,17 @@
import org.hisp.dhis.importexport.dxf2.model.OrgUnitLinks;
import org.hisp.dhis.importexport.dxf2.service.LinkBuilder;
import org.hisp.dhis.importexport.dxf2.service.LinkBuilderImpl;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.web.api.UrlResourceListener;
-import org.springframework.web.util.HtmlUtils;
+import org.springframework.beans.factory.annotation.Required;
@Path( "orgUnits" )
public class OrgUnitsResource
{
private OrganisationUnitService organisationUnitService;
+ private VelocityManager velocityManager;
+
private LinkBuilder linkBuilder = new LinkBuilderImpl();
@Context
@@ -38,24 +39,20 @@
@Produces( MediaType.TEXT_HTML )
public String getOrgUnitsHtml()
{
- StringBuilder sb = Html.head( "Org units" );
-
- sb.append( "<p>See the <a href=\"orgUnits.xml\">xml version</a></p>\n" );
- sb.append( "<ul>" );
-
- for ( OrganisationUnit unit : organisationUnitService.getAllOrganisationUnits() )
- {
- sb.append( "<li><a href=\"orgUnits/" ).append( unit.getId() ).append( "\">" );
- sb.append( HtmlUtils.htmlEscape( unit.getName() ) ).append( "</a></li>" );
- }
-
- sb.append( "</ul></body>\n</html>\n" );
-
- return sb.toString();
+ OrgUnitLinks orgUnitLinks = new OrgUnitLinks( linkBuilder.getLinks( organisationUnitService.getAllOrganisationUnits() ) );
+ new UrlResourceListener( uriInfo ).beforeMarshal( orgUnitLinks );
+ return velocityManager.render( orgUnitLinks.getOrgUnit(), "orgUnits" );
}
+ @Required
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
{
this.organisationUnitService = organisationUnitService;
}
+
+ @Required
+ public void setVelocityManager( VelocityManager velocityManager )
+ {
+ this.velocityManager = velocityManager;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityManager.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityManager.java 2011-09-12 08:29:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityManager.java 2011-09-13 11:10:12 +0000
@@ -1,14 +1,10 @@
package org.hisp.dhis.web.api.resources;
-import java.io.IOException;
-import java.io.Writer;
+import java.io.StringWriter;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
public class VelocityManager
@@ -25,15 +21,28 @@
velocity.init();
}
- public void render(Object o, String template, Writer writer) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, IOException, Exception
+ public String render( Object object, String template )
{
- final VelocityContext context = new VelocityContext();
-
- if ( o != null )
- {
- context.put( "object", o );
- }
-
- velocity.getTemplate( templatePath + template + ".vm").merge( context, writer );
+ try
+ {
+ StringWriter writer = new StringWriter();
+
+ VelocityContext context = new VelocityContext();
+
+ if ( object != null )
+ {
+ context.put( "object", object );
+ }
+
+ velocity.getTemplate( templatePath + template + ".vm" ).merge( context, writer );
+
+ return writer.toString();
+
+ // TODO include encoder in context
+ }
+ catch ( Exception ex )
+ {
+ throw new RuntimeException( "Failed to merge velocity template", ex );
+ }
}
}
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityProcessor.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityProcessor.java 2011-09-12 14:39:31 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityProcessor.java 1970-01-01 00:00:00 +0000
@@ -1,92 +0,0 @@
-package org.hisp.dhis.web.api.resources;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
-
-import com.sun.jersey.api.view.Viewable;
-import com.sun.jersey.spi.template.ViewProcessor;
-
-//@Provider
-//@Singleton
-public class VelocityProcessor
- implements ViewProcessor<Template>
-{
- private static final Log log = LogFactory.getLog( VelocityProcessor.class );
-
- private static final String RESOURCE_LOADER_NAME = "class";
-
- private VelocityEngine velocity = new VelocityEngine();
-
- private String templatePrefix = "dhis-web-api/";
-
- public void init()
- throws Exception
- {
- velocity.setProperty( Velocity.RESOURCE_LOADER, RESOURCE_LOADER_NAME );
- velocity.setProperty( RESOURCE_LOADER_NAME + ".resource.loader.class", ClasspathResourceLoader.class.getName() );
- velocity.init();
- }
-
- public void render( Object o, String template, Writer writer )
- throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, IOException, Exception
- {
- final VelocityContext context = new VelocityContext();
-
- if ( o != null )
- {
- context.put( "object", o );
- }
-
- velocity.getTemplate( templatePrefix + template + ".vm" ).merge( context, writer );
- }
-
- @Override
- public Template resolve( String name )
- {
- String templatePath = templatePrefix + name + ".vm";
-
- if ( !velocity.resourceExists( templatePath ) )
- {
- log.warn( "Template could not be found: " + templatePath );
- return null;
- }
- try
- {
- return velocity.getTemplate( templatePath );
- }
- catch ( Exception e )
- {
- // TODO handle
- return null;
- }
- }
-
- @Override
- public void writeTo( Template t, Viewable viewable, OutputStream out )
- throws IOException
- {
- final VelocityContext context = new VelocityContext();
-
- Object model = viewable.getModel();
-
- if (model != null)
- {
- context.put( "object", model );
- }
-
- t.merge( context, new OutputStreamWriter( out ) );
- }
-}
=== 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-02 10:40:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2011-09-13 11:10:12 +0000
@@ -12,20 +12,24 @@
<bean id="org.hisp.dhis.web.api.resources.DataSetsResource" class="org.hisp.dhis.web.api.resources.DataSetsResource"
scope="prototype">
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="velocityManager" ref="org.hisp.dhis.web.api.resources.VelocityManager" />
</bean>
<bean id="org.hisp.dhis.web.api.resources.DataSetResource" class="org.hisp.dhis.web.api.resources.DataSetResource"
scope="prototype">
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="velocityManager" ref="org.hisp.dhis.web.api.resources.VelocityManager" />
</bean>
<bean id="org.hisp.dhis.web.api.resources.DataValueSetResource" class="org.hisp.dhis.web.api.resources.DataValueSetsResource">
<property name="dataValueSetService" ref="org.hisp.dhis.importexport.dxf2.service.DataValueSetService" />
+ <property name="velocityManager" ref="org.hisp.dhis.web.api.resources.VelocityManager" />
</bean>
<bean id="org.hisp.dhis.web.api.resources.OrgUnitsResource" class="org.hisp.dhis.web.api.resources.OrgUnitsResource"
scope="prototype">
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="velocityManager" ref="org.hisp.dhis.web.api.resources.VelocityManager" />
</bean>
<bean id="org.hisp.dhis.web.api.resources.OrgUnitResource" class="org.hisp.dhis.web.api.resources.OrgUnitResource"
@@ -35,7 +39,7 @@
<bean id="JacksonJaxbJsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" scope="singleton" />
- <!-- ImportDataValue beans -->
+ <!-- ImportDataValue -->
<bean id="org.hisp.dhis.web.api.action.ImportDataValueAction" class="org.hisp.dhis.web.api.action.ImportDataValueAction">
<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
@@ -45,10 +49,7 @@
<property name="dataElementCategoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
</bean>
-<bean id="org.hisp.dhis.web.api.resources.VelocityManager" class="org.hisp.dhis.web.api.resources.VelocityManager" />
-
-<!-- <bean id="org.hisp.dhis.web.api.resources.VelocityProcessor" class="org.hisp.dhis.web.api.resources.VelocityProcessor" -->
-<!-- scope="singleton" init-method="init" /> -->
+ <bean id="org.hisp.dhis.web.api.resources.VelocityManager" class="org.hisp.dhis.web.api.resources.VelocityManager" />
</beans>
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataSet.vm'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataSet.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataSet.vm 2011-09-13 11:10:12 +0000
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<h1>Data sets available for reporting</h1>
+<p>See the <a href="${object.id}">xml version</a></p>
+<p>UUID: ${object.id}</p>
+<p>Period type: ${object.periodType} - ${object.periodType.isoFormat}</p>
+
+<h2>Org units reporting data set</h2>
+
+<ul>
+#foreach( $unit in $object.sources )
+<li>${unit.name} - ${unit.uuid}</li>
+#end
+</ul>
+
+<h2>Data elements in data set</h2>
+
+<ul>
+#foreach( $dataElement in $object.dataElements )
+<li>${dataElement.name} - ${dataElement.type} - ${dataElement.uuid}
+#set( $optionCombos = $dataElement.categoryCombo.optionCombos )
+#if( $optionCombos && $optionCombos.size() > 0 )
+<ul>
+#foreach( $optionCombo in $optionCombos )
+<li>${optionCombo.name} - ${optionCombo.uuid}</li>
+#end
+</ul>
+#end
+</li>
+#end
+</ul>
+</body>
+</html>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataSets.vm'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataSets.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataSets.vm 2011-09-13 11:10:12 +0000
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<h1>Data sets available for reporting</h1>
+<p>See the <a href="dataSets.xml">xml version</a></p>
+<ul>
+#foreach( $link in $object )
+<li><a href="${link.href}">${link.name}</a></li>
+#end
+</ul>
+</body>
+</html>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataValueSets.vm'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataValueSets.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/dataValueSets.vm 2011-09-13 11:10:12 +0000
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+ <p>This resource is the place to post data value sets. Take a look at the
+ <a href="${object}">data sets</a> to see what to post.</p>
+
+ <pre><dataValueSet xmlns="http://dhis2.org/schema/dxf/2.0-SNAPSHOT"
+ dataSet="dataSet UUID"
+ period="periodInIsoFormat"
+ orgUnit="unit UUID">
+ <dataValue dataElement="data element UUID" categoryOptionCombo="UUID, only specify if used" storedBy="string" value="value" />
+ </dataValueSet></pre>
+</body>
+</html>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/index.vm'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/index.vm 2011-09-02 10:40:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/index.vm 2011-09-13 11:10:12 +0000
@@ -1,4 +1,4 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<!DOCTYPE HTML>
<html>
<head>
<title>DHIS2 Web API</title>
@@ -20,7 +20,7 @@
dataSet="dataSet UUID"
period="periodInIsoFormat"
orgUnit="unit UUID">
- <dataValue dataElement="data element UUID" categoryOptionCombo="UUID, only specify if used" storedBy="string" value="value" />
-</dataValueSet></pre>
+ <dataValue dataElement="data element UUID" categoryOptionCombo="UUID, only specify if used" storedBy="string" value="value" />
+ </dataValueSet></pre>
</body>
</html>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/orgUnits.vm'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/orgUnits.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/dhis-web-api/orgUnits.vm 2011-09-13 11:10:12 +0000
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<h1>Organisation units</h1>
+<p>See the <a href="orgUnits.xml">xml version</a></p>
+<ul>
+#foreach( $link in $object )
+<li><a href="${link.href}">${link.name}</a></li>
+#end
+</ul>
+</body>
+</html>
\ No newline at end of file