Search in sources :

Example 11 with Month

use of org.activityinfo.shared.command.Month in project activityinfo by bedatadriven.

the class MonthlyGrid method updateMonthColumns.

/**
 * Updates the month headers based on the given start month
 */
public void updateMonthColumns(Month startMonth) {
    DateTimeFormat monthFormat = DateTimeFormat.getFormat("MMM yy");
    Month month = startMonth;
    for (int i = 0; i != MONTHS_TO_SHOW; ++i) {
        DateWrapper date = new DateWrapper(month.getYear(), month.getMonth() - 1, 1);
        getColumnModel().setColumnHeader(i + 1, monthFormat.format(date.asDate()));
        getColumnModel().setDataIndex(i + 1, IndicatorRowDTO.propertyName(month));
        month = month.next();
    }
}
Also used : Month(org.activityinfo.shared.command.Month) DateWrapper(com.extjs.gxt.ui.client.util.DateWrapper) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat)

Example 12 with Month

use of org.activityinfo.shared.command.Month in project activityinfo by bedatadriven.

the class HandlerUtil method monthFromRange.

static Month monthFromRange(Date date1, Date date2) {
    Calendar c1 = Calendar.getInstance();
    c1.setTime(date1);
    if (c1.get(Calendar.DAY_OF_MONTH) != 1) {
        return null;
    }
    Calendar c2 = Calendar.getInstance();
    c2.setTime(date2);
    if (c2.get(Calendar.DAY_OF_MONTH) != c2.getActualMaximum(Calendar.DAY_OF_MONTH)) {
        return null;
    }
    if (c2.get(Calendar.MONTH) != c1.get(Calendar.MONTH) || c2.get(Calendar.YEAR) != c2.get(Calendar.YEAR)) {
        return null;
    }
    return new Month(c1.get(Calendar.YEAR), c1.get(Calendar.MONTH) + 1);
}
Also used : Month(org.activityinfo.shared.command.Month) Calendar(java.util.Calendar)

Example 13 with Month

use of org.activityinfo.shared.command.Month in project activityinfo by bedatadriven.

the class MonthlyReportsTest method testGetReports.

@Test
public void testGetReports() throws Exception {
    GetMonthlyReports cmd = new GetMonthlyReports(6);
    cmd.setStartMonth(new Month(2009, 1));
    cmd.setEndMonth(new Month(2009, 2));
    MonthlyReportResult result = execute(cmd);
    Assert.assertEquals(1, result.getData().size());
    Assert.assertEquals(35, result.getData().get(0).getValue(2009, 1).intValue());
    Assert.assertEquals(70, result.getData().get(0).getValue(2009, 2).intValue());
}
Also used : Month(org.activityinfo.shared.command.Month) GetMonthlyReports(org.activityinfo.shared.command.GetMonthlyReports) MonthlyReportResult(org.activityinfo.shared.command.result.MonthlyReportResult) Test(org.junit.Test)

Aggregations

Month (org.activityinfo.shared.command.Month)13 MonthlyReportResult (org.activityinfo.shared.command.result.MonthlyReportResult)4 Test (org.junit.Test)4 DateWrapper (com.extjs.gxt.ui.client.util.DateWrapper)3 GetMonthlyReports (org.activityinfo.shared.command.GetMonthlyReports)3 DateTimeFormat (com.google.gwt.i18n.client.DateTimeFormat)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 ReportingPeriod (org.activityinfo.server.database.hibernate.entity.ReportingPeriod)2 UpdateMonthlyReports (org.activityinfo.shared.command.UpdateMonthlyReports)2 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 LabelToolItem (com.extjs.gxt.ui.client.widget.toolbar.LabelToolItem)1 ActionToolBar (org.activityinfo.client.page.common.toolbar.ActionToolBar)1 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)1 IndicatorValue (org.activityinfo.server.database.hibernate.entity.IndicatorValue)1 Site (org.activityinfo.server.database.hibernate.entity.Site)1 VoidResult (org.activityinfo.shared.command.result.VoidResult)1 AttributeDTO (org.activityinfo.shared.dto.AttributeDTO)1 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)1 IndicatorRowDTO (org.activityinfo.shared.dto.IndicatorRowDTO)1