← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8209: Implemented support for relative periods for reports, meaning that you can access relative period...

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 8209 [merge]
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-09-23 17:49:44 +0200
message:
  Implemented support for relative periods for reports, meaning that you can access relative period identifiers as a report parameter in ireport and use it in a SQL query. Added RelativePeriods as its own entity. Upgraded to jasperreports 4.7.0.
added:
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/RelativePeriods.hbm.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/AbstractRelativePeriodsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/relativePeriodsInput.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Report.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  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/hibernate/HibernatePeriodStore.java
  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/resources/META-INF/dhis/beans.xml
  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/dashboard/DashboardStoreTest.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java
  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/GetReportOptionsAction.java
  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/SaveTableAction.java
  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/addTableForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js
  dhis-2/pom.xml


--
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/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 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd";>
+
+<hibernate-mapping>
+  <class name="org.hisp.dhis.period.RelativePeriods" table="relativeperiods">
+
+    <cache usage="read-write" />
+
+    <id name="id" column="relativeperiodsid">
+      <generator class="native" />
+    </id>
+    
+    <property name="reportingMonth" />
+    <property name="reportingBimonth" />
+    <property name="reportingQuarter" />
+    <property name="lastSixMonth" />
+    <property name="monthsThisYear" />
+    <property name="quartersThisYear" />
+    <property name="thisYear" />
+    
+    <property name="monthsLastYear" />
+    <property name="quartersLastYear" />
+    <property name="lastYear" />
+    
+    <property name="last5Years" />
+    <property name="last12Months" />
+    <property name="last3Months" />
+    <property name="last6BiMonths" />
+    <property name="last4Quarters" />
+    <property name="last2SixMonths" />
+    <property name="thisFinancialYear" />
+    <property name="lastFinancialYear" />
+    <property name="last5FinancialYears" />
+    <property name="last52Weeks" />
+    
+  </class>
+</hibernate-mapping>
\ 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<Period> 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<Report> 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 @@
     <property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
     <property name="statementManager" ref="statementManager" />
     <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
+    <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
   </bean>
 
   <!-- Chart -->

=== 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" />
 
     <property name="usingOrgUnitGroupSets" />
-
+    
+    <many-to-one name="relatives" unique="true" class="org.hisp.dhis.period.RelativePeriods" column="relativeperiodsid"
+         cascade="all-delete-orphan" foreign-key="fk_report_relativeperiodsid" />
   </class>
 </hibernate-mapping>
\ 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<ReportTable> reportTables;
 
     public List<ReportTable> 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<DataElement> selectedDataElements = new ArrayList<DataElement>();
 
     public List<DataElement> 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 @@
 <input type="hidden" id="currentDesign" name="currentDesign" value="$!report.design" />
 
 <table>
+	<col width="220"/>
+	<col/>
     <tr>
         <th colspan="2">$i18n.getString( "details" )</th>
     </tr>
     <tr>
         <td><label for="name">$i18n.getString( "name" )</label></td>
-        <td><input type="text" id="name" name="name" style="width:95%" value="$!report.name"></td>
+        <td><input type="text" id="name" name="name" style="width:290px" value="$!report.name"></td>
     </tr>
 	<tr>
 		<td><label for="upload">$i18n.getString( "jasper_design" )</label></td>
@@ -29,10 +31,29 @@
 		#end
 		</td>
 	</tr>
