1 |
9479da48
|
Andreas Müller
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
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.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
package eu.etaxonomy.cdm.model.reference;
|
11 |
|
|
|
12 |
|
|
|
13 |
788ff862
|
Andreas Müller
|
import javax.persistence.Entity;
|
14 |
|
|
import javax.persistence.Transient;
|
15 |
c4c118de
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlAccessType;
|
16 |
|
|
import javax.xml.bind.annotation.XmlAccessorType;
|
17 |
|
|
import javax.xml.bind.annotation.XmlRootElement;
|
18 |
|
|
import javax.xml.bind.annotation.XmlType;
|
19 |
788ff862
|
Andreas Müller
|
|
20 |
9479da48
|
Andreas Müller
|
import org.apache.log4j.Logger;
|
21 |
ee91bcd9
|
ben.clark
|
import org.hibernate.envers.Audited;
|
22 |
5d49833e
|
ben.clark
|
import org.hibernate.search.annotations.Indexed;
|
23 |
4208745a
|
ben.clark
|
import org.springframework.beans.factory.annotation.Configurable;
|
24 |
9479da48
|
Andreas Müller
|
|
25 |
788ff862
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
26 |
1b95b0ef
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
27 |
788ff862
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
28 |
|
|
import eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy;
|
29 |
4208745a
|
ben.clark
|
import eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy;
|
30 |
9479da48
|
Andreas Müller
|
|
31 |
04c7a71a
|
m.geoffroy
|
|
32 |
9479da48
|
Andreas Müller
|
/**
|
33 |
33fe95bf
|
m.geoffroy
|
* This class represents articles in a {@link Journal journal}. An article is an independent
|
34 |
|
|
* piece of prose written by an {@link TeamOrPersonBase author (team)} which is published among
|
35 |
|
|
* other articles within a particular issue of a journal.
|
36 |
04c7a71a
|
m.geoffroy
|
* <P>
|
37 |
|
|
* This class corresponds, according to the TDWG ontology, to the publication type
|
38 |
|
|
* terms (from PublicationTypeTerm): <ul>
|
39 |
|
|
* <li> "JournalArticle"
|
40 |
|
|
* <li> "NewspaperArticle"
|
41 |
|
|
* <li> "MagazineArticle"
|
42 |
|
|
* </ul>
|
43 |
|
|
*
|
44 |
9479da48
|
Andreas Müller
|
* @author m.doering
|
45 |
|
|
* @version 1.0
|
46 |
|
|
* @created 08-Nov-2007 13:06:10
|
47 |
|
|
*/
|
48 |
c4c118de
|
a.babadshanjan
|
@XmlAccessorType(XmlAccessType.FIELD)
|
49 |
|
|
@XmlType(name = "Article", propOrder = {
|
50 |
57606ee3
|
Andreas Müller
|
// "volume",
|
51 |
|
|
// "pages",
|
52 |
|
|
// "series",
|
53 |
|
|
// "inJournal"
|
54 |
c4c118de
|
a.babadshanjan
|
})
|
55 |
|
|
@XmlRootElement(name = "Article")
|
56 |
9479da48
|
Andreas Müller
|
@Entity
|
57 |
5d49833e
|
ben.clark
|
@Indexed(index = "eu.etaxonomy.cdm.model.reference.ReferenceBase")
|
58 |
ee91bcd9
|
ben.clark
|
@Audited
|
59 |
4208745a
|
ben.clark
|
@Configurable
|
60 |
57606ee3
|
Andreas Müller
|
public class Article extends ReferenceBase<INomenclaturalReferenceCacheStrategy<Article>> implements INomenclaturalReference, IVolumeReference, Cloneable {
|
61 |
961ee94b
|
Andreas Müller
|
private static final long serialVersionUID = -1528079480114388117L;
|
62 |
b235afbf
|
Andreas Müller
|
private static final Logger logger = Logger.getLogger(Article.class);
|
63 |
c4c118de
|
a.babadshanjan
|
|
64 |
57606ee3
|
Andreas Müller
|
// @XmlElement(name = "Series")
|
65 |
|
|
// @Field(index=Index.TOKENIZED)
|
66 |
|
|
// private String series;
|
67 |
|
|
//
|
68 |
|
|
// @XmlElement(name = "Volume")
|
69 |
|
|
// @Field(index=Index.TOKENIZED)
|
70 |
|
|
// private String volume;
|
71 |
|
|
//
|
72 |
|
|
// @XmlElement(name = "Pages")
|
73 |
|
|
// @Field(index=Index.TOKENIZED)
|
74 |
|
|
// private String pages;
|
75 |
|
|
//
|
76 |
|
|
// @XmlElement(name = "InJournal")
|
77 |
|
|
// @XmlIDREF
|
78 |
|
|
// @XmlSchemaType(name = "IDREF")
|
79 |
|
|
// @ManyToOne(fetch = FetchType.LAZY)
|
80 |
|
|
// @IndexedEmbedded
|
81 |
|
|
// @Cascade(CascadeType.SAVE_UPDATE)
|
82 |
|
|
// private Journal inJournal;
|
83 |
788ff862
|
Andreas Müller
|
|
84 |
|
|
|
85 |
04c7a71a
|
m.geoffroy
|
/**
|
86 |
|
|
* Class constructor: creates a new empty article instance
|
87 |
5fea4b1e
|
m.geoffroy
|
* only containing the {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}.
|
88 |
04c7a71a
|
m.geoffroy
|
*
|
89 |
5fea4b1e
|
m.geoffroy
|
* @see eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy
|
90 |
04c7a71a
|
m.geoffroy
|
*/
|
91 |
|
|
protected Article(){
|
92 |
|
|
super();
|
93 |
57606ee3
|
Andreas Müller
|
this.type = ReferenceType.Article;
|
94 |
04c7a71a
|
m.geoffroy
|
this.cacheStrategy = ArticleDefaultCacheStrategy.NewInstance();
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
/**
|
98 |
|
|
* Creates a new empty article instance
|
99 |
5fea4b1e
|
m.geoffroy
|
* only containing the {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}.
|
100 |
04c7a71a
|
m.geoffroy
|
*
|
101 |
|
|
* @see #Article()
|
102 |
|
|
* @see #NewInstance(Journal, TeamOrPersonBase, String, String, String, String, TimePeriod)
|
103 |
5fea4b1e
|
m.geoffroy
|
* @see eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy
|
104 |
04c7a71a
|
m.geoffroy
|
*/
|
105 |
788ff862
|
Andreas Müller
|
public static Article NewInstance(){
|
106 |
|
|
Article result = new Article();
|
107 |
|
|
return result;
|
108 |
|
|
}
|
109 |
|
|
|
110 |
04c7a71a
|
m.geoffroy
|
/**
|
111 |
|
|
* Creates a new article instance with the given values and with the
|
112 |
5fea4b1e
|
m.geoffroy
|
* {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}.
|
113 |
04c7a71a
|
m.geoffroy
|
*
|
114 |
|
|
* @param inJournal the journal in which <i>this</i> article has
|
115 |
|
|
* been published
|
116 |
|
|
* @param authorTeam the team or person who wrote <i>this</i> article
|
117 |
|
|
* @param articleTitle the string representing the title of <i>this</i>
|
118 |
|
|
* article
|
119 |
|
|
* @param pages the string representing the pages in the journal
|
120 |
33fe95bf
|
m.geoffroy
|
* issue where <i>this</i> article can be found
|
121 |
04c7a71a
|
m.geoffroy
|
* @param series the string representing the series (within the
|
122 |
|
|
* journal) in which <i>this</i> article has been
|
123 |
|
|
* published
|
124 |
|
|
* @param volume the string representing the volume of the journal
|
125 |
|
|
* in which <i>this</i> article has been published
|
126 |
|
|
* @param datePublished the date (time period) in which <i>this</i>
|
127 |
|
|
* article has been published
|
128 |
|
|
* @see #NewInstance()
|
129 |
|
|
* @see Journal
|
130 |
5fea4b1e
|
m.geoffroy
|
* @see TeamOrPersonBase
|
131 |
|
|
* @see TimePeriod
|
132 |
|
|
* @see eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy
|
133 |
04c7a71a
|
m.geoffroy
|
*/
|
134 |
3a5aa8ca
|
Andreas Müller
|
public static Article NewInstance(Journal inJournal, TeamOrPersonBase authorTeam, String articleTitle, String pages, String series, String volume, TimePeriod datePublished ){
|
135 |
788ff862
|
Andreas Müller
|
Article result = new Article();
|
136 |
|
|
result.setInJournal(inJournal);
|
137 |
|
|
result.setTitle(articleTitle);
|
138 |
|
|
result.setPages(pages);
|
139 |
|
|
result.setAuthorTeam(authorTeam);
|
140 |
|
|
result.setSeries(series);
|
141 |
|
|
result.setDatePublished(datePublished);
|
142 |
3a5aa8ca
|
Andreas Müller
|
result.setVolume(volume);
|
143 |
788ff862
|
Andreas Müller
|
return result;
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
|
147 |
9479da48
|
Andreas Müller
|
|
148 |
04c7a71a
|
m.geoffroy
|
/**
|
149 |
474cf8da
|
m.geoffroy
|
* Returns the {@link Journal journal} in which <i>this</i> article has been published.
|
150 |
04c7a71a
|
m.geoffroy
|
*
|
151 |
|
|
* @return the journal
|
152 |
|
|
* @see Journal
|
153 |
|
|
*/
|
154 |
ece46ca8
|
Andreas Kohlbecker
|
@Transient
|
155 |
9479da48
|
Andreas Müller
|
public Journal getInJournal(){
|
156 |
2c7d2d0a
|
Andreas Müller
|
if (inReference == null){
|
157 |
|
|
return null;
|
158 |
|
|
}
|
159 |
1b95b0ef
|
Andreas Müller
|
if (! this.inReference.isInstanceOf(Journal.class)){
|
160 |
|
|
throw new IllegalStateException("The in-reference of an article may only be of type Journal");
|
161 |
|
|
}
|
162 |
|
|
return CdmBase.deproxy(this.inReference,Journal.class);
|
163 |
9479da48
|
Andreas Müller
|
}
|
164 |
ee91bcd9
|
ben.clark
|
|
165 |
04c7a71a
|
m.geoffroy
|
/**
|
166 |
|
|
* @see #getInJournal()
|
167 |
|
|
*/
|
168 |
9479da48
|
Andreas Müller
|
public void setInJournal(Journal inJournal){
|
169 |
57606ee3
|
Andreas Müller
|
this.inReference = inJournal;
|
170 |
9479da48
|
Andreas Müller
|
}
|
171 |
|
|
|
172 |
04c7a71a
|
m.geoffroy
|
/**
|
173 |
|
|
* Returns the string representing the series (within the journal) in which
|
174 |
|
|
* <i>this</i> article was published.
|
175 |
|
|
*
|
176 |
|
|
* @return the string identifying the series
|
177 |
|
|
*/
|
178 |
9479da48
|
Andreas Müller
|
public String getSeries(){
|
179 |
|
|
return this.series;
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
/**
|
183 |
04c7a71a
|
m.geoffroy
|
* @see #getSeries()
|
184 |
45528416
|
Katja Luther
|
*//*
|
185 |
9479da48
|
Andreas Müller
|
public void setSeries(String series){
|
186 |
|
|
this.series = series;
|
187 |
|
|
}
|
188 |
|
|
|
189 |
04c7a71a
|
m.geoffroy
|
/**
|
190 |
|
|
* Returns the string representing the volume of the journal in which
|
191 |
|
|
* <i>this</i> article was published.
|
192 |
|
|
*
|
193 |
|
|
* @return the string identifying the series
|
194 |
|
|
*/
|
195 |
9479da48
|
Andreas Müller
|
public String getVolume(){
|
196 |
|
|
return this.volume;
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
/**
|
200 |
04c7a71a
|
m.geoffroy
|
* @see #getVolume()
|
201 |
9479da48
|
Andreas Müller
|
*/
|
202 |
|
|
public void setVolume(String volume){
|
203 |
|
|
this.volume = volume;
|
204 |
|
|
}
|
205 |
|
|
|
206 |
04c7a71a
|
m.geoffroy
|
/**
|
207 |
|
|
* Returns the string representing the page(s) where the content of
|
208 |
33fe95bf
|
m.geoffroy
|
* <i>this</i> article is located within the journal issue.
|
209 |
04c7a71a
|
m.geoffroy
|
*
|
210 |
|
|
* @return the string with the pages corresponding to <i>this</i> article
|
211 |
|
|
*/
|
212 |
9479da48
|
Andreas Müller
|
public String getPages(){
|
213 |
|
|
return this.pages;
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
/**
|
217 |
7ba2b731
|
m.geoffroy
|
* @see #getPages()
|
218 |
9479da48
|
Andreas Müller
|
*/
|
219 |
|
|
public void setPages(String pages){
|
220 |
|
|
this.pages = pages;
|
221 |
|
|
}
|
222 |
|
|
|
223 |
788ff862
|
Andreas Müller
|
|
224 |
04c7a71a
|
m.geoffroy
|
/**
|
225 |
|
|
* Returns a formatted string containing the entire reference citation,
|
226 |
|
|
* including authors, title, journal, pages, corresponding to <i>this</i>
|
227 |
7ba2b731
|
m.geoffroy
|
* article.<BR>
|
228 |
5fea4b1e
|
m.geoffroy
|
* This method overrides the generic and inherited getCitation method
|
229 |
|
|
* from {@link StrictReferenceBase StrictReferenceBase}.
|
230 |
04c7a71a
|
m.geoffroy
|
*
|
231 |
5fea4b1e
|
m.geoffroy
|
* @see #getNomenclaturalCitation(String)
|
232 |
7ba2b731
|
m.geoffroy
|
* @see StrictReferenceBase#getCitation()
|
233 |
9479da48
|
Andreas Müller
|
*/
|
234 |
4208745a
|
ben.clark
|
// @Override
|
235 |
|
|
// @Transient
|
236 |
|
|
// public String getCitation(){
|
237 |
|
|
// return nomRefBase.getCitation();
|
238 |
|
|
// }
|
239 |
9479da48
|
Andreas Müller
|
|
240 |
04c7a71a
|
m.geoffroy
|
/**
|
241 |
|
|
* Returns a formatted string containing the entire citation used for
|
242 |
|
|
* nomenclatural purposes based on <i>this</i> article - including
|
243 |
1cfec1e9
|
m.geoffroy
|
* (abbreviated) title of the journal but not authors of the article -
|
244 |
04c7a71a
|
m.geoffroy
|
* and on the given details.
|
245 |
|
|
*
|
246 |
|
|
* @param microReference the string with the details (generally pages)
|
247 |
1cfec1e9
|
m.geoffroy
|
* within the journal
|
248 |
04c7a71a
|
m.geoffroy
|
* @return the formatted string representing the
|
249 |
|
|
* nomenclatural citation
|
250 |
5fea4b1e
|
m.geoffroy
|
*
|
251 |
|
|
* @see #getCitation()
|
252 |
9479da48
|
Andreas Müller
|
*/
|
253 |
b70a7f94
|
Andreas Kohlbecker
|
@Transient
|
254 |
bef42c31
|
Andreas Müller
|
public String getNomenclaturalCitation(String microReference) {
|
255 |
4208745a
|
ben.clark
|
if (cacheStrategy == null){
|
256 |
|
|
logger.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid());
|
257 |
|
|
return null;
|
258 |
|
|
}else{
|
259 |
|
|
return cacheStrategy.getNomenclaturalCitation(this,microReference);
|
260 |
|
|
}
|
261 |
9479da48
|
Andreas Müller
|
}
|
262 |
|
|
|
263 |
788ff862
|
Andreas Müller
|
|
264 |
04c7a71a
|
m.geoffroy
|
/**
|
265 |
5fea4b1e
|
m.geoffroy
|
* Generates, according to the {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}
|
266 |
04c7a71a
|
m.geoffroy
|
* assigned to <i>this</i> article, a string that identifies <i>this</i>
|
267 |
|
|
* article and returns it. This string may be stored in the inherited
|
268 |
5fea4b1e
|
m.geoffroy
|
* {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
|
269 |
|
|
* This method overrides the generic and inherited generateTitle method
|
270 |
|
|
* from {@link ReferenceBase ReferenceBase}.
|
271 |
04c7a71a
|
m.geoffroy
|
*
|
272 |
|
|
* @return the string identifying <i>this</i> article
|
273 |
|
|
* @see #getCitation()
|
274 |
5fea4b1e
|
m.geoffroy
|
* @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
|
275 |
|
|
* @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
|
276 |
788ff862
|
Andreas Müller
|
*/
|
277 |
4208745a
|
ben.clark
|
// @Override
|
278 |
|
|
// public String generateTitle(){
|
279 |
|
|
// return nomRefBase.generateTitle();
|
280 |
|
|
// }
|
281 |
835c12dd
|
Andreas Müller
|
|
282 |
|
|
|
283 |
|
|
|
284 |
45528416
|
Katja Luther
|
|
285 |
04c7a71a
|
m.geoffroy
|
/**
|
286 |
|
|
* Clones <i>this</i> article. This is a shortcut that enables to
|
287 |
|
|
* create a new instance that differs only slightly from <i>this</i> article
|
288 |
|
|
* by modifying only some of the attributes.<BR>
|
289 |
5fea4b1e
|
m.geoffroy
|
* This method overrides the clone method from {@link StrictReferenceBase StrictReferenceBase}.
|
290 |
04c7a71a
|
m.geoffroy
|
*
|
291 |
|
|
* @see StrictReferenceBase#clone()
|
292 |
dc776ce0
|
a.babadshanjan
|
* @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
|
293 |
04c7a71a
|
m.geoffroy
|
* @see java.lang.Object#clone()
|
294 |
835c12dd
|
Andreas Müller
|
*/
|
295 |
e1c9b32e
|
a.babadshanjan
|
@Override
|
296 |
835c12dd
|
Andreas Müller
|
public Article clone(){
|
297 |
|
|
Article result = (Article)super.clone();
|
298 |
4208745a
|
ben.clark
|
result.cacheStrategy = ArticleDefaultCacheStrategy.NewInstance();
|
299 |
04c7a71a
|
m.geoffroy
|
//no changes to: inJournal, pages, series, volume
|
300 |
835c12dd
|
Andreas Müller
|
return result;
|
301 |
|
|
}
|
302 |
|
|
|
303 |
9479da48
|
Andreas Müller
|
|
304 |
|
|
}
|