Search in sources :

Example 6 with DateRange

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);
    }
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MessagingException(javax.mail.MessagingException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) Timed(org.activityinfo.server.util.monitoring.Timed)

Example 7 with DateRange

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());
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) User(org.activityinfo.server.database.hibernate.entity.User) Report(org.activityinfo.legacy.shared.reports.model.Report) DateUtil(org.activityinfo.legacy.shared.reports.util.DateUtil) DateUtilCalendarImpl(org.activityinfo.server.report.util.DateUtilCalendarImpl) Test(org.junit.Test)

Example 8 with DateRange

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));
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) Calendar(java.util.Calendar) Test(org.junit.Test)

Example 9 with DateRange

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;
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) DateWrapper(com.extjs.gxt.ui.client.util.DateWrapper)

Example 10 with DateRange

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;
    }
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) GetReportModel(org.activityinfo.legacy.shared.command.GetReportModel) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO) ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement) TextReportElement(org.activityinfo.legacy.shared.reports.model.TextReportElement)

Aggregations

DateRange (org.activityinfo.legacy.shared.reports.model.DateRange)15 DateWrapper (com.extjs.gxt.ui.client.util.DateWrapper)4 Calendar (java.util.Calendar)3 Filter (org.activityinfo.legacy.shared.command.Filter)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 CommandException (org.activityinfo.legacy.shared.exception.CommandException)2 ReportElement (org.activityinfo.legacy.shared.reports.model.ReportElement)2 User (org.activityinfo.server.database.hibernate.entity.User)2 SqlInsert (com.bedatadriven.rebar.sql.client.query.SqlInsert)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 StringWriter (java.io.StringWriter)1 Date (java.util.Date)1 MessagingException (javax.mail.MessagingException)1 GetDimensionLabels (org.activityinfo.legacy.shared.command.GetDimensionLabels)1 GetReportModel (org.activityinfo.legacy.shared.command.GetReportModel)1 PivotSites (org.activityinfo.legacy.shared.command.PivotSites)1 HtmlResult (org.activityinfo.legacy.shared.command.result.HtmlResult)1 UrlResult (org.activityinfo.legacy.shared.command.result.UrlResult)1