Search in sources :

Example 1 with Cal

use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.

the class EthiopianCalendarTest method testGenerateQuarterlyPeriods.

@Test
public void testGenerateQuarterlyPeriods() {
    Date startDate = new Cal(1975, 1, 1, true).time();
    Date endDate = new Cal(2025, 1, 2, true).time();
    List<Period> quarters = new QuarterlyPeriodType().generatePeriods(calendar, startDate, endDate);
    assertEquals(201, quarters.size());
}
Also used : QuarterlyPeriodType(org.hisp.dhis.period.QuarterlyPeriodType) Period(org.hisp.dhis.period.Period) Date(java.util.Date) Cal(org.hisp.dhis.period.Cal) Test(org.junit.Test)

Example 2 with Cal

use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.

the class PersianCalendarTest method testGenerateMonthlyPeriods.

@Test
public void testGenerateMonthlyPeriods() {
    Date startDate = new Cal(1997, 1, 1, true).time();
    Date endDate = new Cal(1998, 1, 1, true).time();
    List<Period> monthly = new MonthlyPeriodType().generatePeriods(calendar, startDate, endDate);
    assertEquals(13, monthly.size());
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) Period(org.hisp.dhis.period.Period) Date(java.util.Date) Cal(org.hisp.dhis.period.Cal) Test(org.junit.Test)

Example 3 with Cal

use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.

the class EthiopianCalendarTest method testGenerateDailyPeriods.

@Test
public void testGenerateDailyPeriods() {
    Date startDate = new Cal(1975, 1, 1, true).time();
    Date endDate = new Cal(2025, 1, 2, true).time();
    List<Period> days = new DailyPeriodType().generatePeriods(calendar, startDate, endDate);
    assertEquals(18001, days.size());
}
Also used : DailyPeriodType(org.hisp.dhis.period.DailyPeriodType) Period(org.hisp.dhis.period.Period) Date(java.util.Date) Cal(org.hisp.dhis.period.Cal) Test(org.junit.Test)

Example 4 with Cal

use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.

the class DatePeriodResourceTable method getPopulateTempTableContent.

@Override
public Optional<List<Object[]>> getPopulateTempTableContent() {
    List<PeriodType> periodTypes = PeriodType.getAvailablePeriodTypes();
    List<Object[]> batchArgs = new ArrayList<>();
    //TODO
    Date startDate = new Cal(1975, 1, 1, true).time();
    Date endDate = new Cal(2025, 1, 1, true).time();
    List<Period> days = new UniqueArrayList<>(new DailyPeriodType().generatePeriods(startDate, endDate));
    Calendar calendar = PeriodType.getCalendar();
    for (Period day : days) {
        List<Object> values = new ArrayList<>();
        values.add(day.getStartDate());
        for (PeriodType periodType : periodTypes) {
            values.add(periodType.createPeriod(day.getStartDate(), calendar).getIsoDate());
        }
        batchArgs.add(values.toArray());
    }
    return Optional.of(batchArgs);
}
Also used : DailyPeriodType(org.hisp.dhis.period.DailyPeriodType) DailyPeriodType(org.hisp.dhis.period.DailyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) Calendar(org.hisp.dhis.calendar.Calendar) UniqueArrayList(org.hisp.dhis.commons.collection.UniqueArrayList) ArrayList(java.util.ArrayList) Period(org.hisp.dhis.period.Period) UniqueArrayList(org.hisp.dhis.commons.collection.UniqueArrayList) Date(java.util.Date) Cal(org.hisp.dhis.period.Cal)

Example 5 with Cal

use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.

the class EthiopianCalendarTest method testGenerateMonthlyPeriods.

@Test
public void testGenerateMonthlyPeriods() {
    Date startDate = new Cal(1975, 1, 1, true).time();
    Date endDate = new Cal(2025, 1, 2, true).time();
    List<Period> monthly = new MonthlyPeriodType().generatePeriods(calendar, startDate, endDate);
    assertEquals(601, monthly.size());
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) Period(org.hisp.dhis.period.Period) Date(java.util.Date) Cal(org.hisp.dhis.period.Cal) Test(org.junit.Test)

Aggregations

Date (java.util.Date)8 Cal (org.hisp.dhis.period.Cal)8 Period (org.hisp.dhis.period.Period)7 Test (org.junit.Test)6 DailyPeriodType (org.hisp.dhis.period.DailyPeriodType)2 MonthlyPeriodType (org.hisp.dhis.period.MonthlyPeriodType)2 QuarterlyPeriodType (org.hisp.dhis.period.QuarterlyPeriodType)2 ArrayList (java.util.ArrayList)1 Calendar (org.hisp.dhis.calendar.Calendar)1 UniqueArrayList (org.hisp.dhis.commons.collection.UniqueArrayList)1 PeriodType (org.hisp.dhis.period.PeriodType)1 WeeklyPeriodType (org.hisp.dhis.period.WeeklyPeriodType)1