import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
* @version 1.0
*/
@Service
-@Transactional(readOnly = true)
+@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class TaxonTreeServiceImpl extends IdentifiableServiceBase<TaxonomicTree, ITaxonomicTreeDao>
implements ITaxonTreeService {
private static final Logger logger = Logger
* @see eu.etaxonomy.cdm.api.service.ITaxonTreeService#loadRankSpecificRootNodes(eu.etaxonomy.cdm.model.taxon.TaxonomicTree, eu.etaxonomy.cdm.model.name.Rank, java.util.List)
*/
public List<TaxonNode> loadRankSpecificRootNodes(TaxonomicTree taxonomicTree, Rank rank, List<String> propertyPaths){
- TaxonomicTree tree = dao.load(taxonomicTree.getUuid());
- List<TaxonNode> rootNodes = tree.getRankSpecificRootNodes(rank);
- //sort nodes by TaxonName
+ List<TaxonNode> rootNodes = dao.loadRankSpecificRootNodes(taxonomicTree, rank, propertyPaths);
+ //sort nodes by TaxonName
Collections.sort(rootNodes, taxonNodeComparator);
// initialize all nodes
List<TaxonNode> pathToRoot = new ArrayList<TaxonNode>();
pathToRoot.add(thisNode);
- TaxonNode parentNode = thisNode.getParent();
- while(parentNode != null){
- Rank parentNodeRank = parentNode.getTaxon().getName().getRank();
+ ITreeNode parentNode = thisNode.getParent();
+ while(parentNode instanceof TaxonNode){
+ TaxonNode parent = (TaxonNode) parentNode;
+ Rank parentNodeRank = parent.getTaxon().getName().getRank();
// stop if the next parent is higher than the baseRank
if(baseRank != null && baseRank.isLower(parentNodeRank)){
break;
}
- pathToRoot.add(parentNode);
- parentNode = parentNode.getParent();
+ pathToRoot.add(parent);
+ parentNode = parent.getParent();
}
// initialize and invert order of nodes in list
return null;
}
-
+ public List<TaxonNode> getAllNodes(){
+ return taxonNodeDao.list(null,null);
+ }
/*
* (non-Javadoc)
* @see eu.etaxonomy.cdm.api.service.ITaxonService#getUuidAndTitleCacheOfAcceptedTaxa(eu.etaxonomy.cdm.model.taxon.TaxonomicTree)
*/
- public List<UuidAndTitleCache> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByTaxonomicTree(TaxonomicTree taxonomicTree) {
+ public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByTaxonomicTree(TaxonomicTree taxonomicTree) {
return taxonDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByTaxonomicTree(taxonomicTree);
}