use of org.springframework.web.bind.annotation.ResponseStatus 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);
}
use of org.springframework.web.bind.annotation.ResponseStatus 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.springframework.web.bind.annotation.ResponseStatus 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);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class CompleteDataSetRegistrationController method saveCompleteDataSetRegistration.
@ApiVersion({ DhisApiVersion.V23, DhisApiVersion.V24, DhisApiVersion.V25 })
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", value = MULTIPLE_SAVE_RESOURCE_PATH)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void saveCompleteDataSetRegistration(@RequestBody CompleteDataSetRegistrationRequests completeDataSetRegistrationRequests, HttpServletResponse response) throws WebMessageException {
List<CompleteDataSetRegistration> registrations = new ArrayList<>();
for (CompleteDataSetRegistrationRequest completeDataSetRegistrationRequest : completeDataSetRegistrationRequests) {
String ds = completeDataSetRegistrationRequest.getDs();
DataSet dataSet = dataSetService.getDataSet(ds);
if (dataSet == null) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal data set identifier: " + ds));
}
String pe = completeDataSetRegistrationRequest.getPe();
Period period = PeriodType.getPeriodFromIsoString(pe);
if (period == null) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal period identifier: " + pe));
}
String ou = completeDataSetRegistrationRequest.getOu();
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(ou);
if (organisationUnit == null) {
throw new WebMessageException(WebMessageUtils.conflict("Illegal organisation unit identifier: " + ou));
}
String cc = completeDataSetRegistrationRequest.getCc();
String cp = completeDataSetRegistrationRequest.getCp();
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo(cc, cp, false);
if (attributeOptionCombo == null) {
return;
}
// ---------------------------------------------------------------------
// Check locked status
// ---------------------------------------------------------------------
boolean multiOu = completeDataSetRegistrationRequest.isMultiOu();
if (dataSetService.isLocked(dataSet, period, organisationUnit, attributeOptionCombo, null, multiOu)) {
throw new WebMessageException(WebMessageUtils.conflict("Data set is locked: " + ds));
}
// ---------------------------------------------------------------------
// Register as completed data set
// ---------------------------------------------------------------------
String sb = completeDataSetRegistrationRequest.getSb();
String storedBy = (sb == null) ? currentUserService.getCurrentUsername() : sb;
Date cd = completeDataSetRegistrationRequest.getCd();
Date completionDate = (cd == null) ? new Date() : cd;
Set<OrganisationUnit> orgUnits = new HashSet<>();
orgUnits.add(organisationUnit);
if (multiOu) {
orgUnits.addAll(organisationUnit.getChildren());
}
addRegistrationsForOrgUnits(registrations, orgUnits, dataSet, period, attributeOptionCombo, storedBy, completionDate);
}
registrationService.saveCompleteDataSetRegistrations(registrations, true);
}
use of org.springframework.web.bind.annotation.ResponseStatus 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);
}
Aggregations