Search in sources :

Example 11 with DateRange

use of org.activityinfo.legacy.shared.reports.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.legacy.shared.reports.model.DateRange) Calendar(java.util.Calendar)

Example 12 with DateRange

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

the class RenderElementHandler method execute.

@Override
public CommandResult execute(RenderElement cmd, User user) throws CommandException {
    try {
        Renderer renderer = rendererFactory.get(cmd.getFormat());
        GeneratedResource storage = storageProvider.create(renderer.getMimeType(), cmd.getFilename() + renderer.getFileSuffix());
        LOGGER.fine("Rendering element: " + cmd + "\nURL: " + storage.getDownloadUri());
        try (OutputStream out = storage.openOutputStream()) {
            generator.generateElement(user, cmd.getElement(), new Filter(), new DateRange());
            renderer.render(cmd.getElement(), out);
        }
        return new UrlResult(storage.getDownloadUri());
    } catch (Exception e) {
        throw new RuntimeException("Exception generating export", e);
    }
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) Filter(org.activityinfo.legacy.shared.command.Filter) OutputStream(java.io.OutputStream) Renderer(org.activityinfo.server.report.renderer.Renderer) GeneratedResource(org.activityinfo.server.generated.GeneratedResource) UrlResult(org.activityinfo.legacy.shared.command.result.UrlResult) CommandException(org.activityinfo.legacy.shared.exception.CommandException)

Example 13 with DateRange

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

Example 14 with DateRange

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

the class DateRangeDialog method onButtonPressed.

@Override
protected void onButtonPressed(Button button) {
    if (button.getItemId().equals("ok")) {
        if (callback != null) {
            callback.onSelected(new DateRange(date1.getValue(), date2.getValue()));
        }
    }
    this.callback = null;
    hide();
}
Also used : DateRange(org.activityinfo.legacy.shared.reports.model.DateRange)

Example 15 with DateRange

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

the class EmptyChartsTest method generate.

@Test
public void generate() {
    PivotChartReportElement element = new PivotChartReportElement(Type.StackedBar);
    element.setIndicator(1);
    element.addCategoryDimension(new Dimension(DimensionType.Partner));
    element.addSeriesDimension(new Dimension(DimensionType.Database));
    DispatcherSync dispatcher = createMock(DispatcherSync.class);
    expect(dispatcher.execute(isA(PivotSites.class))).andReturn(new PivotSites.PivotResult(Collections.EMPTY_LIST));
    expect(dispatcher.execute(isA(GetDimensionLabels.class))).andReturn(new GetDimensionLabels.DimensionLabels(Collections.EMPTY_MAP));
    replay(dispatcher);
    IndicatorDAO indicatorDAO = createMock(IndicatorDAO.class);
    expect(indicatorDAO.findById(eq(1))).andReturn(new Indicator());
    replay(indicatorDAO);
    PivotChartGenerator generator = new PivotChartGenerator(dispatcher, indicatorDAO);
    generator.generate(new User(), element, new Filter(), new DateRange());
}
Also used : IndicatorDAO(org.activityinfo.server.database.hibernate.dao.IndicatorDAO) GetDimensionLabels(org.activityinfo.legacy.shared.command.GetDimensionLabels) User(org.activityinfo.server.database.hibernate.entity.User) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension) Indicator(org.activityinfo.server.database.hibernate.entity.Indicator) PivotSites(org.activityinfo.legacy.shared.command.PivotSites) DateRange(org.activityinfo.legacy.shared.reports.model.DateRange) Filter(org.activityinfo.legacy.shared.command.Filter) PivotChartGenerator(org.activityinfo.server.report.generator.PivotChartGenerator) PivotChartReportElement(org.activityinfo.legacy.shared.reports.model.PivotChartReportElement) DispatcherSync(org.activityinfo.server.command.DispatcherSync) Test(org.junit.Test)

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