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
;
14 import java
.util
.List
;
16 import javax
.persistence
.Column
;
17 import javax
.persistence
.Embedded
;
18 import javax
.persistence
.Entity
;
19 import javax
.persistence
.FetchType
;
20 import javax
.persistence
.Inheritance
;
21 import javax
.persistence
.InheritanceType
;
22 import javax
.persistence
.Lob
;
23 import javax
.persistence
.ManyToOne
;
24 import javax
.persistence
.Transient
;
25 import javax
.validation
.constraints
.NotNull
;
26 import javax
.validation
.constraints
.Pattern
;
27 import javax
.xml
.bind
.annotation
.XmlAccessType
;
28 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
29 import javax
.xml
.bind
.annotation
.XmlAttribute
;
30 import javax
.xml
.bind
.annotation
.XmlElement
;
31 import javax
.xml
.bind
.annotation
.XmlIDREF
;
32 import javax
.xml
.bind
.annotation
.XmlRootElement
;
33 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
34 import javax
.xml
.bind
.annotation
.XmlType
;
36 import org
.apache
.commons
.lang
.StringUtils
;
37 import org
.apache
.log4j
.Logger
;
38 import org
.hibernate
.annotations
.Cascade
;
39 import org
.hibernate
.annotations
.CascadeType
;
40 import org
.hibernate
.annotations
.Table
;
41 import org
.hibernate
.annotations
.Type
;
42 import org
.hibernate
.envers
.Audited
;
43 import org
.hibernate
.search
.annotations
.Analyze
;
44 import org
.hibernate
.search
.annotations
.Field
;
45 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
46 import org
.hibernate
.validator
.constraints
.Length
;
48 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
49 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
50 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
51 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
52 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
53 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.ArticleDefaultCacheStrategy
;
54 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.BookDefaultCacheStrategy
;
55 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.BookSectionDefaultCacheStrategy
;
56 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.GenericDefaultCacheStrategy
;
57 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.INomenclaturalReferenceCacheStrategy
;
58 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.IReferenceBaseCacheStrategy
;
59 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.JournalDefaultCacheStrategy
;
60 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.ReferenceDefaultCacheStrategy
;
61 import eu
.etaxonomy
.cdm
.strategy
.match
.Match
;
62 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
63 import eu
.etaxonomy
.cdm
.strategy
.merge
.Merge
;
64 import eu
.etaxonomy
.cdm
.strategy
.merge
.MergeMode
;
65 import eu
.etaxonomy
.cdm
.strategy
.parser
.ParserProblem
;
66 import eu
.etaxonomy
.cdm
.validation
.Level2
;
67 import eu
.etaxonomy
.cdm
.validation
.annotation
.InReference
;
68 import eu
.etaxonomy
.cdm
.validation
.annotation
.NullOrNotEmpty
;
69 import eu
.etaxonomy
.cdm
.validation
.annotation
.ReferenceCheck
;
72 * The upmost (abstract) class for references (information sources).
74 * This class corresponds to: <ul>
75 * <li> PublicationCitation according to the TDWG ontology
76 * <li> Publication according to the TCS
77 * <li> Reference according to the ABCD schema
81 * @created 08-Nov-2007 13:06:47
83 @XmlAccessorType(XmlAccessType
.FIELD
)
84 @XmlType(name
= "Reference", propOrder
= {
88 "protectedAbbrevTitleCache",
89 "nomenclaturallyRelevant",
111 @XmlRootElement(name
= "Reference")
113 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
115 @Table(appliesTo
="Reference", indexes
= { @org.hibernate
.annotations
.Index(name
= "ReferenceTitleCacheIndex", columnNames
= { "titleCache" }) })
116 @InReference(groups
= Level2
.class)
117 @ReferenceCheck(groups
= Level2
.class)
118 public class Reference
<S
extends IReferenceBaseCacheStrategy
> extends IdentifiableMediaEntity
<S
> implements INomenclaturalReference
, IArticle
, IBook
, IPatent
, IDatabase
, IJournal
, IBookSection
,ICdDvd
,IGeneric
,IInProceedings
, IProceedings
, IPrintSeries
, IReport
, IThesis
,IWebPage
, IPersonalCommunication
, IReference
, Cloneable
{
119 private static final long serialVersionUID
= -2034764545042691295L;
120 private static final Logger logger
= Logger
.getLogger(Reference
.class);
122 @XmlAttribute(name
="type")
123 @Column(name
="refType")
125 @Type(type
= "eu.etaxonomy.cdm.hibernate.EnumUserType",
126 parameters
= {@org.hibernate
.annotations
.Parameter(name
= "enumClass", value
= "eu.etaxonomy.cdm.model.reference.ReferenceType")}
128 protected ReferenceType type
;
130 //Title of the reference
131 @XmlElement(name
="Title" )
132 @Column(length
=4096, name
="title")
135 @Match(MatchMode
.EQUAL_REQUIRED
)
138 @Length(max
= 4096) //TODO is the length attribute really requried twice (see @Column)??
139 private String title
;
141 //Title of the reference
142 @XmlElement(name
="AbbrevTitle" )
144 @Match(MatchMode
.EQUAL
) //TODO check if this is correct
147 private String abbrevTitle
;
149 //Title of the reference
150 @XmlElement(name
="AbbrevTitleCache" )
152 @Match(MatchMode
.CACHE
)
156 private String abbrevTitleCache
;
158 @XmlElement(name
= "protectedAbbrevTitleCache")
160 private boolean protectedAbbrevTitleCache
;
162 //********************************************************/
165 @XmlElement(name
= "Editor")
170 protected String editor
;
172 @XmlElement(name
= "Series")
177 protected String series
;
179 @XmlElement(name
= "Volume")
184 protected String volume
;
186 @XmlElement(name
= "Pages")
191 protected String pages
;
193 @XmlElement(name
= "Edition")
198 protected String edition
;
200 @XmlElement(name
= "ISBN")
205 @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}")
206 protected String isbn
;
208 @XmlElement(name
= "Doi")
212 // @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.doi.message}")
213 protected String doi
;
216 @XmlElement(name
= "ISSN")
221 @Pattern(regexp
= "(?=.{9}$)\\d{4}([- ])\\d{4} (\\d|X)$", groups
= Level2
.class, message
= "{eu.etaxonomy.cdm.model.reference.Reference.issn.message}")
222 protected String issn
;
224 @XmlElement(name
= "SeriesPart")
229 protected String seriesPart
;
231 @XmlElement(name
= "Organization")
236 protected String organization
;
238 @XmlElement(name
= "Publisher")
243 protected String publisher
;
246 @XmlElement(name
= "PlacePublished")
251 protected String placePublished
;
253 @XmlElement(name
= "Institution")
255 @XmlSchemaType(name
= "IDREF")
256 @ManyToOne(fetch
= FetchType
.LAZY
)
258 @Cascade(CascadeType
.SAVE_UPDATE
)
259 protected Institution institution
;
261 @XmlElement(name
= "School")
263 @XmlSchemaType(name
= "IDREF")
264 @ManyToOne(fetch
= FetchType
.LAZY
)
266 @Cascade(CascadeType
.SAVE_UPDATE
)
267 protected Institution school
;
269 @XmlElement(name
= "InReference")
271 @XmlSchemaType(name
= "IDREF")
272 @ManyToOne(fetch
= FetchType
.LAZY
)
274 @Cascade(CascadeType
.SAVE_UPDATE
)
275 // @InReference(groups=Level2.class)
276 protected Reference
<?
> inReference
;
278 // @XmlElement(name = "FullReference")
280 // @XmlSchemaType(name = "IDREF")
281 // @ManyToOne(fetch = FetchType.LAZY)
282 //// @IndexedEmbedded
283 // @Cascade(CascadeType.SAVE_UPDATE)
284 // protected Reference fullReference;
286 // @XmlElement(name = "AbbreviatedReference")
288 // @XmlSchemaType(name = "IDREF")
289 // @ManyToOne(fetch = FetchType.LAZY)
290 //// @IndexedEmbedded
291 // @Cascade(CascadeType.SAVE_UPDATE)
292 // protected Reference abbreviatedReference;
295 //********************************************************/
297 //The date range assigned to the reference. ISO Date range like. Flexible, year can be left out, etc
298 @XmlElement(name
="DatePublished" )
301 private TimePeriod datePublished
= TimePeriod
.NewInstance();
303 @XmlElement(name
="Abstract" )
304 @Column(length
=65536, name
="referenceAbstract")
310 private String referenceAbstract
; //abstract is a reserved term in Java
313 //URIs like DOIs, LSIDs or Handles for this reference
314 @XmlElement(name
= "URI")
315 @Field(analyze
= Analyze
.NO
)
316 @Type(type
="uriUserType")
319 //flag to subselect only references that could be useful for nomenclatural citations. If a reference is used as a
320 //nomenclatural reference in a name this flag should be automatically set
321 @XmlElement(name
= "IsNomenclaturallyRelevant")
323 private boolean nomenclaturallyRelevant
;
325 @XmlElement(name
= "AuthorTeam")
327 @XmlSchemaType(name
= "IDREF")
328 @ManyToOne(fetch
= FetchType
.LAZY
)
330 @Cascade(CascadeType
.SAVE_UPDATE
)
331 private TeamOrPersonBase
<?
> authorTeam
;
333 // @XmlElement(name = "ReferenceIdentity")
335 // @XmlSchemaType(name = "IDREF")
336 // @ManyToOne(fetch = FetchType.LAZY)
337 // //@IndexedEmbedded
338 // @Cascade(CascadeType.SAVE_UPDATE)
340 // private ReferenceIdentity referenceIdentity;
343 @Match(MatchMode
.IGNORE
)
344 private int parsingProblem
= 0;
347 @Match(MatchMode
.IGNORE
)
348 private int problemStarts
= -1;
351 @Match(MatchMode
.IGNORE
)
352 private int problemEnds
= -1;
356 @Match(MatchMode
.IGNORE
)
357 private boolean cacheStrategyRectified
= false;
359 protected Reference(){
360 this(ReferenceType
.Generic
);
363 protected Reference(ReferenceType type
) {
365 this.cacheStrategy
=(S
) type
.getCacheStrategy();
369 //*************************** GETTER / SETTER ******************************************/
373 public String
getAbbrevTitleCache() {
374 if (protectedAbbrevTitleCache
){
375 return this.abbrevTitleCache
;
377 // is title dirty, i.e. equal NULL?
378 if (abbrevTitleCache
== null){
379 this.abbrevTitleCache
= generateAbbrevTitle();
380 this.abbrevTitleCache
= getTruncatedCache(this.abbrevTitleCache
) ;
382 return abbrevTitleCache
;
387 public void setAbbrevTitleCache(String abbrevTitleCache
) {
388 this.abbrevTitleCache
= abbrevTitleCache
;
392 public void setAbbrevTitleCache(String abbrevTitleCache
, boolean isProtected
) {
393 this.protectedAbbrevTitleCache
= isProtected
;
394 setAbbrevTitleCache(abbrevTitleCache
);
398 public boolean isProtectedAbbrevTitleCache() {
399 return protectedAbbrevTitleCache
;
403 public void setProtectedAbbrevTitleCache(boolean protectedAbbrevTitleCache
) {
404 this.protectedAbbrevTitleCache
= protectedAbbrevTitleCache
;
408 public String
getAbbrevTitle() {
413 public void setAbbrevTitle(String abbrevTitle
) {
414 this.abbrevTitle
= abbrevTitle
;
419 public String
getEditor() {
425 public void setEditor(String editor
) {
426 this.editor
= editor
;
430 public String
getSeries() {
435 public void setSeries(String series
) {
436 this.series
= series
;
440 public String
getVolume() {
445 public void setVolume(String volume
) {
446 this.volume
= volume
;
450 public String
getPages() {
455 public void setPages(String pages
) {
460 public String
getEdition() {
465 public void setEdition(String edition
) {
466 this.edition
= edition
;
470 public String
getIsbn() {
475 public void setIsbn(String isbn
) {
480 public String
getIssn() {
485 public void setIssn(String issn
) {
490 public String
getDoi() {
495 public void setDoi(String doi
) {
500 public String
getSeriesPart() {
505 public void setSeriesPart(String seriesPart
) {
506 this.seriesPart
= seriesPart
;
510 public String
getOrganization() {
515 public void setOrganization(String organization
) {
516 this.organization
= organization
;
520 public String
getPublisher() {
525 public void setPublisher(String publisher
) {
526 this.publisher
= publisher
;
530 public void setPublisher(String publisher
, String placePublished
){
531 this.publisher
= publisher
;
532 this.placePublished
= placePublished
;
536 public String
getPlacePublished() {
537 return placePublished
;
541 public void setPlacePublished(String placePublished
) {
542 this.placePublished
= placePublished
;
546 public Institution
getInstitution() {
551 public void setInstitution(Institution institution
) {
552 this.institution
= institution
;
556 public Institution
getSchool() {
561 public void setSchool(Institution school
) {
562 this.school
= school
;
566 public Reference
getInReference() {
571 public void setInReference(Reference inReference
) {
572 this.inReference
= inReference
;
576 public void setType(ReferenceType type
) {
577 this.setCacheStrategy(type
.getCacheStrategy());
585 public ReferenceType
getType() {
590 * Whether this reference is of the given type
596 public boolean isOfType(ReferenceType type
){
597 return type
== getType();
601 * Returns a string representing the title of <i>this</i> reference. If a
602 * reference has different titles (for instance abbreviated and not
603 * abbreviated) then for each title a new instance must be created.
605 * @return the title string of <i>this</i> reference
606 * @see #getCitation()
609 public String
getTitle(){
616 public void setTitle(String title
){
621 * Returns the date (mostly only the year) of publication / creation of
622 * <i>this</i> reference.
625 public TimePeriod
getDatePublished(){
626 return this.datePublished
;
629 * @see #getDatePublished()
632 public void setDatePublished(TimePeriod datePublished
){
633 this.datePublished
= datePublished
;
636 public boolean hasDatePublished(){
637 boolean result
= ! ( (this.datePublished
== null) || StringUtils
.isBlank(datePublished
.toString()));
642 * Returns the {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author (team)} who created the
643 * content of <i>this</i> reference.
645 * @return the author (team) of <i>this</i> reference
646 * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase
649 public TeamOrPersonBase
getAuthorTeam(){
650 return this.authorTeam
;
654 * @see #getAuthorTeam()
657 public void setAuthorTeam(TeamOrPersonBase authorTeam
){
658 this.authorTeam
= authorTeam
;
662 * Returns the Uniform Resource Identifier (URI) corresponding to <i>this</i>
663 * reference. An URI is a string of characters used to identify a resource
666 * @return the URI of <i>this</i> reference
676 public void setUri(URI uri
){
681 * @return the referenceAbstract
684 public String
getReferenceAbstract() {
685 return referenceAbstract
;
689 * @param referenceAbstract the referenceAbstract to set
692 public void setReferenceAbstract(String referenceAbstract
) {
693 this.referenceAbstract
= referenceAbstract
;
700 * Returns "true" if the isNomenclaturallyRelevant flag is set. This
701 * indicates that a {@link TaxonNameBase taxon name} has been originally
702 * published in <i>this</i> reference following the rules of a
703 * {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode nomenclature code} and is therefore used for
704 * nomenclatural citations. This flag will be set as soon as <i>this</i>
705 * reference is used as a nomenclatural reference for any taxon name.<BR>
706 * FIXME what happens if the only taxon name referencing this reference is not
707 * any longer using this reference as a nomenclatural reference. How does the
708 * reference get informed about the fact that it is not nomenclaturally relevant
711 public boolean isNomenclaturallyRelevant(){
712 return this.nomenclaturallyRelevant
;
716 * @see #isNomenclaturallyRelevant()
718 public void setNomenclaturallyRelevant(boolean nomenclaturallyRelevant
){
719 this.nomenclaturallyRelevant
= nomenclaturallyRelevant
;
724 // * Returns the full reference that belongs to this abbreviated reference. If this
725 // * reference is not abbreviated the full reference should be <code>null</code>.<BR>
726 // * A full reference should be added to a reference
727 // * which represents the abbreviated form of a reference. The full reference can be used
728 // * by publication tools to link to the unabbreviated and therefore more complete version
729 // * of the reference.
731 // * @see #getAbbreviatedReference()
732 // * @return the full reference
734 // public Reference getFullReference() {
735 // return fullReference;
739 // * @see #getFullReference()
740 // * @param fullReference
742 // public void setFullReference(Reference fullReference) {
743 // this.fullReference = fullReference;
747 // * Returns the abbreviated reference that belongs to this full reference. If this
748 // * reference is not a full reference the abbeviated referece must be <code>null</code>.<BR>
749 // * An abbreviated reference should be added to a reference which represents the long (full)
750 // * form of a reference.
751 // * In future this may become a set or handled differently as there are multiple
753 // * @see #getFullReference()
754 // * @return the full reference
756 // public Reference getAbbreviatedReference() {
757 // return abbreviatedReference;
761 // * @see #getAbbreviatedReference()
762 // * @param abbreviatedReference
765 // public void setAbbreviatedReference(Reference abbreviatedReference) {
766 // this.abbreviatedReference = abbreviatedReference;
769 //**************************************************** /
772 // * Returns the string representing the name of the editor of <i>this</i>
773 // * generic reference. An editor is mostly a person (team) who assumed the
774 // * responsibility for the content of the publication as a whole without
775 // * being the author of this content.<BR>
776 // * If there is an editor then the generic reference must be some
777 // * kind of {@link PrintedUnitBase physical printed unit}.
779 // * @return the string identifying the editor of <i>this</i>
780 // * generic reference
781 // * @see #getPublisher()
783 // protected String getEditor(){
784 // return this.editor;
788 // * @see #getEditor()
790 // protected void setEditor(String editor){
791 // this.editor = editor;
795 // * Returns the string representing the series (for instance for books or
796 // * within journals) - and series part - in which <i>this</i> generic reference
797 // * was published.<BR>
798 // * If there is a series then the generic reference must be some
799 // * kind of {@link PrintedUnitBase physical printed unit} or an {@link Article article}.
801 // * @return the string identifying the series for <i>this</i>
802 // * generic reference
804 // protected String getSeries(){
805 // return this.series;
809 // * @see #getSeries()
811 // protected void setSeries(String series){
812 // this.series = series;
816 // * Returns the string representing the volume (for instance for books or
817 // * within journals) in which <i>this</i> generic reference was published.<BR>
818 // * If there is a volume then the generic reference must be some
819 // * kind of {@link PrintedUnitBase physical printed unit} or an {@link Article article}.
821 // * @return the string identifying the volume for <i>this</i>
822 // * generic reference
824 // protected String getVolume(){
825 // return this.volume;
829 // * @see #getVolume()
831 // protected void setVolume(String volume){
832 // this.volume = volume;
836 // * Returns the string representing the page(s) where the content of
837 // * <i>this</i> generic reference is located.<BR>
838 // * If there is a pages information then the generic reference must be some
839 // * kind of {@link PrintedUnitBase physical printed unit} or an {@link Article article}.
841 // * @return the string containing the pages corresponding to <i>this</i>
842 // * generic reference
844 // protected String getPages(){
845 // return this.pages;
849 // * @see #getPages()
851 // protected void setPages(String pages){
852 // this.pages = pages;
857 * Returns a formatted string containing the entire reference citation,
858 * including authors, corresponding to <i>this</i> reference.
860 * @see #generateTitle()
864 public String
getCitation(){
865 rectifyCacheStrategy();
866 if (cacheStrategy
== null){
867 logger
.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid());
870 return cacheStrategy
.getTitleCache(this);
875 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
878 public String
generateTitle() {
879 rectifyCacheStrategy();
880 return super.generateTitle();
883 public String
generateAbbrevTitle() {
884 rectifyCacheStrategy();
885 return this.cacheStrategy
.getAbbrevTitleCache(this);
889 * Returns a string representation for the year of publication / creation
890 * of <i>this</i> reference. If the {@link #getDatePublished() datePublished}
891 * of this reference contains more date information then (starting) year
892 * only the year is returned.
897 public String
getYear(){
898 TimePeriod datePublished
= this.getDatePublished();
899 if (datePublished
!= null ){
900 String result
= getDatePublished().getYear();
908 * Convenience method that returns a string representation for the publication date / creation
909 * of <i>this</i> reference. The string is obtained by
910 * {@link #getDatePublished()#toString() the string representation
911 * of the date published}.
914 public String
getDatePublishedString(){
915 TimePeriod datePublished
= this.getDatePublished();
916 if (datePublished
!= null ){
917 return getDatePublished().toString();
926 * @see eu.etaxonomy.cdm.model.common.IParsable#getHasProblem()
929 public int getParsingProblem(){
930 return this.parsingProblem
;
934 * @see eu.etaxonomy.cdm.model.common.IParsable#setHasProblem(boolean)
937 public void setParsingProblem(int parsingProblem
){
938 this.parsingProblem
= parsingProblem
;
942 * @see eu.etaxonomy.cdm.model.common.IParsable#hasProblem()
945 public boolean hasProblem(){
946 return parsingProblem
!= 0;
950 * @see eu.etaxonomy.cdm.model.common.IParsable#hasProblem(eu.etaxonomy.cdm.strategy.parser.ParserProblem)
953 public boolean hasProblem(ParserProblem problem
) {
954 return getParsingProblems().contains(problem
);
959 * @see eu.etaxonomy.cdm.model.common.IParsable#problemStarts()
962 public int getProblemStarts(){
963 return this.problemStarts
;
967 * @see eu.etaxonomy.cdm.model.common.IParsable#setProblemStarts(int)
970 public void setProblemStarts(int start
) {
971 this.problemStarts
= start
;
975 * @see eu.etaxonomy.cdm.model.common.IParsable#problemEnds()
978 public int getProblemEnds(){
979 return this.problemEnds
;
983 * @see eu.etaxonomy.cdm.model.common.IParsable#setProblemEnds(int)
986 public void setProblemEnds(int end
) {
987 this.problemEnds
= end
;
991 * @see eu.etaxonomy.cdm.model.common.IParsable#addProblem(eu.etaxonomy.cdm.strategy.parser.NameParserWarning)
994 public void addParsingProblem(ParserProblem warning
){
995 parsingProblem
= ParserProblem
.addProblem(parsingProblem
, warning
);
999 * @see eu.etaxonomy.cdm.model.common.IParsable#removeParsingProblem(eu.etaxonomy.cdm.strategy.parser.ParserProblem)
1002 public void removeParsingProblem(ParserProblem problem
) {
1003 parsingProblem
= ParserProblem
.removeProblem(parsingProblem
, problem
);
1007 * @see eu.etaxonomy.cdm.model.common.IParsable#getParsingProblems()
1011 public List
<ParserProblem
> getParsingProblems() {
1012 return ParserProblem
.warningList(this.parsingProblem
);
1018 public String
getNomenclaturalCitation(String microReference
) {
1019 rectifyCacheStrategy();
1020 String typeName
= this.getType()== null ?
"(no type defined)" : this.getType().getMessage();
1021 if (cacheStrategy
== null){
1022 logger
.warn("No CacheStrategy defined for "+ typeName
+ ": " + this.getUuid());
1025 if (cacheStrategy
instanceof INomenclaturalReferenceCacheStrategy
){
1026 return ((INomenclaturalReferenceCacheStrategy
)cacheStrategy
).getNomenclaturalCitation(this,microReference
);
1028 logger
.warn("No INomenclaturalReferenceCacheStrategy defined for "+ typeName
+ ": " + this.getUuid());
1036 * Generates, according to the {@link eu.etaxonomy.cdm.strategy.strategy.cache.reference.IReferenceBaseCacheStrategy cache strategy}
1037 * assigned to <i>this</i> reference, a string that identifies <i>this</i>
1038 * reference and returns it. This string may be stored in the inherited
1039 * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
1040 * This method overrides the generic and inherited generateTitle method
1041 * from {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity IdentifiableEntity}.
1043 * @return the string identifying <i>this</i> reference
1044 * @see #getCitation()
1045 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
1046 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
1047 * @see eu.etaxonomy.cdm.strategy.strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache()
1050 // public String generateTitle(){
1051 // if (cacheStrategy == null){
1052 // logger.warn("No CacheStrategy defined for Reference: " + this.getUuid());
1055 // return cacheStrategy.getTitleCache(this);
1062 // * Returns the reference identity object
1063 // * @return the referenceIdentity
1065 // public ReferenceIdentity getReferenceIdentity() {
1066 // return referenceIdentity;
1070 // * For bidirectional use only
1071 // * @param referenceIdentity the referenceIdentity to set
1073 // protected void setReferenceIdentity(ReferenceIdentity referenceIdentity) {
1074 // this.referenceIdentity = referenceIdentity;
1078 // * Returns the set of all identical references. Same as getReferenceIdentity().getReferences()
1081 // public Set<Reference> identicalReferences(){
1082 // return referenceIdentity.getReferences();
1086 //********** Casting methods ***********************************/
1088 public IArticle
castReferenceToArticle(){
1089 setType(ReferenceType
.Article
);
1093 public IBook
castReferenceToBook(){
1094 setType(ReferenceType
.Book
);
1098 public IBookSection
castReferenceToBookSection(){
1099 setType(ReferenceType
.BookSection
);
1103 public ICdDvd
castReferenceToCdDvd(){
1104 setType(ReferenceType
.CdDvd
);
1108 public IDatabase
castReferenceToDatabase(){
1109 setType(ReferenceType
.Database
);
1113 public IGeneric
castReferenceToGeneric(){
1114 setType(ReferenceType
.Generic
);
1118 public IInProceedings
castReferenceToInProceedings(){
1119 setType(ReferenceType
.InProceedings
);
1123 public IJournal
castReferenceToJournal(){
1124 setType(ReferenceType
.Journal
);
1128 public IMap
castReferenceToMap(){
1129 setType(ReferenceType
.Map
);
1133 public IPatent
castReferenceToPatent(){
1134 setType(ReferenceType
.Patent
);
1138 public IPersonalCommunication
castReferenceToPersonalCommunication(){
1139 setType(ReferenceType
.PersonalCommunication
);
1143 public IPrintSeries
castReferenceToPrintSeries(){
1144 setType(ReferenceType
.PrintSeries
);
1148 public IWebPage
castReferenceToWebPage(){
1149 setType(ReferenceType
.WebPage
);
1153 public IProceedings
castReferenceToProceedings(){
1154 setType(ReferenceType
.Proceedings
);
1158 public IReport
castReferenceToReport(){
1159 setType(ReferenceType
.Report
);
1163 public IThesis
castReferenceToThesis(){
1164 setType(ReferenceType
.Thesis
);
1170 @Transient // prevent from being serialized by webservice
1171 public IJournal
getInJournal() {
1172 IJournal journal
= this.inReference
;
1177 public void setInJournal(IJournal journal
) {
1178 this.inReference
= (Reference
<JournalDefaultCacheStrategy
<Reference
>>) journal
;
1183 @Transient // prevent from being serialized by webservice
1184 public IPrintSeries
getInSeries() {
1185 IPrintSeries printSeries
= this.inReference
;
1190 public void setInSeries(IPrintSeries inSeries
) {
1191 this.inReference
= (Reference
<IReferenceBaseCacheStrategy
<Reference
>>) inSeries
;
1195 @Transient // prevent from being serialized by webservice
1196 public IBook
getInBook() {
1197 IBook book
= this.inReference
;
1201 //********************** In-References *****************************************
1204 public void setInBook(IBook book
) {
1205 this.inReference
= (Reference
<BookDefaultCacheStrategy
<Reference
>>) book
;
1209 @Transient // prevent from being serialized by webservice
1210 public IProceedings
getInProceedings() {
1211 IProceedings proceedings
= this.inReference
;
1216 public void setInProceedings(IProceedings proceeding
) {
1217 this.inReference
= (Reference
<BookDefaultCacheStrategy
<Reference
>>) proceeding
;
1220 //*************************** CACHE STRATEGIES ******************************/
1223 * The type property of this class is mapped on the field level to the data base column, so
1224 * Hibernate will consequently use the {@link org.hibernate.property.DirectPropertyAccessor}
1225 * to set the property. This PropertyAccessor directly sets the field instead of using the according setter so
1226 * the CacheStrategy is not correctly set after the initialization of the bean. Thus we need to
1227 * validate the CacheStrategy before it is to be used.
1229 private void rectifyCacheStrategy() {
1230 if(!cacheStrategyRectified
){
1232 cacheStrategyRectified
= true;
1237 //public void setCacheStrategy(S cacheStrategy){
1238 // this.cacheStrategy = cacheStrategy;
1242 public void setCacheStrategy(IReferenceBaseCacheStrategy iReferenceBaseCacheStrategy
) {
1243 this.cacheStrategy
= (S
) iReferenceBaseCacheStrategy
;
1248 public void setCacheStrategy(ArticleDefaultCacheStrategy cacheStrategy
) {
1249 this.cacheStrategy
= (S
) cacheStrategy
;
1253 public void setCacheStrategy(BookDefaultCacheStrategy cacheStrategy
) {
1254 this.cacheStrategy
= (S
) cacheStrategy
;
1258 public void setCacheStrategy(JournalDefaultCacheStrategy cacheStrategy
) {
1259 this.cacheStrategy
= (S
) cacheStrategy
;
1263 public void setCacheStrategy(BookSectionDefaultCacheStrategy cacheStrategy
) {
1264 this.cacheStrategy
= (S
) cacheStrategy
;
1268 public void setCacheStrategy(GenericDefaultCacheStrategy cacheStrategy
) {
1269 this.cacheStrategy
= (S
) cacheStrategy
;
1272 public void setCacheStrategy(ReferenceDefaultCacheStrategy cacheStrategy
) {
1273 this.cacheStrategy
= (S
)cacheStrategy
;
1278 //*********************** CLONE ********************************************************/
1281 * Clones <i>this</i> reference. This is a shortcut that enables to create
1282 * a new instance that differs only slightly from <i>this</i> reference by
1283 * modifying only some of the attributes.
1285 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
1286 * @see java.lang.Object#clone()
1289 public Object
clone() {
1291 Reference result
= (Reference
)super.clone();
1292 result
.setDatePublished(datePublished
!= null?
(TimePeriod
)datePublished
.clone(): null);
1293 //no changes to: title, authorTeam, hasProblem, nomenclaturallyRelevant, uri
1295 } catch (CloneNotSupportedException e
) {
1296 logger
.warn("Object does not implement cloneable");
1297 e
.printStackTrace();