From: Andreas Kohlbecker Date: Fri, 17 May 2013 09:25:00 +0000 (+0000) Subject: TODO comment X-Git-Tag: cdmlib-parent-3.2.1~16 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/commitdiff_plain/69e054851b4cff3622c6231f02536e5a885c04c4 TODO comment --- diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/Distribution.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/Distribution.java index 9cdf1decb4..c1d0a4590b 100644 --- a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/Distribution.java +++ b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/Distribution.java @@ -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 this 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){