← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5488: Implemented new relative period LastSixMonth

 

------------------------------------------------------------
revno: 5488
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-12-19 20:58:47 +0100
message:
  Implemented new relative period LastSixMonth
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-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.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


--
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-12-19 19:01:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java	2011-12-19 19:58:47 +0000
@@ -55,6 +55,7 @@
     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 LAST_SIXMONTH = "last_sixmonth";
     public static final String THIS_YEAR = "year";
     public static final String LAST_YEAR = "last_year";
 
@@ -133,12 +134,14 @@
 
     private static final int MONTHS_IN_YEAR = 12;
 
-    private boolean reportingMonth = false;
-
-    private boolean reportingBimonth = false;
-
-    private boolean reportingQuarter = false;
-
+    private boolean reportingMonth = false; // TODO rename to lastMonth
+
+    private boolean reportingBimonth = false; // TODO rename to lastBimonth
+
+    private boolean reportingQuarter = false; // TODO rename to lastQuarter
+
+    private boolean lastSixMonth = false;
+    
     private boolean monthsThisYear = false;
 
     private boolean quartersThisYear = false;
@@ -185,7 +188,7 @@
      * @param last4Quarters    last 4 quarters
      * @param last2SixMonths   last 2 six-months
      */
-    public RelativePeriods( boolean reportingMonth, boolean reportingBimonth, boolean reportingQuarter,
+    public RelativePeriods( boolean reportingMonth, boolean reportingBimonth, boolean reportingQuarter, boolean lastSixMonth,
                             boolean monthsThisYear, boolean quartersThisYear, boolean thisYear,
                             boolean monthsLastYear, boolean quartersLastYear, boolean lastYear, boolean last5Years,
                             boolean last12Months, boolean last6BiMonths, boolean last4Quarters, boolean last2SixMonths )
@@ -193,6 +196,7 @@
         this.reportingMonth = reportingMonth;
         this.reportingBimonth = reportingBimonth;
         this.reportingQuarter = reportingQuarter;
+        this.lastSixMonth = lastSixMonth;
         this.monthsThisYear = monthsThisYear;
         this.quartersThisYear = quartersThisYear;
         this.thisYear = thisYear;
@@ -254,6 +258,11 @@
         {
             return PeriodType.getPeriodTypeByName( QuarterlyPeriodType.NAME );
         }
+        
+        if ( isLastSixMonth() )
+        {
+            return PeriodType.getPeriodTypeByName( SixMonthlyPeriodType.NAME );
+        }
 
         return PeriodType.getPeriodTypeByName( YearlyPeriodType.NAME );
     }
@@ -330,6 +339,11 @@
         {
             periods.add( getRelativePeriod( new QuarterlyPeriodType(), REPORTING_QUARTER, date, dynamicNames, format ) );
         }
+        
+        if ( isLastSixMonth() )
+        {
+            periods.add( getRelativePeriod( new SixMonthlyPeriodType(), LAST_SIXMONTH, date, dynamicNames, format ) );
+        }
 
         if ( isMonthsThisYear() )
         {
@@ -554,6 +568,18 @@
         this.reportingQuarter = reportingQuarter;
         return this;
     }
+    
+    @XmlElement
+    @JsonProperty
+    public boolean isLastSixMonth()
+    {
+        return lastSixMonth;
+    }
+
+    public void setLastSixMonth( boolean lastSixMonth )
+    {
+        this.lastSixMonth = lastSixMonth;
+    }
 
     @XmlElement
     @JsonProperty
@@ -712,6 +738,7 @@
         result = prime * result + (reportingMonth ? 1 : 0);
         result = prime * result + (reportingBimonth ? 1 : 0);
         result = prime * result + (reportingQuarter ? 1 : 0);
+        result = prime * result + (lastSixMonth ? 1 : 0);
         result = prime * result + (monthsThisYear ? 1 : 0);
         result = prime * result + (quartersThisYear ? 1 : 0);
         result = prime * result + (thisYear ? 1 : 0);
