Search in sources :

Example 11 with TaxonOccurrence

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

the class SpeciesManager method findByFamilyCode.

public List<TaxonOccurrence> findByFamilyCode(CollectTaxonomy taxonomy, String searchString, int maxResults, TaxonSearchParameters parameters) {
    List<TaxonOccurrence> result = new ArrayList<TaxonOccurrence>();
    TaxonTree taxonTree = loadTaxonTree(taxonomy);
    List<Taxon> families = taxonTree.findTaxaByCodeStartingWith(searchString, parameters.getHighestRank());
    result.addAll(fromTaxonomiesToTaxonOccurrences(families, parameters));
    for (Taxon familyTaxon : families) {
        List<TaxonOccurrence> descendants = taxonTree.getDescendantOccurrences(familyTaxon, parameters);
        result.addAll(descendants);
    }
    return result;
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) Taxon(org.openforis.idm.model.species.Taxon) ArrayList(java.util.ArrayList) TaxonTree(org.openforis.collect.model.TaxonTree)

Example 12 with TaxonOccurrence

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

the class SpeciesImportProcessIntegrationTest method testVernacularNamesImport.

@Test
public void testVernacularNamesImport() throws Exception {
    SpeciesImportProcess process = importCSVFile(VALID_TEST_CSV);
    SpeciesImportStatus status = process.getStatus();
    assertTrue(status.isComplete());
    CollectTaxonomy taxonomy = speciesManager.loadTaxonomyByName(survey, TEST_TAXONOMY_NAME);
    TaxonSearchParameters taxonSearchParameters = new TaxonSearchParameters();
    taxonSearchParameters.setHighestRank(FAMILY);
    {
        List<TaxonOccurrence> occurrences = speciesManager.findByVernacularName(taxonomy, null, "Mbamba", 10, taxonSearchParameters);
        assertNotNull(occurrences);
        assertEquals(1, occurrences.size());
        TaxonOccurrence stored = occurrences.get(0);
        TaxonOccurrence expected = new TaxonOccurrence(8, "AFZ/QUA", "Afzelia quanzensis", "Mbambakofi", "swh", null);
        expected.setTaxonRank(SPECIES);
        assertEquals(expected, stored);
    }
    {
        List<TaxonOccurrence> occurrences = speciesManager.findByVernacularName(taxonomy, null, "Mshai-mamba", 10, taxonSearchParameters);
        assertNotNull(occurrences);
        assertEquals(1, occurrences.size());
        TaxonOccurrence stored = occurrences.get(0);
        TaxonOccurrence expected = new TaxonOccurrence(10, "ALB/ADI", "Albizia adianthifolia", "Mshai-mamba", "ksb", null);
        expected.setTaxonRank(SPECIES);
        assertEquals(expected, stored);
    }
    {
        Taxon taxon = findTaxonByCode("ALB/ADI");
        Integer taxonId = taxon.getSystemId();
        List<TaxonVernacularName> vernacularNames = taxonVernacularNameDao.findByTaxon(taxonId);
        assertTrue(contains(vernacularNames, "ksb", "Mchao"));
        assertTrue(contains(vernacularNames, "ksb", "Mkengemshaa"));
        assertTrue(contains(vernacularNames, "ksb", "Msai"));
        assertTrue(contains(vernacularNames, "ksb", "Mshai"));
        assertTrue(contains(vernacularNames, "ksb", "Mshai-mamba"));
        assertFalse(contains(vernacularNames, "eng", "Mahogany"));
        assertFalse(contains(vernacularNames, "ksb", "Mahogany"));
    }
    {
        Taxon taxon = findTaxonByCode("BOU/PET");
        assertEquals("Bourreria petiolaris", taxon.getScientificName());
        Integer taxonId = taxon.getSystemId();
        List<TaxonVernacularName> vernacularNames = taxonVernacularNameDao.findByTaxon(taxonId);
        assertEquals(1, vernacularNames.size());
        assertTrue(contains(vernacularNames, "swh", "Mpanda jongoo"));
    }
    {
        Taxon taxon = findTaxonByCode("BOM/RHO");
        assertEquals("Bombax rhodognaphalon", taxon.getScientificName());
        Integer taxonId = taxon.getSystemId();
        List<TaxonVernacularName> vernacularNames = taxonVernacularNameDao.findByTaxon(taxonId);
        assertEquals(1, vernacularNames.size());
        assertTrue(contains(vernacularNames, "swh", "Msufi mwitu"));
    }
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) Taxon(org.openforis.idm.model.species.Taxon) SpeciesImportProcess(org.openforis.collect.manager.speciesimport.SpeciesImportProcess) SpeciesImportStatus(org.openforis.collect.manager.speciesimport.SpeciesImportStatus) List(java.util.List) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 13 with TaxonOccurrence

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

the class SpeciesImportProcessIntegrationTest method findByCode.

protected TaxonOccurrence findByCode(String code) {
    CollectTaxonomy taxonomy = taxonomyDao.loadByName(survey, TEST_TAXONOMY_NAME);
    TaxonSearchParameters taxonSearchParameters = new TaxonSearchParameters();
    List<TaxonOccurrence> occurrences = speciesManager.findByCode(taxonomy, code, 10, taxonSearchParameters);
    assertNotNull(occurrences);
    assertEquals(1, occurrences.size());
    TaxonOccurrence occurrence = occurrences.get(0);
    return occurrence;
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy)

Example 14 with TaxonOccurrence

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

the class SpeciesService method findByFamilyScientificName.

@Secured("ROLE_ENTRY")
public List<TaxonOccurrenceProxy> findByFamilyScientificName(String taxonomyName, String searchString, int maxResults, TaxonSearchParameters parameters) {
    CollectTaxonomy taxonomy = loadTaxonomyByActiveSurvey(taxonomyName);
    List<TaxonOccurrence> list = speciesManager.findByFamilyScientificName(taxonomy, searchString, maxResults, parameters);
    return Proxies.fromList(list, TaxonOccurrenceProxy.class);
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) Secured(org.springframework.security.access.annotation.Secured)

Example 15 with TaxonOccurrence

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

the class SpeciesService method findByScientificName.

@Secured("ROLE_ENTRY")
public List<TaxonOccurrenceProxy> findByScientificName(String taxonomyName, String searchString, int maxResults, TaxonSearchParameters parameters) {
    CollectTaxonomy taxonomy = loadTaxonomyByActiveSurvey(taxonomyName);
    List<TaxonOccurrence> list = speciesManager.findByScientificName(taxonomy, searchString, maxResults, parameters);
    return Proxies.fromList(list, TaxonOccurrenceProxy.class);
}
Also used : TaxonOccurrence(org.openforis.idm.model.TaxonOccurrence) CollectTaxonomy(org.openforis.collect.model.CollectTaxonomy) Secured(org.springframework.security.access.annotation.Secured)

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