Project

General

Profile

Download (18.5 KB) Statistics
| Branch: | Tag: | Revision:
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 javax.persistence.Entity;
14
import javax.persistence.Inheritance;
15
import javax.persistence.InheritanceType;
16
import javax.persistence.ManyToOne;
17
import javax.persistence.Transient;
18

    
19
import org.apache.log4j.Logger;
20
import org.hibernate.annotations.Cascade;
21
import org.hibernate.annotations.CascadeType;
22

    
23
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
24
import eu.etaxonomy.cdm.strategy.cache.reference.BibtexDefaultCacheStrategy;
25

    
26
/**
27
 * This class represents references which are structured according to the BibTeX
28
 * format. The flat BibTeX format is an usual alternative to handle references 
29
 * (see "http://en.wikipedia.org/wiki/BibTeX"). Therefore this class might be
30
 * used instead of {@link StrictReferenceBase StrictReferenceBase} depending on the data
31
 * to be imported in the CDM.
32
 * 
33
 * @see BibtexEntryType
34
 * @author m.doering
35
 * @version 1.0
36
 * @created 08-Nov-2007 13:06:12
37
 */
38
@Entity
39
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
40
public class BibtexReference extends ReferenceBase implements INomenclaturalReference {
41
	private static final Logger logger = Logger.getLogger(BibtexReference.class);
42
	
43
	private BibtexEntryType type;
44
	private String journal;
45
	private String booktitle;
46
	private String chapter;
47
	private String title;
48
	private String series;
49
	private String edition;
50
	private String volume;
51
	private String number;
52
	private String pages;
53
	private String annote;
54
	private String editor;
55
	private String institution;
56
	private String school;
57
	private String organization;
58
	private String publisher;
59
	private String address;
60
	private String howpublished;
61
	private String reportType;
62
	private String month;
63
	private String year;
64
	private String eprint;
65
	private String note;
66
	private BibtexReference crossref;
67

    
68
	private NomenclaturalReferenceHelper nomRefBase = NomenclaturalReferenceHelper.NewInstance(this);
69

    
70
	
71
	/** 
72
	 * Class constructor: creates a new empty BibTeX reference instance only
73
	 * containing the {@link strategy.cache.reference.BibtexDefaultCacheStrategy default cache strategy}.
74
	 * 
75
	 * @see strategy.cache.reference.BibtexDefaultCacheStrategy
76
	 */
77
	protected BibtexReference(){
78
		super();
79
		this.cacheStrategy = BibtexDefaultCacheStrategy.NewInstance();
80
	}
81

    
82
	/** 
83
	 * Creates a new empty BibTeX reference instance only containing the
84
	 * {@link strategy.cache.reference.BibtexDefaultCacheStrategy default cache strategy}.
85
	 * 
86
	 * @see strategy.cache.reference.BibtexDefaultCacheStrategy
87
	 */
88
	public static BibtexReference NewInstance(){
89
		BibtexReference result = new BibtexReference();
90
		return result;
91
	}
92

    
93
	/**
94
	 * Returns the BibTeX reference <i>this</i> BibTeX reference belongs to (for
95
	 * instance a BibTeX reference with the {@link BibtexEntryType entry type} "INBOOK" belongs
96
	 * to another BibTeX reference with the entry type "BOOK").<BR>
97
	 * The returned "crossref" attribute corresponds to the {@link BookSection#getInBook() "inBook"}
98
	 * and {@link InProceedings#getInProceedings() "inProceedings"} attributes of BookSection and of
99
	 * InProccedings.
100
	 * 
101
	 * @return  the BibTeX reference containing <i>this</i> BibTeX reference
102
	 * @see 	BibtexEntryType
103
	 */
104
	@ManyToOne
105
	@Cascade({CascadeType.SAVE_UPDATE})
106
	public BibtexReference getCrossref(){
107
		return this.crossref;
108
	}
109
	/**
110
	 * @see #getCrossref()
111
	 */
112
	public void setCrossref(BibtexReference crossref){
113
		this.crossref = crossref;
114
	}
115

    
116
	/**
117
	 * Returns the string representing the journal or magazine title <i>this</i>
118
	 * BibTeX reference with the {@link BibtexEntryType entry type} "ARTICLE" was
119
	 * published in.<BR>
120
	 * The returned "journal" attribute corresponds to the {@link Article#getInJournal() "inJournal"}
121
	 * attribute of Article.
122
	 * 
123
	 * @return  the string identifying the journal where <i>this</i> BibTeX
124
	 * 			reference (article) was published
125
	 */
126
	public String getJournal(){
127
		return this.journal;
128
	}
129

    
130
	/**
131
	 * @see #getJournal()
132
	 */
133
	public void setJournal(String journal){
134
		this.journal = journal;
135
	}
136

    
137
	/**
138
	 * Returns the string representing the book title <i>this</i>
139
	 * BibTeX reference, with the {@link BibtexEntryType entry type} "INBOOK", "INCOLLECTION"
140
	 * "INPROCEEDINGS" or "CONFERENCE", was published in.<BR>
141
	 * The returned "booktitle" attribute corresponds to the {@link BookSection#getInBook() "inBook"}
142
	 * attribute of BookSection.
143
	 * 
144
	 * @return  the string identifying the book where <i>this</i> BibTeX
145
	 * 			reference (part of a book) was published
146
	 */
147
	public String getBooktitle(){
148
		return this.booktitle;
149
	}
150

    
151
	/**
152
	 * @see #getBooktitle()
153
	 */
154
	public void setBooktitle(String booktitle){
155
		this.booktitle = booktitle;
156
	}
157

    
158
	/**
159
	 * Returns the string representing the chapter number of <i>this</i>
160
	 * BibTeX reference with the {@link BibtexEntryType entry type} "INBOOK" or "INCOLLECTION"
161
	 * if this part of a book is a chapter.<BR>
162
	 * In this case the returned string is included in the inherited {@link BookSection#getTitle() "title"}
163
	 * attribute of BookSection.
164
	 * 
165
	 * @return  the string with the chapter number corresponding to <i>this</i>
166
	 * 			BibTeX reference
167
	 */
168
	public String getChapter(){
169
		return this.chapter;
170
	}
171

    
172
	/**
173
	 * @see #getChapter()
174
	 */
175
	public void setChapter(String chapter){
176
		this.chapter = chapter;
177
	}
178

    
179
	/**
180
	 * Returns the string representing the title of <i>this</i> BibTeX reference.<BR>
181
	 * The returned "title" attribute corresponds to the {@link StrictReferenceBase#getTitle() "title"}
182
	 * attribute of StrictReferenceBase.
183
	 * 
184
	 * @return  the string with the title of <i>this</i> BibTeX reference
185
	 */
186
	public String getTitle(){
187
		return this.title;
188
	}
189

    
190
	/**
191
	 * @see #getTitle()
192
	 */
193
	public void setTitle(String title){
194
		this.title = title;
195
	}
196

    
197
	/**
198
	 * Returns the string representing the series of books <i>this</i>
199
	 * BibTeX reference with the {@link BibtexEntryType entry type} "BOOK" or "INBOOK"
200
	 * was published in.<BR>
201
	 * The returned "series" attribute corresponds to the inherited {@link PrintedUnitBase#getInSeries() "inSeries"}
202
	 * attribute of Book.
203
	 * 
204
	 * @return  the string identifying the book series <i>this</i> BibTeX
205
	 * 			reference (book) was published in
206
	 */
207
	public String getSeries(){
208
		return this.series;
209
	}
210

    
211
	/**
212
	 * @see #getSeries()
213
	 */
214
	public void setSeries(String series){
215
		this.series = series;
216
	}
217

    
218
	/**
219
	 * Returns the string representing the edition of <i>this</i>
220
	 * BibTeX reference with the {@link BibtexEntryType entry type} "BOOK", "INBOOK"
221
	 * or "MANUAL".<BR>
222
	 * The returned "edition" attribute corresponds to the {@link Book#getEdition() "edition"}
223
	 * attribute of Book.
224
	 * 
225
	 * @return  the string identifying the edition of <i>this</i> BibTeX
226
	 * 			reference (book)
227
	 */
228
	public String getEdition(){
229
		return this.edition;
230
	}
231

    
232
	/**
233
	 * @see #getEdition()
234
	 */
235
	public void setEdition(String edition){
236
		this.edition = edition;
237
	}
238

    
239
	/**
240
	 * Returns the string representing either the volume of <i>this</i>
241
	 * BibTeX reference if it is a {@link BibtexEntryType#BOOK() "BOOK"} or of the journal
242
	 * in which <i>this</i> BibTeX reference was published if it is an {@link BibtexEntryType#ARTICLE() "ARTICLE"}.<BR>
243
	 * The returned "volume" attribute corresponds to the "volume" attributes
244
	 * of {@link PrintedUnitBase#getVolume() PrintedUnitBase} and {@link Article#getVolume() Article}.
245
	 * 
246
	 * @return  the string identifying the volume of <i>this</i> BibTeX
247
	 * 			reference (article or book)
248
	 */
249
	public String getVolume(){
250
		return this.volume;
251
	}
252

    
253
	/**
254
	 * @see #getVolume()
255
	 */
256
	public void setVolume(String volume){
257
		this.volume = volume;
258
	}
259

    
260
	/**
261
	 * Returns the string representing, if applicable, either the number of <i>this</i>
262
	 * BibTeX reference if it is a {@link BibtexEntryType#TECHREPORT() "TECHREPORT" (report)}
263
	 * or of the journal in which <i>this</i> BibTeX reference was published if
264
	 * it is an {@link BibtexEntryType#ARTICLE() "ARTICLE"}. Most publications have a "volume", but no "number".<BR>
265
	 * In this case the returned string is included in the {@link StrictReferenceBase#getTitle() "title"}
266
	 * attribute of StrictReferenceBase.
267
	 * 
268
	 * @return  the string identifying the number for <i>this</i> BibTeX
269
	 * 			reference (article or technical report)
270
	 */
271
	public String getNumber(){
272
		return this.number;
273
	}
274

    
275
	/**
276
	 * @see #getNumber()
277
	 */
278
	public void setNumber(String number){
279
		this.number = number;
280
	}
281

    
282
	/**
283
	 * Returns the string representing the pages range (separated either by
284
	 * commas or double-hyphens) of <i>this</i> BibTeX reference.
285
	 * 
286
	 * @return  the string with the pages corresponding to <i>this</i> BibTeX
287
	 * 			reference
288
	 */
289
	public String getPages(){
290
		return this.pages;
291
	}
292

    
293
	/**
294
	 * @see #getPages()
295
	 */
296
	public void setPages(String pages){
297
		this.pages = pages;
298
	}
299

    
300
	/**
301
	 * Returns the string representing a (not typical) annotation for annotated
302
	 * bibliography styles to be applied to <i>this</i> BibTeX reference.
303
	 * 
304
	 * @return  the string with the annotation for annotated bibliography styles
305
	 */
306
	public String getAnnote(){
307
		return this.annote;
308
	}
309

    
310
	/**
311
	 * @see #getAnnote()
312
	 */
313
	public void setAnnote(String annote){
314
		this.annote = annote;
315
	}
316

    
317
	/**
318
	 * Returns the string representing the name(s) of the editor(s) of <i>this</i>
319
	 * BibTeX reference.<BR>
320
	 * The returned "editor" attribute corresponds to the {@link PrintedUnitBase#getEditor() "editor"} attribute
321
	 * of PrintedUnitBase.
322
	 * 
323
	 * @return  the string identifying the editor of <i>this</i>
324
	 * 			BibTeX reference
325
	 */
326
	public String getEditor(){
327
		return this.editor;
328
	}
329

    
330
	/**
331
	 * @see #getEditor()
332
	 */
333
	public void setEditor(String editor){
334
		this.editor = editor;
335
	}
336

    
337
	/**
338
	 * Returns the string representing the name of the institution that was
339
	 * involved in the publishing of <i>this</i> BibTeX reference or the name of
340
	 * its publisher, if it is a {@link BibtexEntryType#TECHREPORT() "TECHREPORT" (report)}.<BR>
341
	 * The returned "institution" attribute corresponds to the {@link Report#getInstitution() "institution"}
342
	 * attribute of Report or to its inherited {@link PublicationBase#getPublisher() "publisher"} attribute.
343
	 * 
344
	 * @return  the string identifying the institution assigned to <i>this</i>
345
	 * 			BibTeX reference
346
	 */
347
	public String getInstitution(){
348
		return this.institution;
349
	}
350

    
351
	/**
352
	 * @see #getInstitution()
353
	 */
354
	public void setInstitution(String institution){
355
		this.institution = institution;
356
	}
357

    
358
	/**
359
	 * Returns the string representing the name of the school where <i>this</i> BibTeX
360
	 * reference (a {@link BibtexEntryType#MASTERTHESIS() "MASTERTHESIS"} or a
361
	 * {@link BibtexEntryType#PHDTHESIS() "PHDTHESIS"}) was written.<BR>
362
	 * The returned "school" attribute corresponds to the {@link Thesis#getSchool() "school"}
363
	 * attribute of Thesis.
364
	 * 
365
	 * @return  the string identifying the school where <i>this</i> BibTeX 
366
	 * 			reference was written
367
	 */
368
	public String getSchool(){
369
		return this.school;
370
	}
371

    
372
	/**
373
	 * @see #getSchool()
374
	 */
375
	public void setSchool(String school){
376
		this.school = school;
377
	}
378

    
379
	/**
380
	 * Returns the string representing the name of the organization responsible for the
381
	 * conference in the context of which <i>this</i> BibTeX reference ({@link BibtexEntryType#PROCEEDINGS() "PROCEEDINGS"},
382
	 * {@link BibtexEntryType#INPROCEEDINGS() "INPROCEEDINGS"} or a {@link BibtexEntryType#CONFERENCE() "CONFERENCE"})
383
	 * has been printed.<BR>
384
	 * The returned "organization" attribute corresponds to the {@link Proceedings#getOrganization() "organization"}
385
	 * attribute of Proceedings.
386
	 * 
387
	 * @return  the string with the responsible organization of the conference
388
	 */
389
	public String getOrganization(){
390
		return this.organization;
391
	}
392

    
393
	/**
394
	 * @see #getOrganization()
395
	 */
396
	public void setOrganization(String organization){
397
		this.organization = organization;
398
	}
399

    
400
	/**
401
	 * Returns the string representing the name of the publisher of <i>this</i>
402
	 * BibTeX reference.<BR>
403
	 * The returned "publisher" attribute corresponds to the {@link PublicationBase#getPublisher() "publisher"} attribute
404
	 * of PublicationBase.
405
	 * 
406
	 * @return  the string identifying the publisher of <i>this</i>
407
	 * 			BibTeX reference
408
	 */
409
	public String getPublisher(){
410
		return this.publisher;
411
	}
412

    
413
	/**
414
	 * @see #getPublisher()
415
	 */
416
	public void setPublisher(String publisher){
417
		this.publisher = publisher;
418
	}
419

    
420
	/**
421
	 * Returns the string representing the address of the publisher of <i>this</i>
422
	 * BibTeX reference (usually just the city, but can be the full address for
423
	 * lesser-known publishers).<BR>
424
	 * The returned "address" attribute corresponds to the {@link PublicationBase#getPlacePublished() "placePublished"} attribute
425
	 * of PublicationBase.
426
	 * 
427
	 * @return  the string with the publisher's address
428
	 */
429
	public String getAddress(){
430
		return this.address;
431
	}
432

    
433
	/**
434
	 * @see #getAddress()
435
	 */
436
	public void setAddress(String address){
437
		this.address = address;
438
	}
439

    
440
	/**
441
	 * Returns the string describing how <i>this</i> BibTeX reference was
442
	 * published, if the publishing method was nonstandard. This can apply to
443
	 * the entry types {@link BibtexEntryType#BOOKLET() "BOOKLET"} or {@link BibtexEntryType#MISC() "MISC"}.<BR>
444
	 * The returned "howpublished" attribute might correspond to one of the
445
	 * {@link common.AnnotatableEntity#getAnnotations()() annotations}
446
	 * of PublicationBase.
447
	 * 
448
	 * @return  the string describing the publishing method
449
	 */
450
	public String getHowpublished(){
451
		return this.howpublished;
452
	}
453

    
454
	/**
455
	 * @see #getHowpublished()
456
	 */
457
	public void setHowpublished(String howpublished){
458
		this.howpublished = howpublished;
459
	}
460

    
461
	/**
462
	 * Returns the string describing the kind of technical report (for instance
463
	 * "Research Note") <i>this</i> BibTeX reference ({@link BibtexEntryType#TECHREPORT() "TECHREPORT"}) is.<BR>
464
	 * The returned "reportType" attribute might correspond to one of the
465
	 * {@link common.AnnotatableEntity#getAnnotations()() annotations}
466
	 * of Report.
467
	 * 
468
	 * @return  the string describing the kind of technical report
469
	 */
470
	public String getReportType(){
471
		return this.reportType;
472
	}
473

    
474
	/**
475
	 * @see #getReportType()
476
	 */
477
	public void setReportType(String type){
478
		this.reportType = type;
479
	}
480

    
481
	/**
482
	 * Returns the string with the month of publication (or, if unpublished,
483
	 * the month of creation) of <i>this</i> BibTeX reference.<BR>
484
	 * The returned "month" attribute corresponds partially to the {@link StrictReferenceBase#getDatePublished() "datePublished"}
485
	 * attribute of StrictReferenceBase.
486
	 * 
487
	 * @return  the string with the month of publication
488
	 */
489
	public String getMonth(){
490
		return this.month;
491
	}
492

    
493
	/**
494
	 * @see #getMonth()
495
	 */
496
	public void setMonth(String month){
497
		this.month = month;
498
	}
499

    
500
	/**
501
	 * Returns the string with the year of publication (or, if unpublished,
502
	 * the year of creation) of <i>this</i> BibTeX reference.<BR>
503
	 * The returned "year" attribute corresponds partially to the {@link StrictReferenceBase#getDatePublished() "datePublished"}
504
	 * attribute of StrictReferenceBase.
505
	 * 
506
	 * @return  the string with the year of publication
507
	 */
508
	public String getYear(){
509
		return this.year;
510
	}
511

    
512
	/**
513
	 * @see #getYear()
514
	 */
515
	public void setYear(String year){
516
		this.year = year;
517
	}
518

    
519
	//A specification of an electronic publication, often a preprint or a technical report
520
	/**
521
	 * Returns the string specifying <i>this</i> BibTeX reference as an electronic
522
	 * publication (often a preprint or a technical report).<BR>
523
	 * The returned "eprint" attribute might correspond to one of the
524
	 * {@link common.AnnotatableEntity#getAnnotations()() annotations}
525
	 * of StrictReferenceBase.
526
	 * 
527
	 * @return  the string specifying <i>this</i> electronic BibTeX reference
528
	 */
529
	public String getEprint(){
530
		return this.eprint;
531
	}
532

    
533
	/**
534
	 * @see #getEprint()
535
	 */
536
	public void setEprint(String eprint){
537
		this.eprint = eprint;
538
	}
539

    
540
	/**
541
	 * Returns the string with miscellaneous extra information for <i>this</i> BibTeX
542
	 * reference.<BR>
543
	 * The returned "note" attribute corresponds to one of the {@link common.AnnotatableEntity#getAnnotations()() annotations}
544
	 * of StrictReferenceBase.
545
	 * 
546
	 * @return  the string with extra information for <i>this</i> BibTeX reference
547
	 */
548
	public String getNote(){
549
		return this.note;
550
	}
551

    
552
	/**
553
	 * @see #getNote()
554
	 */
555
	public void setNote(String note){
556
		this.note = note;
557
	}
558

    
559
	/**
560
	 * Returns the {@link BibtexEntryType entry type} of <i>this</i> BibTeX reference.
561
	 * BibTeX references are split by types which correspond to subclasses of
562
	 * {@link StrictReferenceBase StrictReferenceBase}.
563
	 * 
564
	 * @return  the BibTeX entry type of <i>this</i> BibTeX reference
565
	 */
566
	@ManyToOne
567
	public BibtexEntryType getType() {
568
		return type;
569
	}
570

    
571
	/**
572
	 * @see #getType()
573
	 */
574
	public void setType(BibtexEntryType type) {
575
		this.type = type;
576
	}
577
	
578

    
579
	/**
580
	 * Returns a formatted string containing the entire reference citation,
581
	 * including authors and other elements corresponding to <i>this</i> BibTeX
582
	 * reference.
583
	 * 
584
	 * @see  NomenclaturalReferenceHelper#getCitation()
585
	 */
586
	@Transient
587
	public String getCitation(){
588
		return nomRefBase.getCitation();
589
	}
590

    
591
	/**
592
	 * Returns a formatted string containing the entire citation used for
593
	 * nomenclatural purposes based on <i>this</i> BibTeX reference - including
594
	 * (abbreviated) title  but not authors - and on the given details.
595
	 * 
596
	 * @param  microReference	the string with the details (generally pages)
597
	 * 							within <i>this</i> BibTeX reference
598
	 * @return					the formatted string representing the
599
	 * 							nomenclatural citation
600
	 * @see  					NomenclaturalReferenceHelper#getNomenclaturalCitation(String)
601
	 * @see  					INomenclaturalReference#getNomenclaturalCitation(String)
602
	 */
603
	@Transient
604
	public String getNomenclaturalCitation(String microReference) {
605
		return nomRefBase.getNomenclaturalCitation(microReference);
606
	}
607

    
608

    
609
	/**
610
	 * Generates, according to the {@link strategy.cache.reference.BibtexDefaultCacheStrategy default cache strategy}
611
	 * assigned to <i>this</i> BibTeX reference, a string that identifies <i>this</i>
612
	 * BibTeX reference and returns it. This string may be stored in the
613
	 * inherited {@link common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
614
	 * This method overrides the generic and inherited
615
	 * ReferenceBase#generateTitle() method.
616
	 *
617
	 * @return  the string identifying <i>this</i> BibTeX reference
618
	 * @see  	#getCitation()
619
	 * @see  	NomenclaturalReferenceHelper#generateTitle()
620
	 * @see  	common.IdentifiableEntity#getTitleCache()
621
	 * @see  	common.IdentifiableEntity#generateTitle()
622
	 */
623
	public String generateTitle(){
624
		return nomRefBase.generateTitle();
625
	}
626

    
627
}
(3-3/26)