Project

General

Profile

Revision 94d72025

ID94d72025a5d0686d46e70c8812d5a6108735ec94
Parent 46366f19
Child a88787bf

Added by Andreas Müller over 2 years ago

ref #6581 first incomplete version for making nomenclatural reference an orginal source

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/OriginalSourceType.java
18 18

  
19 19
import org.apache.log4j.Logger;
20 20

  
21
import eu.etaxonomy.cdm.model.name.TaxonName;
22

  
21 23

  
22 24

  
23 25
/**
24 26
 * The original source type is used to define the type of an {@link OriginalSourceBase original source}.<BR>
25 27
 * It is used to distinguish e.g. data lineage when importing data from one database to another from e.g. content oriented
26 28
 * sources such as the citation in a book.
27
 * In future they may come further source types. 
29
 * In future they may come further source types.
28 30
 * @author a.mueller
29 31
 * @since 15.05.2013
30 32
 */
31 33
@XmlEnum
32 34
public enum OriginalSourceType implements IEnumTerm<OriginalSourceType>, Serializable{
33
	
35

  
34 36
	//0
35 37
	/**
36 38
	 * Unknown provenance is the type to be used if no information is available about the type
37 39
	 * of activity that happened.
38
	 *   
40
	 *
39 41
	 */
40 42
	@XmlEnumValue("Unknown")
41 43
	Unknown(UUID.fromString("b48a443c-05f2-47ff-b885-1d3bd31118e1"), "Unknown Provenance", "UNK", null),
42
	
44

  
43 45
	//1
44 46
	/**
45
	 * Primary Taxonomic Source describes the sources a taxonomist uses to gather certain information. 
47
	 * Primary Taxonomic Source describes the sources a taxonomist uses to gather certain information.
46 48
	 * E.g. a taxonomist may have used three books/articles/other references to gather information
47 49
	 * about the distribution status of a taxon.
48 50
	 * He/she will store these references as original source of type Primary Taxonomic Source.
49
	 * This is a specialization of PROV-O Primary Source 
51
	 * This is a specialization of PROV-O Primary Source
50 52
	 * ({@link http://www.w3.org/TR/2013/REC-prov-o-20130430/#PrimarySource})
51
	 *   
53
	 *
52 54
	 */
53 55
	@XmlEnumValue("Primary Taxonomic Source")
54 56
	PrimaryTaxonomicSource(UUID.fromString("c990beb3-3bc9-4dad-bbdf-9c11683493da"), "Primary Taxonomic Source", "PTS", null),
55
	
57

  
56 58
	//2
57 59
	/**
58 60
	 * Data Lineage describes the data life cycle of electronically available data. A typical
59
	 * use-case for data lineage is a data import from one database to another. Sources of 
60
	 * type data lineage will store information about the original database and the identifier 
61
	 * use-case for data lineage is a data import from one database to another. Sources of
62
	 * type data lineage will store information about the original database and the identifier
61 63
	 * and table (->namespace) used in the original database.
62
	 * There are multiple types of data lineage: Blackbox, Dispatcher, Aggregator 
63
	 * ({@link http://de.wikipedia.org/wiki/Data-Lineage})  
64
	 * There are multiple types of data lineage: Blackbox, Dispatcher, Aggregator
65
	 * ({@link http://de.wikipedia.org/wiki/Data-Lineage})
64 66
	 */
65 67
	@XmlEnumValue("Data Lineage")
66 68
	Lineage(UUID.fromString("4f9fdf9a-f3b5-490c-96f0-90e050599b0e"), "Data Lineage", "DLI", null),
......
76 78

  
77 79
	//4
78 80
	/**
79
	 * Data Transformation is a specialization of {@value #Lineage} and describes a data 
80
	 * transformation process that happens primarily on the given dataset but may also 
81
	 * Data Transformation is a specialization of {@value #Lineage} and describes a data
82
	 * transformation process that happens primarily on the given dataset but may also
81 83
	 * include external data.
82 84
	 */
83 85
	@XmlEnumValue("Data Transformation")
......
86 88

  
87 89
	//5
88 90
	/**
89
	 * Data aggregation is a specification of {@value #Lineage} and describes the 
90
	 * data transformation process that primarily includes data aggregation processes 
91
	 * Data aggregation is a specification of {@value #Lineage} and describes the
92
	 * data transformation process that primarily includes data aggregation processes
91 93
	 * but may also include data imports and transformations.
92 94
	 */
93 95
	@XmlEnumValue("Data Aggregation")
......
95 97

  
96 98
	//6
97 99
	/**
98
	 * Primary Media Source describes the original source for any media file. 
99
	 * E.g. a media may be copy of figure in book. The book itself will then be the primary media source. 
100
	 * Primary Media Source describes the original source for any media file.
101
	 * E.g. a media may be copy of figure in book. The book itself will then be the primary media source.
100 102
     *
101
	 * This is a specialization of PROV-O Primary Source 
103
	 * This is a specialization of PROV-O Primary Source
102 104
	 * ({@link http://www.w3.org/TR/2013/REC-prov-o-20130430/#PrimarySource})
103
	 *   
105
	 *
104 106
	 */
105 107
	@XmlEnumValue("Primary Media Source")
106 108
	PrimaryMediaSource(UUID.fromString("72be3615-a6da-4728-948a-b3c5797fa4bc"), "Primary Media Source", "PMS", null),
107 109

  
110
	//6
111
    /**
112
     * Nomenclatural reference as used for {@link TaxonName taxon names} and
113
     * type designations.
114
     * E.g. a media may be copy of figure in book. The book itself will then be the primary media source.
115
     *
116
     */
117
    @XmlEnumValue("Nomenclatural Reference")
118
    NomenclaturalReference(UUID.fromString(""), "Nomenclatural Reference", "NOR", null),
119

  
108 120

  
109 121
	//7
110 122
	/**
......
114 126
	Other(UUID.fromString("b7c4b7fe-0aef-428a-bb7b-9153a11bf845"), "Other", "OTH", null),
115 127

  
116 128
	;
117
	
118
	
129

  
130

  
119 131
	@SuppressWarnings("unused")
120 132
	private static final Logger logger = Logger.getLogger(OriginalSourceType.class);
121 133

  
......
126 138

  
127 139

  
128 140

  
129
// *************************** DELEGATE **************************************/	
130
	
141
// *************************** DELEGATE **************************************/
142

  
131 143
	private static EnumeratedTermVoc<OriginalSourceType> delegateVoc;
132 144
	private IEnumTerm<OriginalSourceType> delegateVocTerm;
133 145

  
134 146
	static {
135 147
		delegateVoc = EnumeratedTermVoc.getVoc(OriginalSourceType.class);
136 148
	}
137
	
149

  
138 150
	@Override
139 151
	public String getKey(){return delegateVocTerm.getKey();}
140
	
152

  
141 153
	@Override
142 154
    public String getMessage(){return delegateVocTerm.getMessage();}
143 155

  
144 156
	@Override
145 157
    public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
146
		
158

  
147 159
	@Override
148 160
    public UUID getUuid() {return delegateVocTerm.getUuid();}
149 161

  
150 162
	@Override
151 163
    public OriginalSourceType getKindOf() {return delegateVocTerm.getKindOf();}
152
	
164

  
153 165
	@Override
154 166
    public Set<OriginalSourceType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
155
	
167

  
156 168
	@Override
157 169
	public boolean isKindOf(OriginalSourceType ancestor) {return delegateVocTerm.isKindOf(ancestor);	}
158 170

  
159 171
	@Override
160 172
    public Set<OriginalSourceType> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
161 173

  
162
	
174

  
163 175
	public static OriginalSourceType getByKey(String key){return delegateVoc.getByKey(key);}
164 176
    public static OriginalSourceType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
165 177

  
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/ITaxonNameBase.java
17 17
import eu.etaxonomy.cdm.model.common.IParsable;
18 18
import eu.etaxonomy.cdm.model.common.IRelated;
19 19
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
20
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
20 21
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
21 22
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
22
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
23 23
import eu.etaxonomy.cdm.model.reference.Reference;
24 24
import eu.etaxonomy.cdm.model.taxon.Synonym;
25 25
import eu.etaxonomy.cdm.model.taxon.Taxon;
......
335 335
    public void setRank(Rank rank);
336 336

  
337 337
    /**
338
     * Returns the {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} of <i>this</i> taxon name.
338
     * Returns the {@link eu.etaxonomy.cdm.model.reference.Reference nomenclatural reference} of <i>this</i> taxon name.
339 339
     * The nomenclatural reference is here meant to be the one publication
340 340
     * <i>this</i> taxon name was originally published in while fulfilling the formal
341 341
     * requirements as specified by the corresponding {@link NomenclaturalCode nomenclatural code}.
342 342
     *
343
     * @see     eu.etaxonomy.cdm.model.reference.INomenclaturalReference
344 343
     * @see     eu.etaxonomy.cdm.model.reference.Reference
344
     * @see #getNomenclaturalSource()
345 345
     */
346
    public INomenclaturalReference getNomenclaturalReference();
346
    public Reference getNomenclaturalReference();
347 347

  
348 348
    /**
349 349
     * Assigns a {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} to <i>this</i> taxon name.
350 350
     * The corresponding {@link eu.etaxonomy.cdm.model.reference.Reference.isNomenclaturallyRelevant nomenclaturally relevant flag} will be set to true
351 351
     * as it is obviously used for nomenclatural purposes.
352 352
     *
353
     * @throws IllegalArgumentException if parameter <code>nomenclaturalReference</code> is not assignable from {@link INomenclaturalReference}
354 353
     * @see  #getNomenclaturalReference()
355 354
     */
356
    public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference);