@@ -761,6 +788,11 @@
         {
             return false;
         }
+        
+        if ( !lastSixMonth == other.last2SixMonths )
+        {
+            return false;
+        }
 
         if ( !monthsThisYear == other.monthsThisYear )
         {

=== 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-11-21 12:44:20 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java	2011-12-19 19:58:47 +0000
@@ -61,7 +61,7 @@
     @Test
     public void getRelativePeriods()
     {        
-        RelativePeriods periods = new RelativePeriods( true, true, true, true, true, true, true, true, true, true, true, true, true, true );
+        RelativePeriods periods = new RelativePeriods( true, true, true, true, true, true, true, true, true, true, true, true, true, true, true );
         
         List<Period> relatives = periods.getRelativePeriods( getDate( 2001, 1, 1 ), i18nFormat, false );
         
@@ -121,7 +121,7 @@
         assertTrue( relatives.contains( new Period( new YearlyPeriodType(), getDate( 2000, 1, 1 ), getDate( 2000, 12, 31 ) ) ) );
         assertTrue( relatives.contains( new Period( new YearlyPeriodType(), getDate( 2001, 1, 1 ), getDate( 2001, 12, 31 ) ) ) );
         
-        assertEquals( 66, relatives.size() );
+        assertEquals( 67, relatives.size() );
     }
     
     @Test

=== 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-11-21 12:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/DataMartExportStoreTest.java	2011-12-19 19:58:47 +0000
@@ -134,7 +134,7 @@
         periods.add( periodA );
         periods.add( periodB );
         
-        relatives = new RelativePeriods( true, true, true, true, true, true, false, false, false, false, false, false, false, false );
+        relatives = new RelativePeriods( true, true, true, true, true, true, true, false, false, false, false, false, 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-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-11-21 12:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java	2011-12-19 19:58:47 +0000
@@ -206,7 +206,7 @@
     {
         DataMartExport export = id == null ? new DataMartExport() : dataMartService.getDataMartExport( id );
 
-        RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter,
+        RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter, false,
             monthsThisYear, quartersThisYear, thisYear, 
             monthsLastYear, quartersLastYear, lastYear, false, false, false, false, false );
           

=== 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-11-21 12:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java	2011-12-19 19:58:47 +0000
@@ -274,6 +274,13 @@
     {
         this.reportingQuarter = reportingQuarter;
     }
+    
+    private boolean lastSixMonth;
+
+    public void setLastSixMonth( boolean lastSixMonth )
+    {
+        this.lastSixMonth = lastSixMonth;
+    }
 
     private boolean monthsThisYear;
 
@@ -374,7 +381,7 @@
         chart.setPeriods( periods );
         chart.setOrganisationUnits( organisationUnits );
 
-        RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter,
+        RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter, lastSixMonth,
             monthsThisYear, quartersThisYear, thisYear, monthsLastYear, quartersLastYear, lastYear, false, false, false, false, false );
 
         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-11-21 12:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2011-12-19 19:58:47 +0000
@@ -235,6 +235,13 @@
         this.reportingQuarter = reportingQuarter;
     }
 
+    private boolean lastSixMonth;
+
+    public void setLastSixMonth( boolean lastSixMonth )
+    {
+        this.lastSixMonth = lastSixMonth;
+    }
+
     private boolean monthsThisYear;
 
     public void setMonthsThisYear( boolean monthsThisYear )
@@ -383,7 +390,7 @@
         
         DataElementCategoryCombo categoryCombo = categoryComboId != null ? categoryService.getDataElementCategoryCombo( categoryComboId ) : null;
         
-        RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter,
+        RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter, lastSixMonth,
             monthsThisYear, quartersThisYear, thisYear, 
             monthsLastYear, quartersLastYear, lastYear, 
             last5years, last12Months, false, last4Quarters, false );