-	<tr>
-		<td><label for="reportTableId">$i18n.getString( "report_table" )</td>
+    <tr>
+        <td><label for="usingOrgUnitGroupSets">$i18n.getString( "include_organisation_unit_group_sets" )</label></td>
+        <td>
+            <select id="usingOrgUnitGroupSets" name="usingOrgUnitGroupSets" style="width:290px">
+            <option value="false"#if ( $report && $report.usingOrgUnitGroupSets )selected="selected"#end>$i18n.getString( "no" )</option>
+            <option value="true"#if ( $report && $report.usingOrgUnitGroupSets )selected="selected"#end>$i18n.getString( "yes" )</option>           
+            </select>
+        </td>
+    </tr>
+    <tr>
+    	<td></td>
+        <td style="height:25px">
+        	<a class="reportTableDataSource" onclick="toggleDataSource()" style="cursor:pointer">Use JDBC data source</a>
+        	<a class="jdbcDataSource" onclick="toggleDataSource()" style="cursor:pointer; display:none">Use report table data source</a>
+        </td>
+    </tr>
+    <tr class="reportTableDataSource">
+    	<th colspan="2">$i18n.getString( "report_table" )</th>
+    </tr>
+	<tr class="reportTableDataSource">
+		<td>$i18n.getString( "report_table" )</td>
 		<td>
-			<select id="reportTableId" name="reportTableId" style="min-width:325px">
+			<select id="reportTableId" name="reportTableId" style="width:260px">
 			<option value="0">[ $i18n.getString( "none" ) ]</option>
 			#foreach( $table in $reportTables )
 				<option value="$table.id"#if( $!report.reportTable.id == $table.id ) selected="selected"#end>$table.name</option>
@@ -40,18 +61,17 @@
 			</select>
 		</td>
 	</tr>
-	<tr>
-		<td><label for="usingOrgUnitGroupSets">$i18n.getString( "include_organisation_unit_group_sets" )</label></td>
-		<td>
-			<select id="usingOrgUnitGroupSets" name="usingOrgUnitGroupSets" style="min-width:325px">
-			<option value="false"#if ( $report && $report.usingOrgUnitGroupSets )selected="selected"#end>$i18n.getString( "no" )</option>
-			<option value="true"#if ( $report && $report.usingOrgUnitGroupSets )selected="selected"#end>$i18n.getString( "yes" )</option>			
-			</select>
-		</td>
+	<tr class="jdbcDataSource" style="display:none">
+		<th colspan="2">$i18n.getString( "relative_periods" )</th>
 	</tr>
+	<tr class="jdbcDataSource" style="display:none">
+        <td colspan="2">#parse( "/dhis-web-reporting/relativePeriodsInput.vm" )</td>
+    </tr>
+    <tr>
+        <td colspan="2" style="height:15px"></td>
+    </tr>
 	<tr>
-		<td></td>
-		<td>
+		<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>
@@ -60,6 +80,4 @@
 	
 </form>
 
-<span id="info">$i18n.getString( "omit_report_table_explanation" ).</span>
-
 <span id="message"#if ( $message ) style="display:block"#end>$!message</span>

=== 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 @@
 	</tr>
 	<tr>
 		<td>
