use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class PredictionController method runPredictors.
@RequestMapping(method = { RequestMethod.POST, RequestMethod.PUT })
@PreAuthorize("hasRole('ALL') or hasRole('F_PREDICTOR_RUN')")
@ResponseBody
public WebMessage runPredictors(@RequestParam Date startDate, @RequestParam Date endDate, @RequestParam(value = "predictor", required = false) List<String> predictors, @RequestParam(value = "predictorGroup", required = false) List<String> predictorGroups, @RequestParam(defaultValue = "false", required = false) boolean async, HttpServletRequest request) {
if (async) {
JobConfiguration jobId = new JobConfiguration("inMemoryPrediction", PREDICTOR, currentUserService.getCurrentUser().getUid(), true);
taskExecutor.executeTask(new PredictionTask(startDate, endDate, predictors, predictorGroups, predictionService, jobId));
return jobConfigurationReport(jobId).setLocation("/system/tasks/" + PREDICTOR);
}
PredictionSummary predictionSummary = predictionService.predictTask(startDate, endDate, predictors, predictorGroups, null);
return new WebMessage(Status.OK, HttpStatus.OK).setResponse(predictionSummary).withPlainResponseBefore(DhisApiVersion.V38);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class DataValueSetController method postAdxDataValueSet.
@PostMapping(consumes = CONTENT_TYPE_XML_ADX)
@PreAuthorize("hasRole('ALL') or hasRole('F_DATAVALUE_ADD')")
@ResponseBody
public WebMessage postAdxDataValueSet(ImportOptions importOptions, HttpServletRequest request) throws IOException {
if (importOptions.isAsync()) {
return startAsyncImport(importOptions, ImportDataValueTask.FORMAT_ADX, request);
}
ImportSummary summary = adxDataService.saveDataValueSet(request.getInputStream(), importOptions, null);
summary.setImportOptions(importOptions);
return importSummary(summary).withPlainResponseBefore(V38);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class DataValueSetController method postCsvDataValueSet.
@PostMapping(consumes = "application/csv")
@PreAuthorize("hasRole('ALL') or hasRole('F_DATAVALUE_ADD')")
@ResponseBody
public WebMessage postCsvDataValueSet(ImportOptions importOptions, HttpServletRequest request) throws IOException {
if (importOptions.isAsync()) {
return startAsyncImport(importOptions, ImportDataValueTask.FORMAT_CSV, request);
}
ImportSummary summary = dataValueSetService.importDataValueSetCsv(request.getInputStream(), importOptions);
summary.setImportOptions(importOptions);
return importSummary(summary).withPlainResponseBefore(V38);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class ProgramRuleController method validateCondition.
@PostMapping(value = "/condition/description", produces = APPLICATION_JSON_VALUE)
@ResponseBody
public WebMessage validateCondition(@RequestBody String condition, @RequestParam String programId) {
I18n i18n = i18nManager.getI18n();
RuleValidationResult result = programRuleEngineService.getDescription(condition, programId);
if (result.isValid()) {
return new DescriptiveWebMessage(Status.OK, HttpStatus.OK).setDescription(result.getDescription()).setMessage(i18n.getString(ProgramIndicator.VALID));
}
String description = null;
if (result.getErrorMessage() != null) {
description = result.getErrorMessage();
} else if (result.getException() != null) {
description = result.getException().getMessage();
}
return new DescriptiveWebMessage(Status.ERROR, HttpStatus.OK).setDescription(description).setMessage(i18n.getString(ProgramIndicator.EXPRESSION_NOT_VALID));
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class RelationshipController method postRelationshipXml.
@PostMapping(value = "", consumes = APPLICATION_XML_VALUE, produces = APPLICATION_XML_VALUE)
@ResponseBody
public WebMessage postRelationshipXml(@RequestParam(defaultValue = "CREATE_AND_UPDATE") ImportStrategy strategy, ImportOptions importOptions, HttpServletRequest request) throws IOException {
importOptions.setStrategy(strategy);
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat(request.getInputStream());
ImportSummaries importSummaries = relationshipService.addRelationshipsXml(inputStream, importOptions);
importSummaries.getImportSummaries().stream().filter(filterImportSummary(importOptions)).forEach(setImportSummaryHref(request));
return importSummaries(importSummaries);
}
Aggregations