use of org.hisp.dhis.dxf2.datavalueset.tasks.ImportDataValueTask in project dhis2-core by dhis2.
the class ImportDataValueAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
strategy = strategy != null ? strategy : ImportStrategy.NEW_AND_UPDATES;
TaskId taskId = new TaskId(TaskCategory.DATAVALUE_IMPORT, currentUserService.getCurrentUser());
notifier.clear(taskId);
InputStream in = new FileInputStream(upload);
in = StreamUtils.wrapAndCheckCompressionFormat(in);
ImportOptions options = new ImportOptions().setDryRun(dryRun).setStrategy(strategy).setPreheatCache(preheatCache).setSkipExistingCheck(skipExistingCheck).setIdScheme(StringUtils.trimToNull(idScheme)).setDataElementIdScheme(StringUtils.trimToNull(dataElementIdScheme)).setOrgUnitIdScheme(StringUtils.trimToNull(orgUnitIdScheme)).setFilename(uploadFileName);
log.info(options);
scheduler.executeTask(new ImportDataValueTask(dataValueSetService, adxDataService, sessionFactory, in, options, taskId, importFormat));
return SUCCESS;
}
use of org.hisp.dhis.dxf2.datavalueset.tasks.ImportDataValueTask 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.
* @param response the HttpResponse.
* @throws IOException
*/
private void startAsyncImport(ImportOptions importOptions, String format, HttpServletRequest request, HttpServletResponse response) throws IOException {
InputStream inputStream = saveTmp(request.getInputStream());
TaskId taskId = new TaskId(TaskCategory.DATAVALUE_IMPORT, currentUserService.getCurrentUser());
scheduler.executeTask(new ImportDataValueTask(dataValueSetService, adxDataService, sessionFactory, inputStream, importOptions, taskId, format));
response.setHeader("Location", ContextUtils.getRootPath(request) + "/system/tasks/" + TaskCategory.DATAVALUE_IMPORT);
response.setStatus(HttpServletResponse.SC_ACCEPTED);
}
Aggregations