2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.model
.reference
;
13 import javax
.persistence
.Entity
;
14 import javax
.persistence
.FetchType
;
15 import javax
.persistence
.ManyToOne
;
16 import javax
.persistence
.Transient
;
17 import javax
.xml
.bind
.annotation
.XmlAccessType
;
18 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
19 import javax
.xml
.bind
.annotation
.XmlElement
;
20 import javax
.xml
.bind
.annotation
.XmlElementRef
;
21 import javax
.xml
.bind
.annotation
.XmlIDREF
;
22 import javax
.xml
.bind
.annotation
.XmlRootElement
;
23 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
24 import javax
.xml
.bind
.annotation
.XmlTransient
;
25 import javax
.xml
.bind
.annotation
.XmlType
;
27 import org
.apache
.log4j
.Logger
;
28 import org
.hibernate
.annotations
.Cascade
;
29 import org
.hibernate
.annotations
.CascadeType
;
30 import org
.hibernate
.envers
.Audited
;
31 import org
.hibernate
.search
.annotations
.Field
;
32 import org
.hibernate
.search
.annotations
.Index
;
33 import org
.hibernate
.search
.annotations
.Indexed
;
34 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
35 import org
.springframework
.beans
.factory
.annotation
.Configurable
;
37 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
38 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
39 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.ArticleDefaultCacheStrategy
;
40 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.INomenclaturalReferenceCacheStrategy
;
44 * This class represents articles in a {@link Journal journal}. An article is an independent
45 * piece of prose written by an {@link TeamOrPersonBase author (team)} which is published among
46 * other articles within a particular issue of a journal.
48 * This class corresponds, according to the TDWG ontology, to the publication type
49 * terms (from PublicationTypeTerm): <ul>
50 * <li> "JournalArticle"
51 * <li> "NewspaperArticle"
52 * <li> "MagazineArticle"
57 * @created 08-Nov-2007 13:06:10
59 @XmlAccessorType(XmlAccessType
.FIELD
)
60 @XmlType(name
= "Article", propOrder
= {
66 @XmlRootElement(name
= "Article")
68 @Indexed(index
= "eu.etaxonomy.cdm.model.reference.ReferenceBase")
71 public class Article
extends StrictReferenceBase
<INomenclaturalReferenceCacheStrategy
<Article
>> implements INomenclaturalReference
, IVolumeReference
, Cloneable
{
72 private static final long serialVersionUID
= -1528079480114388117L;
73 private static final Logger logger
= Logger
.getLogger(Article
.class);
75 @XmlElement(name
= "Series")
76 @Field(index
=Index
.TOKENIZED
)
77 private String series
;
79 @XmlElement(name
= "Volume")
80 @Field(index
=Index
.TOKENIZED
)
81 private String volume
;
83 @XmlElement(name
= "Pages")
84 @Field(index
=Index
.TOKENIZED
)
87 @XmlElement(name
= "InJournal")
89 @XmlSchemaType(name
= "IDREF")
90 @ManyToOne(fetch
= FetchType
.LAZY
)
92 @Cascade(CascadeType
.SAVE_UPDATE
)
93 private Journal inJournal
;
97 * Class constructor: creates a new empty article instance
98 * only containing the {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}.
100 * @see eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy
104 this.cacheStrategy
= ArticleDefaultCacheStrategy
.NewInstance();
108 * Creates a new empty article instance
109 * only containing the {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}.
112 * @see #NewInstance(Journal, TeamOrPersonBase, String, String, String, String, TimePeriod)
113 * @see eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy
115 public static Article
NewInstance(){
116 Article result
= new Article();
121 * Creates a new article instance with the given values and with the
122 * {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}.
124 * @param inJournal the journal in which <i>this</i> article has
126 * @param authorTeam the team or person who wrote <i>this</i> article
127 * @param articleTitle the string representing the title of <i>this</i>
129 * @param pages the string representing the pages in the journal
130 * issue where <i>this</i> article can be found
131 * @param series the string representing the series (within the
132 * journal) in which <i>this</i> article has been
134 * @param volume the string representing the volume of the journal
135 * in which <i>this</i> article has been published
136 * @param datePublished the date (time period) in which <i>this</i>
137 * article has been published
138 * @see #NewInstance()
140 * @see TeamOrPersonBase
142 * @see eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy
144 public static Article
NewInstance(Journal inJournal
, TeamOrPersonBase authorTeam
, String articleTitle
, String pages
, String series
, String volume
, TimePeriod datePublished
){
145 Article result
= new Article();
146 result
.setInJournal(inJournal
);
147 result
.setTitle(articleTitle
);
148 result
.setPages(pages
);
149 result
.setAuthorTeam(authorTeam
);
150 result
.setSeries(series
);
151 result
.setDatePublished(datePublished
);
152 result
.setVolume(volume
);
159 * Returns the {@link Journal journal} in which <i>this</i> article has been published.
161 * @return the journal
164 public Journal
getInJournal(){
165 return this.inJournal
;
169 * @see #getInJournal()
171 public void setInJournal(Journal inJournal
){
172 this.inJournal
= inJournal
;
176 * Returns the string representing the series (within the journal) in which
177 * <i>this</i> article was published.
179 * @return the string identifying the series
181 public String
getSeries(){
188 public void setSeries(String series
){
189 this.series
= series
;
193 * Returns the string representing the volume of the journal in which
194 * <i>this</i> article was published.
196 * @return the string identifying the series
198 public String
getVolume(){
205 public void setVolume(String volume
){
206 this.volume
= volume
;
210 * Returns the string representing the page(s) where the content of
211 * <i>this</i> article is located within the journal issue.
213 * @return the string with the pages corresponding to <i>this</i> article
215 public String
getPages(){
222 public void setPages(String pages
){
228 * Returns a formatted string containing the entire reference citation,
229 * including authors, title, journal, pages, corresponding to <i>this</i>
231 * This method overrides the generic and inherited getCitation method
232 * from {@link StrictReferenceBase StrictReferenceBase}.
234 * @see #getNomenclaturalCitation(String)
235 * @see StrictReferenceBase#getCitation()
239 // public String getCitation(){
240 // return nomRefBase.getCitation();
244 * Returns a formatted string containing the entire citation used for
245 * nomenclatural purposes based on <i>this</i> article - including
246 * (abbreviated) title of the journal but not authors of the article -
247 * and on the given details.
249 * @param microReference the string with the details (generally pages)
251 * @return the formatted string representing the
252 * nomenclatural citation
254 * @see #getCitation()
257 public String
getNomenclaturalCitation(String microReference
) {
258 if (cacheStrategy
== null){
259 logger
.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid());
262 return cacheStrategy
.getNomenclaturalCitation(this,microReference
);
268 * Generates, according to the {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}
269 * assigned to <i>this</i> article, a string that identifies <i>this</i>
270 * article and returns it. This string may be stored in the inherited
271 * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
272 * This method overrides the generic and inherited generateTitle method
273 * from {@link ReferenceBase ReferenceBase}.
275 * @return the string identifying <i>this</i> article
276 * @see #getCitation()
277 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
278 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
281 // public String generateTitle(){
282 // return nomRefBase.generateTitle();
285 //*********** CLONE **********************************/
289 * Clones <i>this</i> article. This is a shortcut that enables to
290 * create a new instance that differs only slightly from <i>this</i> article
291 * by modifying only some of the attributes.<BR>
292 * This method overrides the clone method from {@link StrictReferenceBase StrictReferenceBase}.
294 * @see StrictReferenceBase#clone()
295 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
296 * @see java.lang.Object#clone()
299 public Article
clone(){
300 Article result
= (Article
)super.clone();
301 result
.cacheStrategy
= ArticleDefaultCacheStrategy
.NewInstance();
302 //no changes to: inJournal, pages, series, volume