-		    <label for="reportingMonth">$i18n.getString( "reporting_month" )</label>
-			<input type="checkbox" id="reportingMonth" name="reportingMonth" value="true"#if( $reportTable.relatives.isReportingMonth() ) checked#end>&nbsp;
-		    <label for="reportingBimonth">$i18n.getString( "reporting_bimonth" )</label>
-			<input type="checkbox" id="reportingBimonth" name="reportingBimonth" value="true"#if( $reportTable.relatives.isReportingBimonth() ) checked#end>&nbsp;
-		    <label for="reportingQuarter">$i18n.getString( "reporting_quarter" )</label>
-			<input type="checkbox" id="reportingQuarter" name="reportingQuarter" value="true"#if( $reportTable.relatives.isReportingQuarter() ) checked#end>&nbsp;
-		    <label for="lastSixMonth">$i18n.getString( "reporting_sixmonth" )</label>
-			<input type="checkbox" id="lastSixMonth" name="lastSixMonth" value="true"#if( $reportTable.relatives.isLastSixMonth() ) checked#end><br><br>
-		
-			<label for="monthsThisYear">$i18n.getString( "months_this_year" )</label>
-			<input type="checkbox" id="monthsThisYear" name="monthsThisYear" value="true""#if( $reportTable.relatives.isMonthsThisYear() ) checked#end>&nbsp;
-			<label for="quartersThisYear">$i18n.getString( "quarters_this_year" )</label>
-			<input type="checkbox" id="quartersThisYear" name="quartersThisYear" value="true"#if( $reportTable.relatives.isQuartersThisYear() ) checked#end>&nbsp;
-			<label for="thisYear">$i18n.getString( "this_year" )</label>
-			<input type="checkbox" id="thisYear" name="thisYear" value="true"#if( $reportTable.relatives.isThisYear() ) checked#end>&nbsp;
-			<label for="thisFinancialYear">$i18n.getString( "this_financial_year" )</label>
-			<input type="checkbox" id="thisFinancialYear" name="thisFinancialYear" value="true"#if( $reportTable.relatives.isThisFinancialYear() ) checked#end><br><br>
-			
-			<label for="monthsLastYear">$i18n.getString( "months_last_year" )</label>
-			<input type="checkbox" id="monthsLastYear" name="monthsLastYear" value="true""#if( $reportTable.relatives.isMonthsLastYear() ) checked#end>&nbsp;
-			<label for="quartersLastYear">$i18n.getString( "quarters_last_year" )</label>
-			<input type="checkbox" id="quartersLastYear" name="quartersLastYear" value="true"#if( $reportTable.relatives.isQuartersLastYear() ) checked#end>&nbsp;
-			<label for="lastYear">$i18n.getString( "last_year" )</label>
-			<input type="checkbox" id="lastYear" name="lastYear" value="true"#if( $reportTable.relatives.isLastYear() ) checked#end>&nbsp;
-			<label for="lastFinancialYear">$i18n.getString( "last_financial_year" )</label>
-			<input type="checkbox" id="lastFinancialYear" name="lastFinancialYear" value="true"#if( $reportTable.relatives.isLastFinancialYear() ) checked#end><br><br>
-				
-			<label for="last5Years">$i18n.getString( "last_5_years" )</label>
-			<input type="checkbox" id="last5Years" name="last5Years" value="true"#if( $reportTable.relatives.isLast5Years() ) checked#end>&nbsp;
-			<label for="last12Months">$i18n.getString( "last_12_months" )</label>
-			<input type="checkbox" id="last12Months" name="last12Months" value="true"#if( $reportTable.relatives.isLast12Months() ) checked#end>&nbsp;
-			<label for="last4Quarters">$i18n.getString( "last_4_quarters" )</label>
-			<input type="checkbox" id="last4Quarters" name="last4Quarters" value="true"#if( $reportTable.relatives.isLast4Quarters() ) checked#end>&nbsp;
-			<label for="last2SixMonths">$i18n.getString( "last_2_sixmonths" )</label>
-			<input type="checkbox" id="last2SixMonths" name="last2SixMonths" value="true"#if( $reportTable.relatives.isLast2SixMonths() ) checked#end>&nbsp;
-			<label for="last3Months">$i18n.getString( "last_3_months" )</label>
-			<input type="checkbox" id="last3Months" name="last3Months" value="true"#if( $reportTable.relatives.isLast3Months() ) checked#end>&nbsp;
-			<label for="last5FinancialYears">$i18n.getString( "last_5_financial_years" )</label>
-			<input type="checkbox" id="last5FinancialYears" name="last5FinancialYears" value="true"#if( $reportTable.relatives.isLast5FinancialYears() ) checked#end>
+		    #parse( "/dhis-web-reporting/relativePeriodsInput.vm" )
         </td>
     </tr>
     <tr>

