Project

General

Profile

Download (14.7 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.name;
11

    
12

    
13
import javax.persistence.Entity;
14
import javax.xml.bind.annotation.XmlAccessType;
15
import javax.xml.bind.annotation.XmlAccessorType;
16
import javax.xml.bind.annotation.XmlElement;
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.Field;
23
import org.hibernate.search.annotations.Index;
24
import org.hibernate.search.annotations.Indexed;
25
import org.springframework.beans.factory.annotation.Configurable;
26

    
27
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
28
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
29
import eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy;
30
import eu.etaxonomy.cdm.strategy.parser.INonViralNameParser;
31
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
32

    
33
/**
34
 * The taxon name class for animals.
35
 * <P>
36
 * This class corresponds to: NameZoological according to the ABCD schema.
37
 * 
38
 * @author m.doering
39
 * @version 1.0
40
 * @created 08-Nov-2007 13:07:03
41
 * @see NonViralName
42
 */
43
@XmlAccessorType(XmlAccessType.FIELD)
44
@XmlType(name = "ZoologicalName", propOrder = {
45
    "breed",
46
    "publicationYear",
47
    "originalPublicationYear"
48
})
49
@XmlRootElement(name = "ZoologicalName")
50
@Entity
51
@Indexed(index = "eu.etaxonomy.cdm.model.name.TaxonNameBase")
52
@Audited
53
@Configurable
54
public class ZoologicalName extends NonViralName<ZoologicalName> {
55
	private static final long serialVersionUID = 845745609734814484L;
56
	@SuppressWarnings("unused")
57
	private static final Logger logger = Logger.getLogger(ZoologicalName.class);
58

    
59
	//Name of the breed of an animal
60
	@XmlElement(name = "Breed")
61
	@Field(index=Index.TOKENIZED)
62
	private String breed;
63
	
64
	@XmlElement(name = "PublicationYear")
65
	@Field(index=Index.UN_TOKENIZED)
66
	private Integer publicationYear;
67
	
68
	@XmlElement(name = "OriginalPublicationYear")
69
	@Field(index=Index.UN_TOKENIZED)
70
	private Integer originalPublicationYear;
71

    
72
	static private INonViralNameParser nameParser = new NonViralNameParserImpl();
73

    
74
	
75
	// ************* CONSTRUCTORS *************/	
76
	/** 
77
	 * Class constructor: creates a new zoological taxon name instance
78
	 * only containing the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
79
	 * 
80
	 * @see #ZoologicalName(Rank, HomotypicalGroup)
81
	 * @see #ZoologicalName(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
82
	 * @see eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
83
	 */
84
	protected ZoologicalName() {
85
		this.cacheStrategy = ZooNameDefaultCacheStrategy.NewInstance();
86
	}
87
	
88
	/** 
89
	 * Class constructor: creates a new zoological taxon name instance
90
	 * only containing its {@link Rank rank},
91
	 * its {@link HomotypicalGroup homotypical group} and
92
	 * the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
93
	 * The new zoological taxon name instance will be also added to the set of
94
	 * zoological taxon names belonging to the given homotypical group.
95
	 * 
96
	 * @param	rank  the rank to be assigned to <i>this</i> zoological taxon name
97
	 * @param	homotypicalGroup  the homotypical group to which <i>this</i> zoological taxon name belongs
98
	 * @see 	#ZoologicalName()
99
	 * @see 	#ZoologicalName(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
100
	 * @see 	eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
101
	 */
102
	protected ZoologicalName(Rank rank, HomotypicalGroup homotypicalGroup) {
103
		super(rank, homotypicalGroup);
104
		this.cacheStrategy = ZooNameDefaultCacheStrategy.NewInstance();
105
	}
106

    
107
	/** 
108
	 * Class constructor: creates a new zoological taxon name instance
109
	 * containing its {@link Rank rank},
110
	 * its {@link HomotypicalGroup homotypical group},
111
	 * its scientific name components, its {@link eu.etaxonomy.cdm.agent.TeamOrPersonBase author(team)},
112
	 * its {@link eu.etaxonomy.cdm.reference.INomenclaturalReference nomenclatural reference} and
113
	 * the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
114
	 * The new zoological taxon name instance will be also added to the set of
115
	 * zoological taxon names belonging to the given homotypical group.
116
	 * 
117
	 * @param	rank  the rank to be assigned to <i>this</i> zoological taxon name
118
	 * @param	genusOrUninomial the string for <i>this</i> zoological taxon name
119
	 * 			if its rank is genus or higher or for the genus part
120
	 * 			if its rank is lower than genus
121
	 * @param	infraGenericEpithet  the string for the first epithet of
122
	 * 			<i>this</i> zoological taxon name if its rank is lower than genus
123
	 * 			and higher than species aggregate
124
	 * @param	specificEpithet  the string for the first epithet of
125
	 * 			<i>this</i> zoological taxon name if its rank is species aggregate or lower
126
	 * @param	infraSpecificEpithet  the string for the second epithet of
127
	 * 			<i>this</i> zoological taxon name if its rank is lower than species
128
	 * @param	combinationAuthorTeam  the author or the team who published <i>this</i> zoological taxon name
129
	 * @param	nomenclaturalReference  the nomenclatural reference where <i>this</i> zoological taxon name was published
130
	 * @param	nomenclMicroRef  the string with the details for precise location within the nomenclatural reference
131
	 * @param	homotypicalGroup  the homotypical group to which <i>this</i> zoological taxon name belongs
132
	 * @see 	#ZoologicalName()
133
	 * @see 	#ZoologicalName(Rank, HomotypicalGroup)
134
	 * @see		#NewInstance(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
135
	 * @see 	eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
136
	 * @see 	eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
137
	 * @see 	eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
138
	 */
139
	protected ZoologicalName (Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
140
		super(rank, genusOrUninomial, infraGenericEpithet, specificEpithet, infraSpecificEpithet, combinationAuthorTeam, nomenclaturalReference, nomenclMicroRef, homotypicalGroup);
141
		this.cacheStrategy = ZooNameDefaultCacheStrategy.NewInstance();
142
	}
143
	
144
	
145
	//********* METHODS **************************************/
146
	
147
	/** 
148
	 * Creates a new zoological taxon name instance
149
	 * only containing its {@link Rank rank} and
150
	 * the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
151
	 * 
152
	 * @param	rank	the rank to be assigned to <i>this</i> zoological taxon name
153
	 * @see 			#ZoologicalName(Rank, HomotypicalGroup)
154
	 * @see 			#NewInstance(Rank, HomotypicalGroup)
155
	 * @see 			#NewInstance(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
156
	 * @see 			eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
157
	 */
158
	public static ZoologicalName NewInstance(Rank rank){
159
		return new ZoologicalName(rank, null);
160
	}
161

    
162
	/** 
163
	 * Creates a new zoological taxon name instance
164
	 * only containing its {@link Rank rank},
165
	 * its {@link HomotypicalGroup homotypical group} and 
166
 	 * the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
167
	 * The new zoological taxon name instance will be also added to the set of
168
	 * zoological taxon names belonging to the given homotypical group.
169
	 * 
170
	 * @param  rank  the rank to be assigned to <i>this</i> zoological taxon name
171
	 * @param  homotypicalGroup  the homotypical group to which <i>this</i> zoological taxon name belongs
172
	 * @see    #NewInstance(Rank)
173
	 * @see    #NewInstance(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
174
	 * @see    #ZoologicalName(Rank, HomotypicalGroup)
175
	 * @see    eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
176
	 */
177
	public static ZoologicalName NewInstance(Rank rank, HomotypicalGroup homotypicalGroup){
178
		return new ZoologicalName(rank, homotypicalGroup);
179
	}
180
	/** 
181
	 * Creates a new zoological taxon name instance
182
	 * containing its {@link Rank rank},
183
	 * its {@link HomotypicalGroup homotypical group},
184
	 * its scientific name components, its {@link eu.etaxonomy.cdm.agent.TeamOrPersonBase author(team)},
185
	 * its {@link eu.etaxonomy.cdm.reference.INomenclaturalReference nomenclatural reference} and
186
	 * the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
187
	 * The new zoological taxon name instance will be also added to the set of
188
	 * zoological taxon names belonging to the given homotypical group.
189
	 * 
190
	 * @param	rank  the rank to be assigned to <i>this</i> zoological taxon name
191
	 * @param	genusOrUninomial the string for <i>this</i> zoological taxon name
192
	 * 			if its rank is genus or higher or for the genus part
193
	 * 			if its rank is lower than genus
194
	 * @param	infraGenericEpithet  the string for the first epithet of
195
	 * 			<i>this</i> zoological taxon name if its rank is lower than genus
196
	 * 			and higher than species aggregate
197
	 * @param	specificEpithet  the string for the first epithet of
198
	 * 			<i>this</i> zoological taxon name if its rank is species aggregate or lower
199
	 * @param	infraSpecificEpithet  the string for the second epithet of
200
	 * 			<i>this</i> zoological taxon name if its rank is lower than species
201
	 * @param	combinationAuthorTeam  the author or the team who published <i>this</i> zoological taxon name
202
	 * @param	nomenclaturalReference  the nomenclatural reference where <i>this</i> zoological taxon name was published
203
	 * @param	nomenclMicroRef  the string with the details for precise location within the nomenclatural reference
204
	 * @param	homotypicalGroup  the homotypical group to which <i>this</i> zoological taxon name belongs
205
	 * @see 	#NewInstance(Rank)
206
	 * @see 	#NewInstance(Rank, HomotypicalGroup)
207
	 * @see		#ZoologicalName(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
208
	 * @see 	eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
209
	 */
210
	public static ZoologicalName NewInstance(Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
211
		return new ZoologicalName(rank, genusOrUninomial, infraGenericEpithet, specificEpithet, infraSpecificEpithet, combinationAuthorTeam, nomenclaturalReference, nomenclMicroRef, homotypicalGroup);
212
	}	
213
	
214
	
215
	/**
216
	 * Returns a zoological taxon name based on parsing a string representing
217
	 * all elements (according to the {@link NomenclaturalCode#ICZN() ICZN}) of a zoological taxon name (where
218
	 * the scientific name is an uninomial) including authorship but without
219
	 * nomenclatural reference.
220
	 * 
221
	 * @param	fullNameString  the string to be parsed 
222
	 * @return					the new zoological taxon name
223
	 */
224
	public static ZoologicalName PARSED_NAME(String fullNameString){
225
		return PARSED_NAME(fullNameString, Rank.GENUS());
226
	}
227
	
228
	/**
229
	 * Returns a zoological taxon name based on parsing a string representing
230
	 * all elements (according to the {@link NomenclaturalCode#ICZN() ICZN})) of a zoological taxon name including
231
	 * authorship but without nomenclatural reference. The parsing result
232
	 * depends on the given rank of the zoological taxon name to be created.
233
	 * 
234
	 * @param 	fullNameString  the string to be parsed 
235
	 * @param   rank			the rank of the taxon name
236
	 * @return					the new zoological taxon name
237
	 */
238
	public static ZoologicalName PARSED_NAME(String fullNameString, Rank rank){
239
		if (nameParser == null){
240
			nameParser  = new NonViralNameParserImpl();
241
		}
242
		return (ZoologicalName)nameParser.parseFullName(fullNameString, NomenclaturalCode.ICZN, rank);
243
	}
244
	
245
	/**
246
	 * Returns the {@link NomenclaturalCode nomenclatural code} that governs
247
	 * the construction of <i>this</i> zoological taxon name, that is the
248
	 * International Code of Zoological Nomenclature. This method overrides
249
	 * the getNomeclaturalCode method from {@link NonViralName NonViralName}.
250
	 *
251
	 * @return  the nomenclatural code for animals
252
	 * @see  	NonViralName#isCodeCompliant()
253
	 * @see  	NonViralName#getNomenclaturalCode()
254
	 * @see  	TaxonNameBase#getHasProblem()
255
	 */
256
	@Override
257
	public NomenclaturalCode getNomenclaturalCode(){
258
		return NomenclaturalCode.ICZN;
259
	}
260
	
261
/* ***************** GETTER / SETTER ***************************/
262
	
263
	/**
264
	 * Returns the breed name string for <i>this</i> animal (zoological taxon name).
265
	 * 
266
	 * @return  the string containing the breed name for <i>this</i> zoological taxon name
267
	 */
268
	public String getBreed(){
269
		return this.breed;
270
	}
271
	/**
272
	 * @see  #getBreed()
273
	 */
274
	public void setBreed(String breed){
275
		this.breed = breed;
276
	}
277

    
278
	/**
279
	 * Returns the publication year (as an integer) for <i>this</i> zoological taxon
280
	 * name. If the publicationYear attribute is null and a nomenclatural
281
	 * reference exists the year could be computed from the
282
	 * {@link eu.etaxonomy.cdm.reference.INomenclaturalReference nomenclatural reference}.
283
	 * 
284
	 * @return  the integer representing the publication year for <i>this</i> zoological taxon name
285
	 * @see  	#getOriginalPublicationYear()
286
	 */
287
	public Integer getPublicationYear() {
288
		return publicationYear;
289
	}
290
	/**
291
	 * @see  #getPublicationYear()
292
	 */
293
	public void setPublicationYear(Integer publicationYear) {
294
		this.publicationYear = publicationYear;
295
	}
296

    
297
	/**
298
	 * Returns the publication year (as an integer) of the original validly
299
	 * published species epithet for <i>this</i> zoological taxon name. This only
300
	 * applies for zoological taxon names that are no {@link TaxonNameBase#isOriginalCombination() original combinations}.
301
	 * If the originalPublicationYear attribute is null the year could be taken
302
	 * from the publication year of the corresponding original name (basionym)
303
	 * or from the {@link eu.etaxonomy.cdm.reference.INomenclaturalReference nomenclatural reference} of the basionym
304
	 * if it exists.
305
	 * 
306
	 * @return  the integer representing the publication year of the original
307
	 * 			species epithet corresponding to <i>this</i> zoological taxon name
308
	 * @see  	#getPublicationYear()
309
	 */
310
	public Integer getOriginalPublicationYear() {
311
		return originalPublicationYear;
312
	}
313
	/**
314
	 * @see  #getOriginalPublicationYear()
315
	 */
316
	public void setOriginalPublicationYear(Integer originalPublicationYear) {
317
		this.originalPublicationYear = originalPublicationYear;
318
	}
319
}
(23-23/25)