use of org.activityinfo.shared.report.model.DateRange in project activityinfo by bedatadriven.
the class DateUtilCalendarImpl method monthRange.
@Override
public DateRange monthRange(int year, int month) {
DateRange range = new DateRange();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DATE, 1);
range.setMinDate(calendar.getTime());
calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
range.setMaxDate(calendar.getTime());
return range;
}
use of org.activityinfo.shared.report.model.DateRange in project activityinfo by bedatadriven.
the class ReportGeneratorTest method testFileName.
@Test
public void testFileName() {
// Input user
User user = new User();
user.setLocale("en");
// Input test data: report model + parameter
Report report = new Report();
report.setFileName("Report ${DATE_RANGE} of Activities");
// Input test data: parameter values
DateUtil dateUtil = new DateUtilCalendarImpl();
DateRange dateRange = dateUtil.monthRange(2009, 1);
// class under test
ReportGenerator generator = new ReportGenerator(null, null, null, null, null);
generator.generate(user, report, null, dateRange);
// VERIFY correct file name
Assert.assertEquals("Report Jan 2009 of Activities", report.getContent().getFileName());
}
use of org.activityinfo.shared.report.model.DateRange in project activityinfo by bedatadriven.
the class PivotSitesHandlerLocalTest method testTargetPivot.
/**
* year, quarter and month functions in SqliteDialect throw java.lang.UnsupportedOperationException
*/
@Test(expected = RuntimeException.class)
@OnDataSet("/dbunit/sites-simple-target.db.xml")
public void testTargetPivot() {
withIndicatorAsDimension();
dimensions.add(new DateDimension(DateUnit.YEAR));
dimensions.add(new Dimension(DimensionType.Target));
filter.addRestriction(DimensionType.Indicator, 1);
filter.setDateRange(new DateRange(new LocalDate(2008, 1, 1), new LocalDate(2008, 12, 31)));
execute();
assertThat().thereAre(2).buckets();
}
use of org.activityinfo.shared.report.model.DateRange in project activityinfo by bedatadriven.
the class DateFilterMenu method addQuarterRange.
private void addQuarterRange(int year, int quarter) {
DateWrapper from = new DateWrapper(year, quarter * 3, 1);
DateWrapper to = from.addMonths(3).addDays(-1);
addFixedRange(I18N.MESSAGES.quarter(year, (quarter + 1)), new DateRange(from.asDate(), to.asDate()));
}
use of org.activityinfo.shared.report.model.DateRange in project activityinfo by bedatadriven.
the class DateFilterMenu method addYearRange.
private void addYearRange(int yearsAgo) {
int year = new DateWrapper().getFullYear() - yearsAgo;
DateWrapper from = new DateWrapper(year, 0, 1);
DateWrapper to = new DateWrapper(year, 11, 31);
addFixedRange(Integer.toString(year), new DateRange(from.asDate(), to.asDate()));
}
Aggregations