(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / ZoologicalName.java
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.persistence.Transient;
15
16 import org.apache.log4j.Logger;
17
18 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
19 import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
20 import eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy;
21 import eu.etaxonomy.cdm.strategy.parser.INonViralNameParser;
22 import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
23
24 import javax.xml.bind.annotation.XmlAccessType;
25 import javax.xml.bind.annotation.XmlAccessorType;
26 import javax.xml.bind.annotation.XmlElement;
27 import javax.xml.bind.annotation.XmlRootElement;
28 import javax.xml.bind.annotation.XmlType;
29
30 /**
31 * The taxon name class for animals.
32 *
33 * @author m.doering
34 * @version 1.0
35 * @created 08-Nov-2007 13:07:03
36 * @see NonViralName
37 */
38 @XmlAccessorType(XmlAccessType.FIELD)
39 @XmlType(name = "ZoologicalName", propOrder = {
40 "breed",
41 "publicationYear",
42 "originalPublicationYear"
43 })
44 @XmlRootElement(name = "ZoologicalName")
45 @Entity
46 public class ZoologicalName extends NonViralName {
47
48 static Logger logger = Logger.getLogger(ZoologicalName.class);
49
50 //Name of the breed of an animal
51 @XmlElement(name = "Breed")
52 private String breed;
53
54 @XmlElement(name = "PublicationYear")
55 private Integer publicationYear;
56
57 @XmlElement(name = "OriginalPublicationYear")
58 private Integer originalPublicationYear;
59
60 static private INonViralNameParser nameParser = new NonViralNameParserImpl();
61
62
63 // ************* CONSTRUCTORS *************/
64 /**
65 * Class constructor: creates a new zoological taxon name instance
66 * only containing the {@link eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy default cache strategy}.
67 *
68 * @see #ZoologicalName(Rank, HomotypicalGroup)
69 * @see #ZoologicalName(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
70 * @see eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy
71 */
72 protected ZoologicalName() {
73 this.cacheStrategy = ZooNameDefaultCacheStrategy.NewInstance();
74 }
75
76 /**
77 * Class constructor: creates a new zoological taxon name instance
78 * only containing its {@link common.Rank rank},
79 * its {@link HomotypicalGroup homotypical group} and
80 * the {@link eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy default cache strategy}.
81 * The new zoological taxon name instance will be also added to the set of
82 * zoological taxon names belonging to this homotypical group.
83 *
84 * @param rank the rank to be assigned to this zoological taxon name
85 * @param homotypicalGroup the homotypical group to which this zoological taxon name belongs
86 * @see #ZoologicalName()
87 * @see #ZoologicalName(Rank, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
88 * @see eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy
89 */
90 protected ZoologicalName(Rank rank, HomotypicalGroup homotypicalGroup) {
91 super(rank, homotypicalGroup);
92 this.cacheStrategy = ZooNameDefaultCacheStrategy.NewInstance();
93 }
94
95 /**
96 * Class constructor: creates a new zoological taxon name instance
97 * containing its {@link common.Rank rank},
98 * its {@link HomotypicalGroup homotypical group},
99 * its scientific name components, its {@link agent.TeamOrPersonBase author(team)},
100 * its {@link reference.INomenclaturalReference nomenclatural reference} and
101 * the {@link eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy default cache strategy}.
102 * The new zoological taxon name instance will be also added to the set of
103 * zoological taxon names belonging to this homotypical group.
104 *
105 * @param rank the rank to be assigned to this zoological taxon name
106 * @param genusOrUninomial the string for this zoological taxon name
107 * if its rank is genus or higher or for the genus part
108 * if its rank is lower than genus
109 * @param infraGenericEpithet the string for the first epithet of
110 * this zoological taxon name if its rank is lower than genus
111 * and higher than species aggregate
112 * @param specificEpithet the string for the first epithet of
113 * this zoological taxon name if its rank is species aggregate or lower
114 * @param infraSpecificEpithet the string for the second epithet of
115 * this zoological taxon name if its rank is lower than species
116 * @param combinationAuthorTeam the author or the team who published this zoological taxon name
117 * @param nomenclaturalReference the nomenclatural reference where this zoological taxon name was published
118 * @param nomenclMicroRef the string with the details for precise location within the nomenclatural reference
119 * @param homotypicalGroup the homotypical group to which this zoological taxon name belongs
120 * @see #ZoologicalName()
121 * @see #ZoologicalName(Rank, HomotypicalGroup)
122 * @see #NewInstance(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
123 * @see eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy
124 * @see eu.etaxonomy.cdm.strategy.cache.INonViralNameCacheStrategy
125 * @see eu.etaxonomy.cdm.strategy.cache.IIdentifiableEntityCacheStrategy
126 */
127 protected ZoologicalName (Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
128 super(rank, genusOrUninomial, infraGenericEpithet, specificEpithet, infraSpecificEpithet, combinationAuthorTeam, nomenclaturalReference, nomenclMicroRef, homotypicalGroup);
129 this.cacheStrategy = ZooNameDefaultCacheStrategy.NewInstance();
130 }
131
132
133 //********* METHODS **************************************/
134
135 /**
136 * Creates a new zoological taxon name instance
137 * only containing its {@link common.Rank rank} and
138 * the {@link eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy default cache strategy}.
139 *
140 * @param rank the rank to be assigned to this zoological taxon name
141 * @see #ZoologicalName(Rank, HomotypicalGroup)
142 * @see #NewInstance(Rank, HomotypicalGroup)
143 * @see #NewInstance(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
144 * @see eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy
145 */
146 public static ZoologicalName NewInstance(Rank rank){
147 return new ZoologicalName(rank, null);
148 }
149
150 /**
151 * Creates a new zoological taxon name instance
152 * only containing its {@link common.Rank rank},
153 * its {@link HomotypicalGroup homotypical group} and
154 * the {@link eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy default cache strategy}.
155 * The new zoological taxon name instance will be also added to the set of
156 * zoological taxon names belonging to this homotypical group.
157 *
158 * @param rank the rank to be assigned to this zoological taxon name
159 * @param homotypicalGroup the homotypical group to which this zoological taxon name belongs
160 * @see #NewInstance(Rank)
161 * @see #NewInstance(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
162 * @see #ZoologicalName(Rank, HomotypicalGroup)
163 * @see eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy
164 */
165 public static ZoologicalName NewInstance(Rank rank, HomotypicalGroup homotypicalGroup){
166 return new ZoologicalName(rank, homotypicalGroup);
167 }
168 /**
169 * Creates a new zoological taxon name instance
170 * containing its {@link common.Rank rank},
171 * its {@link HomotypicalGroup homotypical group},
172 * its scientific name components, its {@link agent.TeamOrPersonBase author(team)},
173 * its {@link reference.INomenclaturalReference nomenclatural reference} and
174 * the {@link eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy default cache strategy}.
175 * The new zoological taxon name instance will be also added to the set of
176 * zoological taxon names belonging to this homotypical group.
177 *
178 * @param rank the rank to be assigned to this zoological taxon name
179 * @param genusOrUninomial the string for this zoological taxon name
180 * if its rank is genus or higher or for the genus part
181 * if its rank is lower than genus
182 * @param infraGenericEpithet the string for the first epithet of
183 * this zoological taxon name if its rank is lower than genus
184 * and higher than species aggregate
185 * @param specificEpithet the string for the first epithet of
186 * this zoological taxon name if its rank is species aggregate or lower
187 * @param infraSpecificEpithet the string for the second epithet of
188 * this zoological taxon name if its rank is lower than species
189 * @param combinationAuthorTeam the author or the team who published this zoological taxon name
190 * @param nomenclaturalReference the nomenclatural reference where this zoological taxon name was published
191 * @param nomenclMicroRef the string with the details for precise location within the nomenclatural reference
192 * @param homotypicalGroup the homotypical group to which this zoological taxon name belongs
193 * @see #NewInstance(Rank)
194 * @see #NewInstance(Rank, HomotypicalGroup)
195 * @see #ZoologicalName(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
196 * @see eu.etaxonomy.cdm.strategy.cache.ZooNameDefaultCacheStrategy
197 */
198 public static ZoologicalName NewInstance(Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
199 return new ZoologicalName(rank, genusOrUninomial, infraGenericEpithet, specificEpithet, infraSpecificEpithet, combinationAuthorTeam, nomenclaturalReference, nomenclMicroRef, homotypicalGroup);
200 }
201
202
203 /**
204 * Returns a zoological taxon name based on parsing a string representing
205 * all elements (according to the ICZN) of a zoological taxon name (where
206 * the scientific name is an uninomial) including authorship but without
207 * nomenclatural reference.
208 *
209 * @param fullNameString the string to be parsed
210 * @return the new zoological taxon name
211 */
212 public static ZoologicalName PARSED_NAME(String fullNameString){
213 return PARSED_NAME(fullNameString, Rank.GENUS());
214 }
215
216 /**
217 * Returns a zoological taxon name based on parsing a string representing
218 * all elements (according to the ICZN) of a zoological taxon name including
219 * authorship but without nomenclatural reference. The parsing result
220 * depends on the given rank of the zoological taxon name to be created.
221 *
222 * @param fullNameString the string to be parsed
223 * @param rank the rank of the taxon name
224 * @return the new zoological taxon name
225 */
226 public static ZoologicalName PARSED_NAME(String fullNameString, Rank rank){
227 if (nameParser == null){
228 nameParser = new NonViralNameParserImpl();
229 }
230 return (ZoologicalName)nameParser.parseFullName(fullNameString, NomenclaturalCode.ICZN(), rank);
231 }
232
233 /**
234 * Returns the {@link NomenclaturalCode nomenclatural code} that governs
235 * the construction of this zoological taxon name, that is the
236 * International Code of Zoological Nomenclature. This method overrides
237 * the getNomeclaturalCode method from {@link NonViralName#getNomeclaturalCode() NonViralName}.
238 *
239 * @return the nomenclatural code for animals
240 * @see NonViralName#isCodeCompliant()
241 * @see TaxonNameBase#getHasProblem()
242 */
243 @Transient
244 @Override
245 public NomenclaturalCode getNomenclaturalCode(){
246 return NomenclaturalCode.ICZN();
247 }
248
249 /* ***************** GETTER / SETTER ***************************/
250
251 /**
252 * Returns the breed name string for this animal (zoological taxon name).
253 *
254 * @return the string containing the breed name for this zoological taxon name
255 */
256 public String getBreed(){
257 return this.breed;
258 }
259 /**
260 * @see #getBreed()
261 */
262 public void setBreed(String breed){
263 this.breed = breed;
264 }
265
266 /**
267 * Returns the publication year (as an integer) for this zoological taxon
268 * name. If the publicationYear attribute is null and a nomenclatural
269 * reference exists the year could be computed from the
270 * {@link reference.INomenclaturalReference#getYear() nomenclatural reference}.
271 *
272 * @return the integer representing the publication year for this zoological taxon name
273 * @see #getOriginalPublicationYear()
274 */
275 public Integer getPublicationYear() {
276 return publicationYear;
277 }
278 /**
279 * @see #getPublicationYear()
280 */
281 public void setPublicationYear(Integer publicationYear) {
282 this.publicationYear = publicationYear;
283 }
284
285 /**
286 * Returns the publication year (as an integer) of the original validly
287 * published species epithet for this zoological taxon name. This only
288 * applies for zoological taxon names that are no {@link TaxonNameBase#isOriginalCombination() original combinations}.
289 * If the originalPublicationYear attribute is null the year could be taken
290 * from the publication year of the corresponding original name (basionym)
291 * or from the {@link reference.INomenclaturalReference#getYear() nomenclatural reference} of the basionym
292 * if it exists.
293 *
294 * @return the integer representing the publication year of the original
295 * species epithet corresponding to this zoological taxon name
296 * @see #getPublicationYear()
297 */
298 public Integer getOriginalPublicationYear() {
299 return originalPublicationYear;
300 }
301 /**
302 * @see #getOriginalPublicationYear()
303 */
304 public void setOriginalPublicationYear(Integer originalPublicationYear) {
305 this.originalPublicationYear = originalPublicationYear;
306 }
307 }