2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.reference
;
13 import javax
.persistence
.Column
;
14 import javax
.persistence
.Entity
;
15 import javax
.persistence
.FetchType
;
16 import javax
.persistence
.ManyToOne
;
17 import javax
.persistence
.Transient
;
18 import javax
.xml
.bind
.annotation
.XmlAccessType
;
19 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
20 import javax
.xml
.bind
.annotation
.XmlElement
;
21 import javax
.xml
.bind
.annotation
.XmlIDREF
;
22 import javax
.xml
.bind
.annotation
.XmlRootElement
;
23 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
24 import javax
.xml
.bind
.annotation
.XmlType
;
26 import org
.apache
.log4j
.Logger
;
27 import org
.hibernate
.envers
.Audited
;
28 import org
.hibernate
.search
.annotations
.Field
;
29 import org
.hibernate
.search
.annotations
.Index
;
30 import org
.hibernate
.search
.annotations
.Indexed
;
31 import org
.springframework
.beans
.factory
.annotation
.Configurable
;
33 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
34 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.BibtexDefaultCacheStrategy
;
35 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.INomenclaturalReferenceCacheStrategy
;
38 * This class represents references which are structured according to the BibTeX
39 * format. The flat BibTeX format is an usual alternative to handle references
40 * (see <a href="http://en.wikipedia.org/wiki/BibTeX">BibTeX</a>)
41 * Therefore this class might be
42 * used instead of {@link StrictReferenceBase StrictReferenceBase} depending on the data
43 * to be imported in the CDM.
45 * @see BibtexEntryType
48 * @created 08-Nov-2007 13:06:12
50 @XmlAccessorType(XmlAccessType
.FIELD
)
51 @XmlType(name
= "BibtexReference", propOrder
= {
78 @XmlRootElement(name
= "BibtexReference")
80 @Indexed(index
= "eu.etaxonomy.cdm.model.reference.ReferenceBase")
83 public class BibtexReference
extends ReferenceBase
<INomenclaturalReferenceCacheStrategy
<BibtexReference
>> implements INomenclaturalReference
, Cloneable
{
87 private static final long serialVersionUID
= 2313713431383650655L;
89 private static final Logger logger
= Logger
.getLogger(BibtexReference
.class);
91 @XmlElement(name
= "BibtexEntryType")
92 @ManyToOne(fetch
= FetchType
.LAZY
)
93 private BibtexEntryType type
;
95 @XmlElement(name
= "Journal")
96 @Field(index
=Index
.TOKENIZED
)
97 private String journal
;
99 @XmlElement(name
= "Booktitle")
100 @Field(index
=Index
.TOKENIZED
)
101 private String booktitle
;
103 @XmlElement(name
= "Chapter")
104 @Field(index
=Index
.TOKENIZED
)
105 private String chapter
;
107 @XmlElement(name
= "Title")
108 @Field(index
=Index
.TOKENIZED
)
109 @Column(name
="bibtextitle")
110 private String title
;
112 @XmlElement(name
= "Series")
113 @Field(index
=Index
.TOKENIZED
)
114 private String series
;
116 @XmlElement(name
= "Edition")
117 @Field(index
=Index
.TOKENIZED
)
118 private String edition
;
120 @XmlElement(name
= "Volume")
121 @Field(index
=Index
.TOKENIZED
)
122 private String volume
;
124 @XmlElement(name
= "Number")
125 @Field(index
=Index
.TOKENIZED
)
126 private String number
;
128 @XmlElement(name
= "Pages")
129 @Field(index
=Index
.TOKENIZED
)
130 private String pages
;
132 @XmlElement(name
= "Annote")
133 @Field(index
=Index
.TOKENIZED
)
134 private String annote
;
136 @XmlElement(name
= "Editor")
137 @Field(index
=Index
.TOKENIZED
)
138 private String editor
;
140 @XmlElement(name
= "Institution")
141 @Field(index
=Index
.TOKENIZED
)
142 private String institution
;
144 @XmlElement(name
= "School")
145 @Field(index
=Index
.TOKENIZED
)
146 private String school
;
148 @XmlElement(name
= "Organization")
149 @Field(index
=Index
.TOKENIZED
)
150 private String organization
;
152 @XmlElement(name
= "Publisher")
153 @Field(index
=Index
.TOKENIZED
)
154 private String publisher
;
156 @XmlElement(name
= "Address")
157 @Field(index
=Index
.TOKENIZED
)
158 private String address
;
160 @XmlElement(name
= "HowPublished")
161 @Field(index
=Index
.TOKENIZED
)
162 private String howpublished
;
164 @XmlElement(name
= "ReportType")
165 @Field(index
=Index
.TOKENIZED
)
166 private String reportType
;
168 @XmlElement(name
= "Month")
169 @Field(index
=Index
.TOKENIZED
)
170 private String month
;
172 @XmlElement(name
= "Year")
173 @Field(index
=Index
.TOKENIZED
)
176 @XmlElement(name
= "Eprint")
177 @Field(index
=Index
.TOKENIZED
)
178 private String eprint
;
180 @XmlElement(name
= "Note")
181 @Field(index
=Index
.TOKENIZED
)
184 @XmlElement(name
= "Crossref")
186 @XmlSchemaType(name
= "IDREF")
187 @ManyToOne(fetch
= FetchType
.LAZY
)
188 private BibtexReference crossref
;
190 // @XmlElementRef(name = "NomenclaturalReferenceBase")
192 // private NomenclaturalReferenceHelper nomRefBase = NomenclaturalReferenceHelper.NewInstance(this);
196 * Class constructor: creates a new empty BibTeX reference instance only
197 * containing the {@link eu.etaxonomy.cdm.strategy.cache.reference.BibtexDefaultCacheStrategy default cache strategy}.
199 * @see eu.etaxonomy.cdm.strategy.cache.reference.BibtexDefaultCacheStrategy
201 protected BibtexReference(){
203 this.cacheStrategy
= BibtexDefaultCacheStrategy
.NewInstance();
207 * Creates a new empty BibTeX reference instance only containing the
208 * {@link eu.etaxonomy.cdm.strategy.cache.reference.BibtexDefaultCacheStrategy default cache strategy}.
210 * @see eu.etaxonomy.cdm.strategy.cache.reference.BibtexDefaultCacheStrategy
212 public static BibtexReference
NewInstance(){
213 BibtexReference result
= new BibtexReference();
218 * Returns the BibTeX reference <i>this</i> BibTeX reference belongs to (for
219 * instance a BibTeX reference with the {@link BibtexEntryType entry type} "INBOOK" belongs
220 * to another BibTeX reference with the entry type "BOOK").<BR>
221 * The returned "crossref" attribute corresponds to the {@link BookSection#getInBook() "inBook"}
222 * and {@link InProceedings#getInProceedings() "inProceedings"} attributes of {@link BookSection BookSection} and of
223 * {@link InProceedings InProceedings}.
225 * @return the BibTeX reference containing <i>this</i> BibTeX reference
226 * @see BibtexEntryType
228 public BibtexReference
getCrossref(){
229 return this.crossref
;
232 * @see #getCrossref()
234 public void setCrossref(BibtexReference crossref
){
235 this.crossref
= crossref
;
239 * Returns the string representing the journal or magazine title <i>this</i>
240 * BibTeX reference with the {@link BibtexEntryType entry type} "ARTICLE" was
242 * The returned "journal" attribute corresponds to the {@link Article#getInJournal() "inJournal"}
243 * attribute of {@link Article Article}.
245 * @return the string identifying the journal where <i>this</i> BibTeX
246 * reference (article) was published
248 public String
getJournal(){
255 public void setJournal(String journal
){
256 this.journal
= journal
;
260 * Returns the string representing the book title <i>this</i>
261 * BibTeX reference, with the {@link BibtexEntryType entry type} "INBOOK", "INCOLLECTION"
262 * "INPROCEEDINGS" or "CONFERENCE", was published in.<BR>
263 * The returned "booktitle" attribute corresponds to the {@link BookSection#getInBook() "inBook"}
264 * attribute of {@link BookSection BookSection}.
266 * @return the string identifying the book where <i>this</i> BibTeX
267 * reference (part of a book) was published
269 public String
getBooktitle(){
270 return this.booktitle
;
274 * @see #getBooktitle()
276 public void setBooktitle(String booktitle
){
277 this.booktitle
= booktitle
;
281 * Returns the string representing the chapter number of <i>this</i>
282 * BibTeX reference with the {@link BibtexEntryType entry type} "INBOOK" or "INCOLLECTION"
283 * if this part of a book is a chapter.<BR>
284 * In this case the returned string is included in the inherited {@link BookSection#getTitle() "title"}
285 * attribute of {@link BookSection BookSection}.
287 * @return the string with the chapter number corresponding to <i>this</i>
290 public String
getChapter(){
297 public void setChapter(String chapter
){
298 this.chapter
= chapter
;
302 * Returns the string representing the title of <i>this</i> BibTeX reference.<BR>
303 * The returned "title" attribute corresponds to the {@link StrictReferenceBase#getTitle() "title"}
304 * attribute of {@link StrictReferenceBase StrictReferenceBase}.
306 * @return the string with the title of <i>this</i> BibTeX reference
308 public String
getTitle(){
315 public void setTitle(String title
){
320 * Returns the string representing the series of books <i>this</i>
321 * BibTeX reference with the {@link BibtexEntryType entry type} "BOOK" or "INBOOK"
322 * was published in.<BR>
323 * The returned "series" attribute corresponds to the inherited {@link PrintedUnitBase#getInSeries() "inSeries"}
324 * attribute of {@link Book Book}.
326 * @return the string identifying the book series <i>this</i> BibTeX
327 * reference (book) was published in
329 public String
getSeries(){
336 public void setSeries(String series
){
337 this.series
= series
;
341 * Returns the string representing the edition of <i>this</i>
342 * BibTeX reference with the {@link BibtexEntryType entry type} "BOOK", "INBOOK"
344 * The returned "edition" attribute corresponds to the {@link Book#getEdition() "edition"}
345 * attribute of {@link Book Book}.
347 * @return the string identifying the edition of <i>this</i> BibTeX
350 public String
getEdition(){
357 public void setEdition(String edition
){
358 this.edition
= edition
;
362 * Returns the string representing either the volume of <i>this</i>
363 * BibTeX reference if it is a {@link BibtexEntryType#BOOK() "BOOK"} or of the journal
364 * in which <i>this</i> BibTeX reference was published if it is an {@link BibtexEntryType#ARTICLE() "ARTICLE"}.<BR>
365 * The returned "volume" attribute corresponds to the "volume" attributes
366 * of {@link PrintedUnitBase#getVolume() PrintedUnitBase} and {@link Article#getVolume() Article}.
368 * @return the string identifying the volume of <i>this</i> BibTeX
369 * reference (article or book)
371 public String
getVolume(){
378 public void setVolume(String volume
){
379 this.volume
= volume
;
383 * Returns the string representing, if applicable, either the number of <i>this</i>
384 * BibTeX reference if it is a {@link BibtexEntryType#TECHREPORT() "TECHREPORT" (report)}
385 * or of the journal in which <i>this</i> BibTeX reference was published if
386 * it is an {@link BibtexEntryType#ARTICLE() "ARTICLE"}. Most publications have a "volume", but no "number".<BR>
387 * In this case the returned string is included in the {@link StrictReferenceBase#getTitle() "title"}
388 * attribute of {@link StrictReferenceBase StrictReferenceBase}.
390 * @return the string identifying the number for <i>this</i> BibTeX
391 * reference (article or technical report)
393 public String
getNumber(){
400 public void setNumber(String number
){
401 this.number
= number
;
405 * Returns the string representing the pages range (separated either by
406 * commas or double-hyphens) of <i>this</i> BibTeX reference.
408 * @return the string with the pages corresponding to <i>this</i> BibTeX
411 public String
getPages(){
418 public void setPages(String pages
){
423 * Returns the string representing a (not typical) annotation for annotated
424 * bibliography styles to be applied to <i>this</i> BibTeX reference.
426 * @return the string with the annotation for annotated bibliography styles
428 public String
getAnnote(){
435 public void setAnnote(String annote
){
436 this.annote
= annote
;
440 * Returns the string representing the name(s) of the editor(s) of <i>this</i>
441 * BibTeX reference.<BR>
442 * The returned "editor" attribute corresponds to the {@link PrintedUnitBase#getEditor() "editor"} attribute
443 * of {@link PrintedUnitBase PrintedUnitBase}.
445 * @return the string identifying the editor of <i>this</i>
448 public String
getEditor(){
455 public void setEditor(String editor
){
456 this.editor
= editor
;
460 * Returns the string representing the name of the institution that was
461 * involved in the publishing of <i>this</i> BibTeX reference or the name of
462 * its publisher, if it is a {@link BibtexEntryType#TECHREPORT() "TECHREPORT" (report)}.<BR>
463 * The returned "institution" attribute corresponds to the {@link Report#getInstitution() "institution"}
464 * attribute of {@link Report Report} or to its inherited {@link PublicationBase#getPublisher() "publisher"} attribute.
466 * @return the string identifying the institution assigned to <i>this</i>
469 public String
getInstitution(){
470 return this.institution
;
474 * @see #getInstitution()
476 public void setInstitution(String institution
){
477 this.institution
= institution
;
481 * Returns the string representing the name of the school where <i>this</i> BibTeX
482 * reference (a {@link BibtexEntryType#MASTERTHESIS() "MASTERTHESIS"} or a
483 * {@link BibtexEntryType#PHDTHESIS() "PHDTHESIS"}) was written.<BR>
484 * The returned "school" attribute corresponds to the {@link Thesis#getSchool() "school"}
485 * attribute of {@link Thesis Thesis}.
487 * @return the string identifying the school where <i>this</i> BibTeX
488 * reference was written
490 public String
getSchool(){
497 public void setSchool(String school
){
498 this.school
= school
;
502 * Returns the string representing the name of the organization responsible for the
503 * conference in the context of which <i>this</i> BibTeX reference ({@link BibtexEntryType#PROCEEDINGS() "PROCEEDINGS"},
504 * {@link BibtexEntryType#INPROCEEDINGS() "INPROCEEDINGS"} or a {@link BibtexEntryType#CONFERENCE() "CONFERENCE"})
505 * has been printed.<BR>
506 * The returned "organization" attribute corresponds to the {@link Proceedings#getOrganization() "organization"}
507 * attribute of {@link Proceedings Proceedings}.
509 * @return the string with the responsible organization of the conference
511 public String
getOrganization(){
512 return this.organization
;
516 * @see #getOrganization()
518 public void setOrganization(String organization
){
519 this.organization
= organization
;
523 * Returns the string representing the name of the publisher of <i>this</i>
524 * BibTeX reference.<BR>
525 * The returned "publisher" attribute corresponds to the {@link PublicationBase#getPublisher() "publisher"} attribute
526 * of {@link PublicationBase PublicationBase}.
528 * @return the string identifying the publisher of <i>this</i>
531 public String
getPublisher(){
532 return this.publisher
;
536 * @see #getPublisher()
538 public void setPublisher(String publisher
){
539 this.publisher
= publisher
;
543 * Returns the string representing the address of the publisher of <i>this</i>
544 * BibTeX reference (usually just the city, but can be the full address for
545 * lesser-known publishers).<BR>
546 * The returned "address" attribute corresponds to the {@link PublicationBase#getPlacePublished() "placePublished"} attribute
547 * of {@link PublicationBase PublicationBase}.
549 * @return the string with the publisher's address
551 public String
getAddress(){
558 public void setAddress(String address
){
559 this.address
= address
;
563 * Returns the string describing how <i>this</i> BibTeX reference was
564 * published, if the publishing method was nonstandard. This can apply to
565 * the entry types {@link BibtexEntryType#BOOKLET() "BOOKLET"} or {@link BibtexEntryType#MISC() "MISC"}.<BR>
566 * The returned "howpublished" attribute might correspond to one of the
567 * {@link eu.etaxonomy.cdm.model.common.AnnotatableEntity#getAnnotations() annotations}
568 * of {@link PublicationBase PublicationBase}.
570 * @return the string describing the publishing method
572 public String
getHowpublished(){
573 return this.howpublished
;
577 * @see #getHowpublished()
579 public void setHowpublished(String howpublished
){
580 this.howpublished
= howpublished
;
584 * Returns the string describing the kind of technical report (for instance
585 * "Research Note") <i>this</i> BibTeX reference ({@link BibtexEntryType#TECHREPORT() "TECHREPORT"}) is.<BR>
586 * The returned "reportType" attribute might correspond to one of the
587 * {@link common.AnnotatableEntity#getAnnotations()() annotations}
588 * of {@link Report Report}.
590 * @return the string describing the kind of technical report
592 public String
getReportType(){
593 return this.reportType
;
597 * @see #getReportType()
599 public void setReportType(String type
){
600 this.reportType
= type
;
604 * Returns the string with the month of publication (or, if unpublished,
605 * the month of creation) of <i>this</i> BibTeX reference.<BR>
606 * The returned "month" attribute corresponds partially to the {@link StrictReferenceBase#getDatePublished() "datePublished"}
607 * attribute of {@link StrictReferenceBase StrictReferenceBase}.
609 * @return the string with the month of publication
611 public String
getMonth(){
618 public void setMonth(String month
){
623 * Returns the string with the year of publication (or, if unpublished,
624 * the year of creation) of <i>this</i> BibTeX reference.<BR>
625 * The returned "year" attribute corresponds partially to the {@link StrictReferenceBase#getDatePublished() "datePublished"}
626 * attribute of {@link StrictReferenceBase StrictReferenceBase}.
628 * @return the string with the year of publication
631 public String
getYear(){
638 public void setYear(String year
){
642 //A specification of an electronic publication, often a preprint or a technical report
644 * Returns the string specifying <i>this</i> BibTeX reference as an electronic
645 * publication (often a preprint or a technical report).<BR>
646 * The returned "eprint" attribute might correspond to one of the
647 * {@link eu.etaxonomy.cdm.model.common.AnnotatableEntity#getAnnotations() annotations}
648 * of {@link StrictReferenceBase StrictReferenceBase}.
650 * @return the string specifying <i>this</i> electronic BibTeX reference
652 public String
getEprint(){
659 public void setEprint(String eprint
){
660 this.eprint
= eprint
;
664 * Returns the string with miscellaneous extra information for <i>this</i> BibTeX
666 * The returned "note" attribute corresponds to one of the {@link eu.etaxonomy.cdm.model.common.AnnotatableEntity#getAnnotations() annotations}
667 * of {@link StrictReferenceBase StrictReferenceBase}.
669 * @return the string with extra information for <i>this</i> BibTeX reference
671 public String
getNote(){
678 public void setNote(String note
){
683 * Returns the {@link BibtexEntryType entry type} of <i>this</i> BibTeX reference.
684 * BibTeX references are split by types which correspond to subclasses of
685 * {@link StrictReferenceBase StrictReferenceBase}.
687 * @return the BibTeX entry type of <i>this</i> BibTeX reference
689 public BibtexEntryType
getType() {
696 public void setType(BibtexEntryType type
) {
701 * @see eu.etaxonomy.cdm.model.reference.INomenclaturalReference#setDatePublished(eu.etaxonomy.cdm.model.common.TimePeriod)
703 public void setDatePublished(TimePeriod datePublished
) {
705 logger
.warn("Not yet implemented");
709 * Returns a formatted string containing the entire reference citation,
710 * including authors and other elements corresponding to <i>this</i> BibTeX
713 * @see #getNomenclaturalCitation(String)
714 * @see ReferenceBase#getCitation()
718 // public String getCitation(){
719 // return nomRefBase.getCitation();
723 * Returns a formatted string containing the entire citation used for
724 * nomenclatural purposes based on <i>this</i> BibTeX reference - including
725 * (abbreviated) title but not authors - and on the given details.
727 * @param microReference the string with the details (generally pages)
728 * within <i>this</i> BibTeX reference
729 * @return the formatted string representing the
730 * nomenclatural citation
732 * @see INomenclaturalReference#getNomenclaturalCitation(String)
735 public String
getNomenclaturalCitation(String microReference
) {
736 if (cacheStrategy
== null){
737 logger
.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid());
740 return cacheStrategy
.getNomenclaturalCitation(this,microReference
);
746 * Generates, according to the {@link strategy.cache.reference.BibtexDefaultCacheStrategy default cache strategy}
747 * assigned to <i>this</i> BibTeX reference, a string that identifies <i>this</i>
748 * BibTeX reference and returns it. This string may be stored in the
749 * inherited {@link common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
750 * This method overrides the generic and inherited generateTitle method
751 * from {@link ReferenceBase ReferenceBase}.
753 * @return the string identifying <i>this</i> BibTeX reference
754 * @see #getCitation()
755 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
756 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
759 // public String generateTitle(){
760 // return nomRefBase.generateTitle();
764 //****************** clone ********************** //
768 * Clones <i>this</i> bibtex reference. This is a shortcut that enables to
769 * create a new instance that differs only slightly from <i>this</i> bibtext
770 * by modifying only some of the attributes.<BR>
771 * This method overrides the clone method from {@link ReferenceBase ReferenceBase}.
773 * @see ReferenceBase#clone()
774 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
775 * @see java.lang.Object#clone()
778 public BibtexReference
clone(){
780 BibtexReference result
= (BibtexReference
)super.clone();
781 result
.cacheStrategy
= BibtexDefaultCacheStrategy
.NewInstance();
782 result
.setCrossref(this.getCrossref());
783 //no changes to: crossref, type
785 } catch (CloneNotSupportedException e
) {
786 logger
.warn("Object does not implement cloneable");