1
package org.hisp.dhis.reporttable;
4
* Copyright (c) 2004-2007, University of Oslo
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright notice, this
10
* list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright notice,
12
* this list of conditions and the following disclaimer in the documentation
13
* and/or other materials provided with the distribution.
14
* * Neither the name of the HISP project nor the names of its contributors may
15
* be used to endorse or promote products derived from this software without
16
* specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
import java.io.Serializable;
33
* @author Lars Helge Overland
36
public class RelativePeriods
37
implements Serializable
39
public static final String REPORTING_MONTH = "reporting_month";
40
public static final String LAST_3_MONTHS = "last3_months";
41
public static final String LAST_6_MONTHS = "last6_months";
42
public static final String LAST_9_MONTHS = "last9_months";
43
public static final String LAST_12_MONTHS = "last12_months";
44
public static final String SO_FAR_THIS_YEAR = "so_far_this_year";
45
public static final String SO_FAR_THIS_FINANCIAL_YEAR = "so_far_this_financial_year";
46
public static final String LAST_3_TO_6_MONTHS = "last3_6_months";
47
public static final String LAST_6_TO_9_MONTHS = "last6_9_months";
48
public static final String LAST_9_TO_12_MONTHS = "last9_12_months";
50
public static final String[] PREVIOUS_MONTH_NAMES = {
62
"previous_month_12" };
64
public static final String[] MONTHS_THIS_YEAR = {
78
public static final String[] QUARTERS_THIS_YEAR = {
84
private Boolean reportingMonth;
86
private Boolean last3Months;
88
private Boolean last6Months;
90
private Boolean last9Months;
92
private Boolean last12Months;
94
private Boolean soFarThisYear;
96
private Boolean soFarThisFinancialYear;
98
private Boolean last3To6Months;
100
private Boolean last6To9Months;
102
private Boolean last9To12Months;
104
private Boolean last12IndividualMonths;
106
private Boolean individualMonthsThisYear;
108
private Boolean individualQuartersThisYear;
110
// -------------------------------------------------------------------------
112
// -------------------------------------------------------------------------
114
public RelativePeriods()
118
public RelativePeriods( boolean reportingMonth, boolean last3Months,
119
boolean last6Months, boolean last9Months, boolean last12Months, boolean soFarThisYear, boolean soFarThisFinancialYear,
120
boolean last3To6Months, boolean last6To9Months, boolean last9To12Months,
121
boolean last12IndividualMonths, boolean individualMonthsThisYear, boolean individualQuartersThisYear )
123
this.reportingMonth = reportingMonth;
124
this.last3Months = last3Months;
125
this.last6Months = last6Months;
126
this.last9Months = last9Months;
127
this.last12Months = last12Months;
128
this.soFarThisYear = soFarThisYear;
129
this.soFarThisFinancialYear = soFarThisFinancialYear;
130
this.last3To6Months = last3To6Months;
131
this.last6To9Months = last6To9Months;
132
this.last9To12Months = last9To12Months;
133
this.last12IndividualMonths = last12IndividualMonths;
134
this.individualMonthsThisYear = individualMonthsThisYear;
135
this.individualQuartersThisYear = individualQuartersThisYear;
138
// -------------------------------------------------------------------------
140
// -------------------------------------------------------------------------
142
public boolean isReportingMonth()
144
return reportingMonth != null && reportingMonth;
147
public boolean isLast3Months()
149
return last3Months != null && last3Months;
152
public boolean isLast6Months()
154
return last6Months != null && last6Months;
157
public boolean isLast9Months()
159
return last9Months != null && last9Months;
162
public boolean isLast12Months()
164
return last12Months != null && last12Months;
167
public boolean isSoFarThisYear()
169
return soFarThisYear != null && soFarThisYear;
172
public boolean isSoFarThisFinancialYear()
174
return soFarThisFinancialYear != null && soFarThisFinancialYear;
177
public boolean isLast3To6Months()
179
return last3To6Months != null && last3To6Months;
182
public boolean isLast6To9Months()
184
return last6To9Months != null && last6To9Months;
187
public boolean isLast9To12Months()
189
return last9To12Months != null && last9To12Months;
192
public boolean isLast12IndividualMonths()
194
return last12IndividualMonths != null && last12IndividualMonths;
197
public boolean isIndividualMonthsThisYear()
199
return individualMonthsThisYear != null && individualMonthsThisYear;
202
public boolean isIndividualQuartersThisYear()
204
return individualQuartersThisYear != null && individualQuartersThisYear;
207
// -------------------------------------------------------------------------
209
// -------------------------------------------------------------------------
211
public Boolean getReportingMonth()
213
return reportingMonth;
216
public void setReportingMonth( Boolean reportingMonth )
218
this.reportingMonth = reportingMonth;
221
public Boolean getLast3Months()
226
public void setLast3Months( Boolean last3Months )
228
this.last3Months = last3Months;
231
public Boolean getLast6Months()
236
public void setLast6Months( Boolean last6Months )
238
this.last6Months = last6Months;
241
public Boolean getLast9Months()
246
public void setLast9Months( Boolean last9Months )
248
this.last9Months = last9Months;
251
public Boolean getLast12Months()
256
public void setLast12Months( Boolean last12Months )
258
this.last12Months = last12Months;
261
public Boolean getSoFarThisYear()
263
return soFarThisYear;
266
public void setSoFarThisYear( Boolean soFarThisYear )
268
this.soFarThisYear = soFarThisYear;
271
public Boolean getSoFarThisFinancialYear()
273
return soFarThisFinancialYear;
276
public void setSoFarThisFinancialYear( Boolean soFarThisFinancialYear )
278
this.soFarThisFinancialYear = soFarThisFinancialYear;
281
public Boolean getLast3To6Months()
283
return last3To6Months;
286
public void setLast3To6Months( Boolean last3To6Months )
288
this.last3To6Months = last3To6Months;
291
public Boolean getLast6To9Months()
293
return last6To9Months;
296
public void setLast6To9Months( Boolean last6To9Months )
298
this.last6To9Months = last6To9Months;
301
public Boolean getLast9To12Months()
303
return last9To12Months;
306
public void setLast9To12Months( Boolean last9To12Months )
308
this.last9To12Months = last9To12Months;
311
public Boolean getLast12IndividualMonths()
313
return last12IndividualMonths;
316
public void setLast12IndividualMonths( Boolean last12IndividualMonths )
318
this.last12IndividualMonths = last12IndividualMonths;
321
public Boolean getIndividualMonthsThisYear()
323
return individualMonthsThisYear;
326
public void setIndividualMonthsThisYear( Boolean individualMonthsThisYear )
328
this.individualMonthsThisYear = individualMonthsThisYear;
331
public Boolean getIndividualQuartersThisYear()
333
return individualQuartersThisYear;
336
public void setIndividualQuartersThisYear( Boolean individualQuartersThisYear )
338
this.individualQuartersThisYear = individualQuartersThisYear;
341
// -------------------------------------------------------------------------
342
// Equals, hashCode, and toString
343
// -------------------------------------------------------------------------
346
public String toString()
348
String toString = "[Reporting month: " + reportingMonth +
349
", Last 3 months: " + last3Months +
350
", Last 6 months: " + last6Months +
351
", Last 9 months: " + last9Months +
352
", Last 12 months: " + last12Months +
353
", So far this year: " + soFarThisYear +
354
", So far this financial year: " + soFarThisFinancialYear +
355
", Last 3 to 6 months: " + last3To6Months +
356
", Last 6 to 9 months: " + last6To9Months +
357
", Last 9 to 12 months: " + last9To12Months +
358
", Last 12 Individual months: " + last12IndividualMonths +
359
", Individual months this year: " + individualMonthsThisYear +
360
", Individual quarters this year: " + individualQuartersThisYear + "]";
366
public int hashCode()
368
final int prime = 31;
372
result = prime * result + ( ( last12Months == null ) ? 0 : last12Months.hashCode() );
373
result = prime * result + ( ( last3Months == null ) ? 0 : last3Months.hashCode() );
374
result = prime * result + ( ( last3To6Months == null ) ? 0 : last3To6Months.hashCode() );
375
result = prime * result + ( ( last6Months == null ) ? 0 : last6Months.hashCode() );
376
result = prime * result + ( ( last6To9Months == null ) ? 0 : last6To9Months.hashCode() );
377
result = prime * result + ( ( last9Months == null ) ? 0 : last9Months.hashCode() );
378
result = prime * result + ( ( last9To12Months == null ) ? 0 : last9To12Months.hashCode() );
379
result = prime * result + ( ( reportingMonth == null ) ? 0 : reportingMonth.hashCode() );
380
result = prime * result + ( ( soFarThisYear == null ) ? 0 : soFarThisYear.hashCode() );
381
result = prime * result + ( ( soFarThisFinancialYear == null ) ? 0 : soFarThisFinancialYear.hashCode() );
382
result = prime * result + ( ( last12IndividualMonths == null ) ? 0 : last12IndividualMonths.hashCode() );
383
result = prime * result + ( ( individualMonthsThisYear == null ) ? 0 : individualMonthsThisYear.hashCode() );
384
result = prime * result + ( ( individualQuartersThisYear == null ) ? 0 : individualQuartersThisYear.hashCode() );
390
public boolean equals( Object object )
392
if ( this == object )
397
if ( object == null )
402
if ( getClass() != object.getClass() )
407
final RelativePeriods other = (RelativePeriods) object;
409
if ( last12Months == null )
411
if ( other.last12Months != null )
416
else if ( !last12Months.equals( other.last12Months ) )
421
if ( last3Months == null )
423
if ( other.last3Months != null )
428
else if ( !last3Months.equals( other.last3Months ) )
433
if ( last3To6Months == null )
435
if ( other.last3To6Months != null )
440
else if ( !last3To6Months.equals( other.last3To6Months ) )
445
if ( last6Months == null )
447
if ( other.last6Months != null )
452
else if ( !last6Months.equals( other.last6Months ) )
457
if ( last6To9Months == null )
459
if ( other.last6To9Months != null )
464
else if ( !last6To9Months.equals( other.last6To9Months ) )
469
if ( last9Months == null )
471
if ( other.last9Months != null )
476
else if ( !last9Months.equals( other.last9Months ) )
481
if ( last9To12Months == null )
483
if ( other.last9To12Months != null )
488
else if ( !last9To12Months.equals( other.last9To12Months ) )
493
if ( reportingMonth == null )
495
if ( other.reportingMonth != null )
500
else if ( !reportingMonth.equals( other.reportingMonth ) )
505
if ( soFarThisYear == null )
507
if ( other.soFarThisYear != null )
512
else if ( !soFarThisYear.equals( other.soFarThisYear ) )
517
if ( soFarThisFinancialYear == null )
519
if ( other.soFarThisFinancialYear != null )
524
else if ( !soFarThisFinancialYear.equals( other.soFarThisFinancialYear ) )
529
if ( last12IndividualMonths == null )
531
if ( other.last12IndividualMonths != null )
536
else if ( !last12IndividualMonths.equals( other.last12IndividualMonths ) )
541
if ( individualMonthsThisYear == null )
543
if ( other.individualMonthsThisYear != null )
548
else if ( !individualMonthsThisYear.equals( other.individualMonthsThisYear ) )
553
if ( individualQuartersThisYear == null )
555
if ( other.individualQuartersThisYear != null )
560
else if ( !individualQuartersThisYear.equals( other.individualQuartersThisYear ) )