Search in sources :

Example 1 with SortaCsvRepository

use of org.molgenis.ontology.sorta.repo.SortaCsvRepository in project molgenis by molgenis.

the class SortaController method startMatchJob.

private String startMatchJob(String jobName, String ontologyIri, Model model, HttpServletRequest httpServletRequest, InputStream inputStream) throws IOException {
    String sessionId = httpServletRequest.getSession().getId();
    File uploadFile = fileStore.store(inputStream, sessionId + // TODO determine whether multiple match jobs during the same session results in wrong file usage
    ".csv");
    String inputRepositoryName = idGenerator.generateId();
    SortaCsvRepository inputRepository = new SortaCsvRepository(inputRepositoryName, jobName + " input", uploadFile, entityTypeFactory, attrMetaFactory);
    if (!validateFileHeader(inputRepository)) {
        model.addAttribute(MODEL_KEY_MESSAGE, "The Name header is missing!");
        return matchTask(model);
    }
    if (!validateEmptyFileHeader(inputRepository)) {
        model.addAttribute(MODEL_KEY_MESSAGE, "The empty header is not allowed!");
        return matchTask(model);
    }
    if (!validateInputFileContent(inputRepository)) {
        model.addAttribute(MODEL_KEY_MESSAGE, "The content of input is empty!");
        return matchTask(model);
    }
    SortaJobExecution jobExecution = createJobExecution(inputRepository, jobName, ontologyIri);
    SortaJobImpl sortaMatchJob = sortaMatchJobFactory.create(jobExecution);
    taskExecutor.submit(sortaMatchJob);
    return "redirect:" + getSortaServiceMenuUrl();
}
Also used : SortaJobImpl(org.molgenis.ontology.sorta.job.SortaJobImpl) SortaCsvRepository(org.molgenis.ontology.sorta.repo.SortaCsvRepository) SortaJobExecution(org.molgenis.ontology.sorta.job.SortaJobExecution) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile)

Aggregations

File (java.io.File)1 SortaJobExecution (org.molgenis.ontology.sorta.job.SortaJobExecution)1 SortaJobImpl (org.molgenis.ontology.sorta.job.SortaJobImpl)1 SortaCsvRepository (org.molgenis.ontology.sorta.repo.SortaCsvRepository)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1