1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.model.reference;
|
11
|
|
12
|
|
13
|
import java.net.URI;
|
14
|
import java.util.List;
|
15
|
|
16
|
import javax.persistence.Column;
|
17
|
import javax.persistence.Embedded;
|
18
|
import javax.persistence.Entity;
|
19
|
import javax.persistence.FetchType;
|
20
|
import javax.persistence.Inheritance;
|
21
|
import javax.persistence.InheritanceType;
|
22
|
import javax.persistence.Lob;
|
23
|
import javax.persistence.ManyToOne;
|
24
|
import javax.persistence.Transient;
|
25
|
import javax.validation.constraints.NotNull;
|
26
|
import javax.validation.constraints.Pattern;
|
27
|
import javax.xml.bind.annotation.XmlAccessType;
|
28
|
import javax.xml.bind.annotation.XmlAccessorType;
|
29
|
import javax.xml.bind.annotation.XmlAttribute;
|
30
|
import javax.xml.bind.annotation.XmlElement;
|
31
|
import javax.xml.bind.annotation.XmlIDREF;
|
32
|
import javax.xml.bind.annotation.XmlRootElement;
|
33
|
import javax.xml.bind.annotation.XmlSchemaType;
|
34
|
import javax.xml.bind.annotation.XmlType;
|
35
|
|
36
|
import org.apache.log4j.Logger;
|
37
|
import org.hibernate.annotations.Cascade;
|
38
|
import org.hibernate.annotations.CascadeType;
|
39
|
import org.hibernate.annotations.Table;
|
40
|
import org.hibernate.annotations.Type;
|
41
|
import org.hibernate.envers.Audited;
|
42
|
import org.hibernate.search.annotations.Field;
|
43
|
import org.hibernate.search.annotations.Index;
|
44
|
import org.hibernate.search.annotations.IndexedEmbedded;
|
45
|
import org.hibernate.validator.constraints.Length;
|
46
|
|
47
|
import eu.etaxonomy.cdm.model.agent.Institution;
|
48
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
49
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
50
|
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
|
51
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
52
|
import eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy;
|
53
|
import eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy;
|
54
|
import eu.etaxonomy.cdm.strategy.cache.reference.BookSectionDefaultCacheStrategy;
|
55
|
import eu.etaxonomy.cdm.strategy.cache.reference.GenericDefaultCacheStrategy;
|
56
|
import eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy;
|
57
|
import eu.etaxonomy.cdm.strategy.cache.reference.IReferenceBaseCacheStrategy;
|
58
|
import eu.etaxonomy.cdm.strategy.cache.reference.JournalDefaultCacheStrategy;
|
59
|
import eu.etaxonomy.cdm.strategy.cache.reference.ReferenceBaseDefaultCacheStrategy;
|
60
|
import eu.etaxonomy.cdm.strategy.match.Match;
|
61
|
import eu.etaxonomy.cdm.strategy.match.MatchMode;
|
62
|
import eu.etaxonomy.cdm.strategy.merge.Merge;
|
63
|
import eu.etaxonomy.cdm.strategy.merge.MergeMode;
|
64
|
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
|
65
|
import eu.etaxonomy.cdm.validation.Level2;
|
66
|
import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
|
67
|
import eu.etaxonomy.cdm.validation.annotation.InReference;
|
68
|
|
69
|
/**
|
70
|
* The upmost (abstract) class for references (information sources).
|
71
|
* <P>
|
72
|
* This class corresponds to: <ul>
|
73
|
* <li> PublicationCitation according to the TDWG ontology
|
74
|
* <li> Publication according to the TCS
|
75
|
* <li> Reference according to the ABCD schema
|
76
|
* </ul>
|
77
|
*
|
78
|
* @author m.doering
|
79
|
* @version 1.0
|
80
|
* @created 08-Nov-2007 13:06:47
|
81
|
*/
|
82
|
@XmlAccessorType(XmlAccessType.FIELD)
|
83
|
@XmlType(name = "Reference", propOrder = {
|
84
|
"type",
|
85
|
"uri",
|
86
|
"nomenclaturallyRelevant",
|
87
|
"authorTeam",
|
88
|
"referenceAbstract",
|
89
|
"title",
|
90
|
"editor",
|
91
|
"volume",
|
92
|
"pages",
|
93
|
"series",
|
94
|
"edition",
|
95
|
"isbn",
|
96
|
"issn",
|
97
|
"seriesPart",
|
98
|
"datePublished",
|
99
|
"publisher",
|
100
|
"placePublished",
|
101
|
"institution",
|
102
|
"school",
|
103
|
"organization",
|
104
|
"inReference"
|
105
|
// ,"fullReference",
|
106
|
// "abbreviatedReference"
|
107
|
})
|
108
|
@XmlRootElement(name = "Reference")
|
109
|
@Entity
|
110
|
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
|
111
|
@Audited
|
112
|
@javax.persistence.Table(name="Reference")
|
113
|
@Table(appliesTo="Reference", indexes = { @org.hibernate.annotations.Index(name = "ReferenceTitleCacheIndex", columnNames = { "titleCache" }) })
|
114
|
@InReference(groups = Level2.class)
|
115
|
//public abstract class Reference<S extends IReferenceBaseCacheStrategy> extends IdentifiableMediaEntity<S> implements IParsable, IMergable, IMatchable, IArticle, IBook, IJournal, IBookSection,ICdDvd,IGeneric,IInProceedings, IProceedings, IPrintSeries, IReport, IThesis,IWebPage {
|
116
|
public class Reference<S extends IReferenceBaseCacheStrategy> extends IdentifiableMediaEntity<S> implements INomenclaturalReference, IArticle, IBook, IPatent, IDatabase, IJournal, IBookSection,ICdDvd,IGeneric,IInProceedings, IProceedings, IPrintSeries, IReport, IThesis,IWebPage, IPersonalCommunication, IReference, Cloneable {
|
117
|
private static final long serialVersionUID = -2034764545042691295L;
|
118
|
private static final Logger logger = Logger.getLogger(Reference.class);
|
119
|
|
120
|
@XmlAttribute(name ="type")
|
121
|
@Column(name="refType")
|
122
|
protected ReferenceType type;
|
123
|
|
124
|
//Title of the reference
|
125
|
@XmlElement(name ="Title" )
|
126
|
@Column(length=4096, name="title")
|
127
|
@Lob
|
128
|
@Field(index=Index.TOKENIZED)
|
129
|
@Match(MatchMode.EQUAL_REQUIRED)
|
130
|
@NullOrNotEmpty(groups = Level2.class)
|
131
|
@Length(max = 4096)
|
132
|
private String title;
|
133
|
|
134
|
//********************************************************/
|
135
|
|
136
|
|
137
|
@XmlElement(name = "Editor")
|
138
|
@Field(index=Index.TOKENIZED)
|
139
|
@NullOrNotEmpty
|
140
|
@Length(max = 255)
|
141
|
protected String editor;
|
142
|
|
143
|
@XmlElement(name = "Series")
|
144
|
@Field(index=Index.TOKENIZED)
|
145
|
@NullOrNotEmpty
|
146
|
@Length(max = 255)
|
147
|
protected String series;
|
148
|
|
149
|
@XmlElement(name = "Volume")
|
150
|
@Field(index=Index.TOKENIZED)
|
151
|
@NullOrNotEmpty
|
152
|
@Length(max = 255)
|
153
|
protected String volume;
|
154
|
|
155
|
@XmlElement(name = "Pages")
|
156
|
@Field(index=Index.TOKENIZED)
|
157
|
@NullOrNotEmpty
|
158
|
@Length(max = 255)
|
159
|
protected String pages;
|
160
|
|
161
|
@XmlElement(name = "Edition")
|
162
|
@Field(index=Index.TOKENIZED)
|
163
|
@NullOrNotEmpty
|
164
|
@Length(max = 255)
|
165
|
protected String edition;
|
166
|
|
167
|
@XmlElement(name = "ISBN")
|
168
|
@Field(index=Index.TOKENIZED)
|
169
|
@NullOrNotEmpty
|
170
|
@Length(max = 255)
|
171
|
@Pattern(regexp = "(?=.{13}$)\\d{1,5}([- ])\\d{1,7}\\1\\d{1,6}\\1(\\d|X)$", groups = Level2.class, message = "{eu.etaxonomy.cdm.model.reference.Reference.isbn.message}")
|
172
|
protected String isbn;
|
173
|
|
174
|
@XmlElement(name = "ISSN")
|
175
|
@Field(index=Index.TOKENIZED)
|
176
|
@NullOrNotEmpty
|
177
|
@Length(max = 255)
|
178
|
@Pattern(regexp = "(?=.{9}$)\\d{4}([- ])\\d{4} (\\d|X)$", groups = Level2.class, message = "{eu.etaxonomy.cdm.model.reference.Reference.issn.message}")
|
179
|
protected String issn;
|
180
|
|
181
|
@XmlElement(name = "SeriesPart")
|
182
|
@Field(index=Index.TOKENIZED)
|
183
|
@NullOrNotEmpty
|
184
|
@Length(max = 255)
|
185
|
protected String seriesPart;
|
186
|
|
187
|
@XmlElement(name = "Organization")
|
188
|
@Field(index=Index.TOKENIZED)
|
189
|
@NullOrNotEmpty
|
190
|
@Length(max = 255)
|
191
|
protected String organization;
|
192
|
|
193
|
@XmlElement(name = "Publisher")
|
194
|
@Field(index=Index.TOKENIZED)
|
195
|
@NullOrNotEmpty
|
196
|
@Length(max = 255)
|
197
|
protected String publisher;
|
198
|
|
199
|
|
200
|
@XmlElement(name = "PlacePublished")
|
201
|
@Field(index=Index.TOKENIZED)
|
202
|
@NullOrNotEmpty
|
203
|
@Length(max = 255)
|
204
|
protected String placePublished;
|
205
|
|
206
|
@XmlElement(name = "Institution")
|
207
|
@XmlIDREF
|
208
|
@XmlSchemaType(name = "IDREF")
|
209
|
@ManyToOne(fetch = FetchType.LAZY)
|
210
|
@IndexedEmbedded
|
211
|
@Cascade(CascadeType.SAVE_UPDATE)
|
212
|
protected Institution institution;
|
213
|
|
214
|
@XmlElement(name = "School")
|
215
|
@XmlIDREF
|
216
|
@XmlSchemaType(name = "IDREF")
|
217
|
@ManyToOne(fetch = FetchType.LAZY)
|
218
|
@IndexedEmbedded
|
219
|
@Cascade(CascadeType.SAVE_UPDATE)
|
220
|
protected Institution school;
|
221
|
|
222
|
@XmlElement(name = "InReference")
|
223
|
@XmlIDREF
|
224
|
@XmlSchemaType(name = "IDREF")
|
225
|
@ManyToOne(fetch = FetchType.LAZY)
|
226
|
|
227
|
// @IndexedEmbedded
|
228
|
@Cascade(CascadeType.SAVE_UPDATE)
|
229
|
@InReference(groups=Level2.class)
|
230
|
protected Reference inReference;
|
231
|
|
232
|
// @XmlElement(name = "FullReference")
|
233
|
// @XmlIDREF
|
234
|
// @XmlSchemaType(name = "IDREF")
|
235
|
// @ManyToOne(fetch = FetchType.LAZY)
|
236
|
//// @IndexedEmbedded
|
237
|
// @Cascade(CascadeType.SAVE_UPDATE)
|
238
|
// protected Reference fullReference;
|
239
|
//
|
240
|
// @XmlElement(name = "AbbreviatedReference")
|
241
|
// @XmlIDREF
|
242
|
// @XmlSchemaType(name = "IDREF")
|
243
|
// @ManyToOne(fetch = FetchType.LAZY)
|
244
|
//// @IndexedEmbedded
|
245
|
// @Cascade(CascadeType.SAVE_UPDATE)
|
246
|
// protected Reference abbreviatedReference;
|
247
|
|
248
|
|
249
|
//********************************************************/
|
250
|
|
251
|
//The date range assigned to the reference. ISO Date range like. Flexible, year can be left out, etc
|
252
|
@XmlElement(name ="DatePublished" )
|
253
|
@Embedded
|
254
|
@IndexedEmbedded
|
255
|
private TimePeriod datePublished = TimePeriod.NewInstance();
|
256
|
|
257
|
@XmlElement(name ="Abstract" )
|
258
|
@Column(length=65536, name="referenceAbstract")
|
259
|
@Lob
|
260
|
@Field(index=Index.TOKENIZED)
|
261
|
@NullOrNotEmpty
|
262
|
@Length(max = 65536)
|
263
|
private String referenceAbstract; //abstract is a reserved term in Java
|
264
|
|
265
|
|
266
|
//URIs like DOIs, LSIDs or Handles for this reference
|
267
|
@XmlElement(name = "URI")
|
268
|
@Field(index=org.hibernate.search.annotations.Index.UN_TOKENIZED)
|
269
|
|
270
|
@Type(type="uriUserType")
|
271
|
private URI uri;
|
272
|
|
273
|
//flag to subselect only references that could be useful for nomenclatural citations. If a reference is used as a
|
274
|
//nomenclatural reference in a name this flag should be automatically set
|
275
|
@XmlElement(name = "IsNomenclaturallyRelevant")
|
276
|
@Merge(MergeMode.OR)
|
277
|
private boolean nomenclaturallyRelevant;
|
278
|
|
279
|
@XmlElement(name = "AuthorTeam")
|
280
|
@XmlIDREF
|
281
|
@XmlSchemaType(name = "IDREF")
|
282
|
@ManyToOne(fetch = FetchType.LAZY)
|
283
|
@IndexedEmbedded
|
284
|
@Cascade(CascadeType.SAVE_UPDATE)
|
285
|
private TeamOrPersonBase authorTeam;
|
286
|
|
287
|
// @XmlElement(name = "ReferenceIdentity")
|
288
|
// @XmlIDREF
|
289
|
// @XmlSchemaType(name = "IDREF")
|
290
|
// @ManyToOne(fetch = FetchType.LAZY)
|
291
|
// //@IndexedEmbedded
|
292
|
// @Cascade(CascadeType.SAVE_UPDATE)
|
293
|
// @Transient
|
294
|
// private ReferenceIdentity referenceIdentity;
|
295
|
|
296
|
@XmlAttribute
|
297
|
@Match(MatchMode.IGNORE)
|
298
|
private int parsingProblem = 0;
|
299
|
|
300
|
@XmlAttribute
|
301
|
@Match(MatchMode.IGNORE)
|
302
|
private int problemStarts = -1;
|
303
|
|
304
|
@XmlAttribute
|
305
|
@Match(MatchMode.IGNORE)
|
306
|
private int problemEnds = -1;
|
307
|
|
308
|
@Transient
|
309
|
@XmlAttribute
|
310
|
@Match(MatchMode.IGNORE)
|
311
|
private boolean cacheStrategyRectified = false;
|
312
|
|
313
|
protected Reference(){
|
314
|
super();
|
315
|
this.type = ReferenceType.Generic;
|
316
|
this.cacheStrategy =(S)this.type.getCacheStrategy();
|
317
|
}
|
318
|
|
319
|
protected Reference(ReferenceType type) {
|
320
|
this.type = type;
|
321
|
this.cacheStrategy =(S) type.getCacheStrategy();
|
322
|
}
|
323
|
|
324
|
|
325
|
//*************************** GETTER / SETTER ******************************************/
|
326
|
public String getEditor() {
|
327
|
return editor;
|
328
|
}
|
329
|
|
330
|
public void setEditor(String editor) {
|
331
|
this.editor = editor;
|
332
|
}
|
333
|
|
334
|
public String getSeries() {
|
335
|
return series;
|
336
|
}
|
337
|
|
338
|
public void setSeries(String series) {
|
339
|
this.series = series;
|
340
|
}
|
341
|
|
342
|
public String getVolume() {
|
343
|
return volume;
|
344
|
}
|
345
|
|
346
|
public void setVolume(String volume) {
|
347
|
this.volume = volume;
|
348
|
}
|
349
|
|
350
|
public String getPages() {
|
351
|
return pages;
|
352
|
}
|
353
|
|
354
|
public void setPages(String pages) {
|
355
|
this.pages = pages;
|
356
|
}
|
357
|
|
358
|
public String getEdition() {
|
359
|
return edition;
|
360
|
}
|
361
|
|
362
|
public void setEdition(String edition) {
|
363
|
this.edition = edition;
|
364
|
}
|
365
|
|
366
|
public String getIsbn() {
|
367
|
return isbn;
|
368
|
}
|
369
|
|
370
|
public void setIsbn(String isbn) {
|
371
|
this.isbn = isbn;
|
372
|
}
|
373
|
|
374
|
public String getIssn() {
|
375
|
return issn;
|
376
|
}
|
377
|
|
378
|
public void setIssn(String issn) {
|
379
|
this.issn = issn;
|
380
|
}
|
381
|
|
382
|
public String getSeriesPart() {
|
383
|
return seriesPart;
|
384
|
}
|
385
|
|
386
|
public void setSeriesPart(String seriesPart) {
|
387
|
this.seriesPart = seriesPart;
|
388
|
}
|
389
|
|
390
|
public String getOrganization() {
|
391
|
return organization;
|
392
|
}
|
393
|
|
394
|
public void setOrganization(String organization) {
|
395
|
this.organization = organization;
|
396
|
}
|
397
|
|
398
|
public String getPublisher() {
|
399
|
return publisher;
|
400
|
}
|
401
|
|
402
|
public void setPublisher(String publisher) {
|
403
|
this.publisher = publisher;
|
404
|
}
|
405
|
|
406
|
public void setPublisher(String publisher, String placePublished){
|
407
|
this.publisher = publisher;
|
408
|
this.placePublished = placePublished;
|
409
|
}
|
410
|
|
411
|
public String getPlacePublished() {
|
412
|
return placePublished;
|
413
|
}
|
414
|
|
415
|
public void setPlacePublished(String placePublished) {
|
416
|
this.placePublished = placePublished;
|
417
|
}
|
418
|
|
419
|
public Institution getInstitution() {
|
420
|
return institution;
|
421
|
}
|
422
|
|
423
|
public void setInstitution(Institution institution) {
|
424
|
this.institution = institution;
|
425
|
}
|
426
|
|
427
|
public Institution getSchool() {
|
428
|
return school;
|
429
|
}
|
430
|
|
431
|
public void setSchool(Institution school) {
|
432
|
this.school = school;
|
433
|
}
|
434
|
|
435
|
public Reference getInReference() {
|
436
|
return inReference;
|
437
|
}
|
438
|
|
439
|
public void setInReference(Reference inReference) {
|
440
|
this.inReference = inReference;
|
441
|
}
|
442
|
|
443
|
public void setType(ReferenceType type) {
|
444
|
this.setCacheStrategy((S) type.getCacheStrategy());
|
445
|
this.type = type;
|
446
|
}
|
447
|
|
448
|
/**
|
449
|
* @return the type
|
450
|
*/
|
451
|
public ReferenceType getType() {
|
452
|
return type;
|
453
|
}
|
454
|
|
455
|
/**
|
456
|
* Whether this reference is of the given type
|
457
|
*
|
458
|
* @param type
|
459
|
* @return
|
460
|
*/
|
461
|
public boolean isOfType(ReferenceType type){
|
462
|
return type == getType();
|
463
|
}
|
464
|
|
465
|
/**
|
466
|
* Returns a string representing the title of <i>this</i> reference. If a
|
467
|
* reference has different titles (for instance abbreviated and not
|
468
|
* abbreviated) then for each title a new instance must be created.
|
469
|
*
|
470
|
* @return the title string of <i>this</i> reference
|
471
|
* @see #getCitation()
|
472
|
*/
|
473
|
public String getTitle(){
|
474
|
return this.title;
|
475
|
}
|
476
|
/**
|
477
|
* @see #getTitle()
|
478
|
*/
|
479
|
public void setTitle(String title){
|
480
|
this.title = title;
|
481
|
}
|
482
|
|
483
|
/**
|
484
|
* Returns the date (mostly only the year) of publication / creation of
|
485
|
* <i>this</i> reference.
|
486
|
*/
|
487
|
public TimePeriod getDatePublished(){
|
488
|
return this.datePublished;
|
489
|
}
|
490
|
/**
|
491
|
* @see #getDatePublished()
|
492
|
*/
|
493
|
public void setDatePublished(TimePeriod datePublished){
|
494
|
this.datePublished = datePublished;
|
495
|
}
|
496
|
|
497
|
/**
|
498
|
* Returns the {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author (team)} who created the
|
499
|
* content of <i>this</i> reference.
|
500
|
*
|
501
|
* @return the author (team) of <i>this</i> reference
|
502
|
* @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase
|
503
|
*/
|
504
|
public TeamOrPersonBase getAuthorTeam(){
|
505
|
return this.authorTeam;
|
506
|
}
|
507
|
|
508
|
/**
|
509
|
* @see #getAuthorTeam()
|
510
|
*/
|
511
|
public void setAuthorTeam(TeamOrPersonBase authorTeam){
|
512
|
this.authorTeam = authorTeam;
|
513
|
}
|
514
|
|
515
|
/**
|
516
|
* Returns the Uniform Resource Identifier (URI) corresponding to <i>this</i>
|
517
|
* reference. An URI is a string of characters used to identify a resource
|
518
|
* on the Internet.
|
519
|
*
|
520
|
* @return the URI of <i>this</i> reference
|
521
|
*/
|
522
|
public URI getUri(){
|
523
|
return this.uri;
|
524
|
}
|
525
|
/**
|
526
|
* @see #getUri()
|
527
|
*/
|
528
|
public void setUri(URI uri){
|
529
|
this.uri = uri;
|
530
|
}
|
531
|
|
532
|
/**
|
533
|
* @return the referenceAbstract
|
534
|
*/
|
535
|
public String getReferenceAbstract() {
|
536
|
return referenceAbstract;
|
537
|
}
|
538
|
|
539
|
/**
|
540
|
* @param referenceAbstract the referenceAbstract to set
|
541
|
*/
|
542
|
public void setReferenceAbstract(String referenceAbstract) {
|
543
|
this.referenceAbstract = referenceAbstract;
|
544
|
}
|
545
|
|
546
|
|
547
|
|
548
|
|
549
|
/**
|
550
|
* Returns "true" if the isNomenclaturallyRelevant flag is set. This
|
551
|
* indicates that a {@link TaxonNameBase taxon name} has been originally
|
552
|
* published in <i>this</i> reference following the rules of a
|
553
|
* {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode nomenclature code} and is therefore used for
|
554
|
* nomenclatural citations. This flag will be set as soon as <i>this</i>
|
555
|
* reference is used as a nomenclatural reference for any taxon name.<BR>
|
556
|
* FIXME what happens if the only taxon name referencing this reference is not
|
557
|
* any longer using this reference as a nomenclatural reference. How does the
|
558
|
* reference get informed about the fact that it is not nomenclaturally relevant
|
559
|
* anymore?
|
560
|
*/
|
561
|
public boolean isNomenclaturallyRelevant(){
|
562
|
return this.nomenclaturallyRelevant;
|
563
|
}
|
564
|
|
565
|
/**
|
566
|
* @see #isNomenclaturallyRelevant()
|
567
|
*/
|
568
|
public void setNomenclaturallyRelevant(boolean nomenclaturallyRelevant){
|
569
|
this.nomenclaturallyRelevant = nomenclaturallyRelevant;
|
570
|
}
|
571
|
|
572
|
|
573
|
// /**
|
574
|
// * Returns the full reference that belongs to this abbreviated reference. If this
|
575
|
// * reference is not abbreviated the full reference should be <code>null</code>.<BR>
|
576
|
// * A full reference should be added to a reference
|
577
|
// * which represents the abbreviated form of a reference. The full reference can be used
|
578
|
// * by publication tools to link to the unabbreviated and therefore more complete version
|
579
|
// * of the reference.
|
580
|
// *
|
581
|
// * @see #getAbbreviatedReference()
|
582
|
// * @return the full reference
|
583
|
// */
|
584
|
// public Reference getFullReference() {
|
585
|
// return fullReference;
|
586
|
// }
|
587
|
//
|
588
|
// /**
|
589
|
// * @see #getFullReference()
|
590
|
// * @param fullReference
|
591
|
// */
|
592
|
// public void setFullReference(Reference fullReference) {
|
593
|
// this.fullReference = fullReference;
|
594
|
// }
|
595
|
//
|
596
|
// /**
|
597
|
// * Returns the abbreviated reference that belongs to this full reference. If this
|
598
|
// * reference is not a full reference the abbeviated referece must be <code>null</code>.<BR>
|
599
|
// * An abbreviated reference should be added to a reference which represents the long (full)
|
600
|
// * form of a reference.
|
601
|
// * In future this may become a set or handled differently as there are multiple
|
602
|
// *
|
603
|
// * @see #getFullReference()
|
604
|
// * @return the full reference
|
605
|
// */
|
606
|
// public Reference getAbbreviatedReference() {
|
607
|
// return abbreviatedReference;
|
608
|
// }
|
609
|
//
|
610
|
// /**
|
611
|
// * @see #getAbbreviatedReference()
|
612
|
// * @param abbreviatedReference
|
613
|
// *
|
614
|
// */
|
615
|
// public void setAbbreviatedReference(Reference abbreviatedReference) {
|
616
|
// this.abbreviatedReference = abbreviatedReference;
|
617
|
// }
|
618
|
|
619
|
//**************************************************** /
|
620
|
|
621
|
// /**
|
622
|
// * Returns the string representing the name of the editor of <i>this</i>
|
623
|
// * generic reference. An editor is mostly a person (team) who assumed the
|
624
|
// * responsibility for the content of the publication as a whole without
|
625
|
// * being the author of this content.<BR>
|
626
|
// * If there is an editor then the generic reference must be some
|
627
|
// * kind of {@link PrintedUnitBase physical printed unit}.
|
628
|
// *
|
629
|
// * @return the string identifying the editor of <i>this</i>
|
630
|
// * generic reference
|
631
|
// * @see #getPublisher()
|
632
|
// */
|
633
|
// protected String getEditor(){
|
634
|
// return this.editor;
|
635
|
// }
|
636
|
//
|
637
|
// /**
|
638
|
// * @see #getEditor()
|
639
|
// */
|
640
|
// protected void setEditor(String editor){
|
641
|
// this.editor = editor;
|
642
|
// }
|
643
|
//
|
644
|
// /**
|
645
|
// * Returns the string representing the series (for instance for books or
|
646
|
// * within journals) - and series part - in which <i>this</i> generic reference
|
647
|
// * was published.<BR>
|
648
|
// * If there is a series then the generic reference must be some
|
649
|
// * kind of {@link PrintedUnitBase physical printed unit} or an {@link Article article}.
|
650
|
// *
|
651
|
// * @return the string identifying the series for <i>this</i>
|
652
|
// * generic reference
|
653
|
// */
|
654
|
// protected String getSeries(){
|
655
|
// return this.series;
|
656
|
// }
|
657
|
//
|
658
|
// /**
|
659
|
// * @see #getSeries()
|
660
|
// */
|
661
|
// protected void setSeries(String series){
|
662
|
// this.series = series;
|
663
|
// }
|
664
|
//
|
665
|
// /**
|
666
|
// * Returns the string representing the volume (for instance for books or
|
667
|
// * within journals) in which <i>this</i> generic reference was published.<BR>
|
668
|
// * If there is a volume then the generic reference must be some
|
669
|
// * kind of {@link PrintedUnitBase physical printed unit} or an {@link Article article}.
|
670
|
// *
|
671
|
// * @return the string identifying the volume for <i>this</i>
|
672
|
// * generic reference
|
673
|
// */
|
674
|
// protected String getVolume(){
|
675
|
// return this.volume;
|
676
|
// }
|
677
|
//
|
678
|
// /**
|
679
|
// * @see #getVolume()
|
680
|
// */
|
681
|
// protected void setVolume(String volume){
|
682
|
// this.volume = volume;
|
683
|
// }
|
684
|
//
|
685
|
// /**
|
686
|
// * Returns the string representing the page(s) where the content of
|
687
|
// * <i>this</i> generic reference is located.<BR>
|
688
|
// * If there is a pages information then the generic reference must be some
|
689
|
// * kind of {@link PrintedUnitBase physical printed unit} or an {@link Article article}.
|
690
|
// *
|
691
|
// * @return the string containing the pages corresponding to <i>this</i>
|
692
|
// * generic reference
|
693
|
// */
|
694
|
// protected String getPages(){
|
695
|
// return this.pages;
|
696
|
// }
|
697
|
//
|
698
|
// /**
|
699
|
// * @see #getPages()
|
700
|
// */
|
701
|
// protected void setPages(String pages){
|
702
|
// this.pages = pages;
|
703
|
// }
|
704
|
|
705
|
|
706
|
/**
|
707
|
* Returns a formatted string containing the entire reference citation,
|
708
|
* including authors, corresponding to <i>this</i> reference.
|
709
|
*
|
710
|
* @see #generateTitle()
|
711
|
*/
|
712
|
// TODO implement
|
713
|
@Transient
|
714
|
public String getCitation(){
|
715
|
rectifyCacheStrategy();
|
716
|
if (cacheStrategy == null){
|
717
|
logger.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid());
|
718
|
return null;
|
719
|
}else{
|
720
|
return cacheStrategy.getTitleCache(this);
|
721
|
}
|
722
|
}
|
723
|
|
724
|
/* (non-Javadoc)
|
725
|
* @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
|
726
|
*/
|
727
|
public String generateTitle() {
|
728
|
rectifyCacheStrategy();
|
729
|
return super.generateTitle();
|
730
|
}
|
731
|
|
732
|
/**
|
733
|
* Returns a string representation for the year of publication / creation
|
734
|
* of <i>this</i> reference. The string is obtained by transformation of
|
735
|
* the {@link #getDatePublished() datePublished} attribute.
|
736
|
*/
|
737
|
@Transient
|
738
|
public String getYear(){
|
739
|
TimePeriod datePublished = this.getDatePublished();
|
740
|
if (datePublished != null ){
|
741
|
String result = getDatePublished().getYear();
|
742
|
return result;
|
743
|
}else{
|
744
|
return null;
|
745
|
}
|
746
|
}
|
747
|
|
748
|
|
749
|
|
750
|
/* (non-Javadoc)
|
751
|
* @see eu.etaxonomy.cdm.model.common.IParsable#getHasProblem()
|
752
|
*/
|
753
|
public int getParsingProblem(){
|
754
|
return this.parsingProblem;
|
755
|
}
|
756
|
|
757
|
/* (non-Javadoc)
|
758
|
* @see eu.etaxonomy.cdm.model.common.IParsable#setHasProblem(boolean)
|
759
|
*/
|
760
|
public void setParsingProblem(int parsingProblem){
|
761
|
this.parsingProblem = parsingProblem;
|
762
|
}
|
763
|
|
764
|
/* (non-Javadoc)
|
765
|
* @see eu.etaxonomy.cdm.model.common.IParsable#hasProblem()
|
766
|
*/
|
767
|
public boolean hasProblem(){
|
768
|
return parsingProblem != 0;
|
769
|
}
|
770
|
|
771
|
/* (non-Javadoc)
|
772
|
* @see eu.etaxonomy.cdm.model.common.IParsable#hasProblem(eu.etaxonomy.cdm.strategy.parser.ParserProblem)
|
773
|
*/
|
774
|
public boolean hasProblem(ParserProblem problem) {
|
775
|
return getParsingProblems().contains(problem);
|
776
|
}
|
777
|
|
778
|
|
779
|
/* (non-Javadoc)
|
780
|
* @see eu.etaxonomy.cdm.model.common.IParsable#problemStarts()
|
781
|
*/
|
782
|
public int getProblemStarts(){
|
783
|
return this.problemStarts;
|
784
|
}
|
785
|
|
786
|
/* (non-Javadoc)
|
787
|
* @see eu.etaxonomy.cdm.model.common.IParsable#setProblemStarts(int)
|
788
|
*/
|
789
|
public void setProblemStarts(int start) {
|
790
|
this.problemStarts = start;
|
791
|
}
|
792
|
|
793
|
/* (non-Javadoc)
|
794
|
* @see eu.etaxonomy.cdm.model.common.IParsable#problemEnds()
|
795
|
*/
|
796
|
public int getProblemEnds(){
|
797
|
return this.problemEnds;
|
798
|
}
|
799
|
|
800
|
/* (non-Javadoc)
|
801
|
* @see eu.etaxonomy.cdm.model.common.IParsable#setProblemEnds(int)
|
802
|
*/
|
803
|
public void setProblemEnds(int end) {
|
804
|
this.problemEnds = end;
|
805
|
}
|
806
|
|
807
|
/* (non-Javadoc)
|
808
|
* @see eu.etaxonomy.cdm.model.common.IParsable#addProblem(eu.etaxonomy.cdm.strategy.parser.NameParserWarning)
|
809
|
*/
|
810
|
public void addParsingProblem(ParserProblem warning){
|
811
|
parsingProblem = ParserProblem.addProblem(parsingProblem, warning);
|
812
|
}
|
813
|
|
814
|
/* (non-Javadoc)
|
815
|
* @see eu.etaxonomy.cdm.model.common.IParsable#removeParsingProblem(eu.etaxonomy.cdm.strategy.parser.ParserProblem)
|
816
|
*/
|
817
|
public void removeParsingProblem(ParserProblem problem) {
|
818
|
parsingProblem = ParserProblem.removeProblem(parsingProblem, problem);
|
819
|
}
|
820
|
|
821
|
/* (non-Javadoc)
|
822
|
* @see eu.etaxonomy.cdm.model.common.IParsable#getParsingProblems()
|
823
|
*/
|
824
|
@Transient
|
825
|
public List<ParserProblem> getParsingProblems() {
|
826
|
return ParserProblem.warningList(this.parsingProblem);
|
827
|
}
|
828
|
|
829
|
|
830
|
@Transient
|
831
|
public String getNomenclaturalCitation(String microReference) {
|
832
|
rectifyCacheStrategy();
|
833
|
String typeName = this.getType()== null ? "(no type defined)" : this.getType().getMessage();
|
834
|
if (cacheStrategy == null){
|
835
|
logger.warn("No CacheStrategy defined for "+ typeName + ": " + this.getUuid());
|
836
|
return null;
|
837
|
}else{
|
838
|
if (cacheStrategy instanceof INomenclaturalReferenceCacheStrategy){
|
839
|
return ((INomenclaturalReferenceCacheStrategy)cacheStrategy).getNomenclaturalCitation(this,microReference);
|
840
|
}else {
|
841
|
logger.warn("No INomenclaturalReferenceCacheStrategy defined for "+ typeName + ": " + this.getUuid());
|
842
|
return null;
|
843
|
}
|
844
|
}
|
845
|
}
|
846
|
|
847
|
|
848
|
/**
|
849
|
* Generates, according to the {@link eu.etaxonomy.cdm.strategy.strategy.cache.reference.IReferenceBaseCacheStrategy cache strategy}
|
850
|
* assigned to <i>this</i> reference, a string that identifies <i>this</i>
|
851
|
* reference and returns it. This string may be stored in the inherited
|
852
|
* {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
|
853
|
* This method overrides the generic and inherited generateTitle method
|
854
|
* from {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity IdentifiableEntity}.
|
855
|
*
|
856
|
* @return the string identifying <i>this</i> reference
|
857
|
* @see #getCitation()
|
858
|
* @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
|
859
|
* @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
|
860
|
* @see eu.etaxonomy.cdm.strategy.strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache()
|
861
|
*/
|
862
|
// @Override
|
863
|
// public String generateTitle(){
|
864
|
// if (cacheStrategy == null){
|
865
|
// logger.warn("No CacheStrategy defined for Reference: " + this.getUuid());
|
866
|
// return null;
|
867
|
// }else{
|
868
|
// return cacheStrategy.getTitleCache(this);
|
869
|
// }
|
870
|
// }
|
871
|
|
872
|
|
873
|
|
874
|
// /**
|
875
|
// * Returns the reference identity object
|
876
|
// * @return the referenceIdentity
|
877
|
// */
|
878
|
// public ReferenceIdentity getReferenceIdentity() {
|
879
|
// return referenceIdentity;
|
880
|
// }
|
881
|
//
|
882
|
// /**
|
883
|
// * For bidirectional use only
|
884
|
// * @param referenceIdentity the referenceIdentity to set
|
885
|
// */
|
886
|
// protected void setReferenceIdentity(ReferenceIdentity referenceIdentity) {
|
887
|
// this.referenceIdentity = referenceIdentity;
|
888
|
// }
|
889
|
//
|
890
|
// /**
|
891
|
// * Returns the set of all identical references. Same as getReferenceIdentity().getReferences()
|
892
|
// * @return
|
893
|
// */
|
894
|
// public Set<Reference> identicalReferences(){
|
895
|
// return referenceIdentity.getReferences();
|
896
|
// }
|
897
|
|
898
|
|
899
|
//********** Casting methods ***********************************/
|
900
|
|
901
|
public IArticle castReferenceToArticle(){
|
902
|
setType(ReferenceType.Article);
|
903
|
return (IArticle) this;
|
904
|
}
|
905
|
|
906
|
public IBook castReferenceToBook(){
|
907
|
setType(ReferenceType.Book);
|
908
|
return (IBook) this;
|
909
|
}
|
910
|
|
911
|
public IBookSection castReferenceToBookSection(){
|
912
|
setType(ReferenceType.BookSection);
|
913
|
return (IBookSection) this;
|
914
|
}
|
915
|
|
916
|
public ICdDvd castReferenceToCdDvd(){
|
917
|
setType(ReferenceType.CdDvd);
|
918
|
return (ICdDvd) this;
|
919
|
}
|
920
|
|
921
|
public IDatabase castReferenceToDatabase(){
|
922
|
setType(ReferenceType.Database);
|
923
|
return (IDatabase) this;
|
924
|
}
|
925
|
|
926
|
public IGeneric castReferenceToGeneric(){
|
927
|
setType(ReferenceType.Generic);
|
928
|
return (IGeneric) this;
|
929
|
}
|
930
|
|
931
|
public IInProceedings castReferenceToInProceedings(){
|
932
|
setType(ReferenceType.InProceedings);
|
933
|
return (IInProceedings) this;
|
934
|
}
|
935
|
|
936
|
public IJournal castReferenceToJournal(){
|
937
|
setType(ReferenceType.Journal);
|
938
|
return (IJournal) this;
|
939
|
}
|
940
|
|
941
|
public IMap castReferenceToMap(){
|
942
|
setType(ReferenceType.Map);
|
943
|
return (IMap) this;
|
944
|
}
|
945
|
|
946
|
public IPatent castReferenceToPatent(){
|
947
|
setType(ReferenceType.Patent);
|
948
|
return (IPatent) this;
|
949
|
}
|
950
|
|
951
|
public IPersonalCommunication castReferenceToPersonalCommunication(){
|
952
|
setType(ReferenceType.PersonalCommunication);
|
953
|
return (IPersonalCommunication) this;
|
954
|
}
|
955
|
|
956
|
public IPrintSeries castReferenceToPrintSeries(){
|
957
|
setType(ReferenceType.PrintSeries);
|
958
|
return (IPrintSeries) this;
|
959
|
}
|
960
|
|
961
|
public IWebPage castReferenceToWebPage(){
|
962
|
setType(ReferenceType.WebPage);
|
963
|
return (IWebPage) this;
|
964
|
}
|
965
|
|
966
|
public IProceedings castReferenceToProceedings(){
|
967
|
setType(ReferenceType.Proceedings);
|
968
|
return (IProceedings) this;
|
969
|
}
|
970
|
|
971
|
public IReport castReferenceToReport(){
|
972
|
setType(ReferenceType.Report);
|
973
|
return (IReport) this;
|
974
|
}
|
975
|
|
976
|
public IThesis castReferenceToThesis(){
|
977
|
setType(ReferenceType.Thesis);
|
978
|
return (IThesis) this;
|
979
|
}
|
980
|
|
981
|
|
982
|
@Transient // prevent from being serialized by webservice
|
983
|
public IJournal getInJournal() {
|
984
|
IJournal journal = this.inReference;
|
985
|
return journal;
|
986
|
}
|
987
|
|
988
|
public void setInJournal(IJournal journal) {
|
989
|
this.inReference = (Reference<JournalDefaultCacheStrategy<Reference>>) journal;
|
990
|
|
991
|
}
|
992
|
|
993
|
@Transient // prevent from being serialized by webservice
|
994
|
public IPrintSeries getInSeries() {
|
995
|
IPrintSeries printSeries = this.inReference;
|
996
|
return printSeries;
|
997
|
}
|
998
|
|
999
|
public void setInSeries(IPrintSeries inSeries) {
|
1000
|
this.inReference = (Reference<IReferenceBaseCacheStrategy<Reference>>) inSeries;
|
1001
|
}
|
1002
|
|
1003
|
@Transient // prevent from being serialized by webservice
|
1004
|
public IBook getInBook() {
|
1005
|
IBook book = this.inReference;
|
1006
|
return book;
|
1007
|
}
|
1008
|
|
1009
|
//********************** In-References *****************************************
|
1010
|
|
1011
|
public void setInBook(IBook book) {
|
1012
|
this.inReference = (Reference<BookDefaultCacheStrategy<Reference>>) book;
|
1013
|
}
|
1014
|
|
1015
|
@Transient // prevent from being serialized by webservice
|
1016
|
public IProceedings getInProceedings() {
|
1017
|
IProceedings proceedings = this.inReference;
|
1018
|
return proceedings;
|
1019
|
}
|
1020
|
|
1021
|
public void setInProceedings(IProceedings proceeding) {
|
1022
|
this.inReference = (Reference<BookDefaultCacheStrategy<Reference>>) proceeding;
|
1023
|
}
|
1024
|
|
1025
|
//*************************** CACHE STRATEGIES ******************************/
|
1026
|
|
1027
|
/**
|
1028
|
* The type property of this class is mapped on the field level to the data base column, so
|
1029
|
* Hibernate will consequently use the {@link org.hibernate.property.DirectPropertyAccessor}
|
1030
|
* to set the property. This PropertyAccessor directly sets the field instead of using the according setter so
|
1031
|
* the CacheStrategy is not correctly set after the initialization of the bean. Thus we need to
|
1032
|
* validate the CacheStrategy before it is to be used.
|
1033
|
*/
|
1034
|
private void rectifyCacheStrategy() {
|
1035
|
if(!cacheStrategyRectified ){
|
1036
|
setType(getType());
|
1037
|
cacheStrategyRectified = true;
|
1038
|
}
|
1039
|
}
|
1040
|
|
1041
|
|
1042
|
//public void setCacheStrategy(S cacheStrategy){
|
1043
|
// this.cacheStrategy = cacheStrategy;
|
1044
|
//}
|
1045
|
|
1046
|
public void setCacheStrategy(IReferenceBaseCacheStrategy iReferenceBaseCacheStrategy) {
|
1047
|
this.cacheStrategy = (S) iReferenceBaseCacheStrategy;
|
1048
|
|
1049
|
}
|
1050
|
|
1051
|
public void setCacheStrategy(ArticleDefaultCacheStrategy cacheStrategy) {
|
1052
|
this.cacheStrategy = (S) cacheStrategy;
|
1053
|
}
|
1054
|
|
1055
|
public void setCacheStrategy(BookDefaultCacheStrategy cacheStrategy) {
|
1056
|
this.cacheStrategy = (S) cacheStrategy;
|
1057
|
}
|
1058
|
|
1059
|
public void setCacheStrategy(JournalDefaultCacheStrategy cacheStrategy) {
|
1060
|
this.cacheStrategy = (S) cacheStrategy;
|
1061
|
}
|
1062
|
|
1063
|
public void setCacheStrategy(BookSectionDefaultCacheStrategy cacheStrategy) {
|
1064
|
this.cacheStrategy = (S) cacheStrategy;
|
1065
|
}
|
1066
|
|
1067
|
public void setCacheStrategy(GenericDefaultCacheStrategy cacheStrategy) {
|
1068
|
this.cacheStrategy = (S) cacheStrategy;
|
1069
|
}
|
1070
|
|
1071
|
public void setCacheStrategy(ReferenceBaseDefaultCacheStrategy cacheStrategy) {
|
1072
|
this.cacheStrategy = (S)cacheStrategy;
|
1073
|
|
1074
|
}
|
1075
|
|
1076
|
|
1077
|
//*********************** CLONE ********************************************************/
|
1078
|
|
1079
|
/**
|
1080
|
* Clones <i>this</i> reference. This is a shortcut that enables to create
|
1081
|
* a new instance that differs only slightly from <i>this</i> reference by
|
1082
|
* modifying only some of the attributes.
|
1083
|
*
|
1084
|
* @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
|
1085
|
* @see java.lang.Object#clone()
|
1086
|
*/
|
1087
|
@Override
|
1088
|
public Object clone() {
|
1089
|
try {
|
1090
|
Reference result = (Reference)super.clone();
|
1091
|
result.setDatePublished(datePublished != null? (TimePeriod)datePublished.clone(): null);
|
1092
|
//no changes to: title, authorTeam, hasProblem, nomenclaturallyRelevant, uri
|
1093
|
return result;
|
1094
|
} catch (CloneNotSupportedException e) {
|
1095
|
logger.warn("Object does not implement cloneable");
|
1096
|
e.printStackTrace();
|
1097
|
return null;
|
1098
|
}
|
1099
|
}
|
1100
|
|
1101
|
}
|
1102
|
|