Search in sources :

Example 1 with ImportDataValueTask

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;
}
Also used : TaskId(org.hisp.dhis.scheduling.TaskId) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream) ImportOptions(org.hisp.dhis.dxf2.common.ImportOptions) ImportDataValueTask(org.hisp.dhis.dxf2.datavalueset.tasks.ImportDataValueTask)

Example 2 with ImportDataValueTask

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);
}
Also used : TaskId(org.hisp.dhis.scheduling.TaskId) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ImportDataValueTask(org.hisp.dhis.dxf2.datavalueset.tasks.ImportDataValueTask)

Aggregations

FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 ImportDataValueTask (org.hisp.dhis.dxf2.datavalueset.tasks.ImportDataValueTask)2 TaskId (org.hisp.dhis.scheduling.TaskId)2 BufferedInputStream (java.io.BufferedInputStream)1 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)1