=== 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 @@
+<label for="reportingMonth">$i18n.getString( "reporting_month" )</label>
+<input type="checkbox" id="reportingMonth" name="reportingMonth" value="true"#if( $relatives.isReportingMonth() ) checked#end>&nbsp;
+<label for="reportingBimonth">$i18n.getString( "reporting_bimonth" )</label>
+<input type="checkbox" id="reportingBimonth" name="reportingBimonth" value="true"#if( $relatives.isReportingBimonth() ) checked#end>&nbsp;
+<label for="reportingQuarter">$i18n.getString( "reporting_quarter" )</label>
+<input type="checkbox" id="reportingQuarter" name="reportingQuarter" value="true"#if( $relatives.isReportingQuarter() ) checked#end>&nbsp;
+<label for="lastSixMonth">$i18n.getString( "reporting_sixmonth" )</label>
+<input type="checkbox" id="lastSixMonth" name="lastSixMonth" value="true"#if( $relatives.isLastSixMonth() ) checked#end><br><br>
+
+<label for="monthsThisYear">$i18n.getString( "months_this_year" )</label>
+<input type="checkbox" id="monthsThisYear" name="monthsThisYear" value="true""#if( $relatives.isMonthsThisYear() ) checked#end>&nbsp;
+<label for="quartersThisYear">$i18n.getString( "quarters_this_year" )</label>
+<input type="checkbox" id="quartersThisYear" name="quartersThisYear" value="true"#if( $relatives.isQuartersThisYear() ) checked#end>&nbsp;
+<label for="thisYear">$i18n.getString( "this_year" )</label>
+<input type="checkbox" id="thisYear" name="thisYear" value="true"#if( $relatives.isThisYear() ) checked#end>&nbsp;
+<label for="thisFinancialYear">$i18n.getString( "this_financial_year" )</label>
+<input type="checkbox" id="thisFinancialYear" name="thisFinancialYear" value="true"#if( $relatives.isThisFinancialYear() ) checked#end><br><br>
+
+<label for="monthsLastYear">$i18n.getString( "months_last_year" )</label>
+<input type="checkbox" id="monthsLastYear" name="monthsLastYear" value="true""#if( $relatives.isMonthsLastYear() ) checked#end>&nbsp;
+<label for="quartersLastYear">$i18n.getString( "quarters_last_year" )</label>
+<input type="checkbox" id="quartersLastYear" name="quartersLastYear" value="true"#if( $relatives.isQuartersLastYear() ) checked#end>&nbsp;
+<label for="lastYear">$i18n.getString( "last_year" )</label>
+<input type="checkbox" id="lastYear" name="lastYear" value="true"#if( $relatives.isLastYear() ) checked#end>&nbsp;
+<label for="lastFinancialYear">$i18n.getString( "last_financial_year" )</label>
+<input type="checkbox" id="lastFinancialYear" name="lastFinancialYear" value="true"#if( $relatives.isLastFinancialYear() ) checked#end><br><br>
+    
+<label for="last5Years">$i18n.getString( "last_5_years" )</label>
+<input type="checkbox" id="last5Years" name="last5Years" value="true"#if( $relatives.isLast5Years() ) checked#end>&nbsp;
+<label for="last12Months">$i18n.getString( "last_12_months" )</label>
+<input type="checkbox" id="last12Months" name="last12Months" value="true"#if( $relatives.isLast12Months() ) checked#end>&nbsp;
+<label for="last4Quarters">$i18n.getString( "last_4_quarters" )</label>
+<input type="checkbox" id="last4Quarters" name="last4Quarters" value="true"#if( $relatives.isLast4Quarters() ) checked#end>&nbsp;
+<label for="last2SixMonths">$i18n.getString( "last_2_sixmonths" )</label>
+<input type="checkbox" id="last2SixMonths" name="last2SixMonths" value="true"#if( $relatives.isLast2SixMonths() ) checked#end><br><br>
+
+<label for="last3Months">$i18n.getString( "last_3_months" )</label>
+<input type="checkbox" id="last3Months" name="last3Months" value="true"#if( $relatives.isLast3Months() ) checked#end>&nbsp;
+<label for="last5FinancialYears">$i18n.getString( "last_5_financial_years" )</label>
+<input type="checkbox" id="last5FinancialYears" name="last5FinancialYears" value="true"#if( $relatives.isLast5FinancialYears() ) checked#end>
\ 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 @@
       <dependency>
         <groupId>net.sf.jasperreports</groupId>
         <artifactId>jasperreports</artifactId>
-        <version>4.5.1</version>
+        <version>4.7.0</version>
         <exclusions>
           <exclusion>
             <groupId>xalan</groupId>