← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4600: Impl relative periods for reporting bi-month and reporting quarter

 

------------------------------------------------------------
revno: 4600
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-09-16 11:29:21 +0200
message:
  Impl relative periods for reporting bi-month and reporting quarter
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/DataMartExportStoreTest.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataSetCompletenessTask.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowAddDataElementForm.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.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/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java	2011-05-05 21:14:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java	2011-09-16 09:29:21 +0000
@@ -48,6 +48,8 @@
     private static final long serialVersionUID = 2949655296199662273L;
 
     public static final String REPORTING_MONTH = "reporting_month";
+    public static final String REPORTING_BIMONTH = "reporting_bimonth";
+    public static final String REPORTING_QUARTER = "reporting_quarter";
     public static final String THIS_YEAR = "year";    
     public static final String LAST_YEAR = "last_year";
         
@@ -95,6 +97,10 @@
     
     private Boolean reportingMonth = false;
     
+    private Boolean reportingBimonth = false;
+    
+    private Boolean reportingQuarter = false;
+    
     private Boolean monthsThisYear = false;
     
     private Boolean quartersThisYear = false;
@@ -117,6 +123,8 @@
     
     /**
      * @param reportingMonth reporting month
+     * @param reportingBimonth reporting bimonth
+     * @param reportingQuarter reporting quarter
      * @param monthsThisYear months this year
      * @param quartersThisYear quarters this year
      * @param thisYear this year
@@ -124,10 +132,13 @@
      * @param quartersLastYear quarters last year
      * @param lastYear last year
      */
