use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class CompleteDataSetRegistrationController method postCompleteRegistrationsXml.
// -------------------------------------------------------------------------
// POST
// -------------------------------------------------------------------------
@PostMapping(consumes = CONTENT_TYPE_XML, produces = CONTENT_TYPE_XML)
@ResponseBody
public WebMessage postCompleteRegistrationsXml(ImportOptions importOptions, HttpServletRequest request) throws IOException {
if (importOptions.isAsync()) {
return asyncImport(importOptions, ImportCompleteDataSetRegistrationsTask.FORMAT_XML, request);
}
ImportSummary summary = registrationExchangeService.saveCompleteDataSetRegistrationsXml(request.getInputStream(), importOptions);
summary.setImportOptions(importOptions);
return importSummary(summary).withPlainResponseBefore(DhisApiVersion.V38);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class DataValueSetController method postDxf2DataValueSet.
// -------------------------------------------------------------------------
// Post
// -------------------------------------------------------------------------
@PostMapping(consumes = APPLICATION_XML_VALUE)
@PreAuthorize("hasRole('ALL') or hasRole('F_DATAVALUE_ADD')")
@ResponseBody
public WebMessage postDxf2DataValueSet(ImportOptions importOptions, HttpServletRequest request) throws IOException {
if (importOptions.isAsync()) {
return startAsyncImport(importOptions, ImportDataValueTask.FORMAT_XML, request);
}
ImportSummary summary = dataValueSetService.importDataValueSetXml(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 DataValueSetController method postJsonDataValueSet.
@PostMapping(consumes = APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ALL') or hasRole('F_DATAVALUE_ADD')")
@ResponseBody
public WebMessage postJsonDataValueSet(ImportOptions importOptions, HttpServletRequest request) throws IOException {
if (importOptions.isAsync()) {
return startAsyncImport(importOptions, ImportDataValueTask.FORMAT_JSON, request);
}
ImportSummary summary = dataValueSetService.importDataValueSetJson(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 DataValueSetController method postPdfDataValueSet.
@PostMapping(consumes = CONTENT_TYPE_PDF)
@PreAuthorize("hasRole('ALL') or hasRole('F_DATAVALUE_ADD')")
@ResponseBody
public WebMessage postPdfDataValueSet(ImportOptions importOptions, HttpServletRequest request) throws IOException {
if (importOptions.isAsync()) {
return startAsyncImport(importOptions, ImportDataValueTask.FORMAT_PDF, request);
}
ImportSummary summary = dataValueSetService.importDataValueSetPdf(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 DataValueSetController method startAsyncImport.
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
/**
* Starts an asynchronous import task.
*
* @param importOptions the ImportOptions.
* @param format the resource representation format.
* @param request the HttpRequest.
*/
private WebMessage startAsyncImport(ImportOptions importOptions, String format, HttpServletRequest request) throws IOException {
InputStream inputStream = saveTmp(request.getInputStream());
JobConfiguration jobId = new JobConfiguration("dataValueImport", DATAVALUE_IMPORT, currentUserService.getCurrentUser().getUid(), true);
taskExecutor.executeTask(new ImportDataValueTask(dataValueSetService, adxDataService, sessionFactory, inputStream, importOptions, jobId, format));
return jobConfigurationReport(jobId).setLocation("/system/tasks/" + DATAVALUE_IMPORT);
}
Aggregations