← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 298: Work in progress on advanced report table display features

 

------------------------------------------------------------
revno: 298
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Mon 2009-05-18 23:42:15 +0200
message:
  Work in progress on advanced report table display features
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
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/DisplayReportTableStatement.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java

=== 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	2009-05-18 20:27:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2009-05-18 21:42:15 +0000
@@ -444,7 +444,7 @@
     // Public methods
     // -------------------------------------------------------------------------
 
-    public List<ReportTableColumn> getFilledReportTableColumns()
+    public List<ReportTableColumn> getFilledDisplayColumns()
     {
         List<String> columns = getAllColumns();
         
@@ -457,8 +457,8 @@
                 ReportTableColumn displayColumn = new ReportTableColumn();
                 
                 displayColumn.setName( column );
-                displayColumn.setHeader( column );
-                displayColumn.setHidden( true );
+                displayColumn.setHeader( prettyPrintColumn( column ) );
+                displayColumn.setHidden( false );
                 
                 displayColumns.add( displayColumn );
             }
@@ -499,6 +499,12 @@
         return false;
     }
     
+    public String prettyPrintColumn( String column )
+    {
+        column = column.replaceAll( "_", " " );
+        return column.substring( 0, 1 ).toUpperCase() + column.substring( 1, column.length() );
+    }
+    
     public boolean isRegression()
     {
         return regression != null && regression;

=== 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	2009-05-18 20:27:17 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2009-05-18 21:42:15 +0000
@@ -286,9 +286,9 @@
         
         reportTable.init();
         
-        return reportTableManager.getReportTableData( reportTable );
+        return reportTableManager.getDisplayReportTableData( reportTable );
     }
-    
+        
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2009-05-18 20:04:49 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2009-05-18 21:42:15 +0000
@@ -207,21 +207,24 @@
 
         try
         {
-            ResultSet resultSet = holder.getStatement().executeQuery( statement.getStatement() );
-            
             log.debug( "Get display report table data statement: " + statement.getStatement() );
             
+            ResultSet resultSet = holder.getStatement().executeQuery( statement.getStatement() );
+            
             // -----------------------------------------------------------------
             // Set columns
             // -----------------------------------------------------------------
 
             int index = 1;
             
-            for ( ReportTableColumn column : reportTable.getDisplayColumns() )
+            for ( ReportTableColumn column : reportTable.getFilledDisplayColumns() )
             {
-                data.getColumns().put( index++, column.getName() );
+                if ( !column.isHidden() )
+                {
+                    data.getColumns().put( index++, column.getName() );
                 
-                data.getPrettyPrintColumns().add( column.getHeader() );                        
+                    data.getPrettyPrintColumns().add( column.getHeader() );
+                }
             }
 
             // -----------------------------------------------------------------
@@ -234,9 +237,12 @@
                 
                 index = 1;
                 
-                for ( ReportTableColumn column : reportTable.getDisplayColumns() )
+                for ( ReportTableColumn column : reportTable.getFilledDisplayColumns() )
                 {
-                    row.put( index++, String.valueOf( resultSet.getObject( column.getName() ) ) );
+                    if ( !column.isHidden() )
+                    {
+                        row.put( index++, String.valueOf( resultSet.getObject( column.getName() ) ) );
+                    }
                 }
                 
                 data.getRows().add( row );
@@ -272,10 +278,10 @@
 
         try
         {
-            ResultSet resultSet = holder.getStatement().executeQuery( statement.getStatement() );
-            
             log.debug( "Get report table data statement: " + statement.getStatement() );
             
+            ResultSet resultSet = holder.getStatement().executeQuery( statement.getStatement() );
+            
             ResultSetMetaData metaData = resultSet.getMetaData();
             
             int columnCount = metaData.getColumnCount();
@@ -290,7 +296,7 @@
                 
                 data.getColumns().put( index, metaData.getColumnName( index ) );
                 
-                data.getPrettyPrintColumns().add( prettyPrintColumn( metaData.getColumnName( index ) ) );                        
+                data.getPrettyPrintColumns().add( reportTable.prettyPrintColumn( metaData.getColumnName( index ) ) );                        
             }
 
             // -----------------------------------------------------------------
@@ -324,14 +330,4 @@
         
         return data;
     }
-
-    // -------------------------------------------------------------------------
-    // Supportive methods
-    // -------------------------------------------------------------------------
-
-    private String prettyPrintColumn( String column )
-    {
-        column = column.replaceAll( "_", " " );
-        return column.substring( 0, 1 ).toUpperCase() + column.substring( 1, column.length() );
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/DisplayReportTableStatement.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/DisplayReportTableStatement.java	2009-05-18 20:04:49 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/statement/DisplayReportTableStatement.java	2009-05-18 21:42:15 +0000
@@ -57,18 +57,17 @@
     {
         StringBuffer buffer = new StringBuffer( "SELECT " );
         
-        Iterator<ReportTableColumn> columns = reportTable.getDisplayColumns().iterator();
+        Iterator<ReportTableColumn> columns = reportTable.getFilledDisplayColumns().iterator();
         
         while ( columns.hasNext() )
         {
             ReportTableColumn column = columns.next();
             
-            if ( !column.isHidden() )
-            {            
-                buffer.append( column.getName() + ( columns.hasNext() ? SEPARATOR : SPACE ) );
-            }
+            buffer.append( column.getName() + ( columns.hasNext() ? SEPARATOR : SPACE ) );
         }
         
         buffer.append( "FROM " + reportTable.getTableName() );
+        
+        statement = buffer.toString();
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java	2009-05-18 20:27:17 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java	2009-05-18 21:42:15 +0000
@@ -45,7 +45,7 @@
         
         reportTable.init();
         
-        columns = reportTable.getFilledReportTableColumns();
+        columns = reportTable.getFilledDisplayColumns();
         
         return SUCCESS;
     }



--
Trunk
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.