Search in sources :

Example 11 with Configuration

use of org.hisp.dhis.configuration.Configuration in project dhis2-core by dhis2.

the class ConfigurationController method setInfrastructuralIndicators.

@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/infrastructuralIndicators", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setInfrastructuralIndicators(@RequestBody String uid) throws NotFoundException {
    IndicatorGroup group = identifiableObjectManager.get(IndicatorGroup.class, uid);
    if (group == null) {
        throw new NotFoundException("Indicator group", uid);
    }
    Configuration config = configurationService.getConfiguration();
    config.setInfrastructuralIndicators(group);
    configurationService.setConfiguration(config);
}
Also used : IndicatorGroup(org.hisp.dhis.indicator.IndicatorGroup) 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 12 with Configuration

use of org.hisp.dhis.configuration.Configuration 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 13 with Configuration

use of org.hisp.dhis.configuration.Configuration in project dhis2-core by dhis2.

the class ConfigurationController method setOfflineOrganisationUnitLevel.

@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/offlineOrganisationUnitLevel", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setOfflineOrganisationUnitLevel(@RequestBody String uid) throws NotFoundException {
    OrganisationUnitLevel organisationUnitLevel = identifiableObjectManager.get(OrganisationUnitLevel.class, uid);
    if (organisationUnitLevel == null) {
        throw new NotFoundException("Organisation unit level", uid);
    }
    Configuration config = configurationService.getConfiguration();
    config.setOfflineOrganisationUnitLevel(organisationUnitLevel);
    configurationService.setConfiguration(config);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) 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 14 with Configuration

use of org.hisp.dhis.configuration.Configuration in project dhis2-core by dhis2.

the class ConfigurationController method setSelfRegistrationOrgUnit.

@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/selfRegistrationOrgUnit", method = RequestMethod.POST)
public void setSelfRegistrationOrgUnit(@RequestBody String uid) throws NotFoundException {
    OrganisationUnit orgunit = identifiableObjectManager.get(OrganisationUnit.class, uid);
    if (orgunit == null) {
        throw new NotFoundException("Organisation unit", uid);
    }
    Configuration config = configurationService.getConfiguration();
    config.setSelfRegistrationOrgUnit(orgunit);
    configurationService.setConfiguration(config);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Configuration(org.hisp.dhis.configuration.Configuration) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with Configuration

use of org.hisp.dhis.configuration.Configuration in project dhis2-core by dhis2.

the class ConfigurationController method removeSelfRegistrationOrgUnit.

@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/selfRegistrationOrgUnit", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removeSelfRegistrationOrgUnit() {
    Configuration config = configurationService.getConfiguration();
    config.setSelfRegistrationOrgUnit(null);
    configurationService.setConfiguration(config);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Configuration (org.hisp.dhis.configuration.Configuration)17 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)12 NotFoundException (org.hisp.dhis.webapi.controller.exception.NotFoundException)7 UserGroup (org.hisp.dhis.user.UserGroup)2 Date (java.util.Date)1 DhisSpringTest (org.hisp.dhis.DhisSpringTest)1 DataElementGroup (org.hisp.dhis.dataelement.DataElementGroup)1 IndicatorGroup (org.hisp.dhis.indicator.IndicatorGroup)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 OrganisationUnitLevel (org.hisp.dhis.organisationunit.OrganisationUnitLevel)1 PeriodType (org.hisp.dhis.period.PeriodType)1 User (org.hisp.dhis.user.User)1 UserAuthorityGroup (org.hisp.dhis.user.UserAuthorityGroup)1 Test (org.junit.Test)1 HttpStatus (org.springframework.http.HttpStatus)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1 HttpServerErrorException (org.springframework.web.client.HttpServerErrorException)1 ResourceAccessException (org.springframework.web.client.ResourceAccessException)1