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