Revision 177a283a
Added by Katja Luther about 7 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImpl.java | ||
---|---|---|
404 | 404 |
taxa.addAll(subCommonNames.list()); |
405 | 405 |
} |
406 | 406 |
|
407 |
//FIXME : the fourth element of the result should be a boolean, but in the case of a synonym |
|
408 |
// (which does require a check) a constant boolean (false) value needs to set. It seems that |
|
409 |
// hql cannot parse a constant boolean value in the select list clause. This implies that the |
|
410 |
// resulting object could be a Boolean or a String. The workaround for this is to convert the |
|
411 |
// resutling object into a String (using toString) and then create a new Boolean object from |
|
412 |
// String. |
|
413 |
if (doTaxa && doSynonyms){ |
|
407 |
|
|
408 |
// if (doTaxa && doSynonyms){ |
|
414 | 409 |
if(synonyms.size()>0 && taxa.size()>0){ |
415 | 410 |
hql = "select " + selectWhat; |
416 | 411 |
// in doNotReturnFullEntities mode it is nesscary to also return the type of the matching entities: |
... | ... | |
446 | 441 |
} else{ |
447 | 442 |
hql = "select " + selectWhat + " from %s t"; |
448 | 443 |
} |
449 |
} else if(doTaxa || doCommonNames){ |
|
450 |
if (taxa.size()>0){ |
|
451 |
hql = "select " + selectWhat; |
|
452 |
// in doNotReturnFullEntities mode it is nesscary to also return the type of the matching entities: |
|
453 |
// also return the computed isOrphaned flag |
|
454 |
if (doNotReturnFullEntities){ |
|
455 |
hql += ", 'taxon', " + |
|
456 |
" case when t.taxonNodes is empty and t.relationsFromThisTaxon is empty and t.relationsToThisTaxon is empty then true else false end "; |
|
457 |
} |
|
458 |
hql += " from %s t " + |
|
459 |
" where t.id in (:taxa) "; |
|
460 |
|
|
461 |
}else{ |
|
462 |
hql = "select " + selectWhat + " from %s t"; |
|
463 |
} |
|
464 |
} else if(doSynonyms){ |
|
465 |
if (synonyms.size()>0){ |
|
466 |
|
|
467 |
hql = "select " + selectWhat; |
|
468 |
// in doNotReturnFullEntities mode it is nesscary to also return the type of the matching entities: |
|
469 |
// also return the computed isOrphaned flag |
|
470 |
if (doNotReturnFullEntities){ |
|
471 |
hql += ", 'synonym', 'false' "; |
|
472 |
} |
|
473 |
hql += " from %s t " + |
|
474 |
" where t.id in (:synonyms) "; |
|
475 |
}else{ |
|
476 |
hql = "select " + selectWhat + " from %s t"; |
|
477 |
} |
|
478 |
} else if (doIncludeMisappliedNames){ |
|
479 |
hql = "select " + selectWhat; |
|
480 |
// in doNotReturnFullEntities mode it is nesscary to also return the type of the matching entities: |
|
481 |
// also return the computed isOrphaned flag |
|
482 |
if (doNotReturnFullEntities){ |
|
483 |
hql += ", 'taxon', " + |
|
484 |
" case when t.taxonNodes is empty and t.relationsFromThisTaxon is empty and t.relationsToThisTaxon is empty then true else false end "; |
|
485 |
} |
|
486 |
hql += " from %s t " + |
|
487 |
" where t.id in (:taxa) "; |
|
488 |
|
|
489 |
} |
|
490 | 444 |
|
491 | 445 |
String classString; |
492 |
if (doTaxa && doSynonyms){
|
|
446 |
if ((doTaxa || doCommonNames || doIncludeMisappliedNames) && doSynonyms){
|
|
493 | 447 |
classString = "TaxonBase"; |
494 | 448 |
} else if (doTaxa || doCommonNames){ |
495 | 449 |
classString = "Taxon"; |
496 |
} else if (doSynonyms){ |
|
450 |
} else if (doSynonyms && !(doCommonNames|| doTaxa || doIncludeMisappliedNames)){
|
|
497 | 451 |
classString = "Synonym"; |
498 | 452 |
} else{//only misappliedNames |
499 | 453 |
classString = "Taxon"; |
... | ... | |
524 | 478 |
Query query = getSession().createQuery(hql); |
525 | 479 |
|
526 | 480 |
|
527 |
if (doTaxa && doSynonyms){
|
|
481 |
if ((doTaxa || doCommonNames || doIncludeMisappliedNames) ){
|
|
528 | 482 |
// find taxa and synonyms |
529 | 483 |
if (taxa.size()>0){ |
530 | 484 |
query.setParameterList("taxa", taxa); |
... | ... | |
535 | 489 |
if (taxa.size()== 0 && synonyms.size() == 0){ |
536 | 490 |
return null; |
537 | 491 |
} |
538 |
}else if(doTaxa || doCommonNames || doIncludeMisappliedNames){ |
|
539 |
//find taxa |
|
540 |
if (taxa.size()>0){ |
|
541 |
query.setParameterList("taxa", taxa ); |
|
542 |
}else{ |
|
543 |
logger.warn("there are no taxa for the query: " + queryString); |
|
544 |
return null; |
|
545 |
} |
|
546 |
} else if(doSynonyms){ |
|
492 |
} |
|
493 |
if(doSynonyms){ |
|
547 | 494 |
// find synonyms |
548 | 495 |
if (synonyms.size()>0){ |
549 | 496 |
query.setParameterList("synonyms", synonyms); |
550 | 497 |
}else{ |
551 | 498 |
return null; |
552 | 499 |
} |
553 |
} else{ |
|
554 |
//only misappliedNames |
|
555 |
if (taxa.size()>0){ |
|
556 |
query.setParameterList("taxa", taxa ); |
|
557 |
}else{ |
|
558 |
return null; |
|
559 |
} |
|
560 | 500 |
} |
561 | 501 |
|
562 | 502 |
return query; |
Also available in: Unified diff
fix #6296: fix the parameter settings in search queries