Search in sources :

Example 1 with SpeciesBackupImportJob

use of org.openforis.collect.io.metadata.species.SpeciesBackupImportJob in project collect by openforis.

the class SpeciesBackupImportJobIntegrationTest method importCSVFile.

private SpeciesBackupImportJob importCSVFile(String fileName) throws Exception {
    File file = getTestFile(fileName);
    CollectTaxonomy taxonomy = new CollectTaxonomy();
    taxonomy.setSurvey(survey);
    taxonomy.setName(TEST_TAXONOMY_NAME);
    speciesManager.save(taxonomy);
    SpeciesBackupImportJob job = jobManager.createJob(SpeciesBackupImportJob.class);
    job.setFile(file);
    job.setSurvey(survey);
    job.setTaxonomyName(TEST_TAXONOMY_NAME);
    jobManager.start(job, false);
    return job;
}
Also used : CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) SpeciesBackupImportJob(org.openforis.collect.io.metadata.species.SpeciesBackupImportJob) File(java.io.File)

Example 2 with SpeciesBackupImportJob

use of org.openforis.collect.io.metadata.species.SpeciesBackupImportJob in project collect by openforis.

the class SpeciesBackupImportJobIntegrationTest method testExport.

@Test
public void testExport() throws Exception {
    SpeciesBackupImportJob job = importCSVFile(VALID_TEST_CSV);
    assertTrue(job.isCompleted());
    CollectTaxonomy taxonomy = taxonomyDao.loadByName(survey, TEST_TAXONOMY_NAME);
    TaxonSummaries summaries = speciesManager.loadFullTaxonSummariesOld(taxonomy);
    assertNotNull(summaries);
}
Also used : SpeciesBackupImportJob(org.openforis.collect.io.metadata.species.SpeciesBackupImportJob) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) TaxonSummaries(org.openforis.collect.metamodel.TaxonSummaries) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 3 with SpeciesBackupImportJob

use of org.openforis.collect.io.metadata.species.SpeciesBackupImportJob in project collect by openforis.

the class SpeciesBackupImportJobIntegrationTest method testSpeciesImport.

@Test
public void testSpeciesImport() throws Exception {
    SpeciesBackupImportJob job = importCSVFile(VALID_TEST_CSV);
    assertTrue(job.isCompleted());
    SpeciesBackupImportTask task = (SpeciesBackupImportTask) job.getTasks().get(0);
    assertTrue(task.getSkippedRows().isEmpty());
    TaxonomyDefinition taxonomyDef = survey.getReferenceDataSchema().getTaxonomyDefinition(TEST_TAXONOMY_NAME);
    assertEquals(Arrays.asList("info1", "info2"), taxonomyDef.getAttributeNames());
    {
        String code = "OLE/CAP/macrocarpa";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(code, "Olea capensis ssp. macrocarpa");
        expected.setInfoAttributes(Arrays.asList("info_value_1", "info_value_2"));
        expected.setTaxonRank(SUBSPECIES);
        assertEquals(expected, occurrence);
    }
    {
        String code = "ALB/ADI";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(code, "Albizia adianthifolia");
        expected.setInfoAttributes(Arrays.asList("info_value_3", null));
        expected.setTaxonRank(SPECIES);
        assertEquals(expected, occurrence);
    }
}
Also used : SpeciesBackupImportTask(org.openforis.collect.io.metadata.species.SpeciesBackupImportTask) TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) TaxonomyDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.TaxonomyDefinition) SpeciesBackupImportJob(org.openforis.collect.io.metadata.species.SpeciesBackupImportJob) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Aggregations

SpeciesBackupImportJob (org.openforis.collect.io.metadata.species.SpeciesBackupImportJob)3 Test (org.junit.Test)2 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)2 CollectTaxonomy (org.openforis.collect.model.CollectTaxonomy)2 File (java.io.File)1 SpeciesBackupImportTask (org.openforis.collect.io.metadata.species.SpeciesBackupImportTask)1 TaxonSummaries (org.openforis.collect.metamodel.TaxonSummaries)1 TaxonomyDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.TaxonomyDefinition)1 TaxonOccurrence (org.openforis.idm.model.TaxonOccurrence)1