← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2895: Made the Report-ReportTable association many-to-one, ie a report can only have one report table. ...

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 2895 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-02-23 00:05:45 +0100
message:
  Made the Report-ReportTable association many-to-one, ie a report can only have one report table. Existing reports must be updated.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/CombinationGenerator.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/exporter/DefaultDhis14XMLExportService.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/ReportDeletionHandler.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableInternalProcess.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/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/ReportContentProvider.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/report.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetAllReportsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportOptionsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm


--
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/common/CombinationGenerator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/CombinationGenerator.java	2011-02-17 18:48:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/CombinationGenerator.java	2011-02-22 18:28:46 +0000
@@ -56,7 +56,7 @@
      */
     public List<List<T>> getCombinations()
     {
-        List<List<T>> combinations = new ArrayList<List<T>>();
+        final List<List<T>> combinations = new ArrayList<List<T>>();
         
         while ( hasNext() )
         {
@@ -108,13 +108,13 @@
         
         return current;
     }
-            
+    
     /**
      * Returns a List with values from the current index of each List.
      */
     private List<T> getCurrent()
     {
-        List<T> current = new ArrayList<T>( no );
+        final List<T> current = new ArrayList<T>( no );
         
         for ( int i = 0; i < no; i++ )
         {

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java	2011-02-01 11:03:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java	2011-02-22 23:05:45 +0000
@@ -27,9 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.HashSet;
-import java.util.Set;
-
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.reporttable.ReportTable;
 
@@ -44,10 +41,8 @@
     
     private String designContent;
          
-    private Set<ReportTable> reportTables = new HashSet<ReportTable>();
+    private ReportTable reportTable;
     
-    private transient String url;
-
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -56,20 +51,20 @@
     {   
     }
     
-    public Report( String name, String designContent, Set<ReportTable> reportTable )
+    public Report( String name, String designContent, ReportTable reportTable )
     {
         this.name = name;
         this.designContent = designContent;
-        this.reportTables = reportTable;
+        this.reportTable = reportTable;
     }
 
     // -------------------------------------------------------------------------
     // Logic
     // -------------------------------------------------------------------------
 
-    public boolean isHasReportTable()
+    public boolean hasReportTable()
     {
-        return reportTables != null;
+        return reportTable != null;
     }
         
     // -------------------------------------------------------------------------
@@ -125,23 +120,13 @@
         this.designContent = designContent;
     }
 
-    public Set<ReportTable> getReportTables()
-    {
-        return reportTables;
-    }
-
-    public void setReportTables( Set<ReportTable> reportTables )
-    {
-        this.reportTables = reportTables;
-    }
-
-    public String getUrl()
-    {
-        return url;
-    }
-
-    public void setUrl( String url )
-    {
-        this.url = url;
+    public ReportTable getReportTable()
+    {
+        return reportTable;
+    }
+
+    public void setReportTable( ReportTable reportTable )
+    {
+        this.reportTable = reportTable;
     }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2011-01-17 16:20:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2011-02-22 23:05:45 +0000
@@ -53,7 +53,7 @@
      *        report parameter, bot parent organisation unit and organisation unit.
      * @param format the I18nFormat to use.
      */
-    void createReportTables( int id, String mode, Integer reportingPeriod, 
+    void createReportTable( int id, String mode, Integer reportingPeriod, 
         Integer organisationUnitId, boolean doDataMart, I18nFormat format );
     
     /**
@@ -138,6 +138,16 @@
      */
     Grid getReportTableGrid( int id, I18nFormat format, Integer reportingPeriod, Integer organisationUnitId );
     
+    /**
+     * If report table mode, this method will return the report table with the
+     * given identifier. If report mode, this method will return the report
+     * tables associated with the report.
+     * 
+     * @param id the identifier.
+     * @param mode the mode.
+     */
+    ReportTable getReportTable( Integer id, String mode );
+    
     Collection<ReportTable> getReportTablesBetween( int first, int max );
     
     Collection<ReportTable> getReportTablesBetweenByName( String name, int first, int max );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2011-02-18 21:50:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2011-02-22 23:05:45 +0000
@@ -85,6 +85,7 @@
         executeSql( "DROP TABLE dashboardcontent_datamartexports" );
         executeSql( "DROP TABLE customvalue" );
         executeSql( "DROP TABLE reporttable_displaycolumns" );
+        executeSql( "DROP TABLE reportreporttables" );
         executeSql( "ALTER TABLE dataelementcategoryoption drop column categoryid" );
         executeSql( "ALTER TABLE reporttable DROP column dimensiontype" );
         executeSql( "ALTER TABLE categoryoptioncombo DROP COLUMN displayorder" );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/exporter/DefaultDhis14XMLExportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/exporter/DefaultDhis14XMLExportService.java	2011-02-17 10:20:29 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/exporter/DefaultDhis14XMLExportService.java	2011-02-22 23:05:45 +0000
@@ -44,26 +44,32 @@
 import org.hisp.dhis.importexport.ExportParams;
 import org.hisp.dhis.importexport.ExportPipeThread;
 import org.hisp.dhis.importexport.ExportService;
-import org.hisp.dhis.importexport.dhis14.xml.converter.OrganisationUnitConverter;
-import org.hisp.dhis.importexport.dhis14.xml.converter.OrganisationUnitGroupConverter;
-import org.hisp.dhis.importexport.dhis14.xml.converter.OrganisationUnitGroupMemberConverter;
-import org.hisp.dhis.importexport.dhis14.xml.converter.OrganisationUnitHierarchyConverter;
 import org.hisp.dhis.importexport.dhis14.xml.converter.CalculatedDataElementAssociationConverter;
 import org.hisp.dhis.importexport.dhis14.xml.converter.DataElementConverter;
 import org.hisp.dhis.importexport.dhis14.xml.converter.DataTypeConverter;
 import org.hisp.dhis.importexport.dhis14.xml.converter.DataValueConverter;
 import org.hisp.dhis.importexport.dhis14.xml.converter.IndicatorConverter;
 import org.hisp.dhis.importexport.dhis14.xml.converter.IndicatorTypeConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.OrganisationUnitConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.OrganisationUnitHierarchyConverter;
 import org.hisp.dhis.importexport.dhis14.xml.converter.PeriodTypeConverter;
 import org.hisp.dhis.importexport.dhis14.xml.converter.UserConverter;
 import org.hisp.dhis.importexport.dhis14.xml.converter.UserRoleConverter;
-
-import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.*;
-
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.CalculatedDataElementAssociationXSDConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.DataElementXSDConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.DataRootXSDConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.DataTypeXSDConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.IndicatorTypeXSDConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.IndicatorXSDConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.OrganisationUnitHierarchyXSDConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.OrganisationUnitXSDConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.PeriodTypeXSDConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.UserRoleXSDConverter;
+import org.hisp.dhis.importexport.dhis14.xml.converter.xsd.UserXSDConverter;
 import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 
 
 /**
@@ -124,18 +130,21 @@
     {
         this.aggregatedDataValueService = aggregatedDataValueService;
     }
+
     private OrganisationUnitService organisationUnitService;
 
     public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
-        {
-            this.organisationUnitService = organisationUnitService;
-        }
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
     private OrganisationUnitGroupService organisationUnitGroupService;
 
     public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
-        {
-            this.organisationUnitGroupService = organisationUnitGroupService;
-        }
+    {
+        this.organisationUnitGroupService = organisationUnitGroupService;
+    }
+    
     // -------------------------------------------------------------------------
     // ExportService implementation
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java	2011-02-02 17:56:01 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java	2011-02-22 23:05:45 +0000
@@ -1108,8 +1108,7 @@
     // Supportive methods
     // -------------------------------------------------------------------------
 
-    @SuppressWarnings( "unchecked" )
-    private void importGroupMemberAssociation( BatchHandler batchHandler, GroupMemberType type,
+    private void importGroupMemberAssociation( BatchHandler<GroupMemberAssociation> batchHandler, GroupMemberType type,
         Map<Object, Integer> groupMapping, Map<Object, Integer> memberMapping )
     {
         GroupMemberAssociationVerifier.clear();

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/ReportDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/ReportDeletionHandler.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/ReportDeletionHandler.java	2011-02-22 23:05:45 +0000
@@ -58,17 +58,16 @@
     }
     
     @Override
-    public void deleteReportTable( ReportTable reportTable )
+    public boolean allowDeleteReportTable( ReportTable reportTable )
     {
         for ( Report report : reportService.getAllReports() )
         {
-            for ( ReportTable table : report.getReportTables() )
+            if ( report.getReportTable() != null && report.getReportTable().equals( report ) )
             {
-                if ( table.equals( reportTable ) )
-                {
-                    reportService.deleteReport( report );
-                }
+                return false;
             }
         }
+        
+        return true;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableInternalProcess.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableInternalProcess.java	2010-11-29 17:23:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableInternalProcess.java	2011-02-22 23:05:45 +0000
@@ -116,6 +116,6 @@
     @Override
     public void executeStatements()
     {
-        reportTableService.createReportTables( id, mode, reportingPeriod, organisationUnitId, doDataMart, format );
+        reportTableService.createReportTable( id, mode, reportingPeriod, organisationUnitId, doDataMart, format );
     }
 }

=== 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-02-19 00:09:05 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2011-02-22 23:05:45 +0000
@@ -153,15 +153,14 @@
     // -------------------------------------------------------------------------
 
     @Transactional
-    public void createReportTables( int id, String mode, Integer reportingPeriod, 
+    public void createReportTable( int id, String mode, Integer reportingPeriod, 
         Integer organisationUnitId, boolean doDataMart, I18nFormat format )
     {
-        for ( ReportTable reportTable : getReportTables( id, mode ) )
-        {
-            reportTable = initDynamicMetaObjects( reportTable, reportingPeriod, organisationUnitId, format );
+        ReportTable reportTable = getReportTable( id, mode );
+        
+        reportTable = initDynamicMetaObjects( reportTable, reportingPeriod, organisationUnitId, format );
 
-            createReportTable( reportTable, doDataMart );
-        }
+        createReportTable( reportTable, doDataMart );
     }
     
     @Transactional
@@ -263,6 +262,20 @@
 
         return getGrid( reportTable );
     }
+
+    public ReportTable getReportTable( Integer id, String mode )
+    {
+        if ( mode.equals( MODE_REPORT_TABLE ) )
+        {
+            return getReportTable( id );
+        }
+        else if ( mode.equals( MODE_REPORT ) )
+        {
+            return reportService.getReport( id ).getReportTable();
+        }
+        
+        return null;
+    }
     
     // -------------------------------------------------------------------------
     // Persistence
@@ -566,28 +579,4 @@
     {
         return value != null ? String.valueOf( value ) : NULL_REPLACEMENT;
     }
-    
-    /**
-     * If report table mode, this method will return the report table with the
-     * given identifier. If report mode, this method will return the report
-     * tables associated with the report.
-     * 
-     * @param id the identifier.
-     * @param mode the mode.
-     */
-    private Collection<ReportTable> getReportTables( Integer id, String mode )
-    {
-        Collection<ReportTable> reportTables = new ArrayList<ReportTable>();
-
-        if ( mode.equals( MODE_REPORT_TABLE ) )
-        {
-            reportTables.add( getReportTable( id ) );
-        }
-        else if ( mode.equals( MODE_REPORT ) )
-        {
-            reportTables = reportService.getReport( id ).getReportTables();
-        }
-
-        return reportTables;
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml	2011-02-01 11:03:47 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml	2011-02-22 23:05:45 +0000
@@ -16,11 +16,8 @@
 
 	<property name="designContent" type="text"/>
         
-    <set name="reportTables" table="reportreporttables">
-      <key column="reportid"/>
-      <many-to-many column="reporttableid"
-        class="org.hisp.dhis.reporttable.ReportTable"/>
-    </set>
+    <many-to-one name="reportTable" class="org.hisp.dhis.reporttable.ReportTable"
+      column="reporttableid" foreign-key="fk_report_reporttableid"/>
     
   </class>
 </hibernate-mapping>
\ No newline at end of file

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java	2011-02-17 16:39:32 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/report/ReportStoreTest.java	2011-02-22 23:05:45 +0000
@@ -33,8 +33,6 @@
 import static junit.framework.Assert.assertTrue;
 
 import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
 
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.common.GenericStore;
@@ -55,8 +53,6 @@
     private ReportTableService reportTableService;
     
     private ReportTable reportTableA;
-    
-    private Set<ReportTable> reportTables;
 
     // -------------------------------------------------------------------------
     // Fixture
@@ -73,9 +69,6 @@
         reportTableA.setName( "ReportTableA" );
         reportTableA.setTableName( "ReportTableA" );
 
-        reportTables = new HashSet<ReportTable>();
-        reportTables.add( reportTableA );
-        
         reportTableService.saveReportTable( reportTableA );
     }
 
@@ -86,8 +79,8 @@
     @Test
     public void testSaveGet()
     {
-        Report reportA = new Report( "ReportA", "DesignA", reportTables );
-        Report reportB = new Report( "ReportB", "DesignB", reportTables );
+        Report reportA = new Report( "ReportA", "DesignA", reportTableA );
+        Report reportB = new Report( "ReportB", "DesignB", reportTableA );
         
         int idA = reportStore.save( reportA );
         int idB = reportStore.save( reportB );
@@ -99,8 +92,8 @@
     @Test
     public void testSaveGetUpdate()
     {
-        Report reportA = new Report( "ReportA", "DesignA", reportTables );
-        Report reportB = new Report( "ReportB", "DesignB", reportTables );
+        Report reportA = new Report( "ReportA", "DesignA", reportTableA );
+        Report reportB = new Report( "ReportB", "DesignB", reportTableA );
         
         int idA = reportStore.save( reportA );
         int idB = reportStore.save( reportB );
@@ -124,8 +117,8 @@
     @Test
     public void testDelete()
     {
-        Report reportA = new Report( "ReportA", "DesignA", reportTables );
-        Report reportB = new Report( "ReportB", "DesignB", reportTables );
+        Report reportA = new Report( "ReportA", "DesignA", reportTableA );
+        Report reportB = new Report( "ReportB", "DesignB", reportTableA );
         
         int idA = reportStore.save( reportA );
         int idB = reportStore.save( reportB );
@@ -147,8 +140,8 @@
     @Test
     public void testGetAll()
     {
-        Report reportA = new Report( "ReportA", "DesignA", reportTables );
-        Report reportB = new Report( "ReportB", "DesignB", reportTables );
+        Report reportA = new Report( "ReportA", "DesignA", reportTableA );
+        Report reportB = new Report( "ReportB", "DesignB", reportTableA );
         
         reportStore.save( reportA );
         reportStore.save( reportB );

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java	2011-02-19 00:09:05 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java	2011-02-22 18:28:46 +0000
@@ -323,8 +323,6 @@
             throw new IllegalArgumentException( "Column index out of bounds: " + columnIndex );
         }
         
-        System.out.println( "col index: " + columnIndex + " order " + order );
-        
         Collections.sort( grid, new GridRowComparator( columnIndex, order ) );
         
         return this;

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/ReportContentProvider.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/ReportContentProvider.java	2011-02-01 11:09:50 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/ReportContentProvider.java	2011-02-22 23:05:45 +0000
@@ -46,9 +46,6 @@
 public class ReportContentProvider
     implements ContentProvider
 {
-    private static final String JASPER_BASE_URL = "../dhis-web-reporting/getReportParams.action?id=";
-    private static final String JASPER_RENDER_URL = "&mode=report&url=renderReport.action?id=";
-    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -90,11 +87,6 @@
             
             List<Report> reports = dashboardContent.getReports();
             
-            for ( Report report : reports )
-            {
-                report.setUrl( JASPER_BASE_URL + report.getId() + JASPER_RENDER_URL + report.getId() );
-            }
-
             Collections.sort( reports, new ReportComparator() );
             
             content.put( key, reports );

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/report.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/report.vm	2010-09-20 08:49:55 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/report.vm	2011-02-22 23:05:45 +0000
@@ -6,7 +6,7 @@
     #foreach ( $report in $reports )
     <tr>
     	<td>
-    		<a href="$encoder.htmlEncode( $report.url )">$report.name</a>
+    		<a href="../dhis-web-reporting/getReportParams.action?id=${report.id}&mode=report">$encoder.htmlEncode( $report.name )</a>
     	</td>
     	<td style="width:16px">
     		<a href="javascript:window.location.href='removeReport.action?id=$report.id'" title="$i18n.getString( 'remove' )">

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java	2011-02-01 11:03:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java	2011-02-22 23:05:45 +0000
@@ -27,11 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.system.util.ConversionUtils.getIntegerCollection;
-import static org.hisp.dhis.system.util.ConversionUtils.getSet;
-
 import java.io.File;
-import java.util.Collection;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -99,13 +95,13 @@
         this.name = name;
     }
 
-    private Collection<String> selectedReportTables;
-
-    public void setSelectedReportTables( Collection<String> selectedReportTables )
+    private Integer reportTableId;
+    
+    public void setReportTableId( Integer reportTableId )
     {
-        this.selectedReportTables = selectedReportTables;
+        this.reportTableId = reportTableId;
     }
-    
+
     private File file;
 
     public void setUpload( File file )
@@ -172,7 +168,7 @@
             return ERROR;
         }
         
-        if ( fileName == null || fileName.trim().length() == 0 )
+        if ( id == null && ( fileName == null || fileName.trim().length() == 0 ) )
         {
             message = i18n.getString( "select_file" );
             
@@ -186,8 +182,7 @@
         Report report = ( id == null ) ? new Report() : reportService.getReport( id );
         
         report.setName( name );
-        report.setReportTables( selectedReportTables != null ? getSet( 
-            reportTableService.getReportTables( getIntegerCollection( selectedReportTables ) ) ) : null );
+        report.setReportTable( reportTableService.getReportTable( reportTableId ) );
                 
         log.info( "Upload file name: " + fileName + ", content type: " + contentType );
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetAllReportsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetAllReportsAction.java	2011-02-01 11:03:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetAllReportsAction.java	2011-02-22 23:05:45 +0000
@@ -44,9 +44,7 @@
  */
 public class GetAllReportsAction
     extends ActionPagingSupport<Report>
-{
-    private static final String JASPER_BASE_URL = "renderReport.action?id=";
-    
+{    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -87,13 +85,8 @@
 
     public String execute() 
         throws Exception
-    {        
-        for ( Report report : reportService.getAllReports() )
-        {
-            report.setUrl( JASPER_BASE_URL + report.getId() );
-            
-            reports.add( report );
-        }
+    {
+        reports = new ArrayList<Report>( reportService.getAllReports() );
         
         Collections.sort( reports, new ReportComparator() );
         

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportOptionsAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportOptionsAction.java	2011-02-22 23:05:45 +0000
@@ -29,6 +29,7 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import org.hisp.dhis.report.Report;
@@ -46,6 +47,8 @@
 public class GetReportOptionsAction
     implements Action
 {
+    private static final Comparator<ReportTable> COMPARATOR = new ReportTableComparator();
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -93,13 +96,6 @@
         return reportTables;
     }
     
-    private List<ReportTable> selectedReportTables;
-
-    public List<ReportTable> getSelectedReportTables()
-    {
-        return selectedReportTables;
-    }
-    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -108,17 +104,11 @@
     {
         reportTables = new ArrayList<ReportTable>( reportTableService.getAllReportTables() );
         
-        Collections.sort( reportTables, new ReportTableComparator() );
+        Collections.sort( reportTables, COMPARATOR );
         
         if ( id != null )
         {
-            report = reportService.getReport( id );
-            
-            reportTables.removeAll( report.getReportTables() );
-            
-            selectedReportTables = new ArrayList<ReportTable>( report.getReportTables() );
-            
-            Collections.sort( selectedReportTables, new ReportTableComparator() );
+            report = reportService.getReport( id );            
         }
         
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java	2011-02-18 21:50:37 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java	2011-02-22 23:05:45 +0000
@@ -56,8 +56,6 @@
     implements Action
 {
     private static final int AVAILABLE_REPORTING_MONTHS = 24;
-    private static final String MODE_REPORT = "report";
-    private static final String MODE_REPORT_TABLE = "table";
     
     // -------------------------------------------------------------------------
     // Dependencies
@@ -70,13 +68,6 @@
         this.reportTableService = reportTableService;
     }
 
-    private ReportService reportService;
-
-    public void setReportService( ReportService reportService )
-    {
-        this.reportService = reportService;
-    }
-
     private OrganisationUnitService organisationUnitService;
 
     public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
@@ -118,19 +109,7 @@
     {
         this.mode = mode;
     }
-    
-    private String url;
-
-    public String getUrl()
-    {
-        return url;
-    }
-
-    public void setUrl( String url )
-    {
-        this.url = url;
-    }
-    
+        
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -178,82 +157,38 @@
     {
         if ( mode != null && id != null )
         {
-            reportParams = getReportParams( mode, id );
-            
-            if ( reportParams.isParamParentOrganisationUnit() || reportParams.isParamOrganisationUnit() )
-            {
-                levels = organisationUnitService.getOrganisationUnitLevels();
-                
-                organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( 1 );
-            }
-            
-            if ( reportParams.isParamReportingMonth() )
-            {
-                MonthlyPeriodType periodType = new MonthlyPeriodType();
-                
-                Calendar cal = PeriodType.createCalendarInstance();
-                
-                for ( int i = 0; i < AVAILABLE_REPORTING_MONTHS; i++ )
-                {
-                    int month = i + 1;    
-                    cal.add( Calendar.MONTH, -1 );                    
-                    Period period = periodType.createPeriod( cal.getTime() );                    
-                    String periodName = format.formatPeriod( period );
-                    
-                    reportingPeriods.put( month, periodName );
-                }                
+            ReportTable reportTable = reportTableService.getReportTable( id, mode);
+            
+            if ( reportTable != null )
+            {
+                reportParams = reportTable.getReportParams();
+                
+                if ( reportParams.isParamParentOrganisationUnit() || reportParams.isParamOrganisationUnit() )
+                {
+                    levels = organisationUnitService.getOrganisationUnitLevels();
+                    
+                    organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( 1 );
+                }
+                
+                if ( reportParams.isParamReportingMonth() )
+                {
+                    MonthlyPeriodType periodType = new MonthlyPeriodType();
+                    
+                    Calendar cal = PeriodType.createCalendarInstance();
+                    
+                    for ( int i = 0; i < AVAILABLE_REPORTING_MONTHS; i++ )
+                    {
+                        int month = i + 1;    
+                        cal.add( Calendar.MONTH, -1 );                    
+                        Period period = periodType.createPeriod( cal.getTime() );                    
+                        String periodName = format.formatPeriod( period );
+                        
+                        reportingPeriods.put( month, periodName );
+                    }                
+                }
             }
         }
         
         return SUCCESS;
     }
-
-    // -------------------------------------------------------------------------
-    // Supportive methods
-    // -------------------------------------------------------------------------
-
-    /**
-     * This method will assemble a ReportParams object. If in report table mode,
-     * the ReportParams of the report table will be returned. If in report mode,
-     * the value of each report param in the ReportParams object will be true
-     * if any of the report params in the set of report tables in the report are
-     * true.
-     * 
-     * @param mode the mode
-     * @param id the id of the report table or the report
-     * @return a ReportParams object.
-     */
-    private ReportParams getReportParams( String mode, Integer id )
-    {
-        ReportParams params = new ReportParams();
-
-        if ( mode.equals( MODE_REPORT_TABLE ) )
-        {
-            params = reportTableService.getReportTable( id ).getReportParams();
-        }
-        else if ( mode.equals( MODE_REPORT ) )
-        {
-            Report report = reportService.getReport( id );
-            
-            for ( ReportTable reportTable : report.getReportTables() )
-            {                
-                if ( reportTable.getReportParams() != null && reportTable.getReportParams().isParamReportingMonth() )
-                {
-                    params.setParamReportingMonth( true );
-                }
-                
-                if ( reportTable.getReportParams() != null && reportTable.getReportParams().isParamOrganisationUnit() )
-                {
-                    params.setParamOrganisationUnit( true );
-                }
-                
-                if ( reportTable.getReportParams() != null && reportTable.getReportParams().isParamParentOrganisationUnit() )
-                {
-                    params.setParamParentOrganisationUnit( true );
-                }
-            }
-        }
-        
-        return params != null ? params : new ReportParams();
-    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-02-18 20:20:07 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-02-22 23:05:45 +0000
@@ -195,8 +195,6 @@
     scope="prototype">
     <property name="reportTableService"
       ref="org.hisp.dhis.reporttable.ReportTableService"/>
-    <property name="reportService"
-      ref="org.hisp.dhis.report.ReportService"/>
     <property name="organisationUnitService"
       ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
   </bean>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm	2011-02-01 11:03:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm	2011-02-22 23:05:45 +0000
@@ -26,39 +26,19 @@
 		<td colspan="2" height="7px"></td>
 	</tr>
 	<tr>
-		<th colspan="2">$i18n.getString( "available_report_tables" )</th>
+		<th colspan="2">$i18n.getString( "report_table" )</th>
 	</tr>
 	<tr>
 		<td colspan="2">
-			<select multiple size="5" id="availableReportTables" name="availableReportTables" style="min-width:325px" ondblclick="moveSelectedById( 'availableReportTables', 'selectedReportTables' )">
+			<select id="reportTableId" name="reportTableId" style="min-width:325px">
+			<option value="0">[ $i18n.getString( "none" ) ]</option>
 			#foreach( $table in $reportTables )
-				<option value="$table.id">$table.name</option>
+				<option value="$table.id"#if( $!report.reportTable.id == $table.id ) selected="selected"#end>$table.name</option>
 			#end
 			</select>
 		</td>
 	</tr>
 	<tr>
-		<td colspan="2">
-			<input type="button" value="$i18n.getString( 'add' )" title="$i18n.getString( 'add' )" style="width:10em" onclick="moveSelectedById( 'availableReportTables', 'selectedReportTables' )"><input
-                   type="button" value="$i18n.getString( 'remove' )" title="$i18n.getString( 'remove' )" style="width:10em" onclick="moveSelectedById( 'selectedReportTables', 'availableReportTables' )"> 
-		</td>
-	</tr>
-	<tr>
-        <th colspan="2">$i18n.getString( "selected_report_tables" )</th>
-    </tr>
-	<tr>
-        <td colspan="2">
-            <select multiple size="5" id="selectedReportTables" name="selectedReportTables" style="min-width:325px" ondblclick="moveSelectedById( 'selectedReportTables', 'availableReportTables' )">
-            #foreach( $table in $selectedReportTables )
-                <option value="$table.id">$table.name</option>
-            #end
-            </select>
-        </td>
-    </tr>
-    <tr>
-        <td colspan="2" height="7px"></td>
-    </tr>
-	<tr>
 		<td colspan="2"><input type="button" value="$i18n.getString( 'save' )" style="width:10em" onclick="addReport()"><input
 		           type="button" value="$i18n.getString( 'cancel' )" style="width:10em" 
 		           onclick="window.location.href='displayViewReportForm.action'"></td>

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2011-02-18 21:50:37 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2011-02-22 23:05:45 +0000
@@ -3,7 +3,6 @@
 
 <input type="hidden" id="id" name="id" value="$!id">
 <input type="hidden" id="mode" name="mode" value="$!mode">
-<input type="hidden" id="url" name="url" value="$!url">
 
 <table>
 	

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2011-01-21 11:06:16 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js	2011-02-22 23:05:45 +0000
@@ -85,7 +85,7 @@
         
         if ( $( "#mode" ).val() == MODE_REPORT )
         {
-        	window.location.href = $( "#url" ).val();
+        	window.location.href = "renderReport.action?id=" + $( "#id" ).val();
         }
         else if ( $( "#mode" ).val() == MODE_TABLE )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js	2010-12-15 17:52:50 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js	2011-02-22 23:05:45 +0000
@@ -1,8 +1,6 @@
 
 function addReport()
 {
-    selectAllById( "selectedReportTables" );
-    
     document.getElementById( "reportForm" ).submit();
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm	2011-01-25 13:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm	2011-02-22 23:05:45 +0000
@@ -26,8 +26,8 @@
                 <tr id="tr${report.id}">
                     <td>$encoder.htmlEncode( $report.name )</td>
                     <td style="text-align:right">
-                    	#if ( $report.hasReportTable ) <a href="getReportParams.action?id=$report.id&mode=report&url=$report.url" title="$i18n.getString( 'create' )">
-                    	#else <a href="javascript:viewReport( '$encoder.htmlEncode( $report.url )' )" title="$i18n.getString( 'create' )">#end
+                    	#if ( $report.hasReportTable() ) <a href="getReportParams.action?id=${report.id}&mode=report" title="$i18n.getString( 'create' )">
+                    	#else <a href="renderReport.action?id=${report.id}" title="$i18n.getString( 'create' )">#end
                     	<img src="../images/start_process.png" alt="$i18n.getString( 'create' )"></a>                   
 						<a href="displayAddReportForm.action?id=$report.id" title="$i18n.getString( 'edit_report' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit_report' )"></a>
 						<a href="javascript:addToDashboard( '$report.id' )" title="$i18n.getString( 'add_to_dashboard' )"><img src="../images/add_to_dashboard.png" alt="$i18n.getString( 'add_to_dashboard' )"></a>