357

  
358
    /**
359
     * Returns the appended phrase string assigned to <i>this</i> taxon name.
360
     * The appended phrase is a non-atomised addition to a name. It is
361
     * not ruled by a nomenclatural code.
362
     */
363
    public String getAppendedPhrase();
364

  
365
    /**
366
     * @see  #getAppendedPhrase()
367
     */
368
    public void setAppendedPhrase(String appendedPhrase);
355
    public void setNomenclaturalReference(Reference nomenclaturalReference);
369 356

  
370 357
    /**
371 358
     * Returns the details string of the {@link #getNomenclaturalReference() nomenclatural reference} assigned
......
374 361
     * (implicitly) pages but can also be figures or tables or any other
375 362
     * element of a publication. A nomenclatural micro reference (details)
376 363
     * requires the existence of a nomenclatural reference.
364
     *
365
     * @see #getNomenclaturalReference()
366
     * @see #getNomenclaturalSource()
377 367
     */
378
    //Details of the nomenclatural reference (protologue).
379 368
    public String getNomenclaturalMicroReference();
380 369

  
381 370
    /**
......
384 373
    public void setNomenclaturalMicroReference(String nomenclaturalMicroReference);
385 374

  
386 375
    /**
376
     * Sets the nomenclatural source which is a combination of the nomenclatural reference
377
     * and the detail information (exact page, table, figure, ...) where to find this name
378
     * for the first time.
379
     *
380
     * @see #getNomenclaturalReference()
381
     * @see #getNomenclaturalMicroReference()
382
     */
