dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17346
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6862: Impl method getRollingPeriods for all PeriodTypes
------------------------------------------------------------
revno: 6862
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-05-04 18:36:15 +0200
message:
Impl method getRollingPeriods for all PeriodTypes
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.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/BiMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java 2012-04-05 11:57:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java 2012-05-04 16:36:15 +0000
@@ -108,8 +108,8 @@
}
/**
- * Generates quarterly Periods for the whole year in which the given
- * Period's startDate exists.
+ * Generates bimonthly Periods for the whole year in which the start date of
+ * the given Period exists.
*/
@Override
public List<Period> generatePeriods( Date date )
@@ -128,7 +128,12 @@
return periods;
}
-
+
+ /**
+ * Generates the last 6 bi-months where the last one is the bi-month
+ * which the given date is inside.
+ */
+ @Override
public List<Period> generateRollingPeriods( Date date )
{
Calendar cal = createCalendarInstance( date );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java 2012-02-12 17:57:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java 2012-05-04 16:36:15 +0000
@@ -99,6 +99,8 @@
*/
public abstract List<Period> generatePeriods( Date date );
+ public abstract List<Period> generateRollingPeriods( Date date );
+
/**
* Generates a list of Periods for the last 5 years. Must be overridden by
* CalendarPeriodTypes which do not generate periods for the current year
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java 2012-02-12 17:33:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java 2012-05-04 16:36:15 +0000
@@ -142,6 +142,27 @@
return periods;
}
+ /**
+ * Generates the last 365 days where the last one is the day of the given
+ * date.
+ */
+ @Override
+ public List<Period> generateRollingPeriods( Date date )
+ {
+ Calendar cal = createCalendarInstance( date );
+ cal.set( Calendar.DAY_OF_MONTH, -364 );
+
+ ArrayList<Period> periods = new ArrayList<Period>();
+
+ for ( int i = 0; i < 365; i++ )
+ {
+ periods.add( createPeriod( cal ) );
+ cal.add( Calendar.MONTH, 1 );
+ }
+
+ return periods;
+ }
+
@Override
public String getIsoDate( Period period )
{
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java 2012-04-20 07:38:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java 2012-05-04 16:36:15 +0000
@@ -111,7 +111,8 @@
}
/**
- * Generates YearlyPeriods for the last 5, current and next 5 years.
+ * Generates financial yearly periods for the last 5, current and next 5
+ * financial years.
*/
@Override
public List<Period> generatePeriods( Date date )
@@ -135,6 +136,16 @@
return periods;
}
+ /**
+ * Generates the last 5 financial years where the last one is the financial
+ * year which the given date is inside.
+ */
+ @Override
+ public List<Period> generateRollingPeriods( Date date )
+ {
+ return generateLast5Years( date );
+ }
+
@Override
public List<Period> generateLast5Years( Date date )
{
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2012-03-16 18:28:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2012-05-04 16:36:15 +0000
@@ -140,9 +140,10 @@
}
/**
- * Generates the last 12 months where the last one is the month
- * which the given date is inside.
+ * Generates the last 12 months where the last one is the month which the
+ * given date is inside.
*/
+ @Override
public List<Period> generateRollingPeriods( Date date )
{
Calendar cal = createCalendarInstance( date );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2012-03-16 18:28:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2012-05-04 16:36:15 +0000
@@ -142,9 +142,10 @@
}
/**
- * Generates the last 4 quarters where the last one is the quarter
- * which the given date is inside.
+ * Generates the last 4 quarters where the last one is the quarter which the
+ * given date is inside.
*/
+ @Override
public List<Period> generateRollingPeriods( Date date )
{
Calendar cal = createCalendarInstance( date );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java 2012-02-13 11:41:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java 2012-05-04 16:36:15 +0000
@@ -141,6 +141,11 @@
return periods;
}
+ /**
+ * Generates the last 2 six-months where the last one is the six-month
+ * which the given date is inside.
+ */
+ @Override
public List<Period> generateRollingPeriods( Date date )
{
Calendar cal = createCalendarInstance( date );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java 2012-04-05 11:57:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java 2012-05-04 16:36:15 +0000
@@ -156,6 +156,12 @@
}
@Override
+ public List<Period> generateRollingPeriods( Date date )
+ {
+ return generateLast5Years( date );
+ }
+
+ @Override
public List<Period> generateLast5Years( Date date )
{
Calendar cal = createCalendarInstance( date );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java 2012-05-04 12:02:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java 2012-05-04 16:36:15 +0000
@@ -155,9 +155,10 @@
}
/**
- * Generates the last 12 months where the last one is the month
- * which the given date is inside.
+ * Generates the last 52 weeks where the last one is the week which the
+ * given date is inside.
*/
+ @Override
public List<Period> generateRollingPeriods( Date date )
{
Calendar cal = createCalendarInstance( date );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java 2012-02-13 11:41:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java 2012-05-04 16:36:15 +0000
@@ -115,7 +115,7 @@
}
/**
- * Generates YearlyPeriods for the last 5, current and next 5 years.
+ * Generates yearly periods for the last 5, current and next 5 years.
*/
@Override
public List<Period> generatePeriods( Date date )
@@ -135,6 +135,20 @@
return periods;
}
+ /**
+ * Generates the last 5 years where the last one is the year which the given
+ * date is inside.
+ */
+ @Override
+ public List<Period> generateRollingPeriods( Date date )
+ {
+ return generateLast5Years( date );
+ }
+
+ /**
+ * Generates the last 5 years where the last one is the year which the given
+ * date is inside.
+ */
@Override
public List<Period> generateLast5Years( Date date )
{