Search in sources :

Example 11 with DailyPeriodType

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

the class DefaultDataQueryService method tryParseDateRange.

/**
 * Parses periods in <code>YYYYMMDD_YYYYMMDD</code> or
 * <code>YYYY-MM-DD_YYYY-MM-DD</code> format.
 */
private Optional<Period> tryParseDateRange(IsoPeriodHolder isoPeriodHolder) {
    String[] dates = isoPeriodHolder.getIsoPeriod().split(PERIOD_FREE_RANGE_SEPARATOR);
    if (dates.length == 2) {
        Optional<Date> start = safelyParseDate(dates[0]);
        Optional<Date> end = safelyParseDate(dates[1]);
        if (start.isPresent() && end.isPresent()) {
            Period period = new Period();
            period.setPeriodType(new DailyPeriodType());
            period.setStartDate(start.get());
            period.setEndDate(end.get());
            period.setDateField(isoPeriodHolder.getDateField());
            return Optional.of(period);
        }
    }
    return Optional.empty();
}
Also used : DailyPeriodType(org.hisp.dhis.period.DailyPeriodType) Period(org.hisp.dhis.period.Period) Date(java.util.Date) LocalDate(java.time.LocalDate)

Example 12 with DailyPeriodType

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

the class EventDateValidationHookTest method getProgramWithRegistration.

private Program getProgramWithRegistration() {
    Program program = createProgram('A');
    program.setUid(PROGRAM_WITH_REGISTRATION_ID);
    program.setProgramType(ProgramType.WITH_REGISTRATION);
    program.setCompleteEventsExpiryDays(5);
    program.setExpiryDays(5);
    program.setExpiryPeriodType(new DailyPeriodType());
    return program;
}
Also used : DailyPeriodType(org.hisp.dhis.period.DailyPeriodType) Program(org.hisp.dhis.program.Program)

Aggregations

DailyPeriodType (org.hisp.dhis.period.DailyPeriodType)12 MonthlyPeriodType (org.hisp.dhis.period.MonthlyPeriodType)5 QuarterlyPeriodType (org.hisp.dhis.period.QuarterlyPeriodType)5 WeeklyPeriodType (org.hisp.dhis.period.WeeklyPeriodType)5 YearlyPeriodType (org.hisp.dhis.period.YearlyPeriodType)5 Date (java.util.Date)4 Period (org.hisp.dhis.period.Period)4 Test (org.junit.jupiter.api.Test)4 Calendar (java.util.Calendar)3 DataSet (org.hisp.dhis.dataset.DataSet)3 PeriodType (org.hisp.dhis.period.PeriodType)3 ArrayList (java.util.ArrayList)2 DataApprovalWorkflow (org.hisp.dhis.dataapproval.DataApprovalWorkflow)2 BiMonthlyPeriodType (org.hisp.dhis.period.BiMonthlyPeriodType)2 BiWeeklyPeriodType (org.hisp.dhis.period.BiWeeklyPeriodType)2 Cal (org.hisp.dhis.period.Cal)2 FinancialAprilPeriodType (org.hisp.dhis.period.FinancialAprilPeriodType)2 FinancialJulyPeriodType (org.hisp.dhis.period.FinancialJulyPeriodType)2 FinancialNovemberPeriodType (org.hisp.dhis.period.FinancialNovemberPeriodType)2 FinancialOctoberPeriodType (org.hisp.dhis.period.FinancialOctoberPeriodType)2