public interface ITaxonNodeService extends IAnnotatableService<TaxonNode>{
/**
- *returns the childnodes of the taxonNode, if recursive is true it returns all descendants
+ *returns the childnodes of the taxonNode, if recursive is true it returns all descendants, if sort is true the nodes are sorted
*
* @param taxonNode
* @param propertyPaths
* @param recursive
- * @return
+ * @return List<TaxonNode>
*/
public List<TaxonNode> loadChildNodesOfTaxonNode(TaxonNode taxonNode, List<String> propertyPaths, boolean recursive, boolean sort);
UpdateResult moveTaxonNode(UUID taxonNodeUuid, UUID targetNodeUuid,
boolean moveToParent);
+ List<TaxonNode> loadChildNodesOfTaxonNode(TaxonNode taxonNode,
+ List<String> propertyPaths, boolean recursive, NodeSortMode sortMode);
+
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonComparatorSearch;
+import eu.etaxonomy.cdm.model.taxon.TaxonNaturalComparator;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
@Override
public List<TaxonNode> loadChildNodesOfTaxonNode(TaxonNode taxonNode,
- List<String> propertyPaths, boolean recursive, boolean sorted) {
+ List<String> propertyPaths, boolean recursive, NodeSortMode sortMode) {
taxonNode = dao.load(taxonNode.getUuid());
List<TaxonNode> childNodes;
if (recursive == true){
}else{
childNodes = new ArrayList<TaxonNode>(taxonNode.getChildNodes());
}
- if (sorted){
- Collections.sort(childNodes, taxonNodeComparator);
- }
+ if (sortMode.equals(NodeSortMode.doNaturalOrder)){
+ TaxonNaturalComparator comparator = new TaxonNaturalComparator();
+ Collections.sort(childNodes, comparator);
+ } else if (sortMode.equals(NodeSortMode.doAlphabeticalOrder)){
+ Collections.sort(childNodes, this.taxonNodeComparator);
+ }
+
defaultBeanInitializer.initializeAll(childNodes, propertyPaths);
return childNodes;
}
result.includeResult(deleteTaxonNode(oldTaxonNode, conf));
}
result.addUpdatedObject(newAcceptedTaxon);
+ result.addUpdatedObject(oldTaxon);
//oldTaxonNode.delete();
return result;
if (treeNode instanceof TaxonNode){
TaxonNode taxonNode;
taxonNode = HibernateProxyHelper.deproxy(treeNode, TaxonNode.class);
-
+ TaxonNode parent = taxonNode.getParent();
//check whether the node has children or the children are already deleted
if(taxonNode.hasChildNodes()){
Set<ITaxonTreeNode> children = new HashSet<ITaxonTreeNode> ();
} else {
//move the children to the parent
- TaxonNode parent = taxonNode.getParent();
+
for (TaxonNode child: childNodesList){
parent.addChildNode(child, child.getReference(), child.getMicroReference());
}
if (config.getTaxonNodeConfig().isDeleteTaxon()){
taxonService.saveOrUpdate(taxon);
saveOrUpdate(taxonNode);
+
TaxonDeletionConfigurator configNew = new TaxonDeletionConfigurator();
DeleteResult resultTaxon = taxonService.deleteTaxon(taxon, configNew, classification);
if (!resultTaxon.isOk()){
Taxon taxon = taxonNode.getTaxon();
//node is rootNode
if (taxon != null){
- taxonNode.getTaxon().removeTaxonNode(taxonNode);
+ taxon.removeTaxonNode(taxonNode);
if (config.getTaxonNodeConfig().isDeleteTaxon()){
TaxonDeletionConfigurator configNew = new TaxonDeletionConfigurator();
saveOrUpdate(taxonNode);
+
taxonService.saveOrUpdate(taxon);
DeleteResult resultTaxon = taxonService.deleteTaxon(taxon, configNew, classification);
if (!resultTaxon.isOk()){