use of org.openforis.idm.model.species.Taxon 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.species.Taxon in project collect by openforis.
the class SpeciesImportProcessIntegrationTest method testHierarchyImport.
@Test
public void testHierarchyImport() throws Exception {
SpeciesImportProcess process = importCSVFile(VALID_TEST_CSV);
SpeciesImportStatus status = process.getStatus();
assertTrue(status.isComplete());
CollectTaxonomy taxonomy = taxonomyDao.loadByName(survey, TEST_TAXONOMY_NAME);
{
Taxon variety = findTaxonByCode("ALB/SCH/amaniensis");
assertNotNull(variety);
assertEquals(VARIETY, variety.getTaxonRank());
Integer speciesId = variety.getParentId();
assertNotNull(speciesId);
Taxon species = taxonDao.loadById(taxonomy, speciesId);
assertNotNull(species);
assertNull(species.getCode());
assertEquals(SPECIES, species.getTaxonRank());
assertEquals("Albizia schimperiana", species.getScientificName());
Integer genusId = species.getParentId();
assertNotNull(genusId);
Taxon genus = taxonDao.loadById(taxonomy, genusId);
assertNotNull(genus);
assertEquals("ALB", genus.getCode());
assertEquals(GENUS, genus.getTaxonRank());
assertEquals("Albizia sp.", genus.getScientificName());
Integer familyId = genus.getParentId();
assertNotNull(familyId);
Taxon family = taxonDao.loadById(taxonomy, familyId);
assertNotNull(family);
assertNull(family.getParentId());
assertEquals(FAMILY, family.getTaxonRank());
assertEquals("Fabaceae", family.getScientificName());
}
{
Taxon subspecies = findTaxonByCode("OLE/EUR/cuspidata");
assertNotNull(subspecies);
assertEquals(SUBSPECIES, subspecies.getTaxonRank());
Integer speciesId = subspecies.getParentId();
assertNotNull(speciesId);
Taxon species = taxonDao.loadById(taxonomy, speciesId);
assertNotNull(species);
assertEquals(SPECIES, species.getTaxonRank());
assertEquals("OLE/EUR", species.getCode());
assertEquals("Olea europaea", species.getScientificName());
}
}
use of org.openforis.idm.model.species.Taxon in project collect by openforis.
the class TaxonTree method index.
protected void index(Node node) {
Taxon taxon = node.getTaxon();
scientificNameToNode.put(taxon.getScientificName(), node);
String code = taxon.getCode();
if (code != null) {
codeToNode.put(code, node);
}
Integer taxonId = taxon.getTaxonId();
if (taxonId != null) {
taxonIdToNode.put(taxonId, node);
}
Integer systemId = taxon.getSystemId();
if (systemId != null) {
systemIdToNode.put(systemId, node);
}
}
use of org.openforis.idm.model.species.Taxon in project collect by openforis.
the class SpeciesImportProcess method createTaxonSpecies.
protected Taxon createTaxonSpecies(SpeciesLine line) throws ParsingException {
String speciesName;
if (line.getRank() == SPECIES) {
speciesName = line.getCanonicalScientificName();
} else {
speciesName = line.getSpeciesName();
}
if (speciesName == null) {
ParsingError error = new ParsingError(ErrorType.INVALID_VALUE, line.getLineNumber(), SpeciesFileColumn.SCIENTIFIC_NAME.getColumnName(), INVALID_SPECIES_NAME_ERROR_MESSAGE_KEY);
throw new ParsingException(error);
}
Taxon taxonGenus = createTaxonGenus(line);
return createTaxon(line, SPECIES, taxonGenus, speciesName);
}
Aggregations