taxa.addAll(subCommonNames.list());
}
- //FIXME : the fourth element of the result should be a boolean, but in the case of a synonym
- // (which does require a check) a constant boolean (false) value needs to set. It seems that
- // hql cannot parse a constant boolean value in the select list clause. This implies that the
- // resulting object could be a Boolean or a String. The workaround for this is to convert the
- // resutling object into a String (using toString) and then create a new Boolean object from
- // String.
- if (doTaxa && doSynonyms){
+
+ // if (doTaxa && doSynonyms){
if(synonyms.size()>0 && taxa.size()>0){
hql = "select " + selectWhat;
// in doNotReturnFullEntities mode it is nesscary to also return the type of the matching entities:
} else{
hql = "select " + selectWhat + " from %s t";
}
- } else if(doTaxa || doCommonNames){
- if (taxa.size()>0){
- hql = "select " + selectWhat;
- // in doNotReturnFullEntities mode it is nesscary to also return the type of the matching entities:
- // also return the computed isOrphaned flag
- if (doNotReturnFullEntities){
- hql += ", 'taxon', " +
- " case when t.taxonNodes is empty and t.relationsFromThisTaxon is empty and t.relationsToThisTaxon is empty then true else false end ";
- }
- hql += " from %s t " +
- " where t.id in (:taxa) ";
-
- }else{
- hql = "select " + selectWhat + " from %s t";
- }
- } else if(doSynonyms){
- if (synonyms.size()>0){
-
- hql = "select " + selectWhat;
- // in doNotReturnFullEntities mode it is nesscary to also return the type of the matching entities:
- // also return the computed isOrphaned flag
- if (doNotReturnFullEntities){
- hql += ", 'synonym', 'false' ";
- }
- hql += " from %s t " +
- " where t.id in (:synonyms) ";
- }else{
- hql = "select " + selectWhat + " from %s t";
- }
- } else if (doIncludeMisappliedNames){
- hql = "select " + selectWhat;
- // in doNotReturnFullEntities mode it is nesscary to also return the type of the matching entities:
- // also return the computed isOrphaned flag
- if (doNotReturnFullEntities){
- hql += ", 'taxon', " +
- " case when t.taxonNodes is empty and t.relationsFromThisTaxon is empty and t.relationsToThisTaxon is empty then true else false end ";
- }
- hql += " from %s t " +
- " where t.id in (:taxa) ";
-
- }
String classString;
- if (doTaxa && doSynonyms){
+ if ((doTaxa || doCommonNames || doIncludeMisappliedNames) && doSynonyms){
classString = "TaxonBase";
} else if (doTaxa || doCommonNames){
classString = "Taxon";
- } else if (doSynonyms){
+ } else if (doSynonyms && !(doCommonNames|| doTaxa || doIncludeMisappliedNames)){
classString = "Synonym";
} else{//only misappliedNames
classString = "Taxon";
Query query = getSession().createQuery(hql);
- if (doTaxa && doSynonyms){
+ if ((doTaxa || doCommonNames || doIncludeMisappliedNames) ){
// find taxa and synonyms
if (taxa.size()>0){
query.setParameterList("taxa", taxa);
if (taxa.size()== 0 && synonyms.size() == 0){
return null;
}
- }else if(doTaxa || doCommonNames || doIncludeMisappliedNames){
- //find taxa
- if (taxa.size()>0){
- query.setParameterList("taxa", taxa );
- }else{
- logger.warn("there are no taxa for the query: " + queryString);
- return null;
- }
- } else if(doSynonyms){
+ }
+ if(doSynonyms){
// find synonyms
if (synonyms.size()>0){
query.setParameterList("synonyms", synonyms);
}else{
return null;
}
- } else{
- //only misappliedNames
- if (taxa.size()>0){
- query.setParameterList("taxa", taxa );
- }else{
- return null;
- }
}
return query;
setTaxaAndNamesModes(conf, false, true, true, true, true);
pager = taxonService.findTaxaAndNames(conf);
- assertEquals(3, pager.getRecords().size());
+ assertEquals(4, pager.getRecords().size());
setTaxaAndNamesModes(conf, true, false, true, true, true);
pager = taxonService.findTaxaAndNames(conf);
// FIXME org.hibernate.QueryParameterException: could not locate named parameter [taxa]
- // setTaxaAndNamesModes(conf, false, true, false, true, true);
- // pager = taxonService.findTaxaAndNames(conf);
- // assertEquals(3, pager.getRecords().size());
+ setTaxaAndNamesModes(conf, false, true, false, true, true);
+ pager = taxonService.findTaxaAndNames(conf);
+ // there are one synonym, two names without taxa and a misapplied name
+ assertEquals(4, pager.getRecords().size());
setTaxaAndNamesModes(conf, true, false, false, true, true);
pager = taxonService.findTaxaAndNames(conf);
assertEquals(10, pager.getRecords().size());
// FIXME the Synonym Abies subalpina missing in result set
-// setTaxaAndNamesModes(conf, false, true, true, false, true);
-// pager = taxonService.findTaxaAndNames(conf);
-// logSearchResults(pager, Level.DEBUG);
-// assertEquals(3, pager.getRecords().size());
+ setTaxaAndNamesModes(conf, false, true, true, false, true);
+ pager = taxonService.findTaxaAndNames(conf);
+ logSearchResults(pager, Level.DEBUG);
+ assertEquals(3, pager.getRecords().size());
setTaxaAndNamesModes(conf, true, false, true, false, true);
pager = taxonService.findTaxaAndNames(conf);
setTaxaAndNamesModes(conf, false, true, true, true, false);
pager = taxonService.findTaxaAndNames(conf);
logSearchResults(pager, Level.DEBUG);
- assertEquals(1, pager.getRecords().size());
+ //There is one synonym and a misapplied name
+ assertEquals(2, pager.getRecords().size());
setTaxaAndNamesModes(conf, true, false, true, true, false);
pager = taxonService.findTaxaAndNames(conf);
assertEquals(8, pager.getRecords().size());
// FIXME org.hibernate.QueryParameterException: could not locate named parameter [taxa]
-// setTaxaAndNamesModes(conf, false, true, false, true, false);
-// pager = taxonService.findTaxaAndNames(conf);
-// logSearchResults(pager, Level.DEBUG);
-// assertEquals(2, pager.getRecords().size());
+ setTaxaAndNamesModes(conf, false, true, false, true, false);
+ pager = taxonService.findTaxaAndNames(conf);
+ logSearchResults(pager, Level.DEBUG);
+ assertEquals(2, pager.getRecords().size());
setTaxaAndNamesModes(conf, true, false, false, true, false);
pager = taxonService.findTaxaAndNames(conf);