Project

General

Profile

Download (9.39 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
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
import javax.persistence.Entity;
14
import javax.persistence.Transient;
15
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

    
20
import org.apache.log4j.Logger;
21
import org.hibernate.envers.Audited;
22
import org.hibernate.search.annotations.Indexed;
23
import org.springframework.beans.factory.annotation.Configurable;
24

    
25
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
26
import eu.etaxonomy.cdm.model.common.CdmBase;
27
import eu.etaxonomy.cdm.model.common.TimePeriod;
28
import eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy;
29
import eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy;
30

    
31

    
32
/**
33
 * 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
 * <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
 * @author m.doering
45
 * @version 1.0
46
 * @created 08-Nov-2007 13:06:10
47
 */
48
@XmlAccessorType(XmlAccessType.FIELD)
49
@XmlType(name = "Article", propOrder = {
50
//		"volume",
51
//		"pages",
52
//		"series",
53
//		"inJournal"
54
})
55
@XmlRootElement(name = "Article")
56
@Entity
57
@Indexed(index = "eu.etaxonomy.cdm.model.reference.ReferenceBase")
58
@Audited
59
@Configurable
60
public class Article extends ReferenceBase<INomenclaturalReferenceCacheStrategy<Article>> implements INomenclaturalReference, IVolumeReference, Cloneable {
61
	private static final long serialVersionUID = -1528079480114388117L;
62
	private static final Logger logger = Logger.getLogger(Article.class);
63
	
64
//    @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

    
84

    
85
	/** 
86
	 * Class constructor: creates a new empty article instance
87
	 * only containing the {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}.
88
	 * 
89
	 * @see eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy
90
	 */
91
	protected Article(){
92
		super();
93
		this.type = ReferenceType.Article;
94
		this.cacheStrategy = ArticleDefaultCacheStrategy.NewInstance();
95
	}	
96
	
97
	/** 
98
	 * Creates a new empty article instance
99
	 * only containing the {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}.
100
	 * 
101
	 * @see #Article()
102
	 * @see #NewInstance(Journal, TeamOrPersonBase, String, String, String, String, TimePeriod)
103
	 * @see eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy
104
	 */
105
	public static Article NewInstance(){
106
		Article result = new Article();
107
		return result;
108
	}
109
	
110
	/** 
111
	 * Creates a new article instance with the given values and with the
112
	 * {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}.
113
	 * 
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
	 * 							issue where <i>this</i> article can be found  
121
	 * @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
	 * @see 					TeamOrPersonBase
131
	 * @see 					TimePeriod
132
	 * @see 					eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy
133
	 */
134
	public static Article NewInstance(Journal inJournal, TeamOrPersonBase authorTeam, String articleTitle, String pages, String series, String volume, TimePeriod datePublished ){
135
		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
		result.setVolume(volume);
143
		return result;
144
	}
145
	
146

    
147

    
148
	/**
149
	 * Returns the {@link Journal journal} in which <i>this</i> article has been published.
150
	 * 
151
	 * @return  the journal
152
	 * @see 	Journal
153
	 */
154
	@Transient
155
	public Journal getInJournal(){
156
		if (inReference == null){
157
			return null;
158
		}
159
		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
	}
164
	
165
	/**
166
	 * @see #getInJournal()
167
	 */
168
	public void setInJournal(Journal inJournal){
169
		this.inReference = inJournal;
170
	}
171

    
172
	/**
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
	public String getSeries(){
179
		return this.series;
180
	}
181

    
182
	/**
183
	 * @see #getSeries()
184
	 *//*
185
	public void setSeries(String series){
186
		this.series = series;
187
	}
188

    
189
	/**
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
	public String getVolume(){
196
		return this.volume;
197
	}
198

    
199
	/**
200
	 * @see #getVolume()
201
	 */
202
	public void setVolume(String volume){
203
		this.volume = volume;
204
	}
205

    
206
	/**
207
	 * Returns the string representing the page(s) where the content of
208
	 * <i>this</i> article is located within the journal issue.
209
	 * 
210
	 * @return  the string with the pages corresponding to <i>this</i> article
211
	 */
212
	public String getPages(){
213
		return this.pages;
214
	}
215

    
216
	/**
217
	 * @see #getPages()
218
	 */
219
	public void setPages(String pages){
220
		this.pages = pages;
221
	}
222

    
223

    
224
	/**
225
	 * Returns a formatted string containing the entire reference citation,
226
	 * including authors, title, journal, pages, corresponding to <i>this</i>
227
	 * article.<BR>
228
	 * This method overrides the generic and inherited getCitation method
229
	 * from {@link StrictReferenceBase StrictReferenceBase}.
230
	 * 
231
	 * @see  #getNomenclaturalCitation(String)
232
	 * @see  StrictReferenceBase#getCitation()
233
	 */
234
//	@Override
235
//	@Transient
236
//	public String getCitation(){
237
//		return nomRefBase.getCitation();
238
//	}
239

    
240
	/**
241
	 * Returns a formatted string containing the entire citation used for
242
	 * nomenclatural purposes based on <i>this</i> article - including
243
	 * (abbreviated) title of the journal but not authors of the article -
244
	 * and on the given details.
245
	 * 
246
	 * @param  microReference	the string with the details (generally pages)
247
	 * 							within the journal
248
	 * @return					the formatted string representing the
249
	 * 							nomenclatural citation
250
	 * 
251
	 * @see  					#getCitation()
252
	 */
253
	@Transient
254
	public String getNomenclaturalCitation(String microReference) {
255
		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
	}
262

    
263

    
264
	/**
265
	 * Generates, according to the {@link eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy default cache strategy}
266
	 * 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
	 * {@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
	 *
272
	 * @return  the string identifying <i>this</i> article
273
	 * @see  	#getCitation()
274
	 * @see  	eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
275
	 * @see  	eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
276
	 */
277
//	@Override
278
//	public String generateTitle(){
279
//		return nomRefBase.generateTitle();
280
//	}
281
	
282

    
283
	
284
	
285
	/** 
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
	 * This method overrides the clone method from {@link StrictReferenceBase StrictReferenceBase}.
290
	 * 
291
	 * @see StrictReferenceBase#clone()
292
	 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
293
	 * @see java.lang.Object#clone()
294
	 */
295
	@Override
296
	public Article clone(){
297
		Article result = (Article)super.clone();
298
		result.cacheStrategy = ArticleDefaultCacheStrategy.NewInstance();
299
		//no changes to: inJournal, pages, series, volume
300
		return result;
301
	}
302
	
303

    
304
}
(1-1/47)