-    public RelativePeriods( boolean reportingMonth, boolean monthsThisYear, boolean quartersThisYear, boolean thisYear,
+    public RelativePeriods( boolean reportingMonth, boolean reportingBimonth, boolean reportingQuarter,
+        boolean monthsThisYear, boolean quartersThisYear, boolean thisYear,
         boolean monthsLastYear, boolean quartersLastYear, boolean lastYear )
     {
         this.reportingMonth = reportingMonth;
+        this.reportingBimonth = reportingBimonth;
+        this.reportingQuarter = reportingQuarter;
         this.monthsThisYear = monthsThisYear;
         this.quartersThisYear = quartersThisYear;
         this.thisYear = thisYear;
@@ -192,6 +203,16 @@
             periods.add( getRelativePeriod( new MonthlyPeriodType(), REPORTING_MONTH, current, dynamicNames, format ) );
         }
         
+        if ( isReportingBimonth() )
+        {
+            periods.add( getRelativePeriod( new BiMonthlyPeriodType(), REPORTING_BIMONTH, current, dynamicNames, format ) );
+        }
+        
+        if ( isReportingQuarter() )
+        {
+            periods.add( getRelativePeriod( new QuarterlyPeriodType(), REPORTING_QUARTER, current, dynamicNames, format ) );
+        }
+        
         if ( isMonthsThisYear() )
         {
             periods.addAll( getRelativePeriodList( new MonthlyPeriodType(), MONTHS_THIS_YEAR, current, dynamicNames, format ) );
@@ -301,6 +322,16 @@
         return reportingMonth != null && reportingMonth;
     }
     
+    public boolean isReportingBimonth()
+    {
+        return reportingBimonth != null && reportingBimonth;
+    }
+    
+    public boolean isReportingQuarter()
+    {
+        return reportingQuarter != null && reportingQuarter;
+    }
+    
     public boolean isMonthsThisYear()
     {
         return monthsThisYear != null && monthsThisYear;
@@ -345,6 +376,26 @@
         this.reportingMonth = reportingMonth;
     }
 
+    public Boolean getReportingBimonth()
+    {
+        return reportingBimonth;
+    }
+
+    public void setReportingBimonth( Boolean reportingBimonth )
+    {
+        this.reportingBimonth = reportingBimonth;
+    }
+
+    public Boolean getReportingQuarter()
+    {
+        return reportingQuarter;
+    }
+
+    public void setReportingQuarter( Boolean reportingQuarter )
+    {
+        this.reportingQuarter = reportingQuarter;
+    }
+
     public Boolean getMonthsThisYear()
     {
         return monthsThisYear;
@@ -417,6 +468,8 @@
         int result = 1;
 
         result = prime * result + ( ( reportingMonth == null ) ? 0 : reportingMonth.hashCode() );
+        result = prime * result + ( ( reportingBimonth == null ) ? 0 : reportingBimonth.hashCode() );
+        result = prime * result + ( ( reportingQuarter == null ) ? 0 : reportingQuarter.hashCode() );
         result = prime * result + ( ( monthsThisYear == null ) ? 0 : monthsThisYear.hashCode() );
         result = prime * result + ( ( quartersThisYear == null ) ? 0 : quartersThisYear.hashCode() );
         result = prime * result + ( ( thisYear == null ) ? 0 : thisYear.hashCode() );
@@ -458,6 +511,30 @@
         {
             return false;
         }
+
+        if ( reportingBimonth == null )
+        {
+            if ( other.reportingBimonth != null )
+            {
+                return false;
+            }
+        }
+        else if ( !reportingBimonth.equals( other.reportingBimonth ) )
+        {
+            return false;
+        }
+
+        if ( reportingQuarter == null )
+        {
+            if ( other.reportingQuarter != null )
+            {
+                return false;
+            }
+        }
+        else if ( !reportingQuarter.equals( other.reportingQuarter ) )
+        {
+            return false;
+        }
         
         if ( monthsThisYear == null )
         {

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java	2011-02-08 13:15:54 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java	2011-09-16 09:29:21 +0000
@@ -58,7 +58,7 @@
     @Test
     public void getRelativePeriodsA()
     {        
-        RelativePeriods periods = new RelativePeriods( true, true, true, true, true, true, true );
+        RelativePeriods periods = new RelativePeriods( true, true, true, true, true, true, true, true, true );
         
         Collection<Period> relatives = periods.getRelativePeriods( 1, getDate( 2002, 1, 1 ), i18nFormat, false );
         
@@ -102,6 +102,6 @@
 
         assertTrue( relatives.contains( new Period( new YearlyPeriodType(), getDate( 2000, 1, 1 ), getDate( 2000, 12, 31 ) ) ) );
         
-        assertEquals( 35, relatives.size() );
+        assertEquals( 37, relatives.size() );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/DataMartExportStoreTest.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/DataMartExportStoreTest.java	2011-01-06 09:03:29 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/DataMartExportStoreTest.java	2011-09-16 09:29:21 +0000
@@ -134,7 +134,7 @@
         periods.add( periodA );
         periods.add( periodB );
         
-        relatives = new RelativePeriods( true, true, true, true, false, false, false );
+        relatives = new RelativePeriods( true, true, true, true, true, true, false, false, false );
         
         exportA = new DataMartExport( "ExportA", dataElements, indicators, organisationUnits, periods, relatives );
         exportB = new DataMartExport( "ExportB", dataElements, indicators, organisationUnits, periods, relatives );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2011-09-14 15:17:22 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2011-09-16 09:29:21 +0000
@@ -70,6 +70,8 @@
 
     <component name="relatives">
       <property name="reportingMonth" />
+      <property name="reportingBimonth" />
+      <property name="reportingQuarter" />
       <property name="monthsThisYear" />
       <property name="quartersThisYear" />
       <property name="thisYear" />

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java	2011-08-29 19:26:15 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java	2011-09-16 09:29:21 +0000
@@ -70,7 +70,7 @@
         Collection<Integer> indicatorIds = ConversionUtils.getIdentifiers( Indicator.class, indicatorService.getAllIndicators() );
         Collection<Integer> organisationUnitIds = ConversionUtils.getIdentifiers( OrganisationUnit.class, organisationUnitService.getAllOrganisationUnits() );
         
-        RelativePeriods relatives = new RelativePeriods( false, true, true, true, false, false, false );
+        RelativePeriods relatives = new RelativePeriods( false, false, false, true, true, true, false, false, false );
         
         dataMartService.export( dataElementIds, indicatorIds, new HashSet<Integer>(), organisationUnitIds, relatives, true );
     }

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataSetCompletenessTask.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataSetCompletenessTask.java	2011-08-29 19:26:15 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataSetCompletenessTask.java	2011-09-16 09:29:21 +0000
@@ -63,7 +63,7 @@
         Collection<Integer> dataSetIds = ConversionUtils.getIdentifiers( DataSet.class, dataSetService.getAllDataSets() );
         Collection<Integer> organisationUnitIds = ConversionUtils.getIdentifiers( OrganisationUnit.class, organisationUnitService.getAllOrganisationUnits() );
 
-        RelativePeriods relatives = new RelativePeriods( false, true, true, true, false, false, false );
+        RelativePeriods relatives = new RelativePeriods( false, false, false, true, true, true, false, false, false );
         
         completenessService.exportDataSetCompleteness( dataSetIds, relatives, organisationUnitIds );        
     }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-09-12 09:15:08 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-09-16 09:29:21 +0000
@@ -149,7 +149,7 @@
  */
 function isChecked( checkboxId )
 {
-	return jQuery( "#" + checkboxId ).attr("checked");   
+	return jQuery( "#" + checkboxId ) && jQuery( "#" + checkboxId ).attr("checked");   
 }
 
 /**
@@ -1363,6 +1363,8 @@
 function relativePeriodsChecked()
 {
     if ( isChecked( "reportingMonth" ) ||
+         isChecked( "reportingBimonth" ) ||
+         isChecked( "reportingQuarter" ) ||
          isChecked( "monthsThisYear" ) ||
          isChecked( "quartersThisYear" ) ||
          isChecked( "thisYear" ) ||

=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java	2011-01-18 15:24:46 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java	2011-09-16 09:29:21 +0000
@@ -142,6 +142,20 @@
         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 monthsThisYear;
 
     public void setMonthsThisYear( boolean monthsThisYear )
@@ -192,7 +206,9 @@
     {
         DataMartExport export = id == null ? new DataMartExport() : dataMartService.getDataMartExport( id );
 
-        RelativePeriods relatives = new RelativePeriods( reportingMonth, monthsThisYear, quartersThisYear, thisYear, monthsLastYear, quartersLastYear, lastYear );
+        RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter,
+            monthsThisYear, quartersThisYear, thisYear, 
+            monthsLastYear, quartersLastYear, lastYear );
           
         export.setName( name );            
         export.setDataElements( getSet( dataElementService.getDataElements( getIntegerCollection( selectedDataElements ) ) ) );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowAddDataElementForm.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowAddDataElementForm.java	2011-09-14 10:14:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowAddDataElementForm.java	2011-09-16 09:29:21 +0000
@@ -31,11 +31,9 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
+import org.hisp.dhis.attribute.Attribute;
 import org.hisp.dhis.attribute.AttributeService;
-import org.hisp.dhis.attribute.AttributeValue;
-import org.hisp.dhis.attribute.Attribute;
 import org.hisp.dhis.attribute.comparator.AttributeNameComparator;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java	2011-09-07 13:14:46 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java	2011-09-16 09:29:21 +0000
@@ -245,6 +245,20 @@
         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 monthsThisYear;
 
     public void setMonthsThisYear( boolean monthsThisYear )
@@ -337,7 +351,8 @@
         chart.setPeriods( periods );
         chart.setOrganisationUnits( organisationUnits );
 
-        RelativePeriods relatives = new RelativePeriods( reportingMonth, monthsThisYear, quartersThisYear, thisYear,
+        RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter,
+            monthsThisYear, quartersThisYear, thisYear,
             monthsLastYear, quartersLastYear, lastYear );
 
         chart.setRelatives( relatives );

=== 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	2011-09-14 15:17:22 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2011-09-16 09:29:21 +0000
@@ -221,6 +221,20 @@
         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 monthsThisYear;
 
     public void setMonthsThisYear( boolean monthsThisYear )
@@ -348,7 +362,9 @@
         
         DataElementCategoryCombo categoryCombo = categoryComboId != null ? categoryService.getDataElementCategoryCombo( categoryComboId ) : null;
         
-        RelativePeriods relatives = new RelativePeriods( reportingMonth, monthsThisYear, quartersThisYear, thisYear, monthsLastYear, quartersLastYear, lastYear );
+        RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter,
+            monthsThisYear, quartersThisYear, thisYear, 
+            monthsLastYear, quartersLastYear, lastYear );
         
         ReportParams reportParams = new ReportParams();
         

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-09-14 15:17:22 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2011-09-16 09:29:21 +0000
@@ -384,4 +384,6 @@
 stacked_bar3d_chart = Stacked 3D bar chart
 domain_axis_label_x = Domain axis label (x)
 range_axis_label_y = Range axis label (y)
-leaf_parent_organisation_unit = Leaf organisation units
\ No newline at end of file
+leaf_parent_organisation_unit = Leaf organisation units
+reporting_bimonth = Reporting bimonth
+reporting_quarter = Reporting quarter
\ No newline at end of file

=== 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	2011-09-14 19:00:28 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm	2011-09-16 09:29:21 +0000
@@ -409,6 +409,11 @@
 		<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><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>