← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9908: Report table, added collection of data element groups and properties subtotals, displayDensity, f...

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 9908 [merge]
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-02-26 19:51:12 +0100
message:
  Report table, added collection of data element groups and properties subtotals, displayDensity, fontSize
renamed:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListMap.java => dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ListMap.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/concept/Concept.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java
  dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsManagerTest.java
  dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java
  dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ReportTableConverter.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ListMap.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
=== renamed file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListMap.java' => 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ListMap.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ListMap.java	2013-01-14 17:31:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ListMap.java	2013-02-26 18:33:01 +0000
@@ -1,4 +1,4 @@
-package org.hisp.dhis.system.util;
+package org.hisp.dhis.common;
 
 /*
  * Copyright (c) 2004-2012, University of Oslo

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/concept/Concept.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/concept/Concept.java	2013-02-25 12:33:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/concept/Concept.java	2013-02-26 18:33:01 +0000
@@ -27,11 +27,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.DxfNamespaces;
 
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
 /**
  * A Concept Name is a short name which is used as an attribute name
  * when representing a data value in xml which does not use

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2013-02-26 17:45:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2013-02-26 18:51:12 +0000
@@ -46,6 +46,7 @@
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryOption;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.indicator.Indicator;
@@ -222,11 +223,17 @@
     private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
 
     /**
+     * The list of DataElementGroups the ReportTable contains.
+     */
+    private List<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>();
+    
+    /**
      * The list of OrganisationUnitGroups the ReportTable contains.
      */
     @Scanned
     private List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
 
+    
     /**
      * The DataElementCategoryCombo for the ReportTable.
      */
@@ -264,10 +271,43 @@
     private Integer sortOrder;
 
     /**
-     * Inidicates whether the table should be limited from top by this value.
+     * Indicates whether the table should be limited from top by this value.
      */
     private Integer topLimit;
 
+    /**
+     * Indicates rendering of sub-totals for the table.
+     */
+    private boolean subtotals;
+    
+    /**
+     * The display density of the text in the table.
+     */
+    private String displayDensity;
+    
+    /**
+     * The font size of the text in the table.
+     */
+    private String fontSize;
+    
+    /**
+     * Indicates use of the organisation unit of the current user.
+     */
+    private boolean userOrganisationUnit;
+    
+    /**
+     * Indicates use of the organisation unit children of the current user.
+     */
+    private boolean userOrganisationUnitChildren;
+
+    // -------------------------------------------------------------------------
+    // Presentation properties
+    // -------------------------------------------------------------------------
+
+    private Map<String, List<DataElementGroup>> dataElementGroupSets = new HashMap<String, List<DataElementGroup>>();
+    
+    private Map<String, List<OrganisationUnitGroup>> organisationUnitGroupSets = new HashMap<String, List<OrganisationUnitGroup>>();
+    
     // -------------------------------------------------------------------------
     // Transient properties
     // -------------------------------------------------------------------------
@@ -491,7 +531,55 @@
     // -------------------------------------------------------------------------
     // Public methods
     // -------------------------------------------------------------------------
