Search in sources :

Example 1 with SpeciesImportStatus

use of org.openforis.collect.manager.speciesimport.SpeciesImportStatus in project collect by openforis.

the class SpeciesImportProcessIntegrationTest method testInvalidColumns.

@Test
public void testInvalidColumns() throws Exception {
    SpeciesImportProcess process = importCSVFile(INVALID_MISSING_COLUMNS_TEST_CSV);
    SpeciesImportStatus status = process.getStatus();
    assertTrue(status.isError());
    List<ParsingError> errors = status.getErrors();
    assertEquals(1, errors.size());
    ParsingError error = errors.get(0);
    ErrorType errorType = error.getErrorType();
    assertEquals(ErrorType.MISSING_REQUIRED_COLUMNS, errorType);
}
Also used : ParsingError(org.openforis.collect.io.metadata.parsing.ParsingError) ErrorType(org.openforis.collect.io.metadata.parsing.ParsingError.ErrorType) SpeciesImportProcess(org.openforis.collect.manager.speciesimport.SpeciesImportProcess) SpeciesImportStatus(org.openforis.collect.manager.speciesimport.SpeciesImportStatus) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 2 with SpeciesImportStatus

use of org.openforis.collect.manager.speciesimport.SpeciesImportStatus in project collect by openforis.

the class SpeciesImportProcessIntegrationTest method testSpeciesImport.

@Test
public void testSpeciesImport() throws Exception {
    SpeciesImportProcess process = importCSVFile(VALID_TEST_CSV);
    SpeciesImportStatus status = process.getStatus();
    assertTrue(status.isComplete());
    assertTrue(status.getSkippedRows().isEmpty());
    {
        String code = "OLE/CAP/macrocarpa";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(5, code, "Olea capensis subsp. macrocarpa");
        expected.setTaxonRank(TaxonRank.SUBSPECIES);
        assertEquals(expected, occurrence);
    }
    {
        String code = "OLE/EUR/cuspidata";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(7, code, "Olea europaea subsp. cuspidata");
        expected.setTaxonRank(TaxonRank.SUBSPECIES);
        assertEquals(expected, occurrence);
    }
    {
        String code = "AFZ/QUA";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(8, code, "Afzelia quanzensis");
        expected.setTaxonRank(TaxonRank.SPECIES);
        assertEquals(expected, occurrence);
    }
    {
        String code = "ALB/GLA";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(11, code, "Albizia glaberrima");
        expected.setTaxonRank(TaxonRank.SPECIES);
        assertEquals(expected, occurrence);
    }
    {
        String code = "ALB/SCH/amaniensis";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(12, code, "Albizia schimperiana var. amaniensis");
        expected.setTaxonRank(TaxonRank.VARIETY);
        assertEquals(expected, occurrence);
    }
    {
        String code = "RUT/CIT/RETxPAR";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(15, code, "Citrus reticulata x Citrus paradisi");
        expected.setTaxonRank(TaxonRank.SPECIES);
        assertEquals(expected, occurrence);
    }
    {
        String code = "IRI/IRI/GER";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(16, code, "Iris ×germanica");
        expected.setTaxonRank(TaxonRank.SPECIES);
        assertEquals(expected, occurrence);
    }
    {
        String code = "IRI/IRI/BUI";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(17, code, "Iris x buiana");
        expected.setTaxonRank(TaxonRank.SPECIES);
        assertEquals(expected, occurrence);
    }
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) SpeciesImportProcess(org.openforis.collect.manager.speciesimport.SpeciesImportProcess) SpeciesImportStatus(org.openforis.collect.manager.speciesimport.SpeciesImportStatus) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 3 with SpeciesImportStatus

use of org.openforis.collect.manager.speciesimport.SpeciesImportStatus in project collect by openforis.

the class SpeciesImportProcessIntegrationTest method testExport.

@Test
public void testExport() throws Exception {
    SpeciesImportProcess process = importCSVFile(VALID_TEST_CSV);
    SpeciesImportStatus status = process.getStatus();
    assertTrue(status.isComplete());
    CollectTaxonomy taxonomy = taxonomyDao.loadByName(survey, TEST_TAXONOMY_NAME);
    TaxonSummaries summaries = speciesManager.loadFullTaxonSummariesOld(taxonomy);
    assertNotNull(summaries);
}
Also used : SpeciesImportProcess(org.openforis.collect.manager.speciesimport.SpeciesImportProcess) SpeciesImportStatus(org.openforis.collect.manager.speciesimport.SpeciesImportStatus) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) TaxonSummaries(org.openforis.collect.metamodel.TaxonSummaries) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 4 with SpeciesImportStatus

