\r
package eu.etaxonomy.cdm.persistence.dao.hibernate.taxon;\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
import org.apache.log4j.Logger;\r
+import org.hibernate.Query;\r
import org.springframework.beans.factory.annotation.Qualifier;\r
import org.springframework.stereotype.Repository;\r
\r
+import eu.etaxonomy.cdm.model.name.Rank;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;\r
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase;\r
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonomicTreeDao;\r
indexedClasses[0] = TaxonomicTree.class;\r
}\r
\r
+ @SuppressWarnings("unchecked")\r
+ public List<TaxonNode> loadRankSpecificRootNodes(TaxonomicTree taxonomicTree, Rank rank, List<String> propertyPaths){\r
+ String hql = "SELECT DISTINCT tn FROM TaxonNode tn LEFT JOIN tn.childNodes as ctn" +\r
+ " WHERE tn.taxonomicTree = :tree AND (" +\r
+ " tn.taxon.name.rank = :rank" +\r
+ " OR (tn.taxon.name.rank < :rank AND tn.parent = null)" +\r
+ " OR (tn.taxon.name.rank > :rank AND ctn.taxon.name.rank < :rank)" +\r
+ " )";\r
+ Query query = getSession().createQuery(hql);\r
+ query.setParameter("rank", rank);\r
+ query.setParameter("tree", taxonomicTree);\r
+ List<TaxonNode> results = query.list();\r
+ defaultBeanInitializer.initializeAll(results, propertyPaths);\r
+ return results;\r
+ }\r
+ \r
\r
}\r