Project

General

Profile

Revision 5eaab3bf

ID5eaab3bfcc0e1851a508b51dfd5c7321d925dd68
Parent c41c3457
Child b5e55a3d

Added by Andreas Müller about 2 months ago

ref #6581 fully remove nomenclaturalReference and nomenclaturalMicroReference fields from TaxonName

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonName.java
236 236
    @Column(length=255)
237 237
    private String appendedPhrase;
238 238

  
239
    //#6581
240
    @XmlElement(name = "NomenclaturalMicroReference")
241
    @Field
242
    @CacheUpdate(noUpdate ="titleCache")
243
    //TODO Val #3379
244
    //@NullOrNotEmpty
245
    @Column(length=255)
246
    private String nomenclaturalMicroReference;
247

  
248 239
    @XmlAttribute
249 240
    @CacheUpdate(noUpdate ={"titleCache","fullTitleCache"})
250 241
    private int parsingProblem = 0;
......
330 321
    private Rank rank;
331 322

  
332 323
    //#6581
333
    @XmlElement(name = "NomenclaturalReference")
334
    @XmlIDREF
335
    @XmlSchemaType(name = "IDREF")
336
    @ManyToOne(fetch = FetchType.LAZY)
337
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
338
    @CacheUpdate(noUpdate ="titleCache")
339
    @IndexedEmbedded
340
    private Reference nomenclaturalReference;
341

  
342
    //#6581
343 324
    @XmlElement(name = "NomenclaturalSource")
344 325
    @XmlIDREF
345 326
    @XmlSchemaType(name = "IDREF")
......
2224 2205
//*************** nom ref/source *******************/
2225 2206

  
2226 2207
    @Override
2227
    @Transient
2228
    public Reference getNomenclaturalReference(){
2229
        //#6581
2230
        if (this.nomenclaturalSource == null){
2231
            return null;
2232
        }
2233
        return this.nomenclaturalSource.getCitation();
2234
    }
2235

  
2236
    @Override
2237 2208
    public DescriptionElementSource getNomenclaturalSource(){
2238 2209
        return this.nomenclaturalSource;
2239 2210
    }
