use of org.openforis.collect.model.CollectTaxonomy in project collect by openforis.
the class SpeciesBackupImportJobIntegrationTest method findByCode.
protected TaxonOccurrence findByCode(String code) {
CollectTaxonomy taxonomy = speciesManager.loadTaxonomyByName(survey, TEST_TAXONOMY_NAME);
TaxonSearchParameters searchParameters = new TaxonSearchParameters();
searchParameters.setHighestRank(FAMILY);
List<TaxonOccurrence> occurrences = speciesManager.findByCode(taxonomy, code, 10, searchParameters);
assertNotNull(occurrences);
assertEquals(1, occurrences.size());
TaxonOccurrence occurrence = occurrences.get(0);
return occurrence;
}
use of org.openforis.collect.model.CollectTaxonomy in project collect by openforis.
the class SurveyManagerIntegrationTest method insertTestTaxonomy.
private void insertTestTaxonomy() {
CollectTaxonomy taxonomy = new CollectTaxonomy();
taxonomy.setName("tree");
taxonomy.setSurvey(survey);
speciesManager.save(taxonomy);
Taxon taxon = new Taxon();
taxon.setTaxonomyId(taxonomy.getId());
taxon.setCode("ALB/GLA");
taxon.setScientificName("Albizia glaberrima");
taxon.setTaxonRank(TaxonRank.GENUS);
speciesManager.save(taxon);
{
TaxonVernacularName vernacularName = new TaxonVernacularName();
vernacularName.setTaxonSystemId(taxon.getSystemId());
vernacularName.setVernacularName("Mgerenge");
vernacularName.setLanguageCode("swh");
speciesManager.save(vernacularName);
}
{
TaxonVernacularName vernacularName = new TaxonVernacularName();
vernacularName.setTaxonSystemId(taxon.getSystemId());
vernacularName.setVernacularName("Mchani");
vernacularName.setLanguageCode("swh");
speciesManager.save(vernacularName);
}
}
use of org.openforis.collect.model.CollectTaxonomy in project collect by openforis.
the class SurveyManagerIntegrationTest method publishSurveyTaxonomyTest.
@Test
public void publishSurveyTaxonomyTest() throws SurveyImportException {
insertTestTaxonomy();
CollectSurvey temporarySurvey = surveyManager.createTemporarySurveyFromPublished(survey.getUri(), adminUser);
{
CollectTaxonomy taxonomy = speciesManager.loadTaxonomyByName(temporarySurvey, "tree");
assertNotNull(taxonomy);
TaxonSummaries summaries = speciesManager.loadFullTaxonSummariesOld(taxonomy);
assertEquals(1, summaries.getTotalCount());
List<TaxonSummary> taxonSummaryList = summaries.getItems();
{
TaxonSummary taxonSummary = taxonSummaryList.get(0);
assertEquals("Albizia glaberrima", taxonSummary.getScientificName());
List<String> vernacularLanguages = taxonSummary.getVernacularLanguages();
assertEquals(Arrays.asList("swh"), vernacularLanguages);
List<String> vernacularNames = taxonSummary.getVernacularNames("swh");
assertEquals(Arrays.asList("Mgerenge", "Mchani"), vernacularNames);
}
}
}
use of org.openforis.collect.model.CollectTaxonomy in project collect by openforis.
the class SpeciesDaoIntegrationTest method testInsertAndLoadTaxonomy.
private CollectTaxonomy testInsertAndLoadTaxonomy(String name) {
CollectSurvey survey = createAndStoreSurvey();
// Insert
CollectTaxonomy t1 = new CollectTaxonomy();
t1.setName(name);
t1.setSurvey(survey);
taxonomyDao.insert(t1);
CollectTaxonomy t = t1;
// Confirm saved
CollectTaxonomy t2 = taxonomyDao.loadById(survey, t.getId());
assertEquals(t.getId(), t2.getId());
assertEquals(t.getName(), t2.getName());
return t2;
}
use of org.openforis.collect.model.CollectTaxonomy in project collect by openforis.
the class SpeciesDaoIntegrationTest method testFindCode.
private void testFindCode(String match, int maxResults, int expectedResults) {
// Create taxonomy
CollectTaxonomy taxonomy1 = testInsertAndLoadTaxonomy("it_bamboo");
testUpdateAndLoadTaxonomy(taxonomy1, "it_trees");
Taxon family1 = testInsertAndLoadTaxon(taxonomy1, -1, "JUGLANDACAE", "Juglandaceae", FAMILY, 9, null);
Taxon genus1 = testInsertAndLoadTaxon(taxonomy1, -2, "JUG", "Juglans sp.", GENUS, 9, family1);
testInsertAndLoadTaxon(taxonomy1, -3, "JUG/REG", "Juglans regia", SPECIES, 9, genus1);
List<Taxon> results = taxonDao.findByCode(taxonomy1, FAMILY, match, maxResults);
assertEquals(expectedResults, results.size());
match = match.toUpperCase();
for (Taxon taxon : results) {
String code = taxon.getCode();
code = (code == null) ? "" : code.toUpperCase();
assertTrue(code.startsWith(match));
}
}
Aggregations