merged/implemented cdm3.3 model adaptations
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / model / FeatureNodeContainer.java
index 900665e9e54e599c08c09e78cc862039c3863490..ce88d1cbc473a87d87bbc713427f5b12d65a5ef7 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -35,11 +35,11 @@ import eu.etaxonomy.cdm.model.description.TaxonDescription;
  * @version 1.0
  */
 public class FeatureNodeContainer{
-       
-       
-       
+
+
+
        private FeatureNodeContainer parent;
-       
+
 
 
        private FeatureNode featureNode;
@@ -48,35 +48,35 @@ public class FeatureNodeContainer{
 
        private FeatureNodeContainerTree containerTree;
 
-       
+
        /**
         * @param description
         */
        protected FeatureNodeContainer(FeatureNodeContainerTree containerTree) {
-               this.containerTree = containerTree; 
+               this.containerTree = containerTree;
                this.containerTree.addContainer(this);
        }
-       
-       
+
+
        /**
-        * Recursively traverse a branch of a feature tree and check if there are 
-        * 
+        * Recursively traverse a branch of a feature tree and check if there are
+        *
         * @param featureNode
-        * @param description 
+        * @param description
         * @return
         */
        protected void findLeaves(FeatureNode featureNode) {
                if(featureNode.isLeaf()){
                        buildLeaf(featureNode);
                }else{
-                       for(FeatureNode childNode : featureNode.getChildren()){
+                       for(FeatureNode childNode : featureNode.getChildNodes()){
                                findLeaves(childNode);
                        }
                }
        }
-       
+
        /**
-        * 
+        *
         * @param featureNode
         * @param description
         * @return
@@ -85,12 +85,12 @@ public class FeatureNodeContainer{
                if(featureNode.getFeature() == null){
                        throw new IllegalArgumentException("The given feature node does not have a feature.");
                }
-               
+
                Feature feature = (Feature) HibernateProxyHelper.deproxy(featureNode.getFeature());
-               
+
                // get feature node container for the given feature
                FeatureNodeContainer container = containerTree.getFeatureNodeContainer(feature);
-               
+
                // get description elements for the given feature
                List<DescriptionElementBase> elements = containerTree.getDescriptionsElementsForFeature(feature);
                // no description elements, so we should also remove the feature node container
@@ -108,12 +108,12 @@ public class FeatureNodeContainer{
                                container.buildBranch();
                        }
                        // add description elements to the feature node container
-                       container.setDescriptionElements(elements);             
+                       container.setDescriptionElements(elements);
                }
        }
-       
+
        /**
-        * 
+        *
         */
        private void remove() {
                if(getParent() != null){
@@ -134,15 +134,15 @@ public class FeatureNodeContainer{
 
 
        /**
-        * Recursively 
-        * 
+        * Recursively
+        *
         * @param featureNodeMap
         * @return
         */
-       private void buildBranch(){     
+       private void buildBranch(){
                if(getParent() == null){
                        FeatureNode parentFeatureNode = getFeatureNode().getParent();
-                       
+
                        if(parentFeatureNode.isRoot()){
                                containerTree.getRoot().addChild(this);
                        }else{
@@ -151,15 +151,15 @@ public class FeatureNodeContainer{
                                        parentContainer = new FeatureNodeContainer(containerTree);
                                        parentContainer.setFeatureNode(parentFeatureNode);
                                }
-                               
+
                                parentContainer.addChild(this);
-                               
+
                                parentContainer.buildBranch();
-                               
+
                        }
                }
        }
-       
+
        /**
         * <p>Getter for the field <code>children</code>.</p>
         *
@@ -182,7 +182,7 @@ public class FeatureNodeContainer{
                        throw new IllegalStateException("Container may not have a description element set when setting children.");
                }
        }
-       
+
        /**
         * Adds a child container to the list of this containers children
         *
@@ -201,11 +201,11 @@ public class FeatureNodeContainer{
        public void addDescriptionElement(DescriptionElementBase descriptionElement){
                descriptionElements.add(descriptionElement);
        }
-       
+
        public void removeDescriptionElement(DescriptionElementBase descriptionElement){
                descriptionElements.remove(descriptionElement);
        }
-       
+
        /**
         * If {@link #isLeaf()} is true, i.e. this container should have elements, returns the list of description elements.
         *
@@ -225,7 +225,7 @@ public class FeatureNodeContainer{
        public List<DescriptionElementBase> getDescriptionElementsForEntireBranch(){
                return getDescriptionElementsRecursively(new ArrayList<DescriptionElementBase>());
        }
-       
+
        private List<DescriptionElementBase> getDescriptionElementsRecursively(List<DescriptionElementBase> descriptionElements){
                if(isLeaf()){
                        descriptionElements.addAll(getDescriptionElements());
@@ -236,20 +236,20 @@ public class FeatureNodeContainer{
                }
                return descriptionElements;
        }
-       
+
        protected List<FeatureNodeContainer> getLeafs(){
                List<FeatureNodeContainer> leafs = new ArrayList<FeatureNodeContainer>();
-               
+
                if(isLeaf()){
                        leafs.add(this);
                }else{
                        for(FeatureNodeContainer container : getChildren()){
                                leafs.addAll(container.getLeafs());
-                       }                       
+                       }
                }
                return leafs;
        }
-       
+
        /**
         * Set the description element
         *
@@ -263,7 +263,7 @@ public class FeatureNodeContainer{
                        throw new IllegalStateException("Container may not contain child container when adding description elements.");
                }
        }
-       
+
        /**
         * If the container is a leaf, it will hold a description element and no child containers
         *
@@ -272,7 +272,7 @@ public class FeatureNodeContainer{
        public boolean isLeaf(){
                return ! descriptionElements.isEmpty() && children.isEmpty();
        }
-       
+
        /**
         * <p>Setter for the field <code>featureNode</code>.</p>
         *
@@ -290,7 +290,7 @@ public class FeatureNodeContainer{
        public FeatureNode getFeatureNode() {
                return featureNode;
        }
-       
+
        /**
         * <p>getFeature</p>
         *
@@ -311,14 +311,14 @@ public class FeatureNodeContainer{
        public DescriptionBase getDescription(){
                return containerTree.getDescription();
        }
-       
+
        public FeatureNodeContainerTree getContainerTree(){
                return containerTree;
        }
 
 
        /**
-        * 
+        *
         */
        public void clear() {
                children.clear();