383
    public DescriptionElementSource getNomenclaturalSource();
384

  
385
    /**
386
     * Sets the nomenclatural source
387
     * @param nomenclaturalSource
388
     */
389
    public void setNomenclaturalSource(DescriptionElementSource nomenclaturalSource);
390

  
391

  
392
    /**
393
     * Returns the appended phrase string assigned to <i>this</i> taxon name.
394
     * The appended phrase is a non-atomised addition to a name. It is
395
     * not ruled by a nomenclatural code.
396
     */
397
    public String getAppendedPhrase();
398

  
399
    /**
400
     * @see  #getAppendedPhrase()
401
     */
402
    public void setAppendedPhrase(String appendedPhrase);
403

  
404

  
405
    /**
387 406
     * @param warnings
388 407
     */
389 408
    public void addParsingProblems(int problems);
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonName.java
72 72
import eu.etaxonomy.cdm.model.common.IParsable;
73 73
import eu.etaxonomy.cdm.model.common.IRelated;
74 74
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
75
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
75 76
import eu.etaxonomy.cdm.model.common.RelationshipBase;
76 77
import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
77 78
import eu.etaxonomy.cdm.model.common.TermType;
......
127 128
    "appendedPhrase",
128 129
    "nomenclaturalMicroReference",
129 130
    "nomenclaturalReference",
