Search in sources :

Example 1 with DateRange

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

Example 2 with DateRange

use of org.activityinfo.legacy.shared.reports.model.DateRange in project activityinfo by bedatadriven.

the class UpdateMonthlyReportsAsync method insertPeriod.

private Promise<Void> insertPeriod(SqlTransaction tx, int siteId, Integer periodId, Month month) {
    DateRange range = DateUtilGWTImpl.INSTANCE.monthRange(month);
    SqlInsert query = SqlInsert.insertInto(Tables.REPORTING_PERIOD).value("ReportingPeriodId", periodId).value("SiteId", siteId).value("Date1", range.getMinLocalDate()).value("Date2", range.getMaxLocalDate()).value("DateCreated", new Date()).value("DateEdited", new Date());
    return executeInsert(tx, query);
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) SqlInsert(com.bedatadriven.rebar.sql.client.query.SqlInsert) Date(java.util.Date)

Example 3 with DateRange

use of org.activityinfo.legacy.shared.reports.model.DateRange in project activityinfo by bedatadriven.

the class DateUtilGWTImpl method yearRange.

@Override
public DateRange yearRange(int year) {
    DateRange range = new DateRange();
    DateWrapper date = new DateWrapper(year, 0, 1);
    range.setMinDate(date.asDate());
    date = new DateWrapper(year, 11, 31);
    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 4 with DateRange

use of org.activityinfo.legacy.shared.reports.model.DateRange in project activityinfo by bedatadriven.

the class RenderReportHtmlHandler method execute.

@Override
public CommandResult execute(RenderReportHtml cmd, User user) throws CommandException {
    ReportElement model = cmd.getModel();
    LOGGER.fine("Model: " + model);
    // don't show the title: it will be rendered by the container
    model.setTitle(null);
    generator.generateElement(user, model, new Filter(), new DateRange());
    StringWriter writer = new StringWriter();
    try {
        renderer.render(model, writer);
    } catch (IOException e) {
        throw new CommandException(e);
    }
    return new HtmlResult(writer.toString());
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) StringWriter(java.io.StringWriter) Filter(org.activityinfo.legacy.shared.command.Filter) HtmlResult(org.activityinfo.legacy.shared.command.result.HtmlResult) ReportElement(org.activityinfo.legacy.shared.reports.model.ReportElement) IOException(java.io.IOException) CommandException(org.activityinfo.legacy.shared.exception.CommandException)

Example 5 with DateRange

use of org.activityinfo.legacy.shared.reports.model.DateRange in project activityinfo by bedatadriven.

the class DateUtilCalendarImpl method yearRange.

@Override
public DateRange yearRange(int year) {
    DateRange range = new DateRange();
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, 0);
    calendar.set(Calendar.DATE, 1);
    range.setMinDate(calendar.getTime());
    calendar.set(Calendar.MONTH, Calendar.DECEMBER);
    calendar.set(Calendar.DATE, 31);
    range.setMaxDate(calendar.getTime());
    return range;
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) Calendar(java.util.Calendar)

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