Search in sources :

Example 1 with TaxonOccurrence

use of org.openforis.idm.model.TaxonOccurrence 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 2 with TaxonOccurrence

use of org.openforis.idm.model.TaxonOccurrence 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 3 with TaxonOccurrence

use of org.openforis.idm.model.TaxonOccurrence in project collect by openforis.

the class SpeciesService method findByVernacularName.

@Secured("ROLE_ENTRY")
public List<TaxonOccurrenceProxy> findByVernacularName(String taxonomyName, int nodeId, String searchString, int maxResults, TaxonSearchParameters parameters) {
    CollectTaxonomy taxonomy = loadTaxonomyByActiveSurvey(taxonomyName);
    CollectRecord activeRecord = sessionManager.getActiveRecord();
    Node<? extends NodeDefinition> attr = activeRecord.getNodeByInternalId(nodeId);
    if (attr instanceof TaxonAttribute) {
        List<TaxonOccurrence> list = speciesManager.findByVernacularName(taxonomy, (TaxonAttribute) attr, searchString, maxResults, parameters);
        return Proxies.fromList(list, TaxonOccurrenceProxy.class);
    } else {
        throw new IllegalArgumentException("TaxonAttribute expected, found: " + attr.getClass().getName());
    }
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) CollectRecord(org.openforis.collect.model.CollectRecord) TaxonAttribute(org.openforis.idm.model.TaxonAttribute) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) Secured(org.springframework.security.access.annotation.Secured)

Example 4 with TaxonOccurrence

use of org.openforis.idm.model.TaxonOccurrence in project collect by openforis.

the class SpeciesManager method fromTaxonomiesToTaxonOccurrences.

private List<TaxonOccurrence> fromTaxonomiesToTaxonOccurrences(List<Taxon> list, TaxonSearchParameters parameters) {
    List<TaxonOccurrence> result = new ArrayList<TaxonOccurrence>(list.size());
    for (Taxon taxon : list) {
        TaxonOccurrence o = new TaxonOccurrence(taxon);
        o.setTaxonRank(taxon.getTaxonRank());
        if (parameters.isIncludeUniqueVernacularName()) {
            includeUniqueVernacularNameIfAny(taxon.getSystemId(), o);
        }
        if (parameters.isIncludeAncestorTaxons()) {
            loadAncestorTaxons(taxon, o);
        }
        result.add(o);
    }
    return result;
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) Taxon(org.openforis.idm.model.species.Taxon) ArrayList(java.util.ArrayList)

Example 5 with TaxonOccurrence

use of org.openforis.idm.model.TaxonOccurrence in project collect by openforis.

the class SpeciesManager method loadAncestorTaxons.

private void loadAncestorTaxons(Taxon taxon, TaxonOccurrence o) {
    Taxon currentTaxon = taxon;
    while (currentTaxon.getParentId() != null) {
        Taxon parentTaxon = taxonDao.loadById((CollectTaxonomy) currentTaxon.getTaxonomy(), currentTaxon.getParentId());
        TaxonOccurrence parentTaxonOccurrence = new TaxonOccurrence(parentTaxon);
        o.addAncestorTaxon(parentTaxonOccurrence);
        currentTaxon = parentTaxon;
    }
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) Taxon(org.openforis.idm.model.species.Taxon)

Aggregations

TaxonOccurrence (org.openforis.idm.model.TaxonOccurrence)18 CollectTaxonomy (org.openforis.collect.model.CollectTaxonomy)8 Taxon (org.openforis.idm.model.species.Taxon)6 Secured (org.springframework.security.access.annotation.Secured)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)4 SpeciesImportProcess (org.openforis.collect.manager.speciesimport.SpeciesImportProcess)3 SpeciesImportStatus (org.openforis.collect.manager.speciesimport.SpeciesImportStatus)3 TaxonTree (org.openforis.collect.model.TaxonTree)2 List (java.util.List)1 SpeciesBackupImportJob (org.openforis.collect.io.metadata.species.SpeciesBackupImportJob)1 SpeciesBackupImportTask (org.openforis.collect.io.metadata.species.SpeciesBackupImportTask)1 TaxonSearchParameters (org.openforis.collect.manager.TaxonSearchParameters)1 CollectRecord (org.openforis.collect.model.CollectRecord)1 TaxonomyDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.TaxonomyDefinition)1 TaxonAttribute (org.openforis.idm.model.TaxonAttribute)1 TaxonRank (org.openforis.idm.model.species.Taxon.TaxonRank)1 TaxonVernacularName (org.openforis.idm.model.species.TaxonVernacularName)1