← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5556: Report table, minor improvement

 

------------------------------------------------------------
revno: 5556
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-12-22 20:41:39 +0100
message:
  Report table, minor improvement
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.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
=== 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	2011-12-22 17:28:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2011-12-22 19:41:39 +0000
@@ -51,7 +51,6 @@
 import org.hisp.dhis.common.Dxf2Namespace;
 import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.common.adapter.CategoryComboXmlAdapter;
-import org.hisp.dhis.common.adapter.CategoryOptionComboXmlAdapter;
 import org.hisp.dhis.common.adapter.DataElementXmlAdapter;
 import org.hisp.dhis.common.adapter.DataSetXmlAdapter;
 import org.hisp.dhis.common.adapter.IndicatorXmlAdapter;
@@ -251,7 +250,7 @@
     /**
      * Static OrganisationUnits and relative OrganisationUnits.
      */
-    private List<OrganisationUnit> allUnits = new ArrayList<OrganisationUnit>();
+    private List<NameableObject> allUnits = new ArrayList<NameableObject>();
 
     /**
      * All Indicatrs, including DateElements, Indicators and DataSets.
@@ -297,10 +296,10 @@
     private String reportingPeriodName;
 
     /**
-     * The name of the (parent) organisation unit based on the report param.
+     * The parent organisation unit.
      */
-    private String organisationUnitName;
-
+    private OrganisationUnit parentOrganisationUnit;
+    
     /**
      * The category option combos derived from the dimension set.
      */
@@ -445,9 +444,9 @@
         {
             Map<Integer, String> map = new HashMap<Integer, String>();
 
-            for ( OrganisationUnit unit : allUnits )
+            for ( NameableObject unit : allUnits )
             {
-                map.put( unit.getId(), unit.getGroupNameInGroupSet( groupSet ) );
+                map.put( unit.getId(), ((OrganisationUnit) unit).getGroupNameInGroupSet( groupSet ) );
             }
 
             organisationUnitGroupMap.put( columnEncode( KEY_ORGUNIT_GROUPSET + groupSet.getName() ), map );
@@ -658,6 +657,14 @@
     {
         return reportParams != null;
     }
+    
+    /**
+     * Returns the name of the parent organisation unit, or an empty string if null.
+     */
+    public String getParentOrganisationUnitName()
+    {
+        return parentOrganisationUnit != null ? parentOrganisationUnit.getName() : EMPTY;
+    }
 
     // -------------------------------------------------------------------------
     // Supportive methods
@@ -850,21 +857,6 @@
         this.dataElements = dataElements;
     }
 
-    @XmlElementWrapper( name = "categoryOptionCombos" )
-    @XmlElement( name = "categoryOptionCombo" )
-    @XmlJavaTypeAdapter( CategoryOptionComboXmlAdapter.class )
-    @JsonProperty
-    @JsonSerialize( contentAs = BaseNameableObject.class )
-    public List<DataElementCategoryOptionCombo> getCategoryOptionCombos()
-    {
-        return categoryOptionCombos;
-    }
-
-    public void setCategoryOptionCombos( List<DataElementCategoryOptionCombo> categoryOptionCombos )
-    {
-        this.categoryOptionCombos = categoryOptionCombos;
-    }
-
     @XmlElementWrapper( name = "indicators" )
     @XmlElement( name = "indicator" )
     @XmlJavaTypeAdapter( IndicatorXmlAdapter.class )
@@ -1047,7 +1039,7 @@
         this.relativeUnits = relativeUnits;
     }
 
-    public List<OrganisationUnit> getAllUnits()
+    public List<NameableObject> getAllUnits()
     {
         return allUnits;
     }
@@ -1072,16 +1064,6 @@
         this.reportingPeriodName = reportingPeriodName;
     }
 
-    public String getOrganisationUnitName()
-    {
-        return organisationUnitName;
-    }
-
-    public void setOrganisationUnitName( String organisationUnitName )
-    {
-        this.organisationUnitName = organisationUnitName;
-    }
-
     public List<List<NameableObject>> getColumns()
     {
         return columns;
@@ -1106,4 +1088,24 @@
     {
         return indexCodeColumns;
     }
+    
+    public OrganisationUnit getParentOrganisationUnit()
+    {
+        return parentOrganisationUnit;
+    }
+
+    public void setParentOrganisationUnit( OrganisationUnit parentOrganisationUnit )
+    {
+        this.parentOrganisationUnit = parentOrganisationUnit;
+    }
+
+    public List<DataElementCategoryOptionCombo> getCategoryOptionCombos()
+    {
+        return categoryOptionCombos;
+    }
+
+    public void setCategoryOptionCombos( List<DataElementCategoryOptionCombo> categoryOptionCombos )
+    {
+        this.categoryOptionCombos = categoryOptionCombos;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-12-22 18:14:45 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-12-22 19:41:39 +0000
@@ -320,7 +320,7 @@
             OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
             reportTable.getRelativeUnits().addAll(
                 new ArrayList<OrganisationUnit>( organisationUnitService.getLeafOrganisationUnits( organisationUnitId ) ) );
-            reportTable.setOrganisationUnitName( organisationUnit.getName() );
+            reportTable.setParentOrganisationUnit( organisationUnit );
 
             log.info( "Leaf parent organisation unit: " + organisationUnit.getName() );
         }
@@ -337,7 +337,7 @@
             reportTable.getRelativeUnits().addAll(
                 new ArrayList<OrganisationUnit>( organisationUnit.getGrandChildren() ) );
             reportTable.getRelativeUnits().add( organisationUnit );
-            reportTable.setOrganisationUnitName( organisationUnit.getName() );
+            reportTable.setParentOrganisationUnit( organisationUnit );
 
             log.info( "Grand parent organisation unit: " + organisationUnit.getName() );
         }
@@ -352,7 +352,7 @@
             organisationUnit.setCurrentParent( true );
             reportTable.getRelativeUnits().addAll( new ArrayList<OrganisationUnit>( organisationUnit.getChildren() ) );
             reportTable.getRelativeUnits().add( organisationUnit );
-            reportTable.setOrganisationUnitName( organisationUnit.getName() );
+            reportTable.setParentOrganisationUnit( organisationUnit );
 
             log.info( "Parent organisation unit: " + organisationUnit.getName() );
         }
@@ -365,7 +365,7 @@
         {
             OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
             reportTable.getRelativeUnits().add( organisationUnit );
-            reportTable.setOrganisationUnitName( organisationUnit.getName() );
+            reportTable.setParentOrganisationUnit( organisationUnit );
 
             log.info( "Organisation unit: " + organisationUnit.getName() );
         }
@@ -388,7 +388,7 @@
      */
     private Grid getGrid( ReportTable reportTable )
     {
-        String subtitle = StringUtils.trimToEmpty( reportTable.getOrganisationUnitName() ) + SPACE
+        String subtitle = StringUtils.trimToEmpty( reportTable.getParentOrganisationUnitName() ) + SPACE
             + StringUtils.trimToEmpty( reportTable.getReportingPeriodName() );
 
         Grid grid = new ListGrid().setTitle( reportTable.getName() ).setSubtitle( subtitle );
@@ -466,7 +466,7 @@
             }
 
             grid.addValue( reportTable.getReportingPeriodName() );
-            grid.addValue( reportTable.getOrganisationUnitName() );
+            grid.addValue( reportTable.getParentOrganisationUnitName() );
             grid.addValue( isCurrentParent( row ) ? YES : NO );
 
             for ( List<NameableObject> column : reportTable.getColumns() ) // Values