use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class MetadataImportExportController method postGmlMetadata.
@PostMapping(value = "/gml", consumes = APPLICATION_XML_VALUE)
@ResponseBody
public WebMessage postGmlMetadata(HttpServletRequest request) throws IOException {
MetadataImportParams params = metadataImportService.getParamsFromMap(contextService.getParameterValuesMap());
if (params.hasJobId()) {
return startAsyncGml(params, request);
}
ImportReport importReport = gmlImportService.importGml(request.getInputStream(), params);
return importReport(importReport).withPlainResponseBefore(DhisApiVersion.V38);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class TrackedEntityInstanceController method updateTrackedEntityInstanceXml.
// -------------------------------------------------------------------------
// UPDATE
// -------------------------------------------------------------------------
@PutMapping(value = "/{id}", consumes = APPLICATION_XML_VALUE)
@ResponseBody
public WebMessage updateTrackedEntityInstanceXml(@PathVariable String id, @RequestParam(required = false) String program, ImportOptions importOptions, HttpServletRequest request) throws IOException {
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat(request.getInputStream());
ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstanceXml(id, program, inputStream, importOptions);
importSummary.setImportOptions(importOptions);
return importSummary(importSummary);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class TrackedEntityInstanceController method postTrackedEntityInstance.
private WebMessage postTrackedEntityInstance(ImportStrategy strategy, ImportOptions importOptions, HttpServletRequest request, String mediaType) throws IOException, BadRequestException {
importOptions.setStrategy(strategy);
importOptions.setSkipLastUpdated(true);
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat(request.getInputStream());
// For in memory Jobs
JobConfiguration jobId = new JobConfiguration("inMemoryEventImport", TEI_IMPORT, currentUserService.getCurrentUser().getUid(), true);
TrackerEntityInstanceRequest trackerEntityInstanceRequest = TrackerEntityInstanceRequest.builder().inputStream(inputStream).importOptions(importOptions).mediaType(mediaType).jobConfiguration(jobId).build();
ImportSummaries importSummaries = trackedEntityInstanceStrategyHandler.mergeOrDeleteTrackedEntityInstances(trackerEntityInstanceRequest);
if (!importOptions.isAsync()) {
ImportSummary singleSummary = finalizeTrackedEntityInstancePostRequest(importOptions, request, importSummaries);
return importSummaries(importSummaries).setLocation(singleSummary == null ? null : "/api/" + "trackedEntityInstances" + "/" + singleSummary.getReference());
}
return jobConfigurationReport(jobId).setLocation("/system/tasks/" + TEI_IMPORT);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class ProgramRuleActionController method getDataExpressionDescription.
@PostMapping(value = "/data/expression/description", produces = APPLICATION_JSON_VALUE)
@ResponseBody
public WebMessage getDataExpressionDescription(@RequestBody String condition, @RequestParam String programId) {
I18n i18n = i18nManager.getI18n();
RuleValidationResult result = programRuleEngineService.getDataExpressionDescription(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.CONFLICT).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 SystemSoftwareUpdateNotifyController method checkSystemUpdate.
@GetMapping(SystemSoftwareUpdateNotifyController.RESOURCE_PATH)
@ResponseBody
public WebMessage checkSystemUpdate(@RequestParam(value = "forceVersion", required = false) String forceVersion) throws Exception {
Semver currentVersion = SystemUpdateService.getCurrentVersion();
if (forceVersion != null) {
currentVersion = new Semver(forceVersion);
}
Map<Semver, Map<String, String>> newerVersions = SystemUpdateService.getLatestNewerThan(currentVersion);
systemUpdateService.sendMessageForEachVersion(newerVersions);
WebMessage ok = WebMessageUtils.ok();
ok.setResponse(new SoftwareUpdateResponse(newerVersions));
return ok;
}
Aggregations