use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class ConfigurationController method setInfrastructuralPeriodType.
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/infrastructuralPeriodType", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setInfrastructuralPeriodType(@RequestBody String name) throws NotFoundException {
PeriodType periodType = PeriodType.getPeriodTypeByName(name);
if (periodType == null) {
throw new NotFoundException("Period type", name);
}
Configuration config = configurationService.getConfiguration();
periodType = periodService.reloadPeriodType(periodType);
config.setInfrastructuralPeriodType(periodType);
configurationService.setConfiguration(config);
}
use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class CompleteDataSetRegistrationController method getCompleteDataSetRegistrations.
private CompleteDataSetRegistrations getCompleteDataSetRegistrations(Set<String> dataSet, String period, Date startDate, Date endDate, Set<String> orgUnit, boolean children) {
Set<Period> periods = new HashSet<>();
Set<DataSet> dataSets = new HashSet<>();
Set<OrganisationUnit> organisationUnits = new HashSet<>();
PeriodType periodType = periodService.getPeriodTypeByName(period);
if (periodType != null) {
periods.addAll(periodService.getPeriodsBetweenDates(periodType, startDate, endDate));
} else {
periods.addAll(periodService.getPeriodsBetweenDates(startDate, endDate));
}
if (periods.isEmpty()) {
return new CompleteDataSetRegistrations();
}
if (children) {
organisationUnits.addAll(organisationUnitService.getOrganisationUnitsWithChildren(orgUnit));
} else {
organisationUnits.addAll(organisationUnitService.getOrganisationUnitsByUid(orgUnit));
}
dataSets.addAll(manager.getByUid(DataSet.class, dataSet));
CompleteDataSetRegistrations completeDataSetRegistrations = new CompleteDataSetRegistrations();
completeDataSetRegistrations.setCompleteDataSetRegistrations(new ArrayList<>(registrationService.getCompleteDataSetRegistrations(dataSets, organisationUnits, periods)));
return completeDataSetRegistrations;
}
Aggregations