=== 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> getCombinations() { - List> combinations = new ArrayList>(); + final List> combinations = new ArrayList>(); while ( hasNext() ) { @@ -108,13 +108,13 @@ return current; } - + /** * Returns a List with values from the current index of each List. */ private List getCurrent() { - List current = new ArrayList( no ); + final List current = new ArrayList( 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 reportTables = new HashSet(); + private ReportTable reportTable; - private transient String url; - // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -56,20 +51,20 @@ { } - public Report( String name, String designContent, Set 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 getReportTables() - { - return reportTables; - } - - public void setReportTables( Set 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 getReportTablesBetween( int first, int max ); Collection 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 batchHandler, GroupMemberType type, Map groupMapping, Map 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 getReportTables( Integer id, String mode ) - { - Collection reportTables = new ArrayList(); - - 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 @@ - - - - + \ 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 reportTables; // ------------------------------------------------------------------------- // Fixture @@ -73,9 +69,6 @@ reportTableA.setName( "ReportTableA" ); reportTableA.setTableName( "ReportTableA" ); - reportTables = new HashSet(); - 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 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 ) - $report.name + $encoder.htmlEncode( $report.name ) === 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 selectedReportTables; - - public void setSelectedReportTables( Collection 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 -{ - 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( 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 COMPARATOR = new ReportTableComparator(); + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -93,13 +96,6 @@ return reportTables; } - private List selectedReportTables; - - public List getSelectedReportTables() - { - return selectedReportTables; - } - // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -108,17 +104,11 @@ { reportTables = new ArrayList( 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( 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"> - === 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 @@ - $i18n.getString( "available_report_tables" ) + $i18n.getString( "report_table" ) - + #foreach( $table in $reportTables ) - + #end - - - - - - $i18n.getString( "selected_report_tables" ) - - - - - - - - - - === 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 @@ - === 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 @@
$encoder.htmlEncode( $report.name ) - #if ( $report.hasReportTable ) - #else #end + #if ( $report.hasReportTable() ) + #else #end $i18n.getString( 'create' ) $i18n.getString( 'edit_report' ) $i18n.getString( 'add_to_dashboard' )