← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11044: Report table, setting proper title

 

------------------------------------------------------------
revno: 11044
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-05-28 12:45:55 +0200
message:
  Report table, setting proper title
modified:
  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/DataQueryParams.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.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	2013-05-27 17:07:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2013-05-28 10:45:55 +0000
@@ -27,10 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.common.DimensionalObject.CATEGORYOPTIONCOMBO_DIM_ID;
 import static org.hisp.dhis.common.DimensionalObject.DATA_X_DIM_ID;
 import static org.hisp.dhis.common.DimensionalObject.ORGUNIT_DIM_ID;
 import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID;
-import static org.hisp.dhis.common.DimensionalObject.CATEGORYOPTIONCOMBO_DIM_ID;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -47,6 +47,7 @@
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
 import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.IdentifiableObjectUtils;
 import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.DimensionalView;
@@ -257,22 +258,27 @@
     /**
      * All crosstabulated columns.
      */
-    private List<List<NameableObject>> gridColumns = new ArrayList<List<NameableObject>>();
+    private transient List<List<NameableObject>> gridColumns = new ArrayList<List<NameableObject>>();
 
     /**
      * All rows.
      */
-    private List<List<NameableObject>> gridRows = new ArrayList<List<NameableObject>>();
+    private transient List<List<NameableObject>> gridRows = new ArrayList<List<NameableObject>>();
 
     /**
      * The name of the reporting month based on the report param.
      */
-    private String reportingPeriodName;
+    private transient String reportingPeriodName;
 
     /**
      * The parent organisation unit.
      */
-    private OrganisationUnit parentOrganisationUnit;
+    private transient OrganisationUnit parentOrganisationUnit;
+    
+    /**
+     * The title of the report table grid.
+     */
+    private transient String title;
 
     // -------------------------------------------------------------------------
     // Constructors
@@ -399,6 +405,7 @@
     {
         List<NameableObject[]> tableColumns = new ArrayList<NameableObject[]>();
         List<NameableObject[]> tableRows = new ArrayList<NameableObject[]>();
+        List<NameableObject> filterItems = new ArrayList<NameableObject>();
         
         for ( String dimension : columnDimensions )
         {
@@ -409,12 +416,19 @@
         {
             tableRows.add( getDimensionalObject( dimension, date, user, true, format ).getItems().toArray( IRT ) );
         }
-                
+        
+        for ( String filter : filterDimensions )
+        {
+            filterItems.addAll( getDimensionalObject( filter, date, user, true, format ).getItems() );
+        }
+
         gridColumns = new CombinationGenerator<NameableObject>( tableColumns.toArray( IRT2D ) ).getCombinations();
         gridRows = new CombinationGenerator<NameableObject>( tableRows.toArray( IRT2D ) ).getCombinations();
 
         addIfEmpty( gridColumns ); 
         addIfEmpty( gridRows );
+        
+        title = IdentifiableObjectUtils.join( filterItems );
     }
     
     @Override
@@ -610,14 +624,23 @@
      */
     public Grid getGrid( Grid grid, Map<String, Double> valueMap, boolean paramColumns )
     {
-        final String subtitle = StringUtils.trimToEmpty( getParentOrganisationUnitName() ) + SPACE
-            + StringUtils.trimToEmpty( reportingPeriodName );
-
         valueMap = new HashMap<String, Double>( valueMap );
         
         sortKeys( valueMap );
-        
-        grid.setTitle( name + " - " + subtitle );
+
+        // ---------------------------------------------------------------------
+        // Title
+        // ---------------------------------------------------------------------
+
+        if ( name != null )
+        {        
+            grid.setTitle( name );
+            grid.setSubtitle( title );
+        }
+        else
+        {
+            grid.setTitle( title );
+        }
 
         // ---------------------------------------------------------------------
         // Headers
@@ -1011,6 +1034,17 @@
         this.parentOrganisationUnit = parentOrganisationUnit;
     }
 
+    @JsonIgnore
+    public String getTitle()
+    {
+        return title;
+    }
+
+    public void setTitle( String title )
+    {
+        this.title = title;
+    }
+
     @Override
     public void mergeWith( IdentifiableObject other )
     {

=== 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-05-28 09:19:19 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2013-05-28 10:45:55 +0000
@@ -699,6 +699,24 @@
         
         return this;
     }
+
+    /**
+     * Get all filter items.
+     */
+    public List<NameableObject> getFilterItems()
+    {
+        List<NameableObject> filterItems = new ArrayList<NameableObject>();
+        
+        for ( DimensionalObject filter : filters )
+        {
+            if ( filter != null && filter.getItems() != null )
+            {
+                filterItems.addAll( filter.getItems() );
+            }
+        }
+        
+        return filterItems;
+    }
     
     // -------------------------------------------------------------------------
     // Static methods

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-05-28 07:52:46 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-05-28 10:45:55 +0000
@@ -86,6 +86,7 @@
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
 import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.IdentifiableObjectUtils;
 import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.constant.ConstantService;
 import org.hisp.dhis.dataelement.DataElement;
@@ -419,6 +420,8 @@
 
         addIfEmpty( reportTable.getGridColumns() ); 
         addIfEmpty( reportTable.getGridRows() );
+        
+        reportTable.setTitle( IdentifiableObjectUtils.join( params.getFilterItems() ) );
 
         return reportTable.getGrid( new ListGrid(), valueMap, false );
     }

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java	2012-11-07 12:31:41 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java	2013-05-28 10:45:55 +0000
@@ -102,16 +102,13 @@
     private static final NodeFilter HTML_ROW_FILTER = new OrFilter( new TagNameFilter( "td" ), new TagNameFilter( "th" ) );    
     
     private static final WritableCellFormat XLS_FORMAT_TTTLE = new WritableCellFormat( new WritableFont(
-        WritableFont.TAHOMA, 13, WritableFont.NO_BOLD, false ) );
+        WritableFont.ARIAL, 10, WritableFont.BOLD, false ) );
 
