Search in sources :

Example 1 with ImportCompleteDataSetRegistrationsTask

use of org.hisp.dhis.dxf2.dataset.tasks.ImportCompleteDataSetRegistrationsTask in project dhis2-core by dhis2.

the class CompleteDataSetRegistrationController method asyncImport.

private void asyncImport(ImportOptions importOptions, String format, HttpServletRequest request, HttpServletResponse response) throws IOException {
    Pair<InputStream, Path> tmpFile = saveTmpFile(request.getInputStream());
    TaskId taskId = new TaskId(TaskCategory.COMPLETE_DATA_SET_REGISTRATION_IMPORT, currentUserService.getCurrentUser());
    scheduler.executeTask(new ImportCompleteDataSetRegistrationsTask(registrationExchangeService, sessionFactory, tmpFile.getLeft(), tmpFile.getRight(), importOptions, format, taskId));
    response.setHeader("Location", ContextUtils.getRootPath(request) + "/system/tasks/" + TaskCategory.COMPLETE_DATA_SET_REGISTRATION_IMPORT);
    response.setStatus(HttpServletResponse.SC_ACCEPTED);
}
Also used : Path(java.nio.file.Path) ImportCompleteDataSetRegistrationsTask(org.hisp.dhis.dxf2.dataset.tasks.ImportCompleteDataSetRegistrationsTask) TaskId(org.hisp.dhis.scheduling.TaskId) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream)

Aggregations

BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 ImportCompleteDataSetRegistrationsTask (org.hisp.dhis.dxf2.dataset.tasks.ImportCompleteDataSetRegistrationsTask)1 TaskId (org.hisp.dhis.scheduling.TaskId)1