=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java 2012-08-29 16:23:35 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java 2012-09-23 14:24:14 +0000 @@ -323,4 +323,15 @@ * @return a Period. */ PeriodType reloadPeriodType( PeriodType periodType ); + + // ------------------------------------------------------------------------- + // RelativePeriods + // ------------------------------------------------------------------------- + + /** + * Deletes a RelativePeriods instance. + * + * @param relativePeriods the RelativePeriods instance. + */ + void deleteRelativePeriods( RelativePeriods relativePeriods ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodStore.java 2012-04-21 08:25:31 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodStore.java 2012-09-23 14:24:14 +0000 @@ -237,4 +237,15 @@ * @return the Period. */ PeriodType reloadPeriodType( PeriodType periodType ); + + // ------------------------------------------------------------------------- + // RelativePeriods + // ------------------------------------------------------------------------- + + /** + * Deletes a RelativePeriods instance. + * + * @param relativePeriods the RelativePeriods instance. + */ + void deleteRelativePeriods( RelativePeriods relativePeriods ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java 2012-07-31 18:18:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java 2012-09-23 14:24:14 +0000 @@ -149,6 +149,8 @@ private static final int MONTHS_IN_YEAR = 12; + private int id; + private boolean reportingMonth = false; // TODO rename to lastMonth private boolean reportingBimonth = false; // TODO rename to lastBimonth @@ -699,6 +701,16 @@ // Getters & setters // ------------------------------------------------------------------------- + public int getId() + { + return id; + } + + public void setId( int id ) + { + this.id = id; + } + @JsonProperty( value = "lastMonth" ) @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) public boolean isReportingMonth() === 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 2012-04-11 04:56:20 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java 2012-09-23 15:49:44 +0000 @@ -37,11 +37,11 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.ExportView; +import org.hisp.dhis.period.RelativePeriods; import org.hisp.dhis.reporttable.ReportTable; /** * @author Lars Helge Overland - * @version $Id$ */ @JacksonXmlRootElement( localName = "report", namespace = Dxf2Namespace.NAMESPACE ) public class Report @@ -57,6 +57,8 @@ private Boolean usingOrgUnitGroupSets; + private RelativePeriods relatives; + // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -71,11 +73,28 @@ this.designContent = designContent; this.reportTable = reportTable; } + + public Report( String name, String designContent, RelativePeriods relatives ) + { + this.name = name; + this.designContent = designContent; + this.relatives = relatives; + } // ------------------------------------------------------------------------- // Logic // ------------------------------------------------------------------------- + public boolean isReportTableDataSource() + { + return reportTable != null; + } + + public boolean isJdbcDataSource() + { + return reportTable == null; + } + public boolean hasReportTable() { return reportTable != null; @@ -86,6 +105,14 @@ return usingOrgUnitGroupSets != null && usingOrgUnitGroupSets; } + /** + * Indicates whether this report has relative periods. + */ + public boolean hasRelativePeriods() + { + return relatives != null && !relatives.getRelativePeriods().isEmpty(); + } + // ------------------------------------------------------------------------- // Equals and hashCode // ------------------------------------------------------------------------- @@ -169,6 +196,19 @@ this.usingOrgUnitGroupSets = usingOrgUnitGroupSets; } + @JsonProperty( value = "relativePeriods" ) + @JsonView( {DetailedView.class, ExportView.class} ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public RelativePeriods getRelatives() + { + return relatives; + } + + public void setRelatives( RelativePeriods relatives ) + { + this.relatives = relatives; + } + @Override public void mergeWith( IdentifiableObject other ) { === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java 2012-05-31 13:16:24 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java 2012-09-23 15:49:44 +0000 @@ -43,6 +43,9 @@ final String REPORTTYPE_PDF = "pdf"; final String REPORTTYPE_XLS = "xls"; + final String PARAM_RELATIVE_PERIODS = "periods"; + final String PARAM_ORG_UNITS = "org_units"; + void renderReport( OutputStream out, String reportUid, Date reportingPeriod, String organisationUnitUid, String type, I18nFormat format ); === 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 2012-04-20 18:31:48 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2012-09-23 15:49:44 +0000 @@ -746,6 +746,14 @@ return organisationUnitGroups != null && organisationUnitGroups.size() > 0; } + /** + * Indicates whether this report table has relative periods. + */ + public boolean hasRelativePeriods() + { + return relatives != null && !relatives.getRelativePeriods().isEmpty(); + } + public void removeAllDataElements() { dataElements.clear(); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java 2012-08-29 14:39:44 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java 2012-09-23 14:24:14 +0000 @@ -309,4 +309,13 @@ { return periodStore.reloadPeriodType( periodType ); } + + // ------------------------------------------------------------------------- + // PeriodType + // ------------------------------------------------------------------------- + + public void deleteRelativePeriods( RelativePeriods relativePeriods ) + { + periodStore.deleteRelativePeriods( relativePeriods ); + } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/hibernate/HibernatePeriodStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/hibernate/HibernatePeriodStore.java 2012-04-21 08:25:31 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/hibernate/HibernatePeriodStore.java 2012-09-23 14:24:14 +0000 @@ -42,6 +42,7 @@ import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodStore; import org.hisp.dhis.period.PeriodType; +import org.hisp.dhis.period.RelativePeriods; /** * Implements the PeriodStore interface. @@ -315,4 +316,13 @@ return reloadedPeriodType; } + + // ------------------------------------------------------------------------- + // RelativePeriods + // ------------------------------------------------------------------------- + + public void deleteRelativePeriods( RelativePeriods relativePeriods ) + { + sessionFactory.getCurrentSession().delete( relativePeriods ); + } } === added file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/RelativePeriods.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/RelativePeriods.hbm.xml 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/RelativePeriods.hbm.xml 2012-09-23 15:49:44 +0000 @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java 2012-05-31 13:16:24 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java 2012-09-23 15:49:44 +0000 @@ -27,6 +27,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers; +import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString; + import java.io.OutputStream; import java.sql.Connection; import java.util.Collection; @@ -45,6 +48,8 @@ import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.report.Report; import org.hisp.dhis.report.ReportService; import org.hisp.dhis.reporttable.ReportTable; @@ -101,6 +106,13 @@ { this.organisationUnitGroupService = organisationUnitGroupService; } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } // ------------------------------------------------------------------------- // ReportService implementation @@ -134,10 +146,17 @@ print = JasperFillManager.fillReport( jasperReport, params, grid ); } - else // Assume SQL report and provide JDBC connection + else // Use JDBC data source { Connection connection = statementManager.getHolder().getConnection(); + if ( report.hasRelativePeriods() ) + { + Collection periods = periodService.reloadPeriods( report.getRelatives().getRelativePeriods() ); + String periodString = getCommaDelimitedString( getIdentifiers( Period.class, periods ) ); + params.put( PARAM_RELATIVE_PERIODS, periodString ); + } + try { print = JasperFillManager.fillReport( jasperReport, params, connection ); @@ -152,7 +171,7 @@ { JRExportUtils.export( type, out, print ); } - } + } catch ( Exception ex ) { throw new RuntimeException( "Failed to render report", ex ); @@ -166,7 +185,11 @@ public void deleteReport( Report report ) { - reportStore.delete( report ); + if ( report != null ) + { + periodService.deleteRelativePeriods( report.getRelatives() ); + reportStore.delete( report ); + } } public Collection getAllReports() === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-08-31 15:35:59 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-09-23 14:24:14 +0000 @@ -39,6 +39,7 @@ + === 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 2012-05-17 09:11:30 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml 2012-09-23 14:24:14 +0000 @@ -21,6 +21,8 @@ foreign-key="fk_report_reporttableid" /> - + + \ No newline at end of file === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.java' --- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.java 2012-06-25 19:23:38 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/dashboard/DashboardStoreTest.java 2012-09-23 14:24:14 +0000 @@ -36,6 +36,7 @@ import org.hisp.dhis.common.GenericStore; import org.hisp.dhis.report.Report; import org.hisp.dhis.report.ReportService; +import org.hisp.dhis.reporttable.ReportTable; import org.hisp.dhis.user.User; import org.hisp.dhis.user.UserService; import org.junit.Test; @@ -72,7 +73,7 @@ userA = createUser( 'A' ); userService.addUser( userA ); - reportA = new Report( "ReportA", "DesignA", null ); + reportA = new Report( "ReportA", "DesignA", new ReportTable() ); reportService.saveReport( reportA ); contentA = new DashboardContent(); === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2012-05-23 19:48:53 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2012-09-23 15:49:44 +0000 @@ -70,6 +70,7 @@ import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.patientdatavalue.PatientDataValue; import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.RelativePeriods; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramInstance; import org.hisp.dhis.program.ProgramStage; @@ -313,6 +314,15 @@ return null; } + public void deleteRelativePeriods( RelativePeriods relativePeriods ) + { + } + + public String allowDeleteRelativePeriods( RelativePeriods relativePeriods ) + { + return null; + } + public void deleteValidationRule( ValidationRule validationRule ) { } === added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/AbstractRelativePeriodsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/AbstractRelativePeriodsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/AbstractRelativePeriodsAction.java 2012-09-23 15:49:44 +0000 @@ -0,0 +1,182 @@ +package org.hisp.dhis.commons.action; + +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.period.RelativePeriods; +import com.opensymphony.xwork2.Action; + +/** + * @author Lars Helge Overland + */ +public abstract class AbstractRelativePeriodsAction + implements Action +{ + protected boolean reportingMonth; + + public void setReportingMonth( boolean reportingMonth ) + { + this.reportingMonth = reportingMonth; + } + + protected boolean reportingBimonth; + + public void setReportingBimonth( boolean reportingBimonth ) + { + this.reportingBimonth = reportingBimonth; + } + + protected boolean reportingQuarter; + + public void setReportingQuarter( boolean reportingQuarter ) + { + this.reportingQuarter = reportingQuarter; + } + + protected boolean lastSixMonth; + + public void setLastSixMonth( boolean lastSixMonth ) + { + this.lastSixMonth = lastSixMonth; + } + + protected boolean monthsThisYear; + + public void setMonthsThisYear( boolean monthsThisYear ) + { + this.monthsThisYear = monthsThisYear; + } + + protected boolean quartersThisYear; + + public void setQuartersThisYear( boolean quartersThisYear ) + { + this.quartersThisYear = quartersThisYear; + } + + protected boolean thisYear; + + public void setThisYear( boolean thisYear ) + { + this.thisYear = thisYear; + } + + protected boolean monthsLastYear; + + public void setMonthsLastYear( boolean monthsLastYear ) + { + this.monthsLastYear = monthsLastYear; + } + + protected boolean quartersLastYear; + + public void setQuartersLastYear( boolean quartersLastYear ) + { + this.quartersLastYear = quartersLastYear; + } + + protected boolean last5Years; + + public void setLast5Years( boolean last5Years ) + { + this.last5Years = last5Years; + } + + protected boolean lastYear; + + public void setLastYear( boolean lastYear ) + { + this.lastYear = lastYear; + } + + protected boolean last12Months; + + public void setLast12Months( boolean last12Months ) + { + this.last12Months = last12Months; + } + + protected boolean last4Quarters; + + public void setLast4Quarters( boolean last4Quarters ) + { + this.last4Quarters = last4Quarters; + } + + protected boolean last2SixMonths; + + public void setLast2SixMonths( boolean last2SixMonths ) + { + this.last2SixMonths = last2SixMonths; + } + + protected boolean thisFinancialYear; + + public void setThisFinancialYear( boolean thisFinancialYear ) + { + this.thisFinancialYear = thisFinancialYear; + } + + protected boolean lastFinancialYear; + + public void setLastFinancialYear( boolean lastFinancialYear ) + { + this.lastFinancialYear = lastFinancialYear; + } + + protected boolean last3Months; + + public void setLast3Months( boolean last3Months ) + { + this.last3Months = last3Months; + } + + protected boolean last5FinancialYears; + + public void setLast5FinancialYears( boolean last5FinancialYears ) + { + this.last5FinancialYears = last5FinancialYears; + } + + protected boolean last52Weeks; + + public void setLast52Weeks( boolean last52Weeks ) + { + this.last52Weeks = last52Weeks; + } + + protected RelativePeriods getRelativePeriods() + { + RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter, lastSixMonth, + monthsThisYear, quartersThisYear, thisYear, + monthsLastYear, quartersLastYear, lastYear, + last5Years, last12Months, last3Months, false, last4Quarters, last2SixMonths, + thisFinancialYear, lastFinancialYear, last5FinancialYears, last52Weeks ); + + return relatives; + } +} === 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-12-26 10:07:59 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java 2012-09-23 14:24:14 +0000 @@ -31,20 +31,20 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hisp.dhis.commons.action.AbstractRelativePeriodsAction; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.report.Report; import org.hisp.dhis.report.ReportService; +import org.hisp.dhis.reporttable.ReportTable; import org.hisp.dhis.reporttable.ReportTableService; import org.hisp.dhis.system.util.StreamUtils; -import com.opensymphony.xwork2.Action; - /** * @author Lars Helge Overland * @version $Id: UploadDesignAction.java 5207 2008-05-22 12:16:36Z larshelg $ */ public class AddReportAction - implements Action + extends AbstractRelativePeriodsAction { private static final Log log = LogFactory.getLog( AddReportAction.class ); @@ -179,9 +179,12 @@ Report report = ( id == null ) ? new Report() : reportService.getReport( id ); + ReportTable reportTable = reportTableService.getReportTable( reportTableId ); + report.setName( name ); - report.setReportTable( reportTableService.getReportTable( reportTableId ) ); + report.setReportTable( reportTable ); report.setUsingOrgUnitGroupSets( usingOrgUnitGroupSets ); + report.setRelatives( getRelativePeriods() ); 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/GetReportOptionsAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportOptionsAction.java 2012-01-25 17:11:43 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportOptionsAction.java 2012-09-23 14:24:14 +0000 @@ -32,6 +32,7 @@ import java.util.List; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.period.RelativePeriods; import org.hisp.dhis.report.Report; import org.hisp.dhis.report.ReportService; import org.hisp.dhis.reporttable.ReportTable; @@ -85,7 +86,14 @@ { return report; } - + + private RelativePeriods relatives; + + public RelativePeriods getRelatives() + { + return relatives; + } + private List reportTables; public List getReportTables() @@ -105,7 +113,9 @@ if ( id != null ) { - report = reportService.getReport( id ); + report = reportService.getReport( id ); + + relatives = report.getRelatives(); } return SUCCESS; === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableOptionsAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableOptionsAction.java 2012-04-07 14:06:33 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetTableOptionsAction.java 2012-09-23 14:24:14 +0000 @@ -55,6 +55,7 @@ import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.period.PeriodType; +import org.hisp.dhis.period.RelativePeriods; import org.hisp.dhis.reporttable.ReportTable; import org.hisp.dhis.reporttable.ReportTableService; import org.hisp.dhis.system.filter.AggregatableDataElementFilter; @@ -242,7 +243,14 @@ { return reportTable; } - + + private RelativePeriods relatives; + + public RelativePeriods getRelatives() + { + return relatives; + } + private List selectedDataElements = new ArrayList(); public List getSelectedDataElements() @@ -363,6 +371,8 @@ { reportTable = reportTableService.getReportTable( id ); + relatives = reportTable.getRelatives(); + dataElements.removeAll( reportTable.getDataElements() ); indicators.removeAll( reportTable.getIndicators() ); === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java 2012-07-24 04:04:14 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java 2012-09-23 14:24:14 +0000 @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.List; +import org.hisp.dhis.commons.action.AbstractRelativePeriodsAction; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryCombo; import org.hisp.dhis.dataelement.DataElementCategoryService; @@ -52,14 +53,11 @@ import org.hisp.dhis.reporttable.ReportTable; import org.hisp.dhis.reporttable.ReportTableService; -import com.opensymphony.xwork2.Action; - /** * @author Lars Helge Overland - * @version $Id$ */ public class SaveTableAction - implements Action + extends AbstractRelativePeriodsAction { // ------------------------------------------------------------------------- // Dependencies @@ -230,125 +228,6 @@ this.selectedOrganisationUnitGroups = selectedOrganisationUnitGroups; } - private boolean reportingMonth; - - public void setReportingMonth( boolean reportingMonth ) - { - this.reportingMonth = reportingMonth; - } - - private boolean reportingBimonth; - - public void setReportingBimonth( boolean reportingBimonth ) - { - this.reportingBimonth = reportingBimonth; - } - - private boolean reportingQuarter; - - public void setReportingQuarter( boolean reportingQuarter ) - { - this.reportingQuarter = reportingQuarter; - } - - private boolean lastSixMonth; - - public void setLastSixMonth( boolean lastSixMonth ) - { - this.lastSixMonth = lastSixMonth; - } - - private boolean monthsThisYear; - - public void setMonthsThisYear( boolean monthsThisYear ) - { - this.monthsThisYear = monthsThisYear; - } - - private boolean quartersThisYear; - - public void setQuartersThisYear( boolean quartersThisYear ) - { - this.quartersThisYear = quartersThisYear; - } - - private boolean thisYear; - - public void setThisYear( boolean thisYear ) - { - this.thisYear = thisYear; - } - - private boolean monthsLastYear; - - public void setMonthsLastYear( boolean monthsLastYear ) - { - this.monthsLastYear = monthsLastYear; - } - - private boolean quartersLastYear; - - public void setQuartersLastYear( boolean quartersLastYear ) - { - this.quartersLastYear = quartersLastYear; - } - - private boolean last5Years; - - public void setLast5Years( boolean last5Years ) - { - this.last5Years = last5Years; - } - - private boolean lastYear; - - public void setLastYear( boolean lastYear ) - { - this.lastYear = lastYear; - } - - private boolean last12Months; - - public void setLast12Months( boolean last12Months ) - { - this.last12Months = last12Months; - } - - private boolean last4Quarters; - - public void setLast4Quarters( boolean last4Quarters ) - { - this.last4Quarters = last4Quarters; - } - - private boolean last2SixMonths; - - public void setLast2SixMonths( boolean last2SixMonths ) - { - this.last2SixMonths = last2SixMonths; - } - - private boolean thisFinancialYear; - - public void setThisFinancialYear( boolean thisFinancialYear ) - { - this.thisFinancialYear = thisFinancialYear; - } - - private boolean lastFinancialYear; - - public void setLastFinancialYear( boolean lastFinancialYear ) - { - this.lastFinancialYear = lastFinancialYear; - } - - private boolean last5FinancialYears; - - public void setLast5FinancialYears( boolean last5FinancialYears ) - { - this.last5FinancialYears = last5FinancialYears; - } - private boolean paramReportingMonth; public void setParamReportingMonth( boolean paramReportingMonth ) @@ -363,13 +242,6 @@ this.paramLeafParentOrganisationUnit = paramLeafParentOrganisationUnit; } - private boolean last3Months; - - public void setLast3Months( boolean last3Months ) - { - this.last3Months = last3Months; - } - private boolean paramGrandParentOrganisationUnit; public void setParamGrandParentOrganisationUnit( boolean paramGrandParentOrganisationUnit ) @@ -442,11 +314,7 @@ DataElementCategoryCombo categoryCombo = categoryComboId != null ? categoryService.getDataElementCategoryCombo( categoryComboId ) : null; - RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter, lastSixMonth, - monthsThisYear, quartersThisYear, thisYear, - monthsLastYear, quartersLastYear, lastYear, - last5Years, last12Months, last3Months, false, last4Quarters, last2SixMonths, - thisFinancialYear, lastFinancialYear, last5FinancialYears, false ); + RelativePeriods relatives = getRelativePeriods(); ReportParams reportParams = new ReportParams(); === 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 2012-05-21 09:33:12 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm 2012-09-23 14:24:14 +0000 @@ -10,12 +10,14 @@ + + - + @@ -29,10 +31,29 @@ #end - - + + + + + + + + + + + + + - - - + + + + + + + + - - @@ -60,6 +80,4 @@ -$i18n.getString( "omit_report_table_explanation" ). - $!message === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm 2012-07-25 12:53:40 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm 2012-09-23 14:24:14 +0000 @@ -431,45 +431,7 @@ === 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 2012-07-19 07:37:36 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js 2012-09-23 14:24:14 +0000 @@ -1,6 +1,6 @@ function addReport() { - if ( !hasText( "upload" ) ) + if ( $( "#id" ).val().length == 0 && !hasText( "upload" ) ) { setMessage( i18n_please_specify_file ); return false; @@ -35,6 +35,12 @@ } } +function toggleDataSource() +{ + $( ".reportTableDataSource" ).toggle(); + $( ".jdbcDataSource" ).toggle(); +} + // ----------------------------------------------------------------------------- // View details // ----------------------------------------------------------------------------- === added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/relativePeriodsInput.vm' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/relativePeriodsInput.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/relativePeriodsInput.vm 2012-09-23 15:49:44 +0000 @@ -0,0 +1,40 @@ + +  + +  + +  + +

+ + +  + +  + +  + +

+ + +  + +  + +  + +

+ + +  + +  + +  + +

+ + +  + + \ No newline at end of file === modified file 'dhis-2/pom.xml' --- dhis-2/pom.xml 2012-08-22 12:45:25 +0000 +++ dhis-2/pom.xml 2012-09-23 15:49:44 +0000 @@ -667,7 +667,7 @@ net.sf.jasperreports jasperreports - 4.5.1 + 4.7.0 xalan
$i18n.getString( "details" )
+ +
+ Use JDBC data source + +
$i18n.getString( "report_table" )
$i18n.getString( "report_table" ) - #foreach( $table in $reportTables ) @@ -40,18 +61,17 @@
- -
+
- -   - -   - -   - -

- - -   - -   - -   - -

- - -   - -   - -   - -

- - -   - -   - -   - -   - -   - - + #parse( "/dhis-web-reporting/relativePeriodsInput.vm" )