use of org.openforis.idm.model.species.TaxonVernacularName in project collect by openforis.
the class SpeciesImportProcess method processVernacularNames.
protected void processVernacularNames(SpeciesLine line, Taxon taxon) {
Map<String, List<String>> langToVernacularName = line.getLanguageToVernacularNames();
Set<String> vernacularLangCodes = langToVernacularName.keySet();
for (String langCode : vernacularLangCodes) {
List<String> vernacularNames = langToVernacularName.get(langCode);
for (String vernacularName : vernacularNames) {
TaxonVernacularName taxonVN = new TaxonVernacularName();
taxonVN.setLanguageCode(langCode);
taxonVN.setVernacularName(vernacularName);
taxonTree.addVernacularName(taxon, taxonVN);
}
}
}
use of org.openforis.idm.model.species.TaxonVernacularName in project collect by openforis.
the class TaxonVernacularNameDao method findByVernacularName.
public List<TaxonVernacularName> findByVernacularName(int taxonomyId, String searchString, String[] qualifierValues, int maxResults) {
TaxonVernacularNameDSLContext dsl = dsl();
// find containing
searchString = "%" + searchString.toLowerCase(Locale.ENGLISH) + "%";
SelectConditionStep selectConditionStep = dsl.select(OFC_TAXON_VERNACULAR_NAME.fields()).from(OFC_TAXON_VERNACULAR_NAME).join(OFC_TAXON).on(OFC_TAXON.ID.equal(OFC_TAXON_VERNACULAR_NAME.TAXON_ID)).where(OFC_TAXON.TAXONOMY_ID.equal(taxonomyId).and(DSL.lower(OFC_TAXON_VERNACULAR_NAME.VERNACULAR_NAME).like(searchString)));
if (qualifierValues != null) {
for (int i = 0; i < qualifierValues.length; i++) {
String value = qualifierValues[i];
if (value != null) {
TableField field = QUALIFIER_FIELDS[i];
selectConditionStep.and(field.equal(value));
}
}
}
selectConditionStep.limit(maxResults);
Result<?> result = selectConditionStep.fetch();
List<TaxonVernacularName> entities = dsl.fromResult(result);
return entities;
}
use of org.openforis.idm.model.species.TaxonVernacularName in project collect by openforis.
the class TaxonVernacularNameDao method findByTaxon.
public List<TaxonVernacularName> findByTaxon(int taxonId) {
TaxonVernacularNameDSLContext dsl = dsl();
SelectConditionStep selectConditionStep = dsl.select(OFC_TAXON_VERNACULAR_NAME.fields()).from(OFC_TAXON_VERNACULAR_NAME).where(OFC_TAXON_VERNACULAR_NAME.TAXON_ID.equal(taxonId));
Result<?> result = selectConditionStep.fetch();
List<TaxonVernacularName> entities = dsl.fromResult(result);
return entities;
}
use of org.openforis.idm.model.species.TaxonVernacularName 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.idm.model.species.TaxonVernacularName in project collect by openforis.
the class SpeciesDaoIntegrationTest method testCRUD.
// Disabled because SQLite does not provide Unicode case support by default
// TODO implement it
// @Test
// public void testFindUnicode() throws Exception {
// testFindVernacularName("Орех", 100, 1);
// }
//
// @Test
// public void testFindUnicodeCaseInsensitive() throws Exception {
// testFindVernacularName("орех", 100, 1);
// }
@Test
public void testCRUD() throws Exception {
// Create taxonomy
CollectTaxonomy taxonomy1 = testInsertAndLoadTaxonomy("it_bamboo");
testUpdateAndLoadTaxonomy(taxonomy1, "it_trees");
// Create taxa
Stack<Taxon> taxa = new Stack<Taxon>();
taxa.push(testInsertAndLoadTaxon(taxonomy1, -1, "JUG", "Juglandaceaex", FAMILY, 9, null));
taxa.push(testInsertAndLoadTaxon(taxonomy1, -2, "JUG2", "sJuglans sp.", GENUS, 0, null));
taxa.push(testUpdateAndLoadTaxon(taxonomy1, taxa.pop(), "Juglans sp.", GENUS, 9, taxa.get(0)));
taxa.push(testInsertAndLoadTaxon(taxonomy1, -4, "JUG3", "Juglans regia", SPECIES, 9, taxa.get(1)));
// Create vernacular names
Stack<TaxonVernacularName> names = new Stack<TaxonVernacularName>();
names.push(testInsertAndLoadVernacularName(taxa.get(0), "Walnut family", "eng", "", 9));
names.push(testInsertAndLoadVernacularName(taxa.get(0), "Walnuts", "en", "Cockney", 0));
names.push(testUpdateAndLoadVernacularName(names.pop(), taxa.get(1), "Walnut", "eng", "", 9));
names.push(testInsertAndLoadVernacularName(taxa.get(1), "Noce", "ita", "", 9));
names.push(testInsertAndLoadVernacularName(taxa.get(2), "Persian walnut", "eng", "", 9));
names.push(testInsertAndLoadVernacularName(taxa.get(2), "English walnut", "eng", "", 9));
names.push(testInsertAndLoadVernacularName(taxa.get(2), "Noce bianco", "ita", "", 9));
names.push(testInsertAndLoadVernacularName(taxa.get(2), "Орех грецкий", "rus", "", 9));
// Remove names
while (!names.isEmpty()) {
testDeleteAndLoadVernacularName(names.pop());
}
// Remove taxa
while (!taxa.isEmpty()) {
testDeleteAndLoadTaxon(taxa.pop());
}
// Remove taxonomy
testDeleteAndLoadTaxonomy(taxonomy1);
}
Aggregations