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;
}
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"));
}
}
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;
}
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);
}
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);
}
Aggregations