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();
}
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;
}
Aggregations