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
.INomenclaturalReferenceCacheStrategy
;
57 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.IReferenceCacheStrategy
;
58 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.NewDefaultReferenceCacheStrategy
;
59 import eu
.etaxonomy
.cdm
.strategy
.match
.Match
;
60 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
61 import eu
.etaxonomy
.cdm
.strategy
.merge
.Merge
;
62 import eu
.etaxonomy
.cdm
.strategy
.merge
.MergeMode
;
63 import eu
.etaxonomy
.cdm
.strategy
.parser
.ParserProblem
;
64 import eu
.etaxonomy
.cdm
.validation
.Level2
;
65 import eu
.etaxonomy
.cdm
.validation
.Level3
;
66 import eu
.etaxonomy
.cdm
.validation
.annotation
.InReference
;
67 import eu
.etaxonomy
.cdm
.validation
.annotation
.NoRecursiveInReference
;
68 import eu
.etaxonomy
.cdm
.validation
.annotation
.NullOrNotEmpty
;
69 import eu
.etaxonomy
.cdm
.validation
.annotation
.ReferenceCheck
;
72 * The class for references (information sources). Originally
73 * an abstract class with many subclasses. Not it is only
74 * one class implementing many interfaces for safe use.
76 * This class corresponds to: <ul>
77 * <li> PublicationCitation according to the TDWG ontology
78 * <li> Publication according to the TCS
79 * <li> Reference according to the ABCD schema
83 * @created 08-Nov-2007 13:06:47
85 @XmlAccessorType(XmlAccessType
.FIELD
)
86 @XmlType(name
= "Reference", propOrder
= {
90 "protectedAbbrevTitleCache",
91 "nomenclaturallyRelevant",
112 @XmlRootElement(name
= "Reference")
114 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
116 @Table(appliesTo
="Reference", indexes
= { @org.hibernate
.annotations
.Index(name
= "ReferenceTitleCacheIndex", columnNames
= { "titleCache" }) })
117 //@InReference(groups=Level3.class)
118 @ReferenceCheck(groups
=Level2
.class)
119 @InReference(groups
=Level3
.class)
120 @NoRecursiveInReference(groups
=Level3
.class) //may become Level1 in future #
121 public class Reference
122 extends IdentifiableMediaEntity
<IReferenceCacheStrategy
>
123 implements IArticle
, IBook
, IPatent
, IDatabase
, IJournal
, IBookSection
,ICdDvd
,
124 IGeneric
,IInProceedings
, IProceedings
, IPrintSeries
, IReport
,
125 IThesis
,IWebPage
, IPersonalCommunication
,
126 INomenclaturalReference
, IReference
,
129 private static final long serialVersionUID
= -2034764545042691295L;
130 private static final Logger logger
= Logger
.getLogger(Reference
.class);
132 @XmlAttribute(name
="type")
133 @Column(name
="refType")
135 @Type(type
= "eu.etaxonomy.cdm.hibernate.EnumUserType",
136 parameters
= {@org.hibernate
.annotations
.Parameter(name
= "enumClass", value
= "eu.etaxonomy.cdm.model.reference.ReferenceType")}
139 protected ReferenceType type
;
141 //Title of the reference
142 @XmlElement(name
="Title" )
143 @Column(length
=4096, name
="title")
146 @Match(MatchMode
.EQUAL_REQUIRED
)
149 private String title
;
151 //Title of the reference
152 @XmlElement(name
="AbbrevTitle" )
154 @Match(MatchMode
.EQUAL
) //TODO check if this is correct
157 private String abbrevTitle
;
159 //Title of the reference
160 @XmlElement(name
="AbbrevTitleCache" )
162 @Match(MatchMode
.CACHE
)
166 private String abbrevTitleCache
;
168 @XmlElement(name
= "protectedAbbrevTitleCache")
170 private boolean protectedAbbrevTitleCache
;
172 //********************************************************/
175 @XmlElement(name
= "Editor")
180 protected String editor
;
182 @XmlElement(name
= "Volume")
187 protected String volume
;
189 @XmlElement(name
= "Pages")
194 protected String pages
;
196 @XmlElement(name
= "Edition")
201 protected String edition
;
203 @XmlElement(name
= "ISBN")
208 @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}")
209 protected String isbn
;
211 @XmlElement(name
= "Doi")
213 @FieldBridge(impl
= DoiBridge
.class)
214 @Type(type
="doiUserType")
215 @Column(length
=DOI
.MAX_LENGTH
)
219 @XmlElement(name
= "ISSN")
224 @Pattern(regexp
= "(?=.{9}$)\\d{4}([- ])\\d{4} (\\d|X)$", groups
= Level2
.class, message
= "{eu.etaxonomy.cdm.model.reference.Reference.issn.message}")
225 protected String issn
;
227 @XmlElement(name
= "SeriesPart")
232 protected String seriesPart
;
234 @XmlElement(name
= "Organization")
239 protected String organization
;
241 @XmlElement(name
= "Publisher")
246 protected String publisher
;
249 @XmlElement(name
= "PlacePublished")
254 protected String placePublished
;
256 @XmlElement(name
= "Institution")
258 @XmlSchemaType(name
= "IDREF")
259 @ManyToOne(fetch
= FetchType
.LAZY
)
261 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
262 protected Institution institution
;
264 @XmlElement(name
= "School")
266 @XmlSchemaType(name
= "IDREF")
267 @ManyToOne(fetch
= FetchType
.LAZY
)
269 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
270 protected Institution school
;
272 @XmlElement(name
= "InReference")
274 @XmlSchemaType(name
= "IDREF")
275 @ManyToOne(fetch
= FetchType
.LAZY
)
277 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
278 // @InReference(groups=Level2.class)
279 protected Reference inReference
;
281 //********************************************************/
283 //The date range assigned to the reference. ISO Date range like. Flexible, year can be left out, etc
284 @XmlElement(name
="DatePublished" )
287 private TimePeriod datePublished
= TimePeriod
.NewInstance();
289 @XmlElement(name
="Abstract" )
290 @Column(length
=65536, name
="referenceAbstract")
295 private String referenceAbstract
; //abstract is a reserved term in Java
298 //URIs like DOIs, LSIDs or Handles for this reference
299 @XmlElement(name
= "URI")
300 @Field(analyze
= Analyze
.NO
)
301 @Type(type
="uriUserType")
304 //flag to subselect only references that could be useful for nomenclatural citations. If a reference is used as a
305 //nomenclatural reference in a name this flag should be automatically set
306 @XmlElement(name
= "IsNomenclaturallyRelevant")
308 private boolean nomenclaturallyRelevant
;
310 @XmlElement(name
= "Authorship")
312 @XmlSchemaType(name
= "IDREF")
313 @ManyToOne(fetch
= FetchType
.LAZY
)
315 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
316 private TeamOrPersonBase
<?
> authorship
;
319 @Match(MatchMode
.IGNORE
)
320 private int parsingProblem
= 0;
323 @Match(MatchMode
.IGNORE
)
324 private int problemStarts
= -1;
327 @Match(MatchMode
.IGNORE
)
328 private int problemEnds
= -1;
332 @Match(MatchMode
.IGNORE
)
333 private boolean cacheStrategyRectified
= false;
335 protected Reference(){
336 this(ReferenceType
.Generic
); //just in case someone uses constructor
339 protected Reference(ReferenceType type
) {
342 this.type
= ReferenceType
.Generic
;
346 this.setCacheStrategy(NewDefaultReferenceCacheStrategy
.NewInstance());
350 public void initListener(){
351 PropertyChangeListener listener
= new PropertyChangeListener() {
353 public void propertyChange(PropertyChangeEvent ev
) {
354 if (!ev
.getPropertyName().equals("titleCache") && !ev
.getPropertyName().equals("abbrevTitleCache") && !ev
.getPropertyName().equals("cacheStrategy")){
355 if (! isProtectedTitleCache()){
358 if (! isProtectedAbbrevTitleCache()){
359 abbrevTitleCache
= null;
364 addPropertyChangeListener(listener
);
368 //*************************** GETTER / SETTER ******************************************/
372 public String
getAbbrevTitleCache() {
373 if (protectedAbbrevTitleCache
){
374 return this.abbrevTitleCache
;
376 // is reference dirty, i.e. equal NULL?
377 if (abbrevTitleCache
== null){
378 this.abbrevTitleCache
= generateAbbrevTitle();
379 this.abbrevTitleCache
= getTruncatedCache(this.abbrevTitleCache
) ;
381 return abbrevTitleCache
;
386 public void setAbbrevTitleCache(String abbrevTitleCache
) {
387 this.abbrevTitleCache
= abbrevTitleCache
;
391 public void setAbbrevTitleCache(String abbrevTitleCache
, boolean isProtected
) {
392 this.protectedAbbrevTitleCache
= isProtected
;
393 setAbbrevTitleCache(abbrevTitleCache
);
397 public boolean isProtectedAbbrevTitleCache() {
398 return protectedAbbrevTitleCache
;
402 public void setProtectedAbbrevTitleCache(boolean protectedAbbrevTitleCache
) {
403 this.protectedAbbrevTitleCache
= protectedAbbrevTitleCache
;
407 public String
getAbbrevTitle() {
412 public void setAbbrevTitle(String abbrevTitle
) {
413 this.abbrevTitle
= StringUtils
.isBlank(abbrevTitle
) ?
null : abbrevTitle
;
418 public String
getEditor() {
424 public void setEditor(String editor
) {
425 this.editor
= StringUtils
.isBlank(editor
)?
null : editor
;
429 public String
getVolume() {
434 public void setVolume(String volume
) {
435 this.volume
= StringUtils
.isBlank(volume
)?
null : volume
;
439 public String
getPages() {
444 public void setPages(String pages
) {
445 this.pages
= StringUtils
.isBlank(pages
)?
null : pages
;
449 public String
getEdition() {
454 public void setEdition(String edition
) {
455 this.edition
= StringUtils
.isBlank(edition
)?
null : edition
;
459 public String
getIsbn() {
464 public void setIsbn(String isbn
) {
465 this.isbn
= StringUtils
.isBlank(isbn
)?
null : isbn
;
469 public String
getIssn() {
474 public void setIssn(String issn
) {
475 this.issn
= StringUtils
.isBlank(issn
)?
null : issn
;
479 public DOI
getDoi() {
484 public void setDoi(DOI doi
) {
489 public String
getSeriesPart() {
494 public void setSeriesPart(String seriesPart
) {
495 this.seriesPart
= StringUtils
.isBlank(seriesPart
)?
null : seriesPart
;
499 public String
getOrganization() {
504 public void setOrganization(String organization
) {
505 this.organization
= StringUtils
.isBlank(organization
)?
null : organization
;
509 public String
getPublisher() {
514 public void setPublisher(String publisher
) {
515 this.publisher
= StringUtils
.isBlank(publisher
)?
null : publisher
;
519 public void setPublisher(String publisher
, String placePublished
){
520 this.publisher
= publisher
;
521 this.placePublished
= placePublished
;
525 public String
getPlacePublished() {
526 return placePublished
;
530 public void setPlacePublished(String placePublished
) {
531 this.placePublished
= StringUtils
.isBlank(placePublished
)?
null: placePublished
;
535 public Institution
getInstitution() {
540 public void setInstitution(Institution institution
) {
541 this.institution
= institution
;
545 public Institution
getSchool() {
550 public void setSchool(Institution school
) {
551 this.school
= school
;
555 public Reference
getInReference() {
560 public void setInReference(Reference inReference
) {
561 this.inReference
= inReference
;
565 public void setType(ReferenceType type
) {
567 this.type
= ReferenceType
.Generic
;
571 this.setCacheStrategy(type
.getCacheStrategy());
574 public ReferenceType
getType() {
579 * Whether this reference is of the given type
585 public boolean isOfType(ReferenceType type
){
586 return type
== getType();
590 * Returns a string representing the title of <i>this</i> reference. If a
591 * reference has different titles (for instance abbreviated and not
592 * abbreviated) then for each title a new instance must be created.
594 * @return the title string of <i>this</i> reference
595 * @see #getCitation()
598 public String
getTitle(){
605 public void setTitle(String title
){
606 this.title
= StringUtils
.isBlank(title
)?
null : title
;
610 * Returns the date (mostly only the year) of publication / creation of
611 * <i>this</i> reference.
614 public TimePeriod
getDatePublished(){
615 return this.datePublished
;
618 * @see #getDatePublished()
621 public void setDatePublished(TimePeriod datePublished
){
622 this.datePublished
= datePublished
;
625 public boolean hasDatePublished(){
626 boolean result
= ! ( (this.datePublished
== null) || StringUtils
.isBlank(datePublished
.toString()));
631 * Returns the {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author (team)} who created the
632 * content of <i>this</i> reference.
634 * @return the author (team) of <i>this</i> reference
635 * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase
638 public TeamOrPersonBase
getAuthorship(){
639 return this.authorship
;
643 * @see #getAuthorship()
646 public void setAuthorship(TeamOrPersonBase authorship
){
647 this.authorship
= authorship
;
651 * Returns the Uniform Resource Identifier (URI) corresponding to <i>this</i>
652 * reference. An URI is a string of characters used to identify a resource
655 * @return the URI of <i>this</i> reference
665 public void setUri(URI uri
){
670 * @return the referenceAbstract
673 public String
getReferenceAbstract() {
674 return referenceAbstract
;
678 * @param referenceAbstract the referenceAbstract to set
681 public void setReferenceAbstract(String referenceAbstract
) {
682 this.referenceAbstract
= StringUtils
.isBlank(referenceAbstract
)?
null : referenceAbstract
;
687 * Returns "true" if the isNomenclaturallyRelevant flag is set. This
688 * indicates that a {@link TaxonNameBase taxon name} has been originally
689 * published in <i>this</i> reference following the rules of a
690 * {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode nomenclature code} and is therefore used for
691 * nomenclatural citations. This flag will be set as soon as <i>this</i>
692 * reference is used as a nomenclatural reference for any taxon name.<BR>
693 * FIXME what happens if the only taxon name referencing this reference is not
694 * any longer using this reference as a nomenclatural reference. How does the
695 * reference get informed about the fact that it is not nomenclaturally relevant
698 public boolean isNomenclaturallyRelevant(){
699 return this.nomenclaturallyRelevant
;
703 * @see #isNomenclaturallyRelevant()
705 public void setNomenclaturallyRelevant(boolean nomenclaturallyRelevant
){
706 this.nomenclaturallyRelevant
= nomenclaturallyRelevant
;
710 //**************************************************** /
714 * Returns a formatted string containing the entire reference citation,
715 * including authors, corresponding to <i>this</i> reference.
717 * @see #generateTitle()
721 public String
getCitation(){
722 rectifyCacheStrategy();
723 if (getCacheStrategy() == null){
724 logger
.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid());
727 return getCacheStrategy().getTitleCache(this);
733 public String
generateTitle() {
734 rectifyCacheStrategy();
735 return super.generateTitle();
738 public String
generateAbbrevTitle() {
739 rectifyCacheStrategy(); //TODO needed, is called by getCacheStrategy already
740 return getCacheStrategy().getFullAbbrevTitleString(this);
744 * Returns a string representation for the year of publication / creation
745 * of <i>this</i> reference. If the {@link #getDatePublished() datePublished}
746 * of this reference contains more date information then (starting) year
747 * only the year is returned.
752 public String
getYear(){
753 TimePeriod datePublished
= this.getDatePublished();
754 if (datePublished
!= null ){
755 String result
= getDatePublished().getYear();
763 * Convenience method that returns a string representation for the publication date / creation
764 * of <i>this</i> reference. The string is obtained by
765 * {@link #getDatePublished()#toString() the string representation
766 * of the date published}.
769 public String
getDatePublishedString(){
770 TimePeriod datePublished
= this.getDatePublished();
771 if (datePublished
!= null ){
772 return getDatePublished().toString();
780 public int getParsingProblem(){
781 return this.parsingProblem
;
785 public void setParsingProblem(int parsingProblem
){
786 this.parsingProblem
= parsingProblem
;
790 public boolean hasProblem(){
791 return parsingProblem
!= 0;
795 public boolean hasProblem(ParserProblem problem
) {
796 return getParsingProblems().contains(problem
);
800 public int getProblemStarts(){
801 return this.problemStarts
;
805 public void setProblemStarts(int start
) {
806 this.problemStarts
= start
;
810 public int getProblemEnds(){
811 return this.problemEnds
;
815 public void setProblemEnds(int end
) {
816 this.problemEnds
= end
;
820 public void addParsingProblem(ParserProblem warning
){
821 parsingProblem
= ParserProblem
.addProblem(parsingProblem
, warning
);
825 public void removeParsingProblem(ParserProblem problem
) {
826 parsingProblem
= ParserProblem
.removeProblem(parsingProblem
, problem
);
831 public List
<ParserProblem
> getParsingProblems() {
832 return ParserProblem
.warningList(this.parsingProblem
);
838 public String
getNomenclaturalCitation(String microReference
) {
839 rectifyCacheStrategy();
840 String typeName
= this.getType()== null ?
"(no type defined)" : this.getType().getMessage();
841 if (getCacheStrategy() == null){
842 logger
.warn("No CacheStrategy defined for "+ typeName
+ ": " + this.getUuid());
845 if (getCacheStrategy() instanceof INomenclaturalReferenceCacheStrategy
){
846 return ((INomenclaturalReferenceCacheStrategy
)cacheStrategy
).getNomenclaturalCitation(this, microReference
);
848 logger
.warn("No INomenclaturalReferenceCacheStrategy defined for "+ typeName
+ ": " + this.getUuid());
856 * Generates, according to the {@link eu.etaxonomy.cdm.strategy.strategy.cache.reference.IReferenceBaseCacheStrategy cache strategy}
857 * assigned to <i>this</i> reference, a string that identifies <i>this</i>
858 * reference and returns it. This string may be stored in the inherited
859 * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
860 * This method overrides the generic and inherited generateTitle method
861 * from {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity IdentifiableEntity}.
863 * @return the string identifying <i>this</i> reference
864 * @see #getCitation()
865 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
866 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
867 * @see eu.etaxonomy.cdm.strategy.strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache()
870 // public String generateTitle(){
871 // if (cacheStrategy == null){
872 // logger.warn("No CacheStrategy defined for Reference: " + this.getUuid());
875 // return cacheStrategy.getTitleCache(this);
881 //********** Casting methods ***********************************/
886 public IArticle
castReferenceToArticle(){
887 setType(ReferenceType
.Article
);
891 public IBook
castReferenceToBook(){
892 setType(ReferenceType
.Book
);
896 public IBookSection
castReferenceToBookSection(){
897 setType(ReferenceType
.BookSection
);
901 public ICdDvd
castReferenceToCdDvd(){
902 setType(ReferenceType
.CdDvd
);
906 public IDatabase
castReferenceToDatabase(){
907 setType(ReferenceType
.Database
);
911 public IGeneric
castReferenceToGeneric(){
912 setType(ReferenceType
.Generic
);
916 public IInProceedings
castReferenceToInProceedings(){
917 setType(ReferenceType
.InProceedings
);
921 public IJournal
castReferenceToJournal(){
922 setType(ReferenceType
.Journal
);
926 public IMap
castReferenceToMap(){
927 setType(ReferenceType
.Map
);
931 public IPatent
castReferenceToPatent(){
932 setType(ReferenceType
.Patent
);
936 public IPersonalCommunication
castReferenceToPersonalCommunication(){
937 setType(ReferenceType
.PersonalCommunication
);
941 public IPrintSeries
castReferenceToPrintSeries(){
942 setType(ReferenceType
.PrintSeries
);
946 public IWebPage
castReferenceToWebPage(){
947 setType(ReferenceType
.WebPage
);
951 public IProceedings
castReferenceToProceedings(){
952 setType(ReferenceType
.Proceedings
);
956 public IReport
castReferenceToReport(){
957 setType(ReferenceType
.Report
);
961 public IThesis
castReferenceToThesis(){
962 setType(ReferenceType
.Thesis
);
968 @Transient // prevent from being serialized by webservice
969 public IJournal
getInJournal() {
970 IJournal journal
= this.inReference
;
975 public void setInJournal(IJournal journal
) {
976 this.inReference
= (Reference
)journal
;
981 @Transient // prevent from being serialized by webservice
982 public IPrintSeries
getInSeries() {
983 IPrintSeries printSeries
= this.inReference
;
988 public void setInSeries(IPrintSeries inSeries
) {
989 this.inReference
= (Reference
) inSeries
;
993 @Transient // prevent from being serialized by webservice
994 public IBook
getInBook() {
995 IBook book
= this.inReference
;
999 //********************** In-References *****************************************
1002 public void setInBook(IBook book
) {
1003 this.inReference
= (Reference
) book
;
1007 @Transient // prevent from being serialized by webservice
1008 public IProceedings
getInProceedings() {
1009 IProceedings proceedings
= this.inReference
;
1014 public void setInProceedings(IProceedings proceeding
) {
1015 this.inReference
= (Reference
) proceeding
;
1018 //*************************** CACHE STRATEGIES ******************************/
1021 public IReferenceCacheStrategy
getCacheStrategy() {
1022 rectifyCacheStrategy();
1023 return this.cacheStrategy
;
1027 * The type property of this class is mapped on the field level to the data base column, so
1028 * Hibernate will consequently use the {@link org.hibernate.property.DirectPropertyAccessor}
1029 * to set the property. This PropertyAccessor directly sets the field instead of using the according setter so
1030 * the CacheStrategy is not correctly set after the initialization of the bean. Thus we need to
1031 * validate the CacheStrategy before it is to be used.
1033 private void rectifyCacheStrategy() {
1034 if(!cacheStrategyRectified
){
1036 cacheStrategyRectified
= true;
1042 public void setCacheStrategy(IReferenceCacheStrategy iReferenceBaseCacheStrategy
) {
1043 this.cacheStrategy
= iReferenceBaseCacheStrategy
;
1051 // protected void initListener(){
1052 // PropertyChangeListener listener = new PropertyChangeListener() {
1054 // public void propertyChange(PropertyChangeEvent e) {
1055 // boolean protectedByLowerCache = false;
1056 // //authorship cache
1057 // if (fieldHasCacheUpdateProperty(e.getPropertyName(), "authorshipCache")){
1058 // if (protectedAuthorshipCache){
1059 // protectedByLowerCache = true;
1061 // authorshipCache = null;
1066 // if (! fieldHasNoUpdateProperty(e.getPropertyName(), "titleCache")){
1067 // if (isProtectedTitleCache()|| protectedByLowerCache == true ){
1068 // protectedByLowerCache = true;
1070 // titleCache = null;
1073 // //full title cache
1074 // if (! fieldHasNoUpdateProperty(e.getPropertyName(), "fullTitleCache")){
1075 // if (isProtectedFullTitleCache()|| protectedByLowerCache == true ){
1076 // protectedByLowerCache = true;
1078 // fullTitleCache = null;
1083 // addPropertyChangeListener(listener); //didn't use this.addXXX to make lsid.AssemblerTest run in cdmlib-remote
1087 //*********************** CLONE ********************************************************/
1090 * Clones <i>this</i> reference. This is a shortcut that enables to create
1091 * a new instance that differs only slightly from <i>this</i> reference by
1092 * modifying only some of the attributes.
1094 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
1095 * @see java.lang.Object#clone()
1098 public Object
clone() {
1100 Reference result
= (Reference
)super.clone();
1101 result
.setDatePublished(datePublished
!= null?
(TimePeriod
)datePublished
.clone(): null);
1102 //no changes to: title, authorship, hasProblem, nomenclaturallyRelevant, uri
1104 } catch (CloneNotSupportedException e
) {
1105 logger
.warn("Object does not implement cloneable");
1106 e
.printStackTrace();
1111 //******************************* toString *****************************/
1114 public String
toString() {
1116 String result
= "Reference [type=" + type
+ ", id= " + this.getId() + ", uuid=" + this.uuid
;
1117 result
+= title
== null ?
"" : ", title=" + title
;
1118 result
+= abbrevTitle
== null ?
"" : ", abbrevTitle=" + abbrevTitle
;
1122 return super.toString();