dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20645
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9552: Added last 4 weeks and last 12 weeks to relative periods object
------------------------------------------------------------
revno: 9552
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-01-18 11:23:47 +0100
message:
Added last 4 weeks and last 12 weeks to relative periods object
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
--
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 2012-09-23 14:24:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java 2013-01-18 10:23:47 +0000
@@ -189,6 +189,10 @@
private boolean last5FinancialYears = false;
+ private boolean last4Weeks = false;
+
+ private boolean last12Weeks = false;
+
private boolean last52Weeks = false;
// -------------------------------------------------------------------------
@@ -220,7 +224,8 @@
boolean monthsThisYear, boolean quartersThisYear, boolean thisYear,
boolean monthsLastYear, boolean quartersLastYear, boolean lastYear, boolean last5Years,
boolean last12Months, boolean last3Months, boolean last6BiMonths, boolean last4Quarters, boolean last2SixMonths,
- boolean thisFinancialYear, boolean lastFinancialYear, boolean last5FinancialYears, boolean last52Weeks )
+ boolean thisFinancialYear, boolean lastFinancialYear, boolean last5FinancialYears,
+ boolean last4Weeks, boolean last12Weeks, boolean last52Weeks )
{
this.reportingMonth = reportingMonth;
this.reportingBimonth = reportingBimonth;
@@ -241,6 +246,8 @@
this.thisFinancialYear = thisFinancialYear;
this.lastFinancialYear = lastFinancialYear;
this.last5FinancialYears = last5FinancialYears;
+ this.last4Weeks = last4Weeks;
+ this.last12Weeks = last12Weeks;
this.last52Weeks = last52Weeks;
}
@@ -272,6 +279,8 @@
this.thisFinancialYear = false;
this.lastFinancialYear = false;
this.last5FinancialYears = false;
+ this.last4Weeks = false;
+ this.last12Weeks = false;
this.last52Weeks = false;
return this;
@@ -501,6 +510,16 @@
periods.addAll( getRollingRelativePeriodList( new FinancialJulyPeriodType(), LAST_5_FINANCIAL_YEARS, date, dynamicNames, format ) );
}
+ if ( isLast4Weeks() )
+ {
+ periods.addAll( getRollingRelativePeriodList( new WeeklyPeriodType(), WEEKS_LAST_52, date, dynamicNames, format ).subList( 48, 52 ) );
+ }
+
+ if ( isLast12Weeks() )
+ {
+ periods.addAll( getRollingRelativePeriodList( new WeeklyPeriodType(), WEEKS_LAST_52, date, dynamicNames, format ).subList( 40, 52 ) );
+ }
+
if ( isLast52Weeks() )
{
periods.addAll( getRollingRelativePeriodList( new WeeklyPeriodType(), WEEKS_LAST_52, date, dynamicNames, format ) );
@@ -959,6 +978,30 @@
@JsonProperty
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public boolean isLast4Weeks()
+ {
+ return last4Weeks;
+ }
+
+ public void setLast4Weeks( boolean last4Weeks )
+ {
+ this.last4Weeks = last4Weeks;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public boolean isLast12Weeks()
+ {
+ return last12Weeks;
+ }
+
+ public void setLast12Weeks( boolean last12Weeks )
+ {
+ this.last12Weeks = last12Weeks;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public boolean isLast52Weeks()
{
return last52Weeks;
@@ -1000,6 +1043,8 @@
result = prime * result + (thisFinancialYear ? 1 : 0);
result = prime * result + (lastFinancialYear ? 1 : 0);
result = prime * result + (last5FinancialYears ? 1 : 0);
+ result = prime * result + (last4Weeks ? 1 : 0);
+ result = prime * result + (last12Weeks ? 1 : 0);
result = prime * result + (last52Weeks ? 1 : 0);
return result;
@@ -1120,6 +1165,16 @@
return false;
}
+ if ( !last4Weeks == other.last4Weeks )
+ {
+ return false;
+ }
+
+ if ( !last12Weeks == other.last12Weeks )
+ {
+ return false;
+ }
+
if ( !last52Weeks == other.last52Weeks )
{
return false;
=== 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 2013-01-14 16:10:34 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java 2013-01-18 10:23:47 +0000
@@ -60,11 +60,11 @@
@Test
public void getRelativePeriods()
{
- RelativePeriods periods = new RelativePeriods( true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true );
+ RelativePeriods periods = new RelativePeriods( true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true );
List<Period> relatives = periods.getRelativePeriods( getDate( 2001, 1, 1 ), i18nFormat, false );
- assertEquals( 126, relatives.size() );
+ assertEquals( 142, relatives.size() );
assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2001, 1, 1 ), getDate( 2001, 1, 31 ) ) ) );
assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2001, 2, 1 ), getDate( 2001, 2, 28 ) ) ) );
assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2001, 3, 1 ), getDate( 2001, 3, 31 ) ) ) );