← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5704: (webapi) changed dataValueSets description to use xsl instead of velocity

 

------------------------------------------------------------
revno: 5704
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-01-11 14:32:20 +0530
message:
  (webapi) changed dataValueSets description to use xsl instead of velocity
removed:
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSet.vm
added:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/DataValueSets.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java
  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/model2html.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
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java	2012-01-06 09:25:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java	2012-01-11 09:02:20 +0000
@@ -29,19 +29,19 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.api.webdomain.DataValueSets;
 import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
 import org.hisp.dhis.importexport.dxf2.service.DataValueSetService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.system.velocity.VelocityManager;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.io.Writer;
 import java.util.Collection;
 
 @Controller
@@ -59,11 +59,11 @@
     private UserService userService;
 
     @RequestMapping( method = RequestMethod.GET )
-    public void getDataValueSet( Writer writer ) throws Exception
+    public String getDataValueSet( Model model ) throws Exception
     {
-        VelocityManager velocityManager = new VelocityManager();
-        String str = velocityManager.render( "/templates/html/dataValueSet" );
-        writer.write( str );
+        model.addAttribute( "model", new DataValueSets() );
+
+        return "dataValueSets";
     }
 
     @RequestMapping( method = RequestMethod.POST )

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/DataValueSets.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/DataValueSets.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/DataValueSets.java	2012-01-11 09:02:20 +0000
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2004-2012, 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.
+*/
+
+package org.hisp.dhis.api.webdomain;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.adapter.DataElementXmlAdapter;
+import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@XmlRootElement( name = "dataValueSets", namespace = Dxf2Namespace.NAMESPACE )
+@XmlAccessorType( value = XmlAccessType.NONE )
+public class DataValueSets
+{
+    private List<DataValueSet> dataValueSets = new ArrayList<DataValueSet>();
+
+    public List<DataValueSet> getDataValueSets()
+    {
+        return dataValueSets;
+    }
+
+    public void setDataValueSets( List<DataValueSet> dataValueSets )
+    {
+        this.dataValueSets = dataValueSets;
+    }
+}

=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSet.vm'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSet.vm	2012-01-06 09:47:59 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSet.vm	1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
-
-The DataValueSet resource gives you a mean to POST dataValues into DHIS 2.
-
-It needs a phoneNumber as the query string, this will be matched against the phoneNumber for the users
-in the system, and the dataValues will be added to their orgUnit.
-
-The supported format is XML, and the root dataValueSet is declared with the following attributes
-
-dataSet     - The UID of the dataset to report on
-period      - The period to report on
-orgUnit     - The UID of organisation unit to report on
-
-The actual dataValues are sent with a format matching this
-
-<dataValues>
-    <dataValue dataElement="dataElementUid" value="1" />
-    <dataValue dataElement="dataElementUid" value="2" />
-    <dataValue dataElement="dataElementUid" value="3" />
-    <dataValue dataElement="dataElementUid" value="4" />
-    <dataValue dataElement="dataElementUid" value="5" />
-</dataValues>
-
-So, a complete example would be:
-
-<dataValueSet dataSet="dataSetUid" period="2012-01-01" orgUnit="orgUnitUid">
-    <dataValues>
-        <dataValue dataElement="dataElementUid" value="1" />
-        <dataValue dataElement="dataElementUid" value="2" />
-        <dataValue dataElement="dataElementUid" value="3" />
-        <dataValue dataElement="dataElementUid" value="4" />
-        <dataValue dataElement="dataElementUid" value="5" />
-    </dataValues>
-</dataValueSet>

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dataValueSets.xsl	2012-01-11 09:02:20 +0000
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
+                xmlns="http://www.w3.org/1999/xhtml";
+                xmlns:d="http://dhis2.org/schema/dxf/2.0";
+    >
+
+  <xsl:template match="d:dataValueSets">
+
+
+    <pre style="font-size: 0.9em;">
+    <![CDATA[
+The DataValueSet resource gives you a mean to POST dataValues into DHIS 2.
+
+an optional phoneNumber query parameter can be provided and will override the organisation unit identifier of the
+data value set, this will be matched against the phoneNumber for the users in the system, and the dataValues will
+be added to their orgUnit.
+
+The supported format is XML, and the root dataValueSet is declared with the following attributes
+
+dataSet     - The UID of the dataset to report on
+period      - The period to report on
+orgUnit     - The UID of organisation unit to report on
+
+The actual dataValues are sent with a format matching this:
+
+<dataValues>
+    <dataValue dataElement="dataElementUid" value="1" />
+    <dataValue dataElement="dataElementUid" value="2" />
+    <dataValue dataElement="dataElementUid" value="3" />
+    <dataValue dataElement="dataElementUid" value="4" />
+    <dataValue dataElement="dataElementUid" value="5" />
+</dataValues>
+
+So, a complete example would be:
+
+<dataValueSet dataSet="dataSetUid" period="2012-01-01" orgUnit="orgUnitUid">
+    <dataValues>
+        <dataValue dataElement="dataElementUid" value="1" />
+        <dataValue dataElement="dataElementUid" value="2" />
+        <dataValue dataElement="dataElementUid" value="3" />
+        <dataValue dataElement="dataElementUid" value="4" />
+        <dataValue dataElement="dataElementUid" value="5" />
+    </dataValues>
+</dataValueSet>
+    ]]>
+    </pre>
+
+  </xsl:template>
+
+</xsl:stylesheet>

=== 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	2011-12-21 11:37:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl	2012-01-11 09:02:20 +0000
@@ -12,7 +12,8 @@
     d:organisationUnits|d:dataElementGroups|d:dataElementGroupSets|d:dataSets|
     d:documents|d:indicatorGroups|d:indicatorGroupSets|d:organisationUnitGroups|
     d:organisationUnitGroupSets|d:indicatorTypes|d:attributeTypes|d:reports|d:constants|
-    d:sqlViews|d:validationRules|d:validationRuleGroups|d:users|d:userGroups|d:reportTables">
+    d:sqlViews|d:validationRules|d:validationRuleGroups|d:users|d:userGroups|d:reportTables|
+    d:dataValueSets">
 
     <xsl:choose>
       <xsl:when test="@page">

=== 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	2011-12-21 11:37:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl	2012-01-11 09:02:20 +0000
@@ -44,6 +44,7 @@
   <xsl:include href="grid.xsl" />
   <xsl:include href="messageConversations.xsl" />
   <xsl:include href="messageConversation.xsl" />
+  <xsl:include href="dataValueSets.xsl" />
 
   <!-- Config elements -->