Project

General

Profile

« Previous | Next » 

Revision f562c76e

Added by Andreas Müller about 9 years ago

fix bug for wrong StringUtils used in PresenceAbsence term

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/PresenceAbsenceTerm.java
22 22
import javax.xml.bind.annotation.XmlRootElement;
23 23
import javax.xml.bind.annotation.XmlType;
24 24

  
25
import org.apache.commons.lang.StringUtils;
25 26
import org.apache.log4j.Logger;
26 27
import org.hibernate.envers.Audited;
27 28
import org.hibernate.search.annotations.Indexed;
28
import org.springframework.util.StringUtils;
29 29

  
30 30
import eu.etaxonomy.cdm.model.common.CdmBase;
31 31
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
......
39 39

  
40 40
/**
41 41
 * This class represents terms describing the {@link AbsenceTerm absence}
42
 * (like "extinct") or the {@link PresenceTerm presence} (like "cultivated") of a 
42
 * (like "extinct") or the {@link PresenceTerm presence} (like "cultivated") of a
43 43
 * {@link Taxon taxon} in a {@link NamedArea named area}. These terms are only
44 44
 * used for {@link Distribution distributions}.
45 45

  
......
58 58
public class PresenceAbsenceTerm extends OrderedTermBase<PresenceAbsenceTerm> {
59 59
	private static final long serialVersionUID = 1036807546935584396L;
60 60
	private static final Logger logger = Logger.getLogger(PresenceAbsenceTerm.class);
61
    
62
	
61

  
62

  
63 63
	//presence base
64 64
	private static final UUID uuidP=UUID.fromString("cef81d25-501c-48d8-bbea-542ec50de2c2");
65 65
	private static final UUID uuidPD=UUID.fromString("75a60279-a4c2-4f53-bc57-466028a4b3db");
66
	
66

  
67 67
	//presence
68 68
	private static final UUID uuidN=UUID.fromString("ddeac4f2-d8fa-43b8-ad7e-ca13abdd32c7");
69 69
	private static final UUID uuidNQ=UUID.fromString("925662c1-bb10-459a-8c53-da5a738ac770");
......
79 79
	private static final UUID uuidE=UUID.fromString("c3ee7048-15b7-4be1-b687-9ce9c1a669d6");
80 80
	private static final UUID uuidNA=UUID.fromString("4e04990a-66fe-4fdf-856c-f40772fbcf0a");
81 81
	private static final UUID uuidIV=UUID.fromString("dc536e3d-a753-4bbe-a386-dd8aff35c234");
82
	
83
	//absence	
82

  
83
	//absence
84 84
	private static final UUID uuidAbsence=UUID.fromString("59709861-f7d9-41f9-bb21-92559cedd598");
85 85
	private static final UUID uuidNF=UUID.fromString("61cee840-801e-41d8-bead-015ad866c2f1");
86 86
	private static final UUID uuidIF=UUID.fromString("aeec2947-2700-4623-8e32-9e3a430569d1");
......
89 89
	private static final UUID uuidIE=UUID.fromString("b74dc30b-ee93-496d-8c00-4d00abae1ec7");
90 90

  
91 91

  
92
	protected static Map<UUID, PresenceAbsenceTerm> termMap = null;	
92
	protected static Map<UUID, PresenceAbsenceTerm> termMap = null;
93 93

  
94 94
    private String defaultColor = "000000";
95
    
95

  
96 96
    @XmlAttribute(name = "absenceTerm")
97 97
    private boolean absenceTerm = false;
98 98

  
99 99
	//********* METHODS **************************************/
100
	/** 
100
	/**
101 101
	 * Creates a new empty presence term.
102
	 * 
102
	 *
103 103
	 * @see #NewInstance(String, String, String)
104 104
	 */
105 105
	public static PresenceAbsenceTerm NewInstance(){
106 106
		return new PresenceAbsenceTerm();
107 107
	}
108 108

  
109
	/** 
109
	/**
110 110
	 * Creates a new presence term with a description (in the {@link Language#DEFAULT() default language}),
111 111
	 * a label and a label abbreviation.
112
	 * 
112
	 *
113 113
	 * @param	term  		 the string (in the default language) describing the
114
	 * 						 new presence term to be created 
114
	 * 						 new presence term to be created
115 115
	 * @param	label  		 the string identifying the new presence term to be created
116 116
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
117 117
	 * 						 new presence term to be created
......
120 120
	public static PresenceAbsenceTerm NewPresenceInstance(String term, String label, String labelAbbrev){
121 121
		return new PresenceAbsenceTerm(term, label, labelAbbrev, false);
122 122
	}
123
	
124
	/** 
123

  
124
	/**
125 125
	 * Creates a new absence term with a description (in the {@link Language#DEFAULT() default language}),
126 126
	 * a label and a label abbreviation.
127
	 * 
127
	 *
128 128
	 * @param	term  		 the string (in the default language) describing the
129
	 * 						 new presence term to be created 
129
	 * 						 new presence term to be created
130 130
	 * @param	label  		 the string identifying the new presence term to be created
131 131
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
132 132
	 * 						 new presence term to be created
......
135 135
	public static PresenceAbsenceTerm NewAbsenceInstance(String term, String label, String labelAbbrev){
136 136
		return new PresenceAbsenceTerm(term, label, labelAbbrev, true);
137 137
	}
138
    
139
    
138

  
139

  
140 140
//********************************** Constructor *******************************************************************/
141 141

  
142 142
  	//for hibernate use only
