use of org.activityinfo.legacy.shared.reports.model.DateRange in project activityinfo by bedatadriven.
the class ReportMailer method execute.
@Timed(name = "mail.report")
public void execute(Date today, ReportSubscription sub, Report report) throws IOException {
// set up authentication for the subscriber of this report
authProvider.set(sub.getUser());
// render the report to a temp file
// generate the report
reportGenerator.generate(sub.getUser(), report, null, new DateRange());
ByteArrayOutputStream rtf = new ByteArrayOutputStream();
rtfReportRenderer.render(report, rtf);
rtf.close();
try {
mailReport(sub, report, today, rtf.toByteArray());
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Report mailing of " + sub.getTemplate().getId() + " failed for user " + sub.getUser().getEmail(), e);
}
}
use of org.activityinfo.legacy.shared.reports.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.legacy.shared.reports.model.DateRange in project activityinfo by bedatadriven.
the class DateUtilCalendarImplTest method lastCompleteMonth.
@Test
public void lastCompleteMonth() {
Calendar fifth = Calendar.getInstance();
fifth.set(2011, Calendar.MAY, 5);
DateRange range = util.lastCompleteMonthRange(fifth.getTime());
assertThat(range.getMinDate().getDate(), equalTo(1));
assertThat(range.getMaxDate().getDate(), equalTo(30));
}
use of org.activityinfo.legacy.shared.reports.model.DateRange in project activityinfo by bedatadriven.
the class DateUtilGWTImpl method monthRange.
@Override
public DateRange monthRange(int year, int month) {
DateRange range = new DateRange();
DateWrapper date = new DateWrapper(year, month - 1, 1);
range.setMinDate(date.asDate());
date = date.addMonths(1);
date = date.addDays(-1);
range.setMaxDate(date.asDate());
return range;
}
use of org.activityinfo.legacy.shared.reports.model.DateRange in project activityinfo by bedatadriven.
the class GenerateDashboardElementHandler method execute.
@Override
public CommandResult execute(GenerateDashboardElement cmd, User user) throws CommandException {
ReportDTO report = dispatcher.execute(new GetReportModel(cmd.getReportId()));
if (report.getReport().getElements().isEmpty()) {
return new TextReportElement("The report is empty");
} else {
ReportElement element = report.getReport().getElements().get(0);
element.setContent(generator.generateElement(user, element, null, new DateRange()));
return element;
}
}
Aggregations