← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11985: html rendering of dashboard on /api/dashboards, wip

 

------------------------------------------------------------
revno: 11985
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-09-09 14:45:37 +0200
message:
  html rendering of dashboard on /api/dashboards, wip
added:
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dashboard.xsl
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/Dashboard.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.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-api/src/main/java/org/hisp/dhis/dashboard/Dashboard.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/Dashboard.java	2013-08-28 09:35:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/Dashboard.java	2013-09-09 12:45:37 +0000
@@ -159,7 +159,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public int getItemCount()
     {
         return items == null ? 0 : items.size();
@@ -171,8 +171,8 @@
 
     @JsonProperty( value = "items" )
     @JsonView( { DetailedView.class } )
-    @JacksonXmlElementWrapper( localName = "items", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "item", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlElementWrapper( localName = "dashboardItems", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( localName = "dashboardItem", namespace = DxfNamespaces.DXF_2_0)
     public List<DashboardItem> getItems()
     {
         return items;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java	2013-09-09 12:34:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItem.java	2013-09-09 12:45:37 +0000
@@ -28,10 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
@@ -43,21 +44,19 @@
 import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.user.User;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author Lars Helge Overland
  */
-@JacksonXmlRootElement( localName = "dashboardItem", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "dashboardItem", namespace = DxfNamespaces.DXF_2_0 )
 public class DashboardItem
     extends BaseIdentifiableObject
 {
     public static final int MAX_CONTENT = 9;
-    
+
     public static final String TYPE_CHART = "chart";
     public static final String TYPE_MAP = "map";
     public static final String TYPE_REPORT_TABLE = "reportTable";
@@ -66,21 +65,21 @@
     public static final String TYPE_REPORTS = "reports";
     public static final String TYPE_RESOURCES = "resources";
     public static final String TYPE_PATIENT_TABULAR_REPORTS = "patientTabularReports";
-    
+
     private Chart chart;
-    
+
     private Map map;
-    
+
     private ReportTable reportTable;
-    
+
     private List<User> users = new ArrayList<User>();
-    
+
     private List<ReportTable> reportTables = new ArrayList<ReportTable>();
-    
+
     private List<Report> reports = new ArrayList<Report>();
 
     private List<Document> resources = new ArrayList<Document>();
-    
+
     private List<PatientTabularReport> patientTabularReports = new ArrayList<PatientTabularReport>();
 
     // -------------------------------------------------------------------------
@@ -102,7 +101,7 @@
     // -------------------------------------------------------------------------
 
     @JsonProperty
-    @JacksonXmlProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getType()
     {
         if ( chart != null )
@@ -141,7 +140,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public int getContentCount()
     {
         int count = 0;
@@ -154,11 +153,11 @@
         count += resources.size();
         return count;
     }
-    
+
     /**
      * Removes the content with the given uid. Returns true if a content with
      * the given uid existed and was removed.
-     * 
+     *
      * @param uid the identifier of the content.
      * @return true if a content was removed.
      */
@@ -181,11 +180,11 @@
             return removeContent( uid, resources );
         }
     }
-    
+
     private boolean removeContent( String uid, List<? extends IdentifiableObject> content )
     {
         Iterator<? extends IdentifiableObject> iterator = content.iterator();
-        
+
         while ( iterator.hasNext() )
         {
             if ( uid.equals( iterator.next().getUid() ) )
@@ -194,16 +193,17 @@
                 return true;
             }
         }
-        
+
         return false;
     }
-    
+
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------
 
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Chart getChart()
     {
         return chart;
@@ -213,9 +213,10 @@
     {
         this.chart = chart;
     }
-    
+
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public Map getMap()
     {
         return map;
@@ -228,8 +229,8 @@
 
     @JsonProperty( value = "users" )
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JacksonXmlElementWrapper( localName = "users", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "user", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlElementWrapper( localName = "users", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "user", namespace = DxfNamespaces.DXF_2_0 )
     public List<User> getUsers()
     {
         return users;
@@ -242,6 +243,7 @@
 
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public ReportTable getReportTable()
     {
         return reportTable;
@@ -254,8 +256,8 @@
 
     @JsonProperty( value = "reportTables" )
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JacksonXmlElementWrapper( localName = "reportTables", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "reportTableItem", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlElementWrapper( localName = "reportTables", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "reportTableItem", namespace = DxfNamespaces.DXF_2_0 )
     public List<ReportTable> getReportTables()
     {
         return reportTables;
@@ -268,8 +270,8 @@
 
     @JsonProperty( value = "reports" )
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JacksonXmlElementWrapper( localName = "reports", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "report", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlElementWrapper( localName = "reports", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "report", namespace = DxfNamespaces.DXF_2_0 )
     public List<Report> getReports()
     {
         return reports;
@@ -282,8 +284,8 @@
 
     @JsonProperty( value = "resources" )
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JacksonXmlElementWrapper( localName = "resources", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "resource", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlElementWrapper( localName = "resources", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "resource", namespace = DxfNamespaces.DXF_2_0 )
     public List<Document> getResources()
     {
         return resources;
@@ -293,11 +295,11 @@
     {
         this.resources = resources;
     }
-    
+
     @JsonProperty( value = "patientTabularReports" )
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JacksonXmlElementWrapper( localName = "patientTabularReports", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "patientTabularReport", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlElementWrapper( localName = "patientTabularReports", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "patientTabularReport", namespace = DxfNamespaces.DXF_2_0 )
     public List<PatientTabularReport> getPatientTabularReports()
     {
         return patientTabularReports;
@@ -312,7 +314,7 @@
     // Merge with
     // -------------------------------------------------------------------------
 
-  
+
     @Override
     public void mergeWith( IdentifiableObject other )
     {
@@ -321,7 +323,7 @@
         if ( other.getClass().isInstance( this ) )
         {
             DashboardItem item = (DashboardItem) other;
-            
+
             chart = item.getChart() == null ? chart : item.getChart();
             map = item.getMap() == null ? map : item.getMap();
             reportTable = item.getReportTable() == null ? reportTable : item.getReportTable();

=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dashboard.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dashboard.xsl	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/dashboard.xsl	2013-09-09 12:45:37 +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:dashboard">
+    <div class="dashboard">
+      <h2> <xsl:value-of select="@name" /> </h2>
+
+      <table>
+        <tr>
+          <td>ID</td>
+          <td> <xsl:value-of select="@id" /> </td>
+        </tr>
+        <tr>
+          <td>Created</td>
+          <td> <xsl:value-of select="@created" /> </td>
+        </tr>
+        <tr>
+          <td>Last Updated</td>
+          <td> <xsl:value-of select="@lastUpdated" /> </td>
+        </tr>
+        <tr>
+          <td>Item Count</td>
+          <td> <xsl:value-of select="d:itemCount" /> </td>
+        </tr>
+      </table>
+
+      <xsl:apply-templates select="d:dashboardItems|d:user" mode="short" />
+    </div>
+  </xsl:template>
+
+  <xsl:template match="d:dashboardItems" mode="short">
+    <h3>Dashboard Items</h3>
+    <xsl:apply-templates select="d:dashboardItem" mode="short" />
+  </xsl:template>
+
+  <xsl:template match="d:dashboardItem" mode="short">
+    <table>
+      <tr>
+        <td>Type</td>
+        <td><xsl:value-of select="d:type" /></td>
+      </tr>
+    </table>
+
+    <xsl:apply-templates select="d:users|d:documents|d:reportTables|d:reports" mode="short" />
+  </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	2013-05-31 04:06:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/list.xsl	2013-09-09 12:45:37 +0000
@@ -19,7 +19,7 @@
       d:organisationUnitGroupSets|d:indicatorTypes|d:attributeTypes|d:reports|d:constants|
       d:sqlViews|d:validationRules|d:validationRuleGroups|d:users|d:userGroups|d:userAuthorityGroups|
       d:reportTables|d:mapLegends|d:mapLegendSets|d:mapLayers|d:optionSets|d:interpretations|
-      d:sections|d:userRoles|d:organisationUnitLevels|d:programs|d:programStages|d:dimensions">
+      d:sections|d:userRoles|d:organisationUnitLevels|d:programs|d:programStages|d:dimensions|d:dashboards">
 
     <h3>
       <xsl:value-of select="local-name()" />

=== 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	2013-07-05 04:25:13 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl	2013-09-09 12:45:37 +0000
@@ -58,6 +58,7 @@
   <xsl:include href="program.xsl" />
   <xsl:include href="programStage.xsl" />
   <xsl:include href="event.xsl" />
+  <xsl:include href="dashboard.xsl" />
 
   <!-- Config elements -->