-    private static final WritableCellFormat XLS_FORMAT_SUBTITLE = new WritableCellFormat( new WritableFont(
-        WritableFont.TAHOMA, 12, WritableFont.NO_BOLD, false ) );
-    
     private static final WritableCellFormat XLS_FORMAT_LABEL = new WritableCellFormat( new WritableFont(
-        WritableFont.ARIAL, 11, WritableFont.NO_BOLD, true ) );
+        WritableFont.ARIAL, 10, WritableFont.NO_BOLD, true ) );
     
     private static final WritableCellFormat XLS_FORMAT_TEXT = new WritableCellFormat( new WritableFont( WritableFont.ARIAL,
-        11, WritableFont.NO_BOLD, false ) );
+        10, WritableFont.NO_BOLD, false ) );
 
     private static final Encoder ENCODER = new Encoder();
     
@@ -273,15 +270,17 @@
 
         int columnIndex = 0;
 
-        sheet.addCell( new Label( 0, rowNumber++, grid.getTitle(), XLS_FORMAT_TTTLE ) );
-
-        rowNumber++;
-
-        String subTitle = StringUtils.isNotEmpty( grid.getSubtitle() ) ? 
-            ( grid.getSubtitle() + "  (" + getGeneratedString() + ")" ) : grid.getSubtitle();
+        if ( StringUtils.isNotEmpty( grid.getTitle() ) )
+        {
+            sheet.addCell( new Label( 0, rowNumber++, grid.getTitle(), XLS_FORMAT_TTTLE ) );
+            rowNumber++;
+        }
         
-        sheet.addCell( new Label( 0, rowNumber++, subTitle, XLS_FORMAT_SUBTITLE ) );
-        rowNumber++;
+        if ( StringUtils.isNotEmpty( grid.getSubtitle() ) )
+        {
+            sheet.addCell( new Label( 0, rowNumber++, grid.getSubtitle(), XLS_FORMAT_TTTLE ) );
+            rowNumber++;
+        }
         
         for ( GridHeader header : grid.getVisibleHeaders() )
         {