-
+    
+    /**
+     * Populates the presentation properties based on the persisted properties.
+     */
+    public ReportTable populatePresentationProperties()
+    {
+        ListMap<String, DataElementGroup> degs = new ListMap<String, DataElementGroup>();
+        
+        for ( DataElementGroup group : dataElementGroups )
+        {
+            degs.putValue( group.getGroupSet().getUid(), group );
+        }
+        
+        ListMap<String, OrganisationUnitGroup> ougs = new ListMap<String, OrganisationUnitGroup>();
+        
+        for ( OrganisationUnitGroup group : organisationUnitGroups )
+        {
+            ougs.putValue( group.getUid(), group );
+        }
+        
+        dataElementGroupSets.clear();
+        dataElementGroupSets.putAll( degs );        
+        organisationUnitGroupSets.clear();
+        organisationUnitGroupSets.putAll( ougs );
+        
+        return this;
+    }
+    
+    /**
+     * Sets the persisted properties based on the presentation properties.
+     */
+    public ReportTable readPresentationProperties()
+    {
+        dataElementGroups.clear();        
+        organisationUnitGroups.clear();
+        
+        for ( String groupSet : dataElementGroupSets.keySet() )
+        {
+            dataElementGroups.addAll( dataElementGroupSets.get( groupSet ) );
+        }
+        
+        for ( String groupSet : organisationUnitGroupSets.keySet() )
+        {
+            organisationUnitGroups.addAll( organisationUnitGroupSets.get( groupSet ) );
+        }
+        
+        return this;
+    }
+    
     /**
      * Creates a map which contains mappings between the organisation unit
      * identifier and the name of the group this organisation unit is a member
@@ -1063,6 +1151,21 @@
     @JsonProperty
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
     @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlElementWrapper( localName = "dataElementGroups", namespace = DxfNamespaces.DXF_2_0)
+    @JacksonXmlProperty( localName = "dataElementGroup", namespace = DxfNamespaces.DXF_2_0)
+    public List<DataElementGroup> getDataElementGroups()
+    {
+        return dataElementGroups;
+    }
+
+    public void setDataElementGroups( List<DataElementGroup> dataElementGroups )
+    {
+        this.dataElementGroups = dataElementGroups;
+    }
+
+    @JsonProperty
+    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
+    @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0)
     @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0)
     public List<OrganisationUnitGroup> getOrganisationUnitGroups()
@@ -1154,6 +1257,9 @@
         this.reportParams = reportParams;
     }
 
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
     public Integer getSortOrder()
     {
         return sortOrder;
@@ -1177,6 +1283,101 @@
         this.topLimit = topLimit;
     }
 
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public boolean isSubtotals()
+    {
+        return subtotals;
+    }
+
+    public void setSubtotals( boolean subtotals )
+    {
+        this.subtotals = subtotals;
+    }
+
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public String getDisplayDensity()
+    {
+        return displayDensity;
+    }
+
+    public void setDisplayDensity( String displayDensity )
+    {
+        this.displayDensity = displayDensity;
+    }
+
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public String getFontSize()
+    {
+        return fontSize;
+    }
+
+    public void setFontSize( String fontSize )
+    {
+        this.fontSize = fontSize;
+    }
+
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public boolean isUserOrganisationUnit()
+    {
+        return userOrganisationUnit;
+    }
+
+    public void setUserOrganisationUnit( boolean userOrganisationUnit )
+    {
+        this.userOrganisationUnit = userOrganisationUnit;
+    }
+
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public boolean isUserOrganisationUnitChildren()
+    {
+        return userOrganisationUnitChildren;
+    }
+
+    public void setUserOrganisationUnitChildren( boolean userOrganisationUnitChildren )
+    {
+        this.userOrganisationUnitChildren = userOrganisationUnitChildren;
+    }
+
+    // -------------------------------------------------------------------------
+    // Get- and set-methods for presentation properties
+    // -------------------------------------------------------------------------
+
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public Map<String, List<DataElementGroup>> getDataElementGroupSets()
+    {
+        return dataElementGroupSets;
+    }
+
+    public void setDataElementGroupSets( Map<String, List<DataElementGroup>> dataElementGroupSets )
+    {
+        this.dataElementGroupSets = dataElementGroupSets;
+    }
+
+    @JsonProperty
+    @JsonView( {DetailedView.class, ExportView.class} )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
+    public Map<String, List<OrganisationUnitGroup>> getOrganisationUnitGroupSets()
+    {
+        return organisationUnitGroupSets;
+    }
+
+    public void setOrganisationUnitGroupSets( Map<String, List<OrganisationUnitGroup>> organisationUnitGroupSets )
+    {
+        this.organisationUnitGroupSets = organisationUnitGroupSets;
+    }
+
     // -------------------------------------------------------------------------
     // Get- and set-methods for transient properties
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsManager.java	2013-01-18 14:18:49 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsManager.java	2013-02-26 18:33:01 +0000
@@ -31,7 +31,7 @@
 import java.util.concurrent.Future;
 
 import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.system.util.ListMap;
+import org.hisp.dhis.common.ListMap;
 
 public interface AnalyticsManager
 {

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2013-02-25 15:15:07 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2013-02-26 18:33:01 +0000
@@ -48,7 +48,7 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.system.util.CollectionUtils;
-import org.hisp.dhis.system.util.ListMap;
+import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.system.util.ListUtils;
 import org.hisp.dhis.system.util.MapMap;
 import org.hisp.dhis.system.util.MathUtils;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java	2013-02-25 15:15:07 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java	2013-02-26 18:33:01 +0000
@@ -55,7 +55,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.system.util.ListMap;
+import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.system.util.MathUtils;
 import org.hisp.dhis.system.util.PaginatedList;
 import org.springframework.beans.factory.annotation.Autowired;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java	2013-02-25 15:15:07 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java	2013-02-26 18:33:01 +0000
@@ -54,7 +54,7 @@
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.system.util.ListMap;
+import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.system.util.MathUtils;
 import org.hisp.dhis.system.util.SqlHelper;
 import org.hisp.dhis.system.util.TextUtils;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java	2013-01-25 10:33:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java	2013-02-26 18:33:01 +0000
@@ -38,7 +38,7 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.period.YearlyPeriodType;
-import org.hisp.dhis.system.util.ListMap;
+import org.hisp.dhis.common.ListMap;
 
 public class PartitionUtils
 {

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsManagerTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsManagerTest.java	2013-01-27 14:20:01 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsManagerTest.java	2013-02-26 18:33:01 +0000
@@ -41,7 +41,7 @@
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.YearlyPeriodType;
-import org.hisp.dhis.system.util.ListMap;
+import org.hisp.dhis.common.ListMap;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java	2013-02-25 15:15:07 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java	2013-02-26 18:33:01 +0000
@@ -63,7 +63,7 @@
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.period.QuarterlyPeriodType;
 import org.hisp.dhis.period.YearlyPeriodType;
-import org.hisp.dhis.system.util.ListMap;
+import org.hisp.dhis.common.ListMap;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java	2013-01-17 17:49:13 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java	2013-02-26 18:33:01 +0000
@@ -40,7 +40,7 @@
 import org.hisp.dhis.period.Cal;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.YearlyPeriodType;
-import org.hisp.dhis.system.util.ListMap;
+import org.hisp.dhis.common.ListMap;
 import org.junit.Test;
 
 public class PartitionUtilsTest

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ReportTableConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ReportTableConverter.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/ReportTableConverter.java	2013-02-26 18:33:01 +0000
@@ -214,7 +214,7 @@
                 writer.closeElement();
                 
                 writer.openElement( FIELD_ORGANISATION_UNITS );
-                for ( OrganisationUnit unit : reportTable.getUnits() )
+                for ( OrganisationUnit unit : reportTable.getOrganisationUnits() )
                 {
                     writer.writeElement( FIELD_ID, String.valueOf( unit.getId() ) );
                 }
@@ -301,7 +301,7 @@
             while ( reader.moveToStartElement( FIELD_ID, FIELD_ORGANISATION_UNITS ) )
             {
                 int id = Integer.parseInt( reader.getElementValue() );
-                reportTable.getUnits().add( organisationUnitService.getOrganisationUnit( organisationUnitMapping.get( id ) ) );
+                reportTable.getOrganisationUnits().add( organisationUnitService.getOrganisationUnit( organisationUnitMapping.get( id ) ) );
             }
             
             reader.moveToStartElement( FIELD_CATEGORY_COMBO );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2013-02-26 17:45:20 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2013-02-26 18:18:49 +0000
@@ -65,6 +65,14 @@
         foreign-key="fk_reporttable_organisationunits_organisationunitid" />
     </list>
 
+    <list name="dataElementGroups" table="reporttable_dataelementgroups">
+      <cache usage="read-write" />
+      <key column="reporttableid" foreign-key="fk_reporttable_dataelementgroups_reporttableid" />
+      <list-index column="sort_order" base="0" />
+      <many-to-many column="dataelementgroupid" class="org.hisp.dhis.dataelement.DataElementGroup"
+        foreign-key="fk_reporttable_dataelementgroups_dataelementgroupid" />
+    </list>
+
     <list name="organisationUnitGroups" table="reporttable_orgunitgroups">
       <cache usage="read-write" />
       <key column="reporttableid" foreign-key="fk_reporttable_orgunitunitgroups_reporttableid" />
@@ -110,6 +118,12 @@
     <property name="sortOrder" />
 
     <property name="topLimit" />
+    
+    <property name="subtotals" />
+    
+    <property name="displayDensity" />
+    
+    <property name="fontSize" />
 
     <!-- Access properties -->
     <many-to-one name="user" class="org.hisp.dhis.user.User" column="userid" foreign-key="fk_reporttable_userid" />