Project

General

Profile

Revision 69e05485

ID69e054851b4cff3622c6231f02536e5a885c04c4
Parent bc45d7e3
Child 26cb375c

Added by Andreas Kohlbecker over 7 years ago

TODO comment

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/Distribution.java
9 9

  
10 10
package eu.etaxonomy.cdm.model.description;
11 11

  
12
import java.util.ArrayList;
13

  
14 12
import javax.persistence.Entity;
15 13
import javax.persistence.FetchType;
16 14
import javax.persistence.ManyToOne;
......
30 28

  
31 29
import eu.etaxonomy.cdm.model.location.NamedArea;
32 30
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
31
import eu.etaxonomy.cdm.model.taxon.Taxon;
33 32
import eu.etaxonomy.cdm.validation.Level2;
34 33

  
35 34
/**
......
157 156
    /**
158 157
     * Special equal method for building an sorted distribution tree.
159 158
     * @param dist the distribution to compare <code>this</code> area with.
160
     * @return true, if both areas do have equal labels and both area levels 
159
     * @return true, if both areas do have equal labels and both area levels
161 160
     * do have equal label or are both null, false otherwise.
161
     *
162
     * FIXME comparing by label is not a good idea! Do we need this method at all?
162 163
     */
163 164
    public boolean equalsForTree(Distribution dist){
164
    	boolean result = false;
165
       	NamedArea thisArea = this.getArea();
166
       	NamedArea distArea = dist.getArea();
167
        
168
       	//avoid NPE 
169
       	if (thisArea == null || distArea == null || thisArea.getLabel() == null) {
170
    	   return false;
165
        boolean result = false;
166
           NamedArea thisArea = this.getArea();
167
           NamedArea distArea = dist.getArea();
168

  
169
           //avoid NPE
170
           if (thisArea == null || distArea == null || thisArea.getLabel() == null) {
171
           return false;
171 172
        }
172 173
        //same area level and area label returns true
173 174
        if (thisArea.getLabel().compareTo(distArea.getLabel()) == 0 ){
174
        	NamedAreaLevel thisLevel = thisArea.getLevel();
175
        	NamedAreaLevel distLevel = distArea.getLevel();
176
        	
177
        	if ((thisLevel == null) && (distLevel == null)){
178
        		result = true;
179
        	}else{
180
        		if ((thisLevel == null) || (thisLevel.getLabel() == null) || (distLevel == null)){
181
        			return false;
182
        		}
183
    	        if (thisLevel.getLabel().compareTo(distLevel.getLabel()) == 0){
184
    	        	result = true;
185
    	        }
186
        	}
175
            NamedAreaLevel thisLevel = thisArea.getLevel();
176
            NamedAreaLevel distLevel = distArea.getLevel();
177

  
178
            if ((thisLevel == null) && (distLevel == null)){
179
                result = true;
180
            }else{
181
                if ((thisLevel == null) || (thisLevel.getLabel() == null) || (distLevel == null)){
182
                    return false;
183
                }
184
                if (thisLevel.getLabel().compareTo(distLevel.getLabel()) == 0){
185
                    result = true;
186
                }
187
            }
187 188
        }
188 189
       return result;
189 190
    }
......
233 234
    /**
234 235
     * Implementation of the toString() function
235 236
     */
237
    @Override
236 238
    public String toString(){
237 239
        String result = "null";
238 240
        if (this.area != null){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)