Project

General

Profile

Revision b5aa6bf0

IDb5aa6bf0eb1f8027a90340f2601bf8cab0240e8a
Parent 4b585df9
Child 2656a2c6

Added by Katja Luther over 1 year ago

ref #6581: fix problems with getter and setter

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TypeDesignationBase.java
29 29
import javax.xml.bind.annotation.XmlSeeAlso;
30 30
import javax.xml.bind.annotation.XmlType;
31 31

  
32
import org.apache.commons.lang3.StringUtils;
32 33
import org.apache.log4j.Logger;
33 34
import org.hibernate.annotations.Cascade;
34 35
import org.hibernate.annotations.CascadeType;
......
244 245
        this.notDesignated = notDesignated;
245 246
    }
246 247

  
247
    public String getCitationMicroReference(){
248
        return this.source.getCitationMicroReference();
249
    }
250
    public void setCitationMicroReference(String citationMicroReference){
251
        this.source.setCitationMicroReference(citationMicroReference);
248
    @Transient
249
    public String getCitationMicroReference() {
250
        return source == null ? null : this.source.getCitationMicroReference();
252 251
    }
253 252

  
253
    public void setCitationMicroReference(String microReference) {
254
        this.getSource(true).setCitationMicroReference(StringUtils.isBlank(microReference)? null : microReference);
255
        checkNullSource();
256
    }
257
    @Transient
254 258
    public Reference getCitation(){
255
        return this.source.getCitation();
259
        return source == null ? null : this.source.getCitation();
256 260
    }
257 261
    public void setCitation(Reference citation) {
258
        this.source.setCitation(citation);
262
        this.getSource(true).setCitation(citation);
263
        checkNullSource();
259 264
    }
260 265

  
261 266
    /**
267
     * @param createNew
262 268
     * @return the source
263 269
     */
264
    public IdentifiableSource getSource() {
270
    public IdentifiableSource getSource(boolean createIfNotExist) {
271
        if (this.source == null && createIfNotExist){
272
            this.source = IdentifiableSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
273
        }
274
        return source;
275
    }
276

  
277
    public IdentifiableSource getSource(){
265 278
        return source;
266 279
    }
267 280

  
......
272 285
        this.source = source;
273 286
    }
274 287

  
288
    private void checkNullSource() {
289
        if (this.source != null && this.source.checkEmpty(true)){
290
            this.source = null;
291
        }
292
    }
293

  
275 294
    /**
276 295
     * Returns the {@link Registration registrations} available for this
277 296
     * type designation.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)