Search in sources :

Example 6 with ImportService

use of org.molgenis.data.importer.ImportService in project molgenis by molgenis.

the class VcfImportServiceIT method testDoImportVcfGzWithSamples.

private void testDoImportVcfGzWithSamples() {
    String entityTypeId = "variantsWithSamplesGz";
    String fileName = entityTypeId + ".vcf.gz";
    File file = getFile("/vcf/" + fileName);
    FileRepositoryCollection repoCollection = fileRepositoryCollectionFactory.createFileRepositoryCollection(file);
    ImportService importService = importServiceFactory.getImportService(file, repoCollection);
    EntityImportReport importReport = importService.doImport(repoCollection, ADD, PACKAGE_DEFAULT);
    validateImportReport(importReport, ImmutableMap.of("variantsWithSamplesGz", 10, "variantsWithSamplesGzSample", 10), ImmutableSet.of("variantsWithSamplesGz", "variantsWithSamplesGzSample"));
    assertVariants(entityTypeId, true);
}
Also used : ImportService(org.molgenis.data.importer.ImportService) FileRepositoryCollection(org.molgenis.data.file.support.FileRepositoryCollection) File(java.io.File) EntityImportReport(org.molgenis.data.importer.EntityImportReport)

Example 7 with ImportService

use of org.molgenis.data.importer.ImportService in project molgenis by molgenis.

the class VcfImportServiceIT method testDoImportVcfWithSamples.

private void testDoImportVcfWithSamples() {
    String entityTypeId = "variantsWithSamples";
    String fileName = entityTypeId + ".vcf";
    File file = getFile("/vcf/" + fileName);
    FileRepositoryCollection repoCollection = fileRepositoryCollectionFactory.createFileRepositoryCollection(file);
    ImportService importService = importServiceFactory.getImportService(file, repoCollection);
    EntityImportReport importReport = importService.doImport(repoCollection, ADD, PACKAGE_DEFAULT);
    validateImportReport(importReport, ImmutableMap.of(entityTypeId, 10, entityTypeId + "Sample", 10), ImmutableSet.of(entityTypeId, entityTypeId + "Sample"));
    assertVariants(entityTypeId, true);
}
Also used : ImportService(org.molgenis.data.importer.ImportService) FileRepositoryCollection(org.molgenis.data.file.support.FileRepositoryCollection) File(java.io.File) EntityImportReport(org.molgenis.data.importer.EntityImportReport)

Example 8 with ImportService

use of org.molgenis.data.importer.ImportService in project molgenis by molgenis.

the class EmxImportServiceIT method testDoImportEmxCsvZip.

private void testDoImportEmxCsvZip() {
    String fileName = "emx-csv.zip";
    File file = getFile("/csv/" + fileName);
    FileRepositoryCollection repoCollection = fileRepositoryCollectionFactory.createFileRepositoryCollection(file);
    ImportService importService = importServiceFactory.getImportService(file, repoCollection);
    EntityImportReport importReport = importService.doImport(repoCollection, ADD, PACKAGE_DEFAULT);
    validateImportReport(importReport, ImmutableMap.of(CSV_HOSPITAL, 3, CSV_PATIENTS, 3), ImmutableSet.of(CSV_HOSPITAL, CSV_PATIENTS));
    verifyFirstAndLastRows(CSV_HOSPITAL, hospitalFirstRow, hospitalLastRow);
    verifyFirstAndLastRows(CSV_PATIENTS, patientsFirstRow, patientsLastRow);
}
Also used : ImportService(org.molgenis.data.importer.ImportService) FileRepositoryCollection(org.molgenis.data.file.support.FileRepositoryCollection) File(java.io.File) EntityImportReport(org.molgenis.data.importer.EntityImportReport)

Example 9 with ImportService

use of org.molgenis.data.importer.ImportService in project molgenis by molgenis.

the class EmxImportServiceIT method testDoImportEmxTsvZip.

private void testDoImportEmxTsvZip() {
    String fileName = "emx-tsv.zip";
    File file = getFile("/tsv/" + fileName);
    FileRepositoryCollection repoCollection = fileRepositoryCollectionFactory.createFileRepositoryCollection(file);
    ImportService importService = importServiceFactory.getImportService(file, repoCollection);
    EntityImportReport importReport = importService.doImport(repoCollection, ADD, PACKAGE_DEFAULT);
    validateImportReport(importReport, ImmutableMap.of(TSV_HOSPITAL, 3, TSV_PATIENTS, 3), ImmutableSet.of(TSV_HOSPITAL, TSV_PATIENTS));
    verifyFirstAndLastRows(TSV_HOSPITAL, hospitalFirstRow, hospitalLastRow);
    verifyFirstAndLastRows(TSV_PATIENTS, patientsFirstRow, patientsLastRow);
}
Also used : ImportService(org.molgenis.data.importer.ImportService) FileRepositoryCollection(org.molgenis.data.file.support.FileRepositoryCollection) File(java.io.File) EntityImportReport(org.molgenis.data.importer.EntityImportReport)

Example 10 with ImportService

use of org.molgenis.data.importer.ImportService in project molgenis by molgenis.

the class EmxImportServiceIT method executeAddUpdateOrUpdateTest.

private void executeAddUpdateOrUpdateTest(File file, File addUpdateFile, Map<String, Integer> entityCountMap, Set<String> addedEntityTypes, Runnable entityValidationMethod) {
    FileRepositoryCollection addRepoCollection = fileRepositoryCollectionFactory.createFileRepositoryCollection(file);
    ImportService addImportService = importServiceFactory.getImportService(file, addRepoCollection);
    addImportService.doImport(addRepoCollection, ADD, PACKAGE_DEFAULT);
    FileRepositoryCollection addUpdateRepoCollection = fileRepositoryCollectionFactory.createFileRepositoryCollection(addUpdateFile);
    ImportService addUpdateImportService = importServiceFactory.getImportService(addUpdateFile, addUpdateRepoCollection);
    EntityImportReport importReport = addUpdateImportService.doImport(addUpdateRepoCollection, ADD_UPDATE_EXISTING, PACKAGE_DEFAULT);
    validateImportReport(importReport, entityCountMap, addedEntityTypes);
    entityValidationMethod.run();
}
Also used : ImportService(org.molgenis.data.importer.ImportService) FileRepositoryCollection(org.molgenis.data.file.support.FileRepositoryCollection) EntityImportReport(org.molgenis.data.importer.EntityImportReport)

Aggregations

ImportService (org.molgenis.data.importer.ImportService)14 EntityImportReport (org.molgenis.data.importer.EntityImportReport)11 File (java.io.File)10 FileRepositoryCollection (org.molgenis.data.file.support.FileRepositoryCollection)10 RepositoryCollection (org.molgenis.data.RepositoryCollection)4 MolgenisDataException (org.molgenis.data.MolgenisDataException)2 FileMeta (org.molgenis.data.file.model.FileMeta)2 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Part (javax.servlet.http.Part)1 DatabaseAction (org.molgenis.data.DatabaseAction)1 EntitiesValidationReport (org.molgenis.data.importer.EntitiesValidationReport)1 Package (org.molgenis.data.meta.model.Package)1 FileIngestJobExecution (org.molgenis.file.ingest.meta.FileIngestJobExecution)1 ObjectError (org.springframework.validation.ObjectError)1