......
161 161
        super(TermType.PresenceAbsenceTerm, term, label, labelAbbrev);
162 162
        this.setAbsenceTerm(isAbsenceTerm);
163 163
    }
164
    
165
    
164

  
165

  
166 166
  //******************************* STATIC METHODS *****************************************
167
	
167

  
168 168
  	protected static PresenceAbsenceTerm getTermByUuid(UUID uuid){
169 169
  		if (termMap == null){
170 170
  			return null;
......
174 174
  	}
175 175

  
176 176
   	//TODO read from label(abbrevs) like in TDWGArea
177
  	public static PresenceAbsenceTerm getPresenceAbsenceTermByAbbreviation(String abbrev) { 
177
  	public static PresenceAbsenceTerm getPresenceAbsenceTermByAbbreviation(String abbrev) {
178 178
  		if (abbrev == null) { throw new NullPointerException("abbrev is 'null' in getPresenceTermByAbbreviation");
179 179
  		} else if (abbrev.equalsIgnoreCase("c"))  { return PresenceAbsenceTerm.CULTIVATED();
180 180
  		} else if (abbrev.equalsIgnoreCase("e"))  { return PresenceAbsenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA();
......
202 202
			return null;
203 203
		}
204 204
  	}
205
  	
206
    
205

  
206

  
207 207
	public static final PresenceAbsenceTerm PRESENT(){
208 208
		return getTermByUuid(uuidP);
209 209
	}
......
250 250
	public static final PresenceAbsenceTerm NATIVE_DOUBTFULLY_NATIVE(){
251 251
		return getTermByUuid(uuidND);
252 252
	}
253
	
253

  
254 254
	public static final PresenceAbsenceTerm NATIVE_PRESENCE_QUESTIONABLE(){
255 255
		return getTermByUuid(uuidNQ);
256 256
	}
257
	
257

  
258 258
	public static final PresenceAbsenceTerm INVASIVE(){
259 259
		return getTermByUuid(uuidIV);
260 260
	}
261
	
261

  
262 262
	public static final PresenceAbsenceTerm NATURALISED(){
263 263
		return getTermByUuid(uuidNA);
264 264
	}
265
	
265

  
266 266
	public static final PresenceAbsenceTerm ABSENT(){
267 267
		return getTermByUuid(uuidAbsence);
268 268
	}
269
	
269

  
270 270
	public static final PresenceAbsenceTerm NATIVE_REPORTED_IN_ERROR(){
271 271
		return getTermByUuid(uuidNF);
272 272
	}
273
	
273

  
274 274
	public static final PresenceAbsenceTerm CULTIVATED_REPORTED_IN_ERROR(){
275 275
		return getTermByUuid(uuidCF);
276 276
	}
......
294 294
	public void resetTerms(){
295 295
		termMap = null;
296 296
	}
297
	
297

  
298 298
	@Override
299 299
	protected void setDefaultTerms(TermVocabulary<PresenceAbsenceTerm> termVocabulary) {
300 300
		termMap = new HashMap<UUID, PresenceAbsenceTerm>();
......
317 317
		}
318 318
        boolean isAbsence = csvLine.get(6).equals("1") ? true : false;
319 319
        newInstance.setAbsenceTerm(isAbsence);
320
        
320

  
321 321
        newInstance.getRepresentation(Language.DEFAULT()).setAbbreviatedLabel(abbreviatedLabel);
322 322
        return newInstance;
323 323
    }
......
331 331

  
332 332
    /**
333 333
     * @param defaultColor the defaultColor to set
334
     * @throws ParseException 
334
     * @throws ParseException
335 335
     */
336 336
    //TODO make format checking a hibernate validation rule
337 337
    public void setDefaultColor(String defaultColor) throws ParseException  {
......
368 368
    	PresenceAbsenceTerm presenceAbsenceTermLocal = CdmBase.deproxy(presenceAbsenceTerm, PresenceAbsenceTerm.class);
369 369
        if(! skipVocabularyCheck){
370 370
            if (this.vocabulary == null || presenceAbsenceTermLocal.vocabulary == null){
371
                throw new IllegalStateException("An ordered term (" + this.toString() + " or " + 
372
                		presenceAbsenceTermLocal.toString() + ") of class " + this.getClass() + " or " + 
371
                throw new IllegalStateException("An ordered term (" + this.toString() + " or " +
372
                		presenceAbsenceTermLocal.toString() + ") of class " + this.getClass() + " or " +
373 373
                		presenceAbsenceTermLocal.getClass() + " does not belong to a vocabulary and therefore "
374 374
                		+ "can not be compared");
375 375
            }

Also available in: Unified diff