Search in sources :

Example 6 with DateRange

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

Example 7 with DateRange

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

Example 8 with DateRange

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();
}
Also used : DateRange(org.activityinfo.shared.report.model.DateRange) Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) LocalDate(com.bedatadriven.rebar.time.calendar.LocalDate) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 9 with DateRange

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

Example 10 with DateRange

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

Aggregations

DateRange (org.activityinfo.shared.report.model.DateRange)17 Test (org.junit.Test)5 DateWrapper (com.extjs.gxt.ui.client.util.DateWrapper)4 Filter (org.activityinfo.shared.command.Filter)4 IOException (java.io.IOException)3 Calendar (java.util.Calendar)3 Dimension (org.activityinfo.shared.report.model.Dimension)3 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 Date (java.util.Date)2 OnDataSet (org.activityinfo.server.database.OnDataSet)2 User (org.activityinfo.server.database.hibernate.entity.User)2 Renderer (org.activityinfo.server.report.renderer.Renderer)2 CommandException (org.activityinfo.shared.exception.CommandException)2 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)2 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)2 DateDimension (org.activityinfo.shared.report.model.DateDimension)2 Report (org.activityinfo.shared.report.model.Report)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1