Search in sources :

Example 66 with PeriodType

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);
}
Also used : PeriodType(org.hisp.dhis.period.PeriodType) Configuration(org.hisp.dhis.configuration.Configuration) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 67 with PeriodType

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;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) PeriodType(org.hisp.dhis.period.PeriodType) DataSet(org.hisp.dhis.dataset.DataSet) Period(org.hisp.dhis.period.Period) CompleteDataSetRegistrations(org.hisp.dhis.dataset.CompleteDataSetRegistrations) HashSet(java.util.HashSet)

Aggregations

PeriodType (org.hisp.dhis.period.PeriodType)67 Period (org.hisp.dhis.period.Period)21 MonthlyPeriodType (org.hisp.dhis.period.MonthlyPeriodType)13 ArrayList (java.util.ArrayList)12 DataSet (org.hisp.dhis.dataset.DataSet)12 DataElement (org.hisp.dhis.dataelement.DataElement)10 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)9 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)7 UniqueArrayList (org.hisp.dhis.commons.collection.UniqueArrayList)6 YearlyPeriodType (org.hisp.dhis.period.YearlyPeriodType)6 ProgramStage (org.hisp.dhis.program.ProgramStage)6 Test (org.junit.Test)6 Date (java.util.Date)5 HashSet (java.util.HashSet)5 QuarterlyPeriodType (org.hisp.dhis.period.QuarterlyPeriodType)5 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)5 CategoryOptionGroupSet (org.hisp.dhis.dataelement.CategoryOptionGroupSet)4 OrganisationUnitGroupSet (org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)4 OrganisationUnitLevel (org.hisp.dhis.organisationunit.OrganisationUnitLevel)4 DailyPeriodType (org.hisp.dhis.period.DailyPeriodType)4