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
;
12 import java
.beans
.PropertyChangeEvent
;
13 import java
.beans
.PropertyChangeListener
;
15 import java
.util
.List
;
17 import javax
.persistence
.Basic
;
18 import javax
.persistence
.Column
;
19 import javax
.persistence
.Embedded
;
20 import javax
.persistence
.Entity
;
21 import javax
.persistence
.FetchType
;
22 import javax
.persistence
.Inheritance
;
23 import javax
.persistence
.InheritanceType
;
24 import javax
.persistence
.Lob
;
25 import javax
.persistence
.ManyToOne
;
26 import javax
.persistence
.Transient
;
27 import javax
.validation
.constraints
.NotNull
;
28 import javax
.validation
.constraints
.Pattern
;
29 import javax
.xml
.bind
.annotation
.XmlAccessType
;
30 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
31 import javax
.xml
.bind
.annotation
.XmlAttribute
;
32 import javax
.xml
.bind
.annotation
.XmlElement
;
33 import javax
.xml
.bind
.annotation
.XmlIDREF
;
34 import javax
.xml
.bind
.annotation
.XmlRootElement
;
35 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
36 import javax
.xml
.bind
.annotation
.XmlTransient
;
37 import javax
.xml
.bind
.annotation
.XmlType
;
38 import javax
.xml
.bind
.annotation
.adapters
.XmlJavaTypeAdapter
;
40 import org
.apache
.commons
.lang
.StringUtils
;
41 import org
.apache
.log4j
.Logger
;
42 import org
.hibernate
.annotations
.Cascade
;
43 import org
.hibernate
.annotations
.CascadeType
;
44 import org
.hibernate
.annotations
.Table
;
45 import org
.hibernate
.annotations
.Type
;
46 import org
.hibernate
.envers
.Audited
;
47 import org
.hibernate
.search
.annotations
.Analyze
;
48 import org
.hibernate
.search
.annotations
.Field
;
49 import org
.hibernate
.search
.annotations
.FieldBridge
;
50 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
51 import org
.joda
.time
.DateTime
;
53 import eu
.etaxonomy
.cdm
.common
.DOI
;
54 import eu
.etaxonomy
.cdm
.hibernate
.search
.DateTimeBridge
;
55 import eu
.etaxonomy
.cdm
.hibernate
.search
.DoiBridge
;
56 import eu
.etaxonomy
.cdm
.jaxb
.DateTimeAdapter
;
57 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
58 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
59 import eu
.etaxonomy
.cdm
.model
.common
.IIntextReferenceTarget
;
60 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
61 import eu
.etaxonomy
.cdm
.model
.common
.VerbatimTimePeriod
;
62 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
63 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
64 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.DefaultReferenceCacheStrategy
;
65 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.INomenclaturalReferenceCacheStrategy
;
66 import eu
.etaxonomy
.cdm
.strategy
.match
.Match
;
67 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
68 import eu
.etaxonomy
.cdm
.strategy
.merge
.Merge
;
69 import eu
.etaxonomy
.cdm
.strategy
.merge
.MergeMode
;
70 import eu
.etaxonomy
.cdm
.strategy
.parser
.ParserProblem
;
71 import eu
.etaxonomy
.cdm
.validation
.Level2
;
72 import eu
.etaxonomy
.cdm
.validation
.Level3
;
73 import eu
.etaxonomy
.cdm
.validation
.annotation
.InReference
;
74 import eu
.etaxonomy
.cdm
.validation
.annotation
.NoRecursiveInReference
;
75 import eu
.etaxonomy
.cdm
.validation
.annotation
.NullOrNotEmpty
;
76 import eu
.etaxonomy
.cdm
.validation
.annotation
.ReferenceCheck
;
79 * The class for references (information sources). Originally
80 * an abstract class with many subclasses. Not it is only
81 * one class implementing many interfaces for safe use.
83 * This class corresponds to: <ul>
84 * <li> PublicationCitation according to the TDWG ontology
85 * <li> Publication according to the TCS
86 * <li> Reference according to the ABCD schema
90 * @since 08-Nov-2007 13:06:47
92 @XmlAccessorType(XmlAccessType
.FIELD
)
93 @XmlType(name
= "Reference", propOrder
= {
97 "protectedAbbrevTitleCache",
98 "nomenclaturallyRelevant",
124 @XmlRootElement(name
= "Reference")
126 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
128 @Table(appliesTo
="Reference", indexes
= { @org.hibernate
.annotations
.Index(name
= "ReferenceTitleCacheIndex", columnNames
= { "titleCache" }) })
129 //@InReference(groups=Level3.class)
130 @ReferenceCheck(groups
=Level2
.class)
131 @InReference(groups
=Level3
.class)
132 @NoRecursiveInReference(groups
=Level3
.class) //may become Level1 in future #
133 public class Reference
134 extends IdentifiableMediaEntity
<INomenclaturalReferenceCacheStrategy
>
135 implements IArticle
, IBook
, IPatent
, IDatabase
, IJournal
, IBookSection
,ICdDvd
,
136 IGeneric
,IInProceedings
, IProceedings
, IPrintSeries
, IReport
,
137 IThesis
,IWebPage
, IPersonalCommunication
,
138 INomenclaturalReference
, IReference
, IIntextReferenceTarget
,
141 private static final long serialVersionUID
= -2034764545042691295L;
142 private static final Logger logger
= Logger
.getLogger(Reference
.class);
144 @XmlAttribute(name
="type")
145 @Column(name
="refType")
147 @Type(type
= "eu.etaxonomy.cdm.hibernate.EnumUserType",
148 parameters
= {@org.hibernate
.annotations
.Parameter(name
= "enumClass", value
= "eu.etaxonomy.cdm.model.reference.ReferenceType")}
151 protected ReferenceType type
;
153 //Title of the reference
154 @XmlElement(name
="Title" )
155 @Column(length
=4096, name
="title")
158 @Match(MatchMode
.EQUAL_REQUIRED
) //TODO correct? was EQUAL_REQUIRED before, but with abbrevTitle this is not realistic anymore
161 private String title
;
163 //Title of the reference
164 @XmlElement(name
="AbbrevTitle" )
166 @Match(MatchMode
.EQUAL
) //TODO check if this is correct
169 private String abbrevTitle
;
171 //Title of the reference
172 @XmlElement(name
="AbbrevTitleCache" )
174 @Match(MatchMode
.CACHE
)
178 private String abbrevTitleCache
;
180 @XmlElement(name
= "protectedAbbrevTitleCache")
182 private boolean protectedAbbrevTitleCache
;
184 //********************************************************/
187 @XmlElement(name
= "Editor")
192 protected String editor
;
194 @XmlElement(name
= "Volume")
199 protected String volume
;
201 @XmlElement(name
= "Pages")
206 protected String pages
;
208 @XmlElement(name
= "Edition")
213 protected String edition
;
215 @XmlElement(name
= "ISBN")
220 @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}")
221 protected String isbn
;
223 @XmlElement(name
= "Doi")
225 @FieldBridge(impl
= DoiBridge
.class)
226 @Type(type
="doiUserType")
227 @Column(length
=DOI
.MAX_LENGTH
)
231 @XmlElement(name
= "ISSN")
236 @Pattern(regexp
= "(?=.{9}$)\\d{4}([- ])\\d{4} (\\d|X)$", groups
= Level2
.class, message
= "{eu.etaxonomy.cdm.model.reference.Reference.issn.message}")
237 protected String issn
;
239 @XmlElement(name
= "SeriesPart")
244 protected String seriesPart
;
246 @XmlElement(name
= "Organization")
251 protected String organization
;
253 @XmlElement(name
= "Publisher")
258 protected String publisher
;
261 @XmlElement(name
= "PlacePublished")
266 protected String placePublished
;
268 @XmlElement(name
= "Institution")
270 @XmlSchemaType(name
= "IDREF")
271 @ManyToOne(fetch
= FetchType
.LAZY
)
273 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
274 protected Institution institution
;
276 @XmlElement(name
= "School")
278 @XmlSchemaType(name
= "IDREF")
279 @ManyToOne(fetch
= FetchType
.LAZY
)
281 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
282 protected Institution school
;
284 @XmlElement(name
= "InReference")
286 @XmlSchemaType(name
= "IDREF")
287 @ManyToOne(fetch
= FetchType
.LAZY
)
289 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
290 // @InReference(groups=Level2.class)
291 protected Reference inReference
;
293 //********************************************************/
295 //The date range assigned to the reference. ISO Date range like. Flexible, year can be left out, etc
296 @XmlElement(name
="DatePublished" )
299 private VerbatimTimePeriod datePublished
= VerbatimTimePeriod
.NewVerbatimInstance();
302 @XmlElement (name
= "Accessed", type
= String
.class)
303 @XmlJavaTypeAdapter(DateTimeAdapter
.class)
304 @Type(type
="dateTimeUserType")
305 @Basic(fetch
= FetchType
.LAZY
)
306 @Match(MatchMode
.EQUAL
)
307 @FieldBridge(impl
= DateTimeBridge
.class)
308 private DateTime accessed
;
310 @XmlElement(name
="Abstract" )
311 @Column(length
=65536, name
="referenceAbstract")
316 private String referenceAbstract
; //abstract is a reserved term in Java
319 //URIs like DOIs, LSIDs or Handles for this reference
320 @XmlElement(name
= "URI")
321 @Field(analyze
= Analyze
.NO
)
322 @Type(type
="uriUserType")
325 //flag to subselect only references that could be useful for nomenclatural citations.
326 //If a reference is used as a
327 //nomenclatural reference in a name this flag should be automatically set
328 @XmlElement(name
= "IsNomenclaturallyRelevant")
330 private boolean nomenclaturallyRelevant
;
332 @XmlElement(name
= "Authorship")
334 @XmlSchemaType(name
= "IDREF")
335 @ManyToOne(fetch
= FetchType
.LAZY
)
337 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
338 private TeamOrPersonBase
<?
> authorship
;
341 @Match(MatchMode
.IGNORE
)
342 private int parsingProblem
= 0;
345 @Match(MatchMode
.IGNORE
)
346 private int problemStarts
= -1;
349 @Match(MatchMode
.IGNORE
)
350 private int problemEnds
= -1;
354 @Match(MatchMode
.IGNORE
)
355 private boolean cacheStrategyRectified
= false;
357 //attributes for externally managed
359 // @XmlElement (name = "LastRetrieved", type= String.class)
360 @XmlJavaTypeAdapter(DateTimeAdapter
.class)
361 @Type(type
="dateTimeUserType")
363 @Basic(fetch
= FetchType
.LAZY
)
364 private DateTime lastRetrieved
;
366 @XmlElement(name
="ExternalId" )
368 // @Match(MatchMode.EQUAL) //TODO check if this is correct
371 private String externalId
;
373 //Actionable link on e.g. on a webservice
374 @XmlElement(name
= "ExternalLink")
375 @Field(analyze
= Analyze
.NO
)
376 @Type(type
="uriUserType")
377 private URI externalLink
;
379 @XmlAttribute(name
="authority")
380 @Column(name
="authorityType", length
=10)
381 @Type(type
= "eu.etaxonomy.cdm.hibernate.EnumUserType",
382 parameters
= {@org.hibernate
.annotations
.Parameter(name
= "enumClass", value
= "eu.etaxonomy.cdm.model.reference.AuthorityType")}
385 private AuthorityType authorityType
;
387 // *********************** CONSTRUCTOR ************************/
389 protected Reference(){
390 this(ReferenceType
.Generic
); //just in case someone uses constructor
393 protected Reference(ReferenceType type
) {
396 this.type
= ReferenceType
.Generic
;
400 this.setCacheStrategy(DefaultReferenceCacheStrategy
.NewInstance());
403 // *********************** LISTENER ************************/
407 public void initListener(){
408 PropertyChangeListener listener
= new PropertyChangeListener() {
410 public void propertyChange(PropertyChangeEvent ev
) {
411 if (!ev
.getPropertyName().equals("titleCache") && !ev
.getPropertyName().equals("abbrevTitleCache") && !ev
.getPropertyName().equals("cacheStrategy")){
412 if (! isProtectedTitleCache()){
415 if (! isProtectedAbbrevTitleCache()){
416 abbrevTitleCache
= null;
421 addPropertyChangeListener(listener
);
425 //*************************** GETTER / SETTER ******************************************/
429 // @Transient - must not be transient, since this property needs to to be included in all serializations produced by the remote layer
431 public String
getTitleCache(){
432 String result
= super.getTitleCache();
433 if (isBlank(result
)){
434 this.titleCache
= this.getAbbrevTitleCache(true);
440 public String
getAbbrevTitleCache() {
441 return getAbbrevTitleCache(false);
445 * Implements {@link #getAbbrevTitleCache()} but allows to
446 * avoid never ending recursions if both caches are empty
447 * avoidRecursion should only be <code>true</code> if called
448 * by {@link #getTitleCache()}
449 * @param avoidRecursion
452 private String
getAbbrevTitleCache(boolean avoidRecursion
) {
453 if (protectedAbbrevTitleCache
){
454 return this.abbrevTitleCache
;
456 // is reference dirty, i.e. equal NULL?
457 if (abbrevTitleCache
== null){
458 this.abbrevTitleCache
= generateAbbrevTitle();
459 this.abbrevTitleCache
= getTruncatedCache(this.abbrevTitleCache
) ;
461 if (isBlank(abbrevTitleCache
) && !avoidRecursion
){
462 this.abbrevTitleCache
= this.getTitleCache();
464 return abbrevTitleCache
;
470 public void setAbbrevTitleCache(String abbrevTitleCache
) {
471 this.abbrevTitleCache
= abbrevTitleCache
;
475 public void setAbbrevTitleCache(String abbrevTitleCache
, boolean isProtected
) {
476 this.protectedAbbrevTitleCache
= isProtected
;
477 setAbbrevTitleCache(abbrevTitleCache
);
481 public boolean isProtectedAbbrevTitleCache() {
482 return protectedAbbrevTitleCache
;
486 public void setProtectedAbbrevTitleCache(boolean protectedAbbrevTitleCache
) {
487 this.protectedAbbrevTitleCache
= protectedAbbrevTitleCache
;
491 public String
getAbbrevTitle() {
496 public void setAbbrevTitle(String abbrevTitle
) {
497 this.abbrevTitle
= StringUtils
.isBlank(abbrevTitle
) ?
null : abbrevTitle
;
502 public String
getEditor() {
508 public void setEditor(String editor
) {
509 this.editor
= StringUtils
.isBlank(editor
)?
null : editor
;
513 public String
getVolume() {
518 public void setVolume(String volume
) {
519 this.volume
= StringUtils
.isBlank(volume
)?
null : volume
;
523 public String
getPages() {
528 public void setPages(String pages
) {
529 this.pages
= StringUtils
.isBlank(pages
)?
null : pages
;
533 public String
getEdition() {
538 public void setEdition(String edition
) {
539 this.edition
= StringUtils
.isBlank(edition
)?
null : edition
;
543 public String
getIsbn() {
548 public void setIsbn(String isbn
) {
549 this.isbn
= StringUtils
.isBlank(isbn
)?
null : isbn
;
553 public String
getIssn() {
558 public void setIssn(String issn
) {
559 this.issn
= StringUtils
.isBlank(issn
)?
null : issn
;
563 public DOI
getDoi() {
567 public void setDoi(DOI doi
) {
571 * Convenience method to retrieve doi as string
573 @Transient @XmlTransient @java.beans
.Transient
574 public String
getDoiString() {
575 return doi
== null?
null : doi
.toString();
579 public String
getSeriesPart() {
583 public void setSeriesPart(String seriesPart
) {
584 this.seriesPart
= StringUtils
.isBlank(seriesPart
)?
null : seriesPart
;
588 public String
getOrganization() {
593 public void setOrganization(String organization
) {
594 this.organization
= StringUtils
.isBlank(organization
)?
null : organization
;
598 public String
getPublisher() {
603 public void setPublisher(String publisher
) {
604 this.publisher
= StringUtils
.isBlank(publisher
)?
null : publisher
;
608 public void setPublisher(String publisher
, String placePublished
){
609 this.publisher
= publisher
;
610 this.placePublished
= placePublished
;
614 public String
getPlacePublished() {
615 return placePublished
;
619 public void setPlacePublished(String placePublished
) {
620 this.placePublished
= StringUtils
.isBlank(placePublished
)?
null: placePublished
;
624 public Institution
getInstitution() {
629 public void setInstitution(Institution institution
) {
630 this.institution
= institution
;
634 public Institution
getSchool() {
639 public void setSchool(Institution school
) {
640 this.school
= school
;
644 public Reference
getInReference() {
649 public void setInReference(Reference inReference
) {
650 this.inReference
= inReference
;
654 public void setType(ReferenceType type
) {
656 this.type
= ReferenceType
.Generic
;
662 public ReferenceType
getType() {
667 * Whether this reference is of the given type
673 public boolean isOfType(ReferenceType type
){
674 return type
== getType();
678 * Returns a string representing the title of <i>this</i> reference. If a
679 * reference has different titles (for instance abbreviated and not
680 * abbreviated) then for each title a new instance must be created.
682 * @return the title string of <i>this</i> reference
683 * @see #getCitation()
686 public String
getTitle(){
693 public void setTitle(String title
){
694 this.title
= StringUtils
.isBlank(title
)?
null : title
;
698 * Returns the date (mostly only the year) of publication / creation of
699 * <i>this</i> reference.
702 public VerbatimTimePeriod
getDatePublished(){
703 return this.datePublished
;
706 * @see #getDatePublished()
709 public void setDatePublished(VerbatimTimePeriod datePublished
){
710 this.datePublished
= datePublished
;
714 public void setDatePublished(TimePeriod datePublished
){
715 setDatePublished(VerbatimTimePeriod
.toVerbatim(datePublished
));
718 public boolean hasDatePublished(){
719 boolean result
= ! ( (this.datePublished
== null) || StringUtils
.isBlank(datePublished
.toString()));
725 public DateTime
getAccessed() {
730 public void setAccessed(DateTime accessed
) {
731 this.accessed
= accessed
;
735 * Returns the {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author (team)} who created the
736 * content of <i>this</i> reference.
738 * @return the author (team) of <i>this</i> reference
739 * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase
742 public TeamOrPersonBase
getAuthorship(){
743 return this.authorship
;
747 * @see #getAuthorship()
750 public void setAuthorship(TeamOrPersonBase authorship
){
751 this.authorship
= authorship
;
755 * Returns the Uniform Resource Identifier (URI) corresponding to <i>this</i>
756 * reference. An URI is a string of characters used to identify a resource
759 * @return the URI of <i>this</i> reference
769 public void setUri(URI uri
){
774 * @return the referenceAbstract
777 public String
getReferenceAbstract() {
778 return referenceAbstract
;
782 * @param referenceAbstract the referenceAbstract to set
785 public void setReferenceAbstract(String referenceAbstract
) {
786 this.referenceAbstract
= StringUtils
.isBlank(referenceAbstract
)?
null : referenceAbstract
;
791 * Returns "true" if the isNomenclaturallyRelevant flag is set. This
792 * indicates that a {@link TaxonName taxon name} has been originally
793 * published in <i>this</i> reference following the rules of a
794 * {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode nomenclature code} and is therefore used for
795 * nomenclatural citations. This flag will be set as soon as <i>this</i>
796 * reference is used as a nomenclatural reference for any taxon name.<BR>
797 * FIXME what happens if the only taxon name referencing this reference is not
798 * any longer using this reference as a nomenclatural reference. How does the
799 * reference get informed about the fact that it is not nomenclaturally relevant
802 public boolean isNomenclaturallyRelevant(){
803 return this.nomenclaturallyRelevant
;
807 * @see #isNomenclaturallyRelevant()
809 public void setNomenclaturallyRelevant(boolean nomenclaturallyRelevant
){
810 this.nomenclaturallyRelevant
= nomenclaturallyRelevant
;
814 //**************************************************** /
818 public void setTitleCaches(String cache
){
819 this.setAbbrevTitleCache(cache
, true);
820 this.setTitleCache(cache
, true);
825 * Returns a formatted string containing the entire reference citation,
826 * including authors, corresponding to <i>this</i> reference.
828 * @see #generateTitle()
832 public String
getCitation(){
833 if (getCacheStrategy() == null){
834 logger
.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid());
837 return getCacheStrategy().getTitleCache(this);
843 public String
generateTitle() {
844 return super.generateTitle();
847 public String
generateAbbrevTitle() {
848 return getCacheStrategy().getFullAbbrevTitleString(this);
852 * Returns a string representation for the year of publication / creation
853 * of <i>this</i> reference. If the {@link #getDatePublished() datePublished}
854 * of this reference contains more date information then (starting) year
855 * only the year is returned.
860 public String
getYear(){
861 TimePeriod datePublished
= this.getDatePublished();
862 if (datePublished
!= null ){
863 String result
= getDatePublished().getYear();
871 * Convenience method that returns a string representation for the publication date / creation
872 * of <i>this</i> reference. The string is obtained by
873 * {@link #getDatePublished()#toString() the string representation
874 * of the date published}.
877 public String
getDatePublishedString(){
878 TimePeriod datePublished
= this.getDatePublished();
879 if (datePublished
!= null ){
880 return getDatePublished().toString();
887 * Convenience method that returns a string representation for the publication date / creation
888 * of <i>this</i> reference. The string is obtained by
889 * {@link #getDatePublished()#toString() the string representation
890 * of the date published}.
893 public String
getTimePeriodPublishedString(){
894 TimePeriod datePublished
= this.getDatePublished();
895 if (datePublished
!= null ){
896 return getDatePublished().getTimePeriod();
905 public int getParsingProblem(){
906 return this.parsingProblem
;
910 public void setParsingProblem(int parsingProblem
){
911 this.parsingProblem
= parsingProblem
;
915 public boolean hasProblem(){
916 return parsingProblem
!= 0;
920 public boolean hasProblem(ParserProblem problem
) {
921 return getParsingProblems().contains(problem
);
925 public int getProblemStarts(){
926 return this.problemStarts
;
930 public void setProblemStarts(int start
) {
931 this.problemStarts
= start
;
935 public int getProblemEnds(){
936 return this.problemEnds
;
940 public void setProblemEnds(int end
) {
941 this.problemEnds
= end
;
945 public void addParsingProblem(ParserProblem warning
){
946 parsingProblem
= ParserProblem
.addProblem(parsingProblem
, warning
);
950 public void removeParsingProblem(ParserProblem problem
) {
951 parsingProblem
= ParserProblem
.removeProblem(parsingProblem
, problem
);
956 public List
<ParserProblem
> getParsingProblems() {
957 return ParserProblem
.warningList(this.parsingProblem
);
963 public String
getNomenclaturalCitation(String microReference
) {
964 String typeName
= this.getType()== null ?
"(no type defined)" : this.getType().getMessage();
965 if (getCacheStrategy() == null){
966 logger
.warn("No CacheStrategy defined for "+ typeName
+ ": " + this.getUuid());
969 if (getCacheStrategy() instanceof INomenclaturalReferenceCacheStrategy
){
970 return cacheStrategy
.getNomenclaturalCitation(this, microReference
);
972 logger
.warn("No INomenclaturalReferenceCacheStrategy defined for "+ typeName
+ ": " + this.getUuid());
980 * Generates, according to the {@link eu.etaxonomy.cdm.strategy.strategy.cache.reference.IReferenceBaseCacheStrategy cache strategy}
981 * assigned to <i>this</i> reference, a string that identifies <i>this</i>
982 * reference and returns it. This string may be stored in the inherited
983 * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
984 * This method overrides the generic and inherited generateTitle method
985 * from {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity IdentifiableEntity}.
987 * @return the string identifying <i>this</i> reference
988 * @see #getCitation()
989 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
990 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
991 * @see eu.etaxonomy.cdm.strategy.strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache()
994 // public String generateTitle(){
995 // if (cacheStrategy == null){
996 // logger.warn("No CacheStrategy defined for Reference: " + this.getUuid());
999 // return cacheStrategy.getTitleCache(this);
1005 //********** Casting methods ***********************************/
1010 public IArticle
castReferenceToArticle(){
1011 setType(ReferenceType
.Article
);
1015 public IBook
castReferenceToBook(){
1016 setType(ReferenceType
.Book
);
1020 public IBookSection
castReferenceToBookSection(){
1021 setType(ReferenceType
.BookSection
);
1025 public ICdDvd
castReferenceToCdDvd(){
1026 setType(ReferenceType
.CdDvd
);
1030 public IDatabase
castReferenceToDatabase(){
1031 setType(ReferenceType
.Database
);
1035 public IGeneric
castReferenceToGeneric(){
1036 setType(ReferenceType
.Generic
);
1040 public IInProceedings
castReferenceToInProceedings(){
1041 setType(ReferenceType
.InProceedings
);
1045 public IJournal
castReferenceToJournal(){
1046 setType(ReferenceType
.Journal
);
1050 public IMap
castReferenceToMap(){
1051 setType(ReferenceType
.Map
);
1055 public IPatent
castReferenceToPatent(){
1056 setType(ReferenceType
.Patent
);
1060 public IPersonalCommunication
castReferenceToPersonalCommunication(){
1061 setType(ReferenceType
.PersonalCommunication
);
1065 public IPrintSeries
castReferenceToPrintSeries(){
1066 setType(ReferenceType
.PrintSeries
);
1070 public IWebPage
castReferenceToWebPage(){
1071 setType(ReferenceType
.WebPage
);
1075 public IProceedings
castReferenceToProceedings(){
1076 setType(ReferenceType
.Proceedings
);
1080 public IReport
castReferenceToReport(){
1081 setType(ReferenceType
.Report
);
1085 public IThesis
castReferenceToThesis(){
1086 setType(ReferenceType
.Thesis
);
1092 @Transient // prevent from being serialized by webservice
1093 public IJournal
getInJournal() {
1094 IJournal journal
= this.inReference
;
1099 public void setInJournal(IJournal journal
) {
1100 setInReference((Reference
)journal
); //user setter to invoke aspect #1815
1104 @Transient // prevent from being serialized by webservice
1105 public IPrintSeries
getInSeries() {
1106 return this.inReference
;
1110 public void setInSeries(IPrintSeries inSeries
) {
1111 setInReference((Reference
)inSeries
); //user setter to invoke aspect #1815
1115 @Transient // prevent from being serialized by webservice
1116 public IBook
getInBook() {
1117 IBook book
= this.inReference
;
1121 //********************** In-References *****************************************
1124 public void setInBook(IBook book
) {
1125 setInReference((Reference
)book
); //user setter to invoke aspect #1815
1129 @Transient // prevent from being serialized by webservice
1130 public IProceedings
getInProceedings() {
1131 IProceedings proceedings
= this.inReference
;
1136 public void setInProceedings(IProceedings proceeding
) {
1137 setInReference((Reference
)proceeding
); //user setter to invoke aspect #1815
1140 //*************************** CACHE STRATEGIES ******************************/
1143 public INomenclaturalReferenceCacheStrategy
getCacheStrategy() {
1144 return this.cacheStrategy
;
1148 public void setCacheStrategy(INomenclaturalReferenceCacheStrategy referenceCacheStrategy
) {
1149 this.cacheStrategy
= referenceCacheStrategy
;
1154 //*********************** CLONE ********************************************************/
1157 * Clones <i>this</i> reference. This is a shortcut that enables to create
1158 * a new instance that differs only slightly from <i>this</i> reference by
1159 * modifying only some of the attributes.
1161 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
1162 * @see java.lang.Object#clone()
1165 public Object
clone() {
1167 Reference result
= (Reference
)super.clone();
1168 result
.setDatePublished(datePublished
!= null?
(TimePeriod
)datePublished
.clone(): null);
1169 //no changes to: title, authorship, hasProblem, nomenclaturallyRelevant, uri
1171 } catch (CloneNotSupportedException e
) {
1172 logger
.warn("Object does not implement cloneable");
1173 e
.printStackTrace();
1178 //******************************* toString *****************************/
1181 public String
toString() {
1183 String result
= "Reference [type=" + type
+ ", id= " + this.getId() + ", uuid=" + this.uuid
;
1184 result
+= title
== null ?
"" : ", title=" + title
;
1185 result
+= abbrevTitle
== null ?
"" : ", abbrevTitle=" + abbrevTitle
;
1189 return super.toString();