TODO comment
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Fri, 17 May 2013 09:25:00 +0000 (09:25 +0000)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Fri, 17 May 2013 09:25:00 +0000 (09:25 +0000)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/Distribution.java

index 9cdf1decb4a38f3d1cf62e369a2ab008d3310f42..c1d0a4590baae8a7ce40e16dcfc7758dda816059 100644 (file)
@@ -9,8 +9,6 @@
 
 package eu.etaxonomy.cdm.model.description;
 
-import java.util.ArrayList;
-
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.ManyToOne;
@@ -30,6 +28,7 @@ import org.hibernate.search.annotations.IndexedEmbedded;
 
 import eu.etaxonomy.cdm.model.location.NamedArea;
 import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.validation.Level2;
 
 /**
@@ -157,33 +156,35 @@ public class Distribution extends DescriptionElementBase implements Cloneable {
     /**
      * Special equal method for building an sorted distribution tree.
      * @param dist the distribution to compare <code>this</code> area with.
-     * @return true, if both areas do have equal labels and both area levels 
+     * @return true, if both areas do have equal labels and both area levels
      * do have equal label or are both null, false otherwise.
+     *
+     * FIXME comparing by label is not a good idea! Do we need this method at all?
      */
     public boolean equalsForTree(Distribution dist){
-       boolean result = false;
-               NamedArea thisArea = this.getArea();
-               NamedArea distArea = dist.getArea();
-        
-               //avoid NPE 
-               if (thisArea == null || distArea == null || thisArea.getLabel() == null) {
-          return false;
+        boolean result = false;
+           NamedArea thisArea = this.getArea();
+           NamedArea distArea = dist.getArea();
+
+           //avoid NPE
+           if (thisArea == null || distArea == null || thisArea.getLabel() == null) {
+           return false;
         }
         //same area level and area label returns true
         if (thisArea.getLabel().compareTo(distArea.getLabel()) == 0 ){
-               NamedAreaLevel thisLevel = thisArea.getLevel();
-               NamedAreaLevel distLevel = distArea.getLevel();
-               
-               if ((thisLevel == null) && (distLevel == null)){
-                       result = true;
-               }else{
-                       if ((thisLevel == null) || (thisLevel.getLabel() == null) || (distLevel == null)){
-                               return false;
-                       }
-               if (thisLevel.getLabel().compareTo(distLevel.getLabel()) == 0){
-                       result = true;
-               }
-               }
+            NamedAreaLevel thisLevel = thisArea.getLevel();
+            NamedAreaLevel distLevel = distArea.getLevel();
+
+            if ((thisLevel == null) && (distLevel == null)){
+                result = true;
+            }else{
+                if ((thisLevel == null) || (thisLevel.getLabel() == null) || (distLevel == null)){
+                    return false;
+                }
+                if (thisLevel.getLabel().compareTo(distLevel.getLabel()) == 0){
+                    result = true;
+                }
+            }
         }
        return result;
     }
@@ -233,6 +234,7 @@ public class Distribution extends DescriptionElementBase implements Cloneable {
     /**
      * Implementation of the toString() function
      */
+    @Override
     public String toString(){
         String result = "null";
         if (this.area != null){