131
    "nomenclaturalSource",
130 132
    "rank",
131 133
    "fullTitleCache",
132 134
    "protectedFullTitleCache",
......
233 235
//    @NullOrNotEmpty
234 236
    @Column(length=255)
235 237
    private String appendedPhrase;
236

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

  
245 247
    @XmlAttribute
246 248
    @CacheUpdate(noUpdate ={"titleCache","fullTitleCache"})
......
325 327
//    @NotNull
326 328
    @IndexedEmbedded(depth=1)
327 329
    private Rank rank;
328

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

  
340
    @XmlElement(name = "NomenclaturalSource")
330 341
    @XmlIDREF
331 342
    @XmlSchemaType(name = "IDREF")
332 343
    @ManyToOne(fetch = FetchType.LAZY)
333 344
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
334 345
    @CacheUpdate(noUpdate ="titleCache")
335 346
    @IndexedEmbedded
336
    private Reference nomenclaturalReference;
347
    private DescriptionElementSource nomenclaturalSource;
348

  
349

  
337 350

  
338 351
    @XmlElementWrapper(name = "Registrations")
339 352
    @XmlElement(name = "Registration")
......
663 676
     * @see     eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
664 677
     * @see     eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
665 678
     */
666
    protected TaxonName(NomenclaturalCode type, Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorship, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
679
    protected TaxonName(NomenclaturalCode type, Rank rank, String genusOrUninomial,
680
            String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet,
681
            TeamOrPersonBase combinationAuthorship, Reference nomenclaturalReference,
682
            String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
667 683
        this(type, rank, homotypicalGroup);
668 684
        setGenusOrUninomial(genusOrUninomial);
669 685
        setInfraGenericEpithet (infraGenericEpithet);
......
2223 2239
        this.rank = rank;
2224 2240
    }
2225 2241

  
2226
    /**
2227
     * Returns the {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} of <i>this</i> taxon name.
2228
     * The nomenclatural reference is here meant to be the one publication
2229
     * <i>this</i> taxon name was originally published in while fulfilling the formal
2230
     * requirements as specified by the corresponding {@link NomenclaturalCode nomenclatural code}.
2231
     *
2232
     * @see 	eu.etaxonomy.cdm.model.reference.INomenclaturalReference
2233
     * @see 	eu.etaxonomy.cdm.model.reference.Reference
2234
     */
2242

  
2235 2243
    @Override
2236
    public INomenclaturalReference getNomenclaturalReference(){
2237
        return this.nomenclaturalReference;
2244
    public Reference getNomenclaturalReference(){
2245
        if (this.nomenclaturalSource == null){
2246
            return null;
2247
        }
2248
        return this.nomenclaturalSource.getCitation();
2249
    }
2250

  
2251
    @Override
2252
    public DescriptionElementSource getNomenclaturalSource(){
2253
        return this.nomenclaturalSource;
2254
    }
2255

  
2256
    protected DescriptionElementSource getNomenclaturalSource(boolean createIfNotExist){
2257
        if (this.nomenclaturalSource == null){
2258
            if (!createIfNotExist){
2259
                return null;
2260
            }
2261
            this.nomenclaturalSource = DescriptionElementSource.NewInstance(OriginalSourceType.NomenclaturalReference);
2262
        }
2263
        return this.nomenclaturalSource;
2238 2264
    }
2265

  
2239 2266
    /**
2240 2267
     * Assigns a {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} to <i>this</i> taxon name.
2241 2268
     * The corresponding {@link eu.etaxonomy.cdm.model.reference.Reference.isNomenclaturallyRelevant nomenclaturally relevant flag} will be set to true
2242 2269
     * as it is obviously used for nomenclatural purposes.
2243 2270
     *
2271
     * Shortcut to set the nomenclatural reference.
2272
     *
2244 2273
     * @throws IllegalArgumentException if parameter <code>nomenclaturalReference</code> is not assignable from {@link INomenclaturalReference}
2245 2274
     * @see  #getNomenclaturalReference()
2246 2275
     */
2276

  
2247 2277
    @Override
2248
    public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference){
2249
        if(nomenclaturalReference != null){
2250
            if(!INomenclaturalReference.class.isAssignableFrom(nomenclaturalReference.getClass())){
2251
                throw new IllegalArgumentException("Parameter nomenclaturalReference is not assignable from INomenclaturalReference");
2252
            }
2253
            this.nomenclaturalReference = (Reference)nomenclaturalReference;
2254
        } else {
2255
            this.nomenclaturalReference = null;
2278
    public void setNomenclaturalReference(Reference nomenclaturalReference){
2279
        getNomenclaturalSource(true).setCitation(nomenclaturalReference);
2280
        checkNullSource();
2281
    }
2282

  
2283

  
2284
    /**
2285
     *
2286
     */
2287
    private void checkNullSource() {
2288
        if (this.nomenclaturalSource == null){
2289
            return;
2290
        }else if (this.nomenclaturalSource.getCitation() != null
2291
           || this.nomenclaturalSource.getCitationMicroReference() != null
2292
           || this.nomenclaturalSource.getNameUsedInSource() != null
2293
           || isBlank(this.nomenclaturalSource.getOriginalNameString())){
2294
            //TODO what about supplemental data?
2295
                return;
2296
        }else{
2297
            this.nomenclaturalSource = null;
2256 2298
        }
2257 2299
    }
2258 2300

  
2301

  
2302
    @Override
2303
    public void setNomenclaturalSource(DescriptionElementSource nomenclaturalSource) throws IllegalArgumentException {
2304
        if (!OriginalSourceType.NomenclaturalReference.equals(nomenclaturalSource.getType()) ){
2305
            throw new IllegalArgumentException("Nomenclatural source must be of type " + OriginalSourceType.NomenclaturalReference.getMessage());
2306
        }
2307
        this.nomenclaturalSource = nomenclaturalSource;
2308
    }
2309

  
2259 2310
    /**
2260 2311
     * Returns the appended phrase string assigned to <i>this</i> taxon name.
2261 2312
     * The appended phrase is a non-atomised addition to a name. It is
......
2285 2336
    //Details of the nomenclatural reference (protologue).
2286 2337
    @Override
2287 2338
    public String getNomenclaturalMicroReference(){
2288
        return this.nomenclaturalMicroReference;
2339
        if (this.nomenclaturalSource == null){
2340
            return null;
2341
        }
2342
        return this.nomenclaturalSource.getCitationMicroReference();
2289 2343
    }
2290 2344
    /**
2291 2345
     * @see  #getNomenclaturalMicroReference()
2292 2346
     */
2293 2347
    @Override
2294 2348
    public void setNomenclaturalMicroReference(String nomenclaturalMicroReference){
2295
        this.nomenclaturalMicroReference = StringUtils.isBlank(nomenclaturalMicroReference)? null : nomenclaturalMicroReference;
2349
        this.getNomenclaturalSource(true).setCitationMicroReference(StringUtils.isBlank(nomenclaturalMicroReference)? null : nomenclaturalMicroReference);
2350
        checkNullSource();
2296 2351
    }
2297 2352

  
2298 2353
    @Override

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)