use of org.activityinfo.shared.command.Month in project activityinfo by bedatadriven.
the class MonthlyGrid method updateMonthColumns.
/**
* Updates the month headers based on the given start month
*/
public void updateMonthColumns(Month startMonth) {
DateTimeFormat monthFormat = DateTimeFormat.getFormat("MMM yy");
Month month = startMonth;
for (int i = 0; i != MONTHS_TO_SHOW; ++i) {
DateWrapper date = new DateWrapper(month.getYear(), month.getMonth() - 1, 1);
getColumnModel().setColumnHeader(i + 1, monthFormat.format(date.asDate()));
getColumnModel().setDataIndex(i + 1, IndicatorRowDTO.propertyName(month));
month = month.next();
}
}
use of org.activityinfo.shared.command.Month in project activityinfo by bedatadriven.
the class HandlerUtil method monthFromRange.
static Month monthFromRange(Date date1, Date date2) {
Calendar c1 = Calendar.getInstance();
c1.setTime(date1);
if (c1.get(Calendar.DAY_OF_MONTH) != 1) {
return null;
}
Calendar c2 = Calendar.getInstance();
c2.setTime(date2);
if (c2.get(Calendar.DAY_OF_MONTH) != c2.getActualMaximum(Calendar.DAY_OF_MONTH)) {
return null;
}
if (c2.get(Calendar.MONTH) != c1.get(Calendar.MONTH) || c2.get(Calendar.YEAR) != c2.get(Calendar.YEAR)) {
return null;
}
return new Month(c1.get(Calendar.YEAR), c1.get(Calendar.MONTH) + 1);
}
use of org.activityinfo.shared.command.Month in project activityinfo by bedatadriven.
the class MonthlyReportsTest method testGetReports.
@Test
public void testGetReports() throws Exception {
GetMonthlyReports cmd = new GetMonthlyReports(6);
cmd.setStartMonth(new Month(2009, 1));
cmd.setEndMonth(new Month(2009, 2));
MonthlyReportResult result = execute(cmd);
Assert.assertEquals(1, result.getData().size());
Assert.assertEquals(35, result.getData().get(0).getValue(2009, 1).intValue());
Assert.assertEquals(70, result.getData().get(0).getValue(2009, 2).intValue());
}
Aggregations