=== 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 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java 2015-04-08 22:57:51 +0000 @@ -138,7 +138,7 @@ Calendar cal = getCalendar(); dateTimeUnit.setDay( 1 ); - dateTimeUnit = cal.minusMonths( dateTimeUnit, (dateTimeUnit.getMonth() % 2) + 10 ); + dateTimeUnit = cal.minusMonths( dateTimeUnit, ( dateTimeUnit.getMonth() % 2 ) + 10 ); List periods = Lists.newArrayList(); @@ -154,7 +154,7 @@ @Override public String getIsoDate( DateTimeUnit dateTimeUnit ) { - return String.format( "%d%02dB", dateTimeUnit.getYear(), (dateTimeUnit.getMonth() + 1) / 2 ); + return String.format( "%d%02dB", dateTimeUnit.getYear(), ( dateTimeUnit.getMonth() + 1 ) / 2 ); } @Override === 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 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java 2015-04-08 22:57:51 +0000 @@ -138,7 +138,9 @@ public List generateRollingPeriods( Date date ) { - return generateRollingPeriods( createLocalDateUnitInstance( date ) ); + DateTimeUnit dateTime = createLocalDateUnitInstance( date ); + + return generateRollingPeriods( dateTime ); } public abstract List generateRollingPeriods( DateTimeUnit dateTimeUnit ); === 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 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2015-04-08 22:57:51 +0000 @@ -75,7 +75,7 @@ { DateTimeUnit start = new DateTimeUnit( dateTimeUnit ); - start.setMonth( ((dateTimeUnit.getMonth() - 1) - ((dateTimeUnit.getMonth() - 1) % 3)) + 1 ); + start.setMonth( ( ( dateTimeUnit.getMonth() - 1 ) - ( ( dateTimeUnit.getMonth() - 1 ) % 3 ) ) + 1 ); start.setDay( 1 ); DateTimeUnit end = new DateTimeUnit( start ); @@ -144,8 +144,8 @@ @Override public List generateRollingPeriods( Date date ) { - // get current quarter start date date = createPeriod( date ).getStartDate(); + return generateRollingPeriods( createLocalDateUnitInstance( date ) ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriodEnum.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriodEnum.java 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriodEnum.java 2015-04-08 22:57:51 +0000 @@ -34,9 +34,13 @@ public enum RelativePeriodEnum { + THIS_MONTH, LAST_MONTH, + THIS_BIMONTH, LAST_BIMONTH, + THIS_QUARTER, LAST_QUARTER, + THIS_SIX_MONTH, LAST_SIX_MONTH, MONTHS_THIS_YEAR, QUARTERS_THIS_YEAR, @@ -54,17 +58,19 @@ THIS_FINANCIAL_YEAR, LAST_FINANCIAL_YEAR, LAST_5_FINANCIAL_YEARS, + THIS_WEEK, LAST_WEEK, LAST_4_WEEKS, LAST_12_WEEKS, LAST_52_WEEKS; public static List OPTIONS = new ArrayList() { { - addAll( Arrays.asList( LAST_MONTH.toString(), LAST_BIMONTH.toString(), LAST_QUARTER.toString(), LAST_SIX_MONTH.toString(), + addAll( Arrays.asList( THIS_MONTH.toString(), LAST_MONTH.toString(), THIS_BIMONTH.toString(), LAST_BIMONTH.toString(), + THIS_QUARTER.toString(), LAST_QUARTER.toString(), THIS_SIX_MONTH.toString(), LAST_SIX_MONTH.toString(), MONTHS_THIS_YEAR.toString(), QUARTERS_THIS_YEAR.toString(), THIS_YEAR.toString(), MONTHS_LAST_YEAR.toString(), QUARTERS_LAST_YEAR.toString(), LAST_YEAR.toString(), LAST_5_YEARS.toString(), LAST_12_MONTHS.toString(), LAST_6_MONTHS.toString(), LAST_3_MONTHS.toString(), LAST_6_BIMONTHS.toString(), LAST_4_QUARTERS.toString(), LAST_2_SIXMONTHS.toString(), THIS_FINANCIAL_YEAR.toString(), LAST_FINANCIAL_YEAR.toString(), - LAST_5_FINANCIAL_YEARS.toString(), LAST_WEEK.toString(), LAST_4_WEEKS.toString(), LAST_12_WEEKS.toString(), LAST_52_WEEKS.toString() ) ); + LAST_5_FINANCIAL_YEARS.toString(), THIS_WEEK.toString(), LAST_WEEK.toString(), LAST_4_WEEKS.toString(), LAST_12_WEEKS.toString(), LAST_52_WEEKS.toString() ) ); } }; public static boolean contains( String relativePeriod ) === 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 2015-04-01 09:10:55 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/RelativePeriods.java 2015-04-08 22:57:51 +0000 @@ -149,12 +149,20 @@ private int id; + private boolean thisMonth = false; + private boolean lastMonth = false; + private boolean thisBimonth = false; + private boolean lastBimonth = false; + private boolean thisQuarter = false; + private boolean lastQuarter = false; + private boolean thisSixMonth = false; + private boolean lastSixMonth = false; private boolean monthsThisYear = false; @@ -189,6 +197,8 @@ private boolean last5FinancialYears = false; + private boolean thisWeek = false; + private boolean lastWeek = false; private boolean last4Weeks = false; @@ -206,9 +216,13 @@ } /** + * @param thisMonth this month * @param lastMonth last month + * @param thisBimonth this bi-month * @param lastBimonth last bi-month + * @param thisQuarter this quarter * @param lastQuarter last quarter + * @param thisSixMonth this six month * @param lastSixMonth last six month * @param monthsThisYear months this year * @param quartersThisYear quarters this year @@ -225,21 +239,27 @@ * @param thisFinancialYear this financial year * @param lastFinancialYear last financial year * @param last5FinancialYears last 5 financial years + * @param thisWeek this week * @param lastWeek last week * @param last4Weeks last 4 weeks * @param last12Weeks last 12 weeks * @param last52Weeks last 52 weeks */ - public RelativePeriods( boolean lastMonth, boolean lastBimonth, boolean lastQuarter, boolean lastSixMonth, + public RelativePeriods( boolean thisMonth, boolean lastMonth, boolean thisBimonth, boolean lastBimonth, + boolean thisQuarter, boolean lastQuarter, boolean thisSixMonth, boolean lastSixMonth, boolean monthsThisYear, boolean quartersThisYear, boolean thisYear, boolean monthsLastYear, boolean quartersLastYear, boolean lastYear, boolean last5Years, boolean last12Months, boolean last6Months, boolean last3Months, boolean last6BiMonths, boolean last4Quarters, boolean last2SixMonths, boolean thisFinancialYear, boolean lastFinancialYear, boolean last5FinancialYears, - boolean lastWeek, boolean last4Weeks, boolean last12Weeks, boolean last52Weeks ) + boolean thisWeek, boolean lastWeek, boolean last4Weeks, boolean last12Weeks, boolean last52Weeks ) { + this.thisMonth = thisMonth; this.lastMonth = lastMonth; + this.thisBimonth = thisBimonth; this.lastBimonth = lastBimonth; + this.thisQuarter = thisQuarter; this.lastQuarter = lastQuarter; + this.thisSixMonth = thisSixMonth; this.lastSixMonth = lastSixMonth; this.monthsThisYear = monthsThisYear; this.quartersThisYear = quartersThisYear; @@ -257,6 +277,7 @@ this.thisFinancialYear = thisFinancialYear; this.lastFinancialYear = lastFinancialYear; this.last5FinancialYears = last5FinancialYears; + this.thisWeek = thisWeek; this.lastWeek = lastWeek; this.last4Weeks = last4Weeks; this.last12Weeks = last12Weeks; @@ -272,9 +293,13 @@ */ public RelativePeriods clear() { + this.thisMonth = false; this.lastMonth = false; + this.thisBimonth = false; this.lastBimonth = false; + this.thisQuarter = false; this.lastQuarter = false; + this.thisSixMonth = false; this.lastSixMonth = false; this.monthsThisYear = false; this.quartersThisYear = false; @@ -292,6 +317,7 @@ this.thisFinancialYear = false; this.lastFinancialYear = false; this.last5FinancialYears = false; + this.thisWeek = false; this.lastWeek = false; this.last4Weeks = false; this.last12Weeks = false; @@ -315,27 +341,27 @@ */ public PeriodType getPeriodType() { - if ( isLastWeek() || isLast4Weeks() || isLast12Weeks() || isLast52Weeks() ) + if ( isThisWeek() || isLastWeek() || isLast4Weeks() || isLast12Weeks() || isLast52Weeks() ) { return PeriodType.getPeriodTypeByName( WeeklyPeriodType.NAME ); } - if ( isLastMonth() || isLast12Months() || isLast6Months() || isLast3Months() ) + if ( isThisMonth() || isLastMonth() || isLast12Months() || isLast6Months() || isLast3Months() ) { return PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME ); } - if ( isLastBimonth() || isLast6BiMonths() ) + if ( isThisBimonth() || isLastBimonth() || isLast6BiMonths() ) { return PeriodType.getPeriodTypeByName( BiMonthlyPeriodType.NAME ); } - if ( isLastQuarter() || isLast4Quarters() ) + if ( isThisQuarter() || isLastQuarter() || isLast4Quarters() ) { return PeriodType.getPeriodTypeByName( QuarterlyPeriodType.NAME ); } - if ( isLastSixMonth() || isLast2SixMonths() ) + if ( isThisSixMonth() || isLastSixMonth() || isLast2SixMonths() ) { return PeriodType.getPeriodTypeByName( SixMonthlyPeriodType.NAME ); } @@ -458,24 +484,44 @@ List periods = new ArrayList<>(); + if ( isThisMonth() ) + { + periods.add( getRelativePeriod( new MonthlyPeriodType(), LAST_MONTH, date, dynamicNames, format ) ); + } + if ( isLastMonth() ) { - periods.add( getRelativePeriod( new MonthlyPeriodType(), LAST_MONTH, date, dynamicNames, format ) ); + periods.add( getRelativePeriod( new MonthlyPeriodType(), LAST_MONTH, new DateTime( date ).minusMonths( 1 ).toDate(), dynamicNames, format ) ); + } + + if ( isThisBimonth() ) + { + periods.add( getRelativePeriod( new BiMonthlyPeriodType(), LAST_BIMONTH, date, dynamicNames, format ) ); } if ( isLastBimonth() ) { - periods.add( getRelativePeriod( new BiMonthlyPeriodType(), LAST_BIMONTH, date, dynamicNames, format ) ); + periods.add( getRelativePeriod( new BiMonthlyPeriodType(), LAST_BIMONTH, new DateTime( date ).minusMonths( 2 ).toDate(), dynamicNames, format ) ); + } + + if ( isThisQuarter() ) + { + periods.add( getRelativePeriod( new QuarterlyPeriodType(), LAST_QUARTER, date, dynamicNames, format ) ); } if ( isLastQuarter() ) { - periods.add( getRelativePeriod( new QuarterlyPeriodType(), LAST_QUARTER, date, dynamicNames, format ) ); + periods.add( getRelativePeriod( new QuarterlyPeriodType(), LAST_QUARTER, new DateTime( date ).minusMonths( 3 ).toDate(), dynamicNames, format ) ); + } + + if ( isThisSixMonth() ) + { + periods.add( getRelativePeriod( new SixMonthlyPeriodType(), LAST_SIXMONTH, date, dynamicNames, format ) ); } if ( isLastSixMonth() ) { - periods.add( getRelativePeriod( new SixMonthlyPeriodType(), LAST_SIXMONTH, date, dynamicNames, format ) ); + periods.add( getRelativePeriod( new SixMonthlyPeriodType(), LAST_SIXMONTH, new DateTime( date ).minusMonths( 6 ).toDate(), dynamicNames, format ) ); } if ( isMonthsThisYear() ) @@ -538,6 +584,11 @@ periods.addAll( getRollingRelativePeriodList( new FinancialOctoberPeriodType(), LAST_5_FINANCIAL_YEARS, date, dynamicNames, format ) ); } + if ( isThisWeek() ) + { + periods.add( getRelativePeriod( new WeeklyPeriodType(), LAST_WEEK, new DateTime( date ).minusWeeks( 1 ).toDate(), dynamicNames, format ) ); + } + if ( isLastWeek() ) { periods.add( getRelativePeriod( new WeeklyPeriodType(), LAST_WEEK, date, dynamicNames, format ) ); @@ -705,10 +756,14 @@ public static List getRelativePeriodsFromEnum( RelativePeriodEnum relativePeriod, Date date, I18nFormat format, boolean dynamicNames ) { Map map = new HashMap<>(); - + + map.put( RelativePeriodEnum.THIS_MONTH, new RelativePeriods().setThisMonth( true ) ); map.put( RelativePeriodEnum.LAST_MONTH, new RelativePeriods().setLastMonth( true ) ); + map.put( RelativePeriodEnum.THIS_BIMONTH, new RelativePeriods().setThisBimonth( true ) ); map.put( RelativePeriodEnum.LAST_BIMONTH, new RelativePeriods().setLastBimonth( true ) ); + map.put( RelativePeriodEnum.THIS_QUARTER, new RelativePeriods().setThisQuarter( true ) ); map.put( RelativePeriodEnum.LAST_QUARTER, new RelativePeriods().setLastQuarter( true ) ); + map.put( RelativePeriodEnum.THIS_SIX_MONTH, new RelativePeriods().setThisSixMonth( true ) ); map.put( RelativePeriodEnum.LAST_SIX_MONTH, new RelativePeriods().setLastSixMonth( true ) ); map.put( RelativePeriodEnum.MONTHS_THIS_YEAR, new RelativePeriods().setMonthsThisYear( true ) ); map.put( RelativePeriodEnum.QUARTERS_THIS_YEAR, new RelativePeriods().setQuartersThisYear( true ) ); @@ -726,6 +781,7 @@ map.put( RelativePeriodEnum.THIS_FINANCIAL_YEAR, new RelativePeriods().setThisFinancialYear( true ) ); map.put( RelativePeriodEnum.LAST_FINANCIAL_YEAR, new RelativePeriods().setLastFinancialYear( true ) ); map.put( RelativePeriodEnum.LAST_5_FINANCIAL_YEARS, new RelativePeriods().setLast5FinancialYears( true ) ); + map.put( RelativePeriodEnum.THIS_WEEK, new RelativePeriods().setThisWeek( true ) ); map.put( RelativePeriodEnum.LAST_WEEK, new RelativePeriods().setLastWeek( true ) ); map.put( RelativePeriodEnum.LAST_4_WEEKS, new RelativePeriods().setLast4Weeks( true ) ); map.put( RelativePeriodEnum.LAST_12_WEEKS, new RelativePeriods().setLast12Weeks( true ) ); @@ -742,10 +798,14 @@ public List getRelativePeriodEnums() { List list = new ArrayList<>(); - + + add( list, RelativePeriodEnum.THIS_MONTH, thisMonth ); add( list, RelativePeriodEnum.LAST_MONTH, lastMonth ); + add( list, RelativePeriodEnum.THIS_BIMONTH, thisBimonth ); add( list, RelativePeriodEnum.LAST_BIMONTH, lastBimonth ); + add( list, RelativePeriodEnum.THIS_QUARTER, thisQuarter ); add( list, RelativePeriodEnum.LAST_QUARTER, lastQuarter ); + add( list, RelativePeriodEnum.THIS_SIX_MONTH, thisSixMonth ); add( list, RelativePeriodEnum.LAST_SIX_MONTH, lastSixMonth ); add( list, RelativePeriodEnum.MONTHS_THIS_YEAR, monthsThisYear ); add( list, RelativePeriodEnum.QUARTERS_THIS_YEAR, quartersThisYear ); @@ -763,6 +823,7 @@ add( list, RelativePeriodEnum.THIS_FINANCIAL_YEAR, thisFinancialYear ); add( list, RelativePeriodEnum.LAST_FINANCIAL_YEAR, lastFinancialYear ); add( list, RelativePeriodEnum.LAST_5_FINANCIAL_YEARS, last5FinancialYears ); + add( list, RelativePeriodEnum.THIS_WEEK, thisWeek ); add( list, RelativePeriodEnum.LAST_WEEK, lastWeek ); add( list, RelativePeriodEnum.LAST_4_WEEKS, last4Weeks ); add( list, RelativePeriodEnum.LAST_12_WEEKS, last12Weeks ); @@ -775,9 +836,13 @@ { if ( relativePeriods != null ) { + thisMonth = relativePeriods.contains( RelativePeriodEnum.THIS_MONTH ); lastMonth = relativePeriods.contains( RelativePeriodEnum.LAST_MONTH ); + thisBimonth = relativePeriods.contains( RelativePeriodEnum.THIS_BIMONTH ); lastBimonth = relativePeriods.contains( RelativePeriodEnum.LAST_BIMONTH ); + thisQuarter = relativePeriods.contains( RelativePeriodEnum.THIS_QUARTER ); lastQuarter = relativePeriods.contains( RelativePeriodEnum.LAST_QUARTER ); + thisSixMonth = relativePeriods.contains( RelativePeriodEnum.THIS_SIX_MONTH ); lastSixMonth = relativePeriods.contains( RelativePeriodEnum.LAST_SIX_MONTH ); monthsThisYear = relativePeriods.contains( RelativePeriodEnum.MONTHS_THIS_YEAR ); quartersThisYear = relativePeriods.contains( RelativePeriodEnum.QUARTERS_THIS_YEAR ); @@ -795,6 +860,7 @@ thisFinancialYear = relativePeriods.contains( RelativePeriodEnum.THIS_FINANCIAL_YEAR ); lastFinancialYear = relativePeriods.contains( RelativePeriodEnum.LAST_FINANCIAL_YEAR ); last5FinancialYears = relativePeriods.contains( RelativePeriodEnum.LAST_5_FINANCIAL_YEARS ); + thisWeek = relativePeriods.contains( RelativePeriodEnum.THIS_WEEK ); lastWeek = relativePeriods.contains( RelativePeriodEnum.LAST_WEEK ); last4Weeks = relativePeriods.contains( RelativePeriodEnum.LAST_4_WEEKS ); last12Weeks = relativePeriods.contains( RelativePeriodEnum.LAST_12_WEEKS ); @@ -826,7 +892,20 @@ this.id = id; } - @JsonProperty( value = "lastMonth" ) + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) + public boolean isThisMonth() + { + return thisMonth; + } + + public RelativePeriods setThisMonth( boolean thisMonth ) + { + this.thisMonth = thisMonth; + return this; + } + + @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) public boolean isLastMonth() { @@ -839,7 +918,20 @@ return this; } - @JsonProperty( value = "lastBimonth" ) + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) + public boolean isThisBimonth() + { + return thisBimonth; + } + + public RelativePeriods setThisBimonth( boolean thisBimonth ) + { + this.thisBimonth = thisBimonth; + return this; + } + + @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) public boolean isLastBimonth() { @@ -852,7 +944,20 @@ return this; } - @JsonProperty( value = "lastQuarter" ) + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) + public boolean isThisQuarter() + { + return thisQuarter; + } + + public RelativePeriods setThisQuarter( boolean thisQuarter ) + { + this.thisQuarter = thisQuarter; + return this; + } + + @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) public boolean isLastQuarter() { @@ -867,6 +972,19 @@ @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) + public boolean isThisSixMonth() + { + return thisSixMonth; + } + + public RelativePeriods setThisSixMonth( boolean thisSixMonth ) + { + this.thisSixMonth = thisSixMonth; + return this; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) public boolean isLastSixMonth() { return lastSixMonth; @@ -1088,6 +1206,19 @@ @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) + public boolean isThisWeek() + { + return thisWeek; + } + + public RelativePeriods setThisWeek( boolean thisWeek ) + { + this.thisWeek = thisWeek; + return this; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0) public boolean isLastWeek() { return lastWeek; === 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 2015-03-26 20:17:08 +0000 +++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java 2015-04-08 22:57:51 +0000 @@ -56,11 +56,11 @@ @Test public void getRelativePeriods() { - RelativePeriods periods = new RelativePeriods( true, true, true, true, true, true, true, true, true, true, true, true, true, false, 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, true, true, true, true, true, true, true, true, true, true, true, true, true, true ); List relatives = periods.getRelativePeriods( getDate( 2001, 1, 1 ), i18nFormat, false ); - assertEquals( 149, relatives.size() ); + assertEquals( 157, 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 ) ) ) ); @@ -89,7 +89,7 @@ assertTrue( relatives.contains( new Period( new SixMonthlyPeriodType(), getDate( 2000, 7, 1 ), getDate( 2000, 12, 31 ) ) ) ); assertTrue( relatives.contains( new Period( new SixMonthlyPeriodType(), getDate( 2001, 1, 1 ), getDate( 2001, 6, 30 ) ) ) ); - assertTrue( relatives.contains( new Period( new YearlyPeriodType(), getDate( 2001, 1, 1 ), getDate( 2001, 12, 31 ) ) ) ); + assertTrue( relatives.contains( new Period( new YearlyPeriodType(), getDate( 2000, 1, 1 ), getDate( 2000, 12, 31 ) ) ) ); assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2000, 1, 1 ), getDate( 2000, 1, 31 ) ) ) ); assertTrue( relatives.contains( new Period( new MonthlyPeriodType(), getDate( 2000, 2, 1 ), getDate( 2000, 2, 29 ) ) ) ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2015-04-07 21:30:38 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2015-04-08 22:57:51 +0000 @@ -676,11 +676,6 @@ executeSql( "ALTER TABLE report DROP CONSTRAINT report_name_key" ); executeSql( "ALTER TABLE usergroup DROP CONSTRAINT usergroup_name_key" ); - executeSql( "update relativeperiods set lastweek = false where lastweek is null" ); - executeSql( "update relativeperiods set last4weeks = false where last4weeks is null" ); - executeSql( "update relativeperiods set last12weeks = false where last12weeks is null" ); - executeSql( "update relativeperiods set last6months = false where last6months is null" ); - upgradeChartRelativePeriods(); upgradeReportTableRelativePeriods(); upgradeReportTables(); @@ -839,9 +834,20 @@ private void updateRelativePeriods() { - executeSql( "update relativeperiods set lastmonth=reportingmonth" ); - executeSql( "update relativeperiods set lastbimonth=reportingbimonth" ); - executeSql( "update relativeperiods set lastquarter=reportingquarter" ); + executeSql( "update relativeperiods set thismonth=reportingmonth" ); + executeSql( "update relativeperiods set thisbimonth=reportingbimonth" ); + executeSql( "update relativeperiods set thisquarter=reportingquarter" ); + + executeSql( "update relativeperiods set lastweek = false where lastweek is null" ); + executeSql( "update relativeperiods set last4weeks = false where last4weeks is null" ); + executeSql( "update relativeperiods set last12weeks = false where last12weeks is null" ); + executeSql( "update relativeperiods set last6months = false where last6months is null" ); + + executeSql( "update relativeperiods set thismonth = false where thismonth is null" ); + executeSql( "update relativeperiods set thisbimonth = false where thisbimonth is null" ); + executeSql( "update relativeperiods set thisquarter = false where thisquarter is null" ); + executeSql( "update relativeperiods set thissixmonth = false where thissixmonth is null" ); + executeSql( "update relativeperiods set thisweek = false where thisweek is null" ); } private void upgradeDataValuesWithAttributeOptionCombo() @@ -934,13 +940,13 @@ while ( rs.next() ) { - RelativePeriods r = new RelativePeriods( rs.getBoolean( "reportingmonth" ), false, - rs.getBoolean( "reportingquarter" ), rs.getBoolean( "lastsixmonth" ), + RelativePeriods r = new RelativePeriods( false, rs.getBoolean( "reportingmonth" ), false, false, + rs.getBoolean( "reportingquarter" ), false, rs.getBoolean( "lastsixmonth" ), false, rs.getBoolean( "monthsthisyear" ), rs.getBoolean( "quartersthisyear" ), rs.getBoolean( "thisyear" ), false, false, rs.getBoolean( "lastyear" ), rs.getBoolean( "last5years" ), rs.getBoolean( "last12months" ), false, rs.getBoolean( "last3months" ), false, rs.getBoolean( "last4quarters" ), rs.getBoolean( "last2sixmonths" ), false, false, false, - false, false, false, false ); + false, false, false, false, false ); int chartId = rs.getInt( "chartid" ); @@ -993,8 +999,8 @@ while ( rs.next() ) { - RelativePeriods r = new RelativePeriods( rs.getBoolean( "reportingmonth" ), - rs.getBoolean( "reportingbimonth" ), rs.getBoolean( "reportingquarter" ), + RelativePeriods r = new RelativePeriods( false, rs.getBoolean( "reportingmonth" ), false, false, + rs.getBoolean( "reportingbimonth" ), false, rs.getBoolean( "reportingquarter" ), rs.getBoolean( "lastsixmonth" ), rs.getBoolean( "monthsthisyear" ), rs.getBoolean( "quartersthisyear" ), rs.getBoolean( "thisyear" ), rs.getBoolean( "monthslastyear" ), rs.getBoolean( "quarterslastyear" ), @@ -1002,7 +1008,7 @@ rs.getBoolean( "last3months" ), false, rs.getBoolean( "last4quarters" ), rs.getBoolean( "last2sixmonths" ), rs.getBoolean( "thisfinancialyear" ), rs.getBoolean( "lastfinancialyear" ), rs.getBoolean( "last5financialyears" ), false, false, false, - false ); + false, false ); int reportTableId = rs.getInt( "reporttableid" ); === modified 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 2015-03-31 15:22:00 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/period/hibernate/RelativePeriods.hbm.xml 2015-04-08 22:57:51 +0000 @@ -12,9 +12,13 @@ + + + + @@ -34,6 +38,8 @@ + + === modified 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 2015-01-17 07:41:26 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/AbstractRelativePeriodsAction.java 2015-04-08 22:57:51 +0000 @@ -207,12 +207,12 @@ protected RelativePeriods getRelativePeriods() { - RelativePeriods relatives = new RelativePeriods( reportingMonth, reportingBimonth, reportingQuarter, lastSixMonth, + RelativePeriods relatives = new RelativePeriods( false, reportingMonth, false, reportingBimonth, false, reportingQuarter, false, lastSixMonth, monthsThisYear, quartersThisYear, thisYear, monthsLastYear, quartersLastYear, lastYear, last5Years, last12Months, last6Months, last3Months, last6BiMonths, last4Quarters, last2SixMonths, thisFinancialYear, lastFinancialYear, last5FinancialYears, - lastWeek, last4Weeks, last12Weeks, last52Weeks ); + false, lastWeek, last4Weeks, last12Weeks, last52Weeks ); return relatives; }