use of org.openforis.collect.manager.speciesimport.SpeciesImportStatus in project collect by openforis.

the class SpeciesImportProcessIntegrationTest method testSpeciesImportWithExtraColumns.

@Test
public void testSpeciesImportWithExtraColumns() throws Exception {
    SpeciesImportProcess process = importCSVFile(VALID_EXTRA_COLUMNS_TEST_CSV);
    SpeciesImportStatus status = process.getStatus();
    assertTrue(status.isComplete());
    assertTrue(status.getSkippedRows().isEmpty());
    {
        String code = "AFZ/QUA";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(8, code, "Afzelia quanzensis");
        expected.setInfoAttributes(Arrays.asList("TEST 3"));
        expected.setTaxonRank(SPECIES);
        assertEquals(expected, occurrence);
    }
    {
        String code = "ALB/GLA";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(11, code, "Albizia glaberrima");
        expected.setInfoAttributes(Arrays.asList((String) null));
        expected.setTaxonRank(SPECIES);
        assertEquals(expected, occurrence);
    }
    {
        String code = "ALB/SCH/amaniensis";
        TaxonOccurrence occurrence = findByCode(code);
        TaxonOccurrence expected = new TaxonOccurrence(12, code, "Albizia schimperiana var. amaniensis");
        expected.setInfoAttributes(Arrays.asList("TEST 1"));
        expected.setTaxonRank(VARIETY);
        assertEquals(expected, occurrence);
    }
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) SpeciesImportProcess(org.openforis.collect.manager.speciesimport.SpeciesImportProcess) SpeciesImportStatus(org.openforis.collect.manager.speciesimport.SpeciesImportStatus) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 5 with SpeciesImportStatus

use of org.openforis.collect.manager.speciesimport.SpeciesImportStatus in project collect by openforis.

the class SpeciesImportService method start.

@Secured("ROLE_ADMIN")
public SpeciesImportStatusProxy start(String tempFileName, CSVFileOptions csvFileOptions, int surveyId, int taxonomyId, boolean overwriteAll) throws DataImportExeption {
    if (importProcess == null || !importProcess.getStatus().isRunning()) {
        CollectSurvey survey = sessionManager.getActiveDesignerSurvey();
        if (survey.getId() != surveyId) {
            throw new IllegalStateException("Error importing species list: different survey found in session");
        }
        File importFile = new File(tempFileName);
        importProcess = new SpeciesImportProcess(surveyManager, speciesManager, survey, taxonomyId, importFile, csvFileOptions, overwriteAll);
        importProcess.init();
        SpeciesImportStatus status = importProcess.getStatus();
        if (status != null && !importProcess.getStatus().isError()) {
            startProcessThread();
        }
    }
    return getStatus();
}
Also used : SpeciesImportProcess(org.openforis.collect.manager.speciesimport.SpeciesImportProcess) SpeciesImportStatus(org.openforis.collect.manager.speciesimport.SpeciesImportStatus) CollectSurvey(org.openforis.collect.model.CollectSurvey) File(java.io.File) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

SpeciesImportProcess (org.openforis.collect.manager.speciesimport.SpeciesImportProcess)8 SpeciesImportStatus (org.openforis.collect.manager.speciesimport.SpeciesImportStatus)8 Test (org.junit.Test)7 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)7 CollectTaxonomy (org.openforis.collect.model.CollectTaxonomy)3 TaxonOccurrence (org.openforis.idm.model.TaxonOccurrence)3 ParsingError (org.openforis.collect.io.metadata.parsing.ParsingError)2 Taxon (org.openforis.idm.model.species.Taxon)2 File (java.io.File)1 List (java.util.List)1 ErrorType (org.openforis.collect.io.metadata.parsing.ParsingError.ErrorType)1 TaxonSummaries (org.openforis.collect.metamodel.TaxonSummaries)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 Secured (org.springframework.security.access.annotation.Secured)1