2240 2211

  
2241 2212
    protected DescriptionElementSource getNomenclaturalSource(boolean createIfNotExist){
2242
        if (this.nomenclaturalSource == null){
2243
            if (!createIfNotExist){
2244
                return null;
2245
            }
2213
        if (this.nomenclaturalSource == null && createIfNotExist){
2246 2214
            this.nomenclaturalSource = DescriptionElementSource.NewInstance(OriginalSourceType.NomenclaturalReference);
2247 2215
        }
2248
        return this.nomenclaturalSource;
2216
        return nomenclaturalSource;
2249 2217
    }
2250 2218

  
2251
    /**
2252
     * Assigns a {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} to <i>this</i> taxon name.
2253
     * The corresponding {@link eu.etaxonomy.cdm.model.reference.Reference.isNomenclaturallyRelevant nomenclaturally relevant flag} will be set to true
2254
     * as it is obviously used for nomenclatural purposes.
2255
     *
2256
     * Shortcut to set the nomenclatural reference.
2257
     *
2258
     * @throws IllegalArgumentException if parameter <code>nomenclaturalReference</code> is not assignable from {@link INomenclaturalReference}
2259
     * @see  #getNomenclaturalReference()
2260
     */
2219
    @Override
2220
    public void setNomenclaturalSource(DescriptionElementSource nomenclaturalSource) throws IllegalArgumentException {
2221
        if (nomenclaturalSource != null && !OriginalSourceType.NomenclaturalReference.equals(nomenclaturalSource.getType()) ){
2222
            throw new IllegalArgumentException("Nomenclatural source must be of type " + OriginalSourceType.NomenclaturalReference.getMessage());
2223
        }
2224
        this.nomenclaturalSource = nomenclaturalSource;
2225
    }
2226

  
2227
    @Override
2228
    @Transient
2229
    public Reference getNomenclaturalReference(){
2230
        //#6581
2231
        return this.nomenclaturalSource == null? null:this.nomenclaturalSource.getCitation();
2232
    }
2261 2233

  
2262 2234
    @Override
2263 2235
    @Transient
......
2285 2257
    @Transient
2286 2258
    public String getNomenclaturalMicroReference(){
2287 2259
        //#6581
2288
        if (this.nomenclaturalSource == null){
2289
            return null;
2290
        }
2291
        return this.nomenclaturalSource.getCitationMicroReference();
2260
        return this.nomenclaturalSource == null? null: this.nomenclaturalSource.getCitationMicroReference();
2292 2261
    }
2262

  
2293 2263
    /**
2294 2264
     * @see  #getNomenclaturalMicroReference()
2295 2265
     */
2296 2266
    @Override
2297 2267
    public void setNomenclaturalMicroReference(String nomenclaturalMicroReference){
2298 2268
        //#6581
2299
        this.getNomenclaturalSource(true).setCitationMicroReference(isBlank(nomenclaturalMicroReference)? null : nomenclaturalMicroReference);
2300
        checkNullSource();
2269
        if (nomenclaturalMicroReference == null && this.getNomenclaturalSource()==null){
2270
            return;
2271
        }else{
2272
            this.getNomenclaturalSource(true).setCitationMicroReference(isBlank(nomenclaturalMicroReference)? null : nomenclaturalMicroReference);
2273
            checkNullSource();
2274
        }
2301 2275
    }
2302 2276

  
2303 2277
    //#6581
2304 2278
    private void checkNullSource() {
2305
        if (this.nomenclaturalSource != null && this.nomenclaturalSource.checkEmpty()){
2279
        if (this.nomenclaturalSource != null && this.nomenclaturalSource.checkEmpty(true)){
2306 2280
            this.nomenclaturalSource = null;
2307 2281
        }
2308 2282
    }
2309 2283

  
2310 2284

  
2311
    @Override
2312
    public void setNomenclaturalSource(DescriptionElementSource nomenclaturalSource) throws IllegalArgumentException {
2313
        if (nomenclaturalSource != null && !OriginalSourceType.NomenclaturalReference.equals(nomenclaturalSource.getType()) ){
2314
            throw new IllegalArgumentException("Nomenclatural source must be of type " + OriginalSourceType.NomenclaturalReference.getMessage());
2315
        }
2316
        this.nomenclaturalSource = nomenclaturalSource;
2317
    }
2318

  
2319 2285
    /**
2320 2286
     * Returns the appended phrase string assigned to <i>this</i> taxon name.
2321 2287
     * The appended phrase is a non-atomised addition to a name. It is
cdmlib-test/src/main/resources/dbscripts/001-cdm.h2.sql
5095 5095
        NAMEAPPROBATION varchar(255),
5096 5096
        NAMECACHE varchar(255),
5097 5097
        NAMETYPE varchar(15),
5098
        NOMENCLATURALMICROREFERENCE varchar(255),
5099 5098
        ORIGINALPUBLICATIONYEAR integer,
5100 5099
        PARSINGPROBLEM integer not null,
5101 5100
        PROBLEMENDS integer not null,
......
5116 5115
        HOMOTYPICALGROUP_ID integer,
5117 5116
        INBASIONYMAUTHORSHIP_ID integer,
5118 5117
        INCOMBINATIONAUTHORSHIP_ID integer,
5119
        NOMENCLATURALREFERENCE_ID integer,
5120 5118
        NOMENCLATURALSOURCE_ID integer,
5121 5119
        RANK_ID integer,
5122 5120
        primary key (ID)
......
5166 5164
        NAMEAPPROBATION varchar(255),
5167 5165
        NAMECACHE varchar(255),
5168 5166
        NAMETYPE varchar(15),
5169
        NOMENCLATURALMICROREFERENCE varchar(255),
5170 5167
        ORIGINALPUBLICATIONYEAR integer,
5171 5168
        PARSINGPROBLEM integer,
5172 5169
        PROBLEMENDS integer,
......
5187 5184
        HOMOTYPICALGROUP_ID integer,
5188 5185
        INBASIONYMAUTHORSHIP_ID integer,
5189 5186
        INCOMBINATIONAUTHORSHIP_ID integer,
5190
        NOMENCLATURALREFERENCE_ID integer,
5191 5187
        NOMENCLATURALSOURCE_ID integer,
5192 5188
        RANK_ID integer,
5193 5189
        primary key (ID, REV)
......
11289 11285
        references PUBLIC.AGENTBASE;
11290 11286

  
11291 11287
    alter table PUBLIC.TAXONNAME 
11292
        add constraint FK1dmy5xlaq1fn7omo0dom0kpbr 
11293
        foreign key (NOMENCLATURALREFERENCE_ID) 
11294
        references PUBLIC.REFERENCE;
11295

  
11296
    alter table PUBLIC.TAXONNAME 
11297 11288
        add constraint FKle80w71xca5aftjkqxfvgjdq6 
11298 11289
        foreign key (NOMENCLATURALSOURCE_ID) 
11299 11290
        references PUBLIC.ORIGINALSOURCEBASE;

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)