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
.Column
;
18 import javax
.persistence
.Embedded
;
19 import javax
.persistence
.Entity
;
20 import javax
.persistence
.FetchType
;
21 import javax
.persistence
.Inheritance
;
22 import javax
.persistence
.InheritanceType
;
23 import javax
.persistence
.Lob
;
24 import javax
.persistence
.ManyToOne
;
25 import javax
.persistence
.Transient
;
26 import javax
.validation
.constraints
.NotNull
;
27 import javax
.validation
.constraints
.Pattern
;
28 import javax
.xml
.bind
.annotation
.XmlAccessType
;
29 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
30 import javax
.xml
.bind
.annotation
.XmlAttribute
;
31 import javax
.xml
.bind
.annotation
.XmlElement
;
32 import javax
.xml
.bind
.annotation
.XmlIDREF
;
33 import javax
.xml
.bind
.annotation
.XmlRootElement
;
34 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
35 import javax
.xml
.bind
.annotation
.XmlType
;
37 import org
.apache
.commons
.lang
.StringUtils
;
38 import org
.apache
.log4j
.Logger
;
39 import org
.hibernate
.annotations
.Cascade
;
40 import org
.hibernate
.annotations
.CascadeType
;
41 import org
.hibernate
.annotations
.Table
;
42 import org
.hibernate
.annotations
.Type
;
43 import org
.hibernate
.envers
.Audited
;
44 import org
.hibernate
.search
.annotations
.Analyze
;
45 import org
.hibernate
.search
.annotations
.Field
;
46 import org
.hibernate
.search
.annotations
.FieldBridge
;
47 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
49 import eu
.etaxonomy
.cdm
.common
.DOI
;
50 import eu
.etaxonomy
.cdm
.hibernate
.search
.DoiBridge
;
51 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
52 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
53 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
54 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
55 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
56 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.ArticleDefaultCacheStrategy
;
57 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.BookDefaultCacheStrategy
;
58 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.BookSectionDefaultCacheStrategy
;
59 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.GenericDefaultCacheStrategy
;
60 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.INomenclaturalReferenceCacheStrategy
;
61 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.IReferenceBaseCacheStrategy
;
62 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.JournalDefaultCacheStrategy
;
63 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.ReferenceDefaultCacheStrategy
;
64 import eu
.etaxonomy
.cdm
.strategy
.match
.Match
;
65 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
66 import eu
.etaxonomy
.cdm
.strategy
.merge
.Merge
;
67 import eu
.etaxonomy
.cdm
.strategy
.merge
.MergeMode
;
68 import eu
.etaxonomy
.cdm
.strategy
.parser
.ParserProblem
;
69 import eu
.etaxonomy
.cdm
.validation
.Level2
;
70 import eu
.etaxonomy
.cdm
.validation
.Level3
;
71 import eu
.etaxonomy
.cdm
.validation
.annotation
.InReference
;
72 import eu
.etaxonomy
.cdm
.validation
.annotation
.NoRecursiveInReference
;
73 import eu
.etaxonomy
.cdm
.validation
.annotation
.NullOrNotEmpty
;
74 import eu
.etaxonomy
.cdm
.validation
.annotation
.ReferenceCheck
;
77 * The upmost (abstract) class for references (information sources).
79 * This class corresponds to: <ul>
80 * <li> PublicationCitation according to the TDWG ontology
81 * <li> Publication according to the TCS
82 * <li> Reference according to the ABCD schema
86 * @created 08-Nov-2007 13:06:47
88 @XmlAccessorType(XmlAccessType
.FIELD
)
89 @XmlType(name
= "Reference", propOrder
= {
93 "protectedAbbrevTitleCache",
94 "nomenclaturallyRelevant",
115 @XmlRootElement(name
= "Reference")
117 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
119 @Table(appliesTo
="Reference", indexes
= { @org.hibernate
.annotations
.Index(name
= "ReferenceTitleCacheIndex", columnNames
= { "titleCache" }) })
120 //@InReference(groups=Level3.class)
121 @ReferenceCheck(groups
=Level2
.class)
122 @InReference(groups
=Level3
.class)
123 @NoRecursiveInReference(groups
=Level3
.class) //may become Level1 in future #
124 public class Reference
<S
extends IReferenceBaseCacheStrategy
>
125 extends IdentifiableMediaEntity
<IReferenceBaseCacheStrategy
>
126 implements INomenclaturalReference
, IArticle
, IBook
, IPatent
, IDatabase
, IJournal
, IBookSection
,ICdDvd
,IGeneric
,IInProceedings
, IProceedings
, IPrintSeries
, IReport
, IThesis
,IWebPage
, IPersonalCommunication
, IReference
, Cloneable
{
128 private static final long serialVersionUID
= -2034764545042691295L;
129 private static final Logger logger
= Logger
.getLogger(Reference
.class);
131 @XmlAttribute(name
="type")
132 @Column(name
="refType")
134 @Type(type
= "eu.etaxonomy.cdm.hibernate.EnumUserType",
135 parameters
= {@org.hibernate
.annotations
.Parameter(name
= "enumClass", value
= "eu.etaxonomy.cdm.model.reference.ReferenceType")}
138 protected ReferenceType type
;
140 //Title of the reference
141 @XmlElement(name
="Title" )
142 @Column(length
=4096, name
="title")
145 @Match(MatchMode
.EQUAL_REQUIRED
)
148 private String title
;
150 //Title of the reference
151 @XmlElement(name
="AbbrevTitle" )
153 @Match(MatchMode
.EQUAL
) //TODO check if this is correct
156 private String abbrevTitle
;
158 //Title of the reference
159 @XmlElement(name
="AbbrevTitleCache" )
161 @Match(MatchMode
.CACHE
)
165 private String abbrevTitleCache
;
167 @XmlElement(name
= "protectedAbbrevTitleCache")
169 private boolean protectedAbbrevTitleCache
;
171 //********************************************************/
174 @XmlElement(name
= "Editor")
179 protected String editor
;
181 @XmlElement(name
= "Volume")
186 protected String volume
;
188 @XmlElement(name
= "Pages")
193 protected String pages
;
195 @XmlElement(name
= "Edition")
200 protected String edition
;
202 @XmlElement(name
= "ISBN")
207 @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}")
208 protected String isbn
;
210 @XmlElement(name
= "Doi")
212 @FieldBridge(impl
= DoiBridge
.class)
213 @Type(type
="doiUserType")
214 @Column(length
=DOI
.MAX_LENGTH
)
218 @XmlElement(name
= "ISSN")
223 @Pattern(regexp
= "(?=.{9}$)\\d{4}([- ])\\d{4} (\\d|X)$", groups
= Level2
.class, message
= "{eu.etaxonomy.cdm.model.reference.Reference.issn.message}")
224 protected String issn
;
226 @XmlElement(name
= "SeriesPart")
231 protected String seriesPart
;
233 @XmlElement(name
= "Organization")
238 protected String organization
;
240 @XmlElement(name
= "Publisher")
245 protected String publisher
;
248 @XmlElement(name
= "PlacePublished")
253 protected String placePublished
;
255 @XmlElement(name
= "Institution")
257 @XmlSchemaType(name
= "IDREF")
258 @ManyToOne(fetch
= FetchType
.LAZY
)
260 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
261 protected Institution institution
;
263 @XmlElement(name
= "School")
265 @XmlSchemaType(name
= "IDREF")
266 @ManyToOne(fetch
= FetchType
.LAZY
)
268 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
269 protected Institution school
;
271 @XmlElement(name
= "InReference")
273 @XmlSchemaType(name
= "IDREF")
274 @ManyToOne(fetch
= FetchType
.LAZY
)
276 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
277 // @InReference(groups=Level2.class)
278 protected Reference inReference
;
280 //********************************************************/
282 //The date range assigned to the reference. ISO Date range like. Flexible, year can be left out, etc
283 @XmlElement(name
="DatePublished" )
286 private TimePeriod datePublished
= TimePeriod
.NewInstance();
288 @XmlElement(name
="Abstract" )
289 @Column(length
=65536, name
="referenceAbstract")
294 private String referenceAbstract
; //abstract is a reserved term in Java
297 //URIs like DOIs, LSIDs or Handles for this reference
298 @XmlElement(name
= "URI")
299 @Field(analyze
= Analyze
.NO
)
300 @Type(type
="uriUserType")
303 //flag to subselect only references that could be useful for nomenclatural citations. If a reference is used as a
304 //nomenclatural reference in a name this flag should be automatically set
305 @XmlElement(name
= "IsNomenclaturallyRelevant")
307 private boolean nomenclaturallyRelevant
;
309 @XmlElement(name
= "Authorship")
311 @XmlSchemaType(name
= "IDREF")
312 @ManyToOne(fetch
= FetchType
.LAZY
)
314 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
315 private TeamOrPersonBase
<?
> authorship
;
318 @Match(MatchMode
.IGNORE
)
319 private int parsingProblem
= 0;
322 @Match(MatchMode
.IGNORE
)
323 private int problemStarts
= -1;
326 @Match(MatchMode
.IGNORE
)
327 private int problemEnds
= -1;
331 @Match(MatchMode
.IGNORE
)
332 private boolean cacheStrategyRectified
= false;
334 protected Reference(){
335 this(ReferenceType
.Generic
); //just in case someone uses constructor
338 protected Reference(ReferenceType type
) {
340 this.type
= ReferenceType
.Generic
;
347 public void initListener(){
348 PropertyChangeListener listener
= new PropertyChangeListener() {
350 public void propertyChange(PropertyChangeEvent ev
) {
351 if (!ev
.getPropertyName().equals("titleCache") && !ev
.getPropertyName().equals("abbrevTitleCache") && !ev
.getPropertyName().equals("cacheStrategy")){
352 if (! isProtectedTitleCache()){
355 if (! isProtectedAbbrevTitleCache()){
356 abbrevTitleCache
= null;
361 addPropertyChangeListener(listener
);
365 //*************************** GETTER / SETTER ******************************************/
369 public String
getAbbrevTitleCache() {
370 if (protectedAbbrevTitleCache
){
371 return this.abbrevTitleCache
;
373 // is title dirty, i.e. equal NULL?
374 if (abbrevTitleCache
== null){
375 this.abbrevTitleCache
= generateAbbrevTitle();
376 this.abbrevTitleCache
= getTruncatedCache(this.abbrevTitleCache
) ;
378 return abbrevTitleCache
;
383 public void setAbbrevTitleCache(String abbrevTitleCache
) {
384 this.abbrevTitleCache
= abbrevTitleCache
;
388 public void setAbbrevTitleCache(String abbrevTitleCache
, boolean isProtected
) {
389 this.protectedAbbrevTitleCache
= isProtected
;
390 setAbbrevTitleCache(abbrevTitleCache
);
394 public boolean isProtectedAbbrevTitleCache() {
395 return protectedAbbrevTitleCache
;
399 public void setProtectedAbbrevTitleCache(boolean protectedAbbrevTitleCache
) {
400 this.protectedAbbrevTitleCache
= protectedAbbrevTitleCache
;
404 public String
getAbbrevTitle() {
409 public void setAbbrevTitle(String abbrevTitle
) {
410 this.abbrevTitle
= StringUtils
.isBlank(abbrevTitle
) ?
null : abbrevTitle
;
415 public String
getEditor() {
421 public void setEditor(String editor
) {
422 this.editor
= StringUtils
.isBlank(editor
)?
null : editor
;
426 public String
getVolume() {
431 public void setVolume(String volume
) {
432 this.volume
= StringUtils
.isBlank(volume
)?
null : volume
;
436 public String
getPages() {
441 public void setPages(String pages
) {
442 this.pages
= StringUtils
.isBlank(pages
)?
null : pages
;
446 public String
getEdition() {
451 public void setEdition(String edition
) {
452 this.edition
= StringUtils
.isBlank(edition
)?
null : edition
;
456 public String
getIsbn() {
461 public void setIsbn(String isbn
) {
462 this.isbn
= StringUtils
.isBlank(isbn
)?
null : isbn
;
466 public String
getIssn() {
471 public void setIssn(String issn
) {
472 this.issn
= StringUtils
.isBlank(issn
)?
null : issn
;
476 public DOI
getDoi() {
481 public void setDoi(DOI doi
) {
486 public String
getSeriesPart() {
491 public void setSeriesPart(String seriesPart
) {
492 this.seriesPart
= StringUtils
.isBlank(seriesPart
)?
null : seriesPart
;
496 public String
getOrganization() {
501 public void setOrganization(String organization
) {
502 this.organization
= StringUtils
.isBlank(organization
)?
null : organization
;
506 public String
getPublisher() {
511 public void setPublisher(String publisher
) {
512 this.publisher
= StringUtils
.isBlank(publisher
)?
null : publisher
;
516 public void setPublisher(String publisher
, String placePublished
){
517 this.publisher
= publisher
;
518 this.placePublished
= placePublished
;
522 public String
getPlacePublished() {
523 return placePublished
;
527 public void setPlacePublished(String placePublished
) {
528 this.placePublished
= StringUtils
.isBlank(placePublished
)?
null: placePublished
;
532 public Institution
getInstitution() {
537 public void setInstitution(Institution institution
) {
538 this.institution
= institution
;
542 public Institution
getSchool() {
547 public void setSchool(Institution school
) {
548 this.school
= school
;
552 public Reference
getInReference() {
557 public void setInReference(Reference inReference
) {
558 this.inReference
= inReference
;
562 public void setType(ReferenceType type
) {
564 this.type
= ReferenceType
.Generic
;
568 this.setCacheStrategy(type
.getCacheStrategy());
576 public ReferenceType
getType() {
581 * Whether this reference is of the given type
587 public boolean isOfType(ReferenceType type
){
588 return type
== getType();
592 * Returns a string representing the title of <i>this</i> reference. If a
593 * reference has different titles (for instance abbreviated and not
594 * abbreviated) then for each title a new instance must be created.
596 * @return the title string of <i>this</i> reference
597 * @see #getCitation()
600 public String
getTitle(){
607 public void setTitle(String title
){
608 this.title
= StringUtils
.isBlank(title
)?
null : title
;
612 * Returns the date (mostly only the year) of publication / creation of
613 * <i>this</i> reference.
616 public TimePeriod
getDatePublished(){
617 return this.datePublished
;
620 * @see #getDatePublished()
623 public void setDatePublished(TimePeriod datePublished
){
624 this.datePublished
= datePublished
;
627 public boolean hasDatePublished(){
628 boolean result
= ! ( (this.datePublished
== null) || StringUtils
.isBlank(datePublished
.toString()));
633 * Returns the {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author (team)} who created the
634 * content of <i>this</i> reference.
636 * @return the author (team) of <i>this</i> reference
637 * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase
640 public TeamOrPersonBase
getAuthorship(){
641 return this.authorship
;
645 * @see #getAuthorship()
648 public void setAuthorship(TeamOrPersonBase authorship
){
649 this.authorship
= authorship
;
653 * Returns the Uniform Resource Identifier (URI) corresponding to <i>this</i>
654 * reference. An URI is a string of characters used to identify a resource
657 * @return the URI of <i>this</i> reference
667 public void setUri(URI uri
){
672 * @return the referenceAbstract
675 public String
getReferenceAbstract() {
676 return referenceAbstract
;
680 * @param referenceAbstract the referenceAbstract to set
683 public void setReferenceAbstract(String referenceAbstract
) {
684 this.referenceAbstract
= StringUtils
.isBlank(referenceAbstract
)?
null : referenceAbstract
;
689 * Returns "true" if the isNomenclaturallyRelevant flag is set. This
690 * indicates that a {@link TaxonNameBase taxon name} has been originally
691 * published in <i>this</i> reference following the rules of a
692 * {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode nomenclature code} and is therefore used for
693 * nomenclatural citations. This flag will be set as soon as <i>this</i>
694 * reference is used as a nomenclatural reference for any taxon name.<BR>
695 * FIXME what happens if the only taxon name referencing this reference is not
696 * any longer using this reference as a nomenclatural reference. How does the
697 * reference get informed about the fact that it is not nomenclaturally relevant
700 public boolean isNomenclaturallyRelevant(){
701 return this.nomenclaturallyRelevant
;
705 * @see #isNomenclaturallyRelevant()
707 public void setNomenclaturallyRelevant(boolean nomenclaturallyRelevant
){
708 this.nomenclaturallyRelevant
= nomenclaturallyRelevant
;
712 //**************************************************** /
716 * Returns a formatted string containing the entire reference citation,
717 * including authors, corresponding to <i>this</i> reference.
719 * @see #generateTitle()
723 public String
getCitation(){
724 rectifyCacheStrategy();
725 if (getCacheStrategy() == null){
726 logger
.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid());
729 return getCacheStrategy().getTitleCache(this);
735 public String
generateTitle() {
736 rectifyCacheStrategy();
737 return super.generateTitle();
740 public String
generateAbbrevTitle() {
741 rectifyCacheStrategy(); //TODO needed, is called by getCacheStrategy already
742 return getCacheStrategy().getAbbrevTitleCache(this);
746 * Returns a string representation for the year of publication / creation
747 * of <i>this</i> reference. If the {@link #getDatePublished() datePublished}
748 * of this reference contains more date information then (starting) year
749 * only the year is returned.
754 public String
getYear(){
755 TimePeriod datePublished
= this.getDatePublished();
756 if (datePublished
!= null ){
757 String result
= getDatePublished().getYear();
765 * Convenience method that returns a string representation for the publication date / creation
766 * of <i>this</i> reference. The string is obtained by
767 * {@link #getDatePublished()#toString() the string representation
768 * of the date published}.
771 public String
getDatePublishedString(){
772 TimePeriod datePublished
= this.getDatePublished();
773 if (datePublished
!= null ){
774 return getDatePublished().toString();
782 public int getParsingProblem(){
783 return this.parsingProblem
;
787 public void setParsingProblem(int parsingProblem
){
788 this.parsingProblem
= parsingProblem
;
792 public boolean hasProblem(){
793 return parsingProblem
!= 0;
797 public boolean hasProblem(ParserProblem problem
) {
798 return getParsingProblems().contains(problem
);
802 public int getProblemStarts(){
803 return this.problemStarts
;
807 public void setProblemStarts(int start
) {
808 this.problemStarts
= start
;
812 public int getProblemEnds(){
813 return this.problemEnds
;
817 public void setProblemEnds(int end
) {
818 this.problemEnds
= end
;
822 public void addParsingProblem(ParserProblem warning
){
823 parsingProblem
= ParserProblem
.addProblem(parsingProblem
, warning
);
827 public void removeParsingProblem(ParserProblem problem
) {
828 parsingProblem
= ParserProblem
.removeProblem(parsingProblem
, problem
);
833 public List
<ParserProblem
> getParsingProblems() {
834 return ParserProblem
.warningList(this.parsingProblem
);
840 public String
getNomenclaturalCitation(String microReference
) {
841 rectifyCacheStrategy();
842 String typeName
= this.getType()== null ?
"(no type defined)" : this.getType().getMessage();
843 if (getCacheStrategy() == null){
844 logger
.warn("No CacheStrategy defined for "+ typeName
+ ": " + this.getUuid());
847 if (getCacheStrategy() instanceof INomenclaturalReferenceCacheStrategy
){
848 return ((INomenclaturalReferenceCacheStrategy
)cacheStrategy
).getNomenclaturalCitation(this, microReference
);
850 logger
.warn("No INomenclaturalReferenceCacheStrategy defined for "+ typeName
+ ": " + this.getUuid());
858 * Generates, according to the {@link eu.etaxonomy.cdm.strategy.strategy.cache.reference.IReferenceBaseCacheStrategy cache strategy}
859 * assigned to <i>this</i> reference, a string that identifies <i>this</i>
860 * reference and returns it. This string may be stored in the inherited
861 * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
862 * This method overrides the generic and inherited generateTitle method
863 * from {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity IdentifiableEntity}.
865 * @return the string identifying <i>this</i> reference
866 * @see #getCitation()
867 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
868 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
869 * @see eu.etaxonomy.cdm.strategy.strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache()
872 // public String generateTitle(){
873 // if (cacheStrategy == null){
874 // logger.warn("No CacheStrategy defined for Reference: " + this.getUuid());
877 // return cacheStrategy.getTitleCache(this);
883 //********** Casting methods ***********************************/
888 public IArticle
castReferenceToArticle(){
889 setType(ReferenceType
.Article
);
893 public IBook
castReferenceToBook(){
894 setType(ReferenceType
.Book
);
898 public IBookSection
castReferenceToBookSection(){
899 setType(ReferenceType
.BookSection
);
903 public ICdDvd
castReferenceToCdDvd(){
904 setType(ReferenceType
.CdDvd
);
908 public IDatabase
castReferenceToDatabase(){
909 setType(ReferenceType
.Database
);
913 public IGeneric
castReferenceToGeneric(){
914 setType(ReferenceType
.Generic
);
918 public IInProceedings
castReferenceToInProceedings(){
919 setType(ReferenceType
.InProceedings
);
923 public IJournal
castReferenceToJournal(){
924 setType(ReferenceType
.Journal
);
928 public IMap
castReferenceToMap(){
929 setType(ReferenceType
.Map
);
933 public IPatent
castReferenceToPatent(){
934 setType(ReferenceType
.Patent
);
938 public IPersonalCommunication
castReferenceToPersonalCommunication(){
939 setType(ReferenceType
.PersonalCommunication
);
943 public IPrintSeries
castReferenceToPrintSeries(){
944 setType(ReferenceType
.PrintSeries
);
948 public IWebPage
castReferenceToWebPage(){
949 setType(ReferenceType
.WebPage
);
953 public IProceedings
castReferenceToProceedings(){
954 setType(ReferenceType
.Proceedings
);
958 public IReport
castReferenceToReport(){
959 setType(ReferenceType
.Report
);
963 public IThesis
castReferenceToThesis(){
964 setType(ReferenceType
.Thesis
);
970 @Transient // prevent from being serialized by webservice
971 public IJournal
getInJournal() {
972 IJournal journal
= this.inReference
;
977 public void setInJournal(IJournal journal
) {
978 this.inReference
= (Reference
)journal
;
983 @Transient // prevent from being serialized by webservice
984 public IPrintSeries
getInSeries() {
985 IPrintSeries printSeries
= this.inReference
;
990 public void setInSeries(IPrintSeries inSeries
) {
991 this.inReference
= (Reference
) inSeries
;
995 @Transient // prevent from being serialized by webservice
996 public IBook
getInBook() {
997 IBook book
= this.inReference
;
1001 //********************** In-References *****************************************
1004 public void setInBook(IBook book
) {
1005 this.inReference
= (Reference
) book
;
1009 @Transient // prevent from being serialized by webservice
1010 public IProceedings
getInProceedings() {
1011 IProceedings proceedings
= this.inReference
;
1016 public void setInProceedings(IProceedings proceeding
) {
1017 this.inReference
= (Reference
) proceeding
;
1020 //*************************** CACHE STRATEGIES ******************************/
1023 public IReferenceBaseCacheStrategy
getCacheStrategy() {
1024 rectifyCacheStrategy();
1025 return this.cacheStrategy
;
1029 * The type property of this class is mapped on the field level to the data base column, so
1030 * Hibernate will consequently use the {@link org.hibernate.property.DirectPropertyAccessor}
1031 * to set the property. This PropertyAccessor directly sets the field instead of using the according setter so
1032 * the CacheStrategy is not correctly set after the initialization of the bean. Thus we need to
1033 * validate the CacheStrategy before it is to be used.
1035 private void rectifyCacheStrategy() {
1036 if(!cacheStrategyRectified
){
1038 cacheStrategyRectified
= true;
1044 public void setCacheStrategy(IReferenceBaseCacheStrategy iReferenceBaseCacheStrategy
) {
1045 this.cacheStrategy
= iReferenceBaseCacheStrategy
;
1050 public void setCacheStrategy(ArticleDefaultCacheStrategy cacheStrategy
) {
1051 this.cacheStrategy
= cacheStrategy
;
1055 public void setCacheStrategy(BookDefaultCacheStrategy cacheStrategy
) {
1056 this.cacheStrategy
= cacheStrategy
;
1060 public void setCacheStrategy(JournalDefaultCacheStrategy cacheStrategy
) {
1061 this.cacheStrategy
= cacheStrategy
;
1065 public void setCacheStrategy(BookSectionDefaultCacheStrategy cacheStrategy
) {
1066 this.cacheStrategy
= cacheStrategy
;
1070 public void setCacheStrategy(GenericDefaultCacheStrategy cacheStrategy
) {
1071 this.cacheStrategy
= cacheStrategy
;
1074 public void setCacheStrategy(ReferenceDefaultCacheStrategy cacheStrategy
) {
1075 this.cacheStrategy
= cacheStrategy
;
1082 // protected void initListener(){
1083 // PropertyChangeListener listener = new PropertyChangeListener() {
1085 // public void propertyChange(PropertyChangeEvent e) {
1086 // boolean protectedByLowerCache = false;
1087 // //authorship cache
1088 // if (fieldHasCacheUpdateProperty(e.getPropertyName(), "authorshipCache")){
1089 // if (protectedAuthorshipCache){
1090 // protectedByLowerCache = true;
1092 // authorshipCache = null;
1097 // if (! fieldHasNoUpdateProperty(e.getPropertyName(), "titleCache")){
1098 // if (isProtectedTitleCache()|| protectedByLowerCache == true ){
1099 // protectedByLowerCache = true;
1101 // titleCache = null;
1104 // //full title cache
1105 // if (! fieldHasNoUpdateProperty(e.getPropertyName(), "fullTitleCache")){
1106 // if (isProtectedFullTitleCache()|| protectedByLowerCache == true ){
1107 // protectedByLowerCache = true;
1109 // fullTitleCache = null;
1114 // addPropertyChangeListener(listener); //didn't use this.addXXX to make lsid.AssemblerTest run in cdmlib-remote
1118 //*********************** CLONE ********************************************************/
1121 * Clones <i>this</i> reference. This is a shortcut that enables to create
1122 * a new instance that differs only slightly from <i>this</i> reference by
1123 * modifying only some of the attributes.
1125 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
1126 * @see java.lang.Object#clone()
1129 public Object
clone() {
1131 Reference result
= (Reference
)super.clone();
1132 result
.setDatePublished(datePublished
!= null?
(TimePeriod
)datePublished
.clone(): null);
1133 //no changes to: title, authorship, hasProblem, nomenclaturallyRelevant, uri
1135 } catch (CloneNotSupportedException e
) {
1136 logger
.warn("Object does not implement cloneable");
1137 e
.printStackTrace();
1142 //******************************* toString *****************************/
1145 public String
toString() {
1147 String result
= "Reference [type=" + type
+ ", id= " + this.getId() + ", uuid=" + this.uuid
;
1148 result
+= title
== null ?
"" : ", title=" + title
;
1149 result
+= abbrevTitle
== null ?
"" : ", abbrevTitle=" + abbrevTitle
;
1153 return super.toString();