root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/ZoologicalName.java

Revision 12582, 16.1 kB (checked in by a.mueller, 10 months ago)

remove unimplemented valueOf methods

  • Property svn:keywords set to Id
Line 
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
10package eu.etaxonomy.cdm.model.name;
11
12
13import java.util.Map;
14
15import javax.persistence.Entity;
16import javax.validation.constraints.Min;
17import javax.xml.bind.annotation.XmlAccessType;
18import javax.xml.bind.annotation.XmlAccessorType;
19import javax.xml.bind.annotation.XmlElement;
20import javax.xml.bind.annotation.XmlRootElement;
21import javax.xml.bind.annotation.XmlType;
22
23import org.apache.log4j.Logger;
24import org.hibernate.envers.Audited;
25import org.hibernate.search.annotations.Field;
26import org.hibernate.search.annotations.Index;
27import org.hibernate.search.annotations.Indexed;
28import org.hibernate.validator.constraints.Length;
29import org.springframework.beans.factory.annotation.Configurable;
30
31import eu.etaxonomy.cdm.common.CdmUtils;
32import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
33import eu.etaxonomy.cdm.model.common.CdmBase;
34import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
35import eu.etaxonomy.cdm.strategy.cache.name.CacheUpdate;
36import eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy;
37import eu.etaxonomy.cdm.strategy.parser.INonViralNameParser;
38import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
39import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
40
41/**
42 * The taxon name class for animals.
43 * <P>
44 * This class corresponds to: NameZoological according to the ABCD schema.
45 *
46 * @author m.doering
47 * @version 1.0
48 * @created 08-Nov-2007 13:07:03
49 * @see NonViralName
50 */
51@XmlAccessorType(XmlAccessType.FIELD)
52@XmlType(name = "ZoologicalName", propOrder = {
53    "breed",
54    "publicationYear",
55    "originalPublicationYear"
56})
57@XmlRootElement(name = "ZoologicalName")
58@Entity
59@Indexed(index = "eu.etaxonomy.cdm.model.name.TaxonNameBase")
60@Audited
61@Configurable
62public class ZoologicalName extends NonViralName<ZoologicalName> implements Cloneable{
63        private static final long serialVersionUID = 845745609734814484L;
64        @SuppressWarnings("unused")
65        private static final Logger logger = Logger.getLogger(ZoologicalName.class);
66
67        //Name of the breed of an animal
68        @XmlElement(name = "Breed")
69        @Field(index=Index.TOKENIZED)
70        @NullOrNotEmpty
71        @Length(max = 255)
72        private String breed;
73       
74        @XmlElement(name = "PublicationYear")
75        @Field(index=Index.UN_TOKENIZED)
76        @CacheUpdate(value ="authorshipCache")
77        @Min(0)
78    private Integer publicationYear;
79       
80        @XmlElement(name = "OriginalPublicationYear")
81        @Field(index=Index.UN_TOKENIZED)
82        @CacheUpdate(value ="authorshipCache")
83        @Min(0)
84    private Integer originalPublicationYear;
85
86        static private INonViralNameParser nameParser = new NonViralNameParserImpl();
87
88       
89        // ************* CONSTRUCTORS *************/   
90        /**
91         * Class constructor: creates a new zoological taxon name instance
92         * only containing the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
93         *
94         * @see #ZoologicalName(Rank, HomotypicalGroup)
95         * @see #ZoologicalName(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
96         * @see eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
97         */
98        protected ZoologicalName() {
99                this.cacheStrategy = ZooNameDefaultCacheStrategy.NewInstance();
100        }
101       
102        /**
103         * Class constructor: creates a new zoological taxon name instance
104         * only containing its {@link Rank rank},
105         * its {@link HomotypicalGroup homotypical group} and
106         * the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
107         * The new zoological taxon name instance will be also added to the set of
108         * zoological taxon names belonging to the given homotypical group.
109         *
110         * @param       rank  the rank to be assigned to <i>this</i> zoological taxon name
111         * @param       homotypicalGroup  the homotypical group to which <i>this</i> zoological taxon name belongs
112         * @see         #ZoologicalName()
113         * @see         #ZoologicalName(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
114         * @see         eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
115         */
116        protected ZoologicalName(Rank rank, HomotypicalGroup homotypicalGroup) {
117                super(rank, homotypicalGroup);
118                this.cacheStrategy = ZooNameDefaultCacheStrategy.NewInstance();
119        }
120
121        /**
122         * Class constructor: creates a new zoological taxon name instance
123         * containing its {@link Rank rank},
124         * its {@link HomotypicalGroup homotypical group},
125         * its scientific name components, its {@link eu.etaxonomy.cdm.agent.TeamOrPersonBase author(team)},
126         * its {@link eu.etaxonomy.cdm.reference.INomenclaturalReference nomenclatural reference} and
127         * the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
128         * The new zoological taxon name instance will be also added to the set of
129         * zoological taxon names belonging to the given homotypical group.
130         *
131         * @param       rank  the rank to be assigned to <i>this</i> zoological taxon name
132         * @param       genusOrUninomial the string for <i>this</i> zoological taxon name
133         *                      if its rank is genus or higher or for the genus part
134         *                      if its rank is lower than genus
135         * @param       infraGenericEpithet  the string for the first epithet of
136         *                      <i>this</i> zoological taxon name if its rank is lower than genus
137         *                      and higher than species aggregate
138         * @param       specificEpithet  the string for the first epithet of
139         *                      <i>this</i> zoological taxon name if its rank is species aggregate or lower
140         * @param       infraSpecificEpithet  the string for the second epithet of
141         *                      <i>this</i> zoological taxon name if its rank is lower than species
142         * @param       combinationAuthorTeam  the author or the team who published <i>this</i> zoological taxon name
143         * @param       nomenclaturalReference  the nomenclatural reference where <i>this</i> zoological taxon name was published
144         * @param       nomenclMicroRef  the string with the details for precise location within the nomenclatural reference
145         * @param       homotypicalGroup  the homotypical group to which <i>this</i> zoological taxon name belongs
146         * @see         #ZoologicalName()
147         * @see         #ZoologicalName(Rank, HomotypicalGroup)
148         * @see         #NewInstance(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
149         * @see         eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
150         * @see         eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
151         * @see         eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
152         */
153        protected ZoologicalName (Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
154                super(rank, genusOrUninomial, infraGenericEpithet, specificEpithet, infraSpecificEpithet, combinationAuthorTeam, nomenclaturalReference, nomenclMicroRef, homotypicalGroup);
155                this.cacheStrategy = ZooNameDefaultCacheStrategy.NewInstance();
156        }
157       
158       
159        //********* METHODS **************************************/
160       
161        /**
162         * Creates a new zoological taxon name instance
163         * only containing its {@link Rank rank} and
164         * the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
165         *
166         * @param       rank    the rank to be assigned to <i>this</i> zoological taxon name
167         * @see                         #ZoologicalName(Rank, HomotypicalGroup)
168         * @see                         #NewInstance(Rank, HomotypicalGroup)
169         * @see                         #NewInstance(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
170         * @see                         eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
171         */
172        public static ZoologicalName NewInstance(Rank rank){
173                return new ZoologicalName(rank, null);
174        }
175
176        /**
177         * Creates a new zoological taxon name instance
178         * only containing its {@link Rank rank},
179         * its {@link HomotypicalGroup homotypical group} and
180         * the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
181         * The new zoological taxon name instance will be also added to the set of
182         * zoological taxon names belonging to the given homotypical group.
183         *
184         * @param  rank  the rank to be assigned to <i>this</i> zoological taxon name
185         * @param  homotypicalGroup  the homotypical group to which <i>this</i> zoological taxon name belongs
186         * @see    #NewInstance(Rank)
187         * @see    #NewInstance(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
188         * @see    #ZoologicalName(Rank, HomotypicalGroup)
189         * @see    eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
190         */
191        public static ZoologicalName NewInstance(Rank rank, HomotypicalGroup homotypicalGroup){
192                return new ZoologicalName(rank, homotypicalGroup);
193        }
194        /**
195         * Creates a new zoological taxon name instance
196         * containing its {@link Rank rank},
197         * its {@link HomotypicalGroup homotypical group},
198         * its scientific name components, its {@link eu.etaxonomy.cdm.agent.TeamOrPersonBase author(team)},
199         * its {@link eu.etaxonomy.cdm.reference.INomenclaturalReference nomenclatural reference} and
200         * the {@link eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy default cache strategy}.
201         * The new zoological taxon name instance will be also added to the set of
202         * zoological taxon names belonging to the given homotypical group.
203         *
204         * @param       rank  the rank to be assigned to <i>this</i> zoological taxon name
205         * @param       genusOrUninomial the string for <i>this</i> zoological taxon name
206         *                      if its rank is genus or higher or for the genus part
207         *                      if its rank is lower than genus
208         * @param       infraGenericEpithet  the string for the first epithet of
209         *                      <i>this</i> zoological taxon name if its rank is lower than genus
210         *                      and higher than species aggregate
211         * @param       specificEpithet  the string for the first epithet of
212         *                      <i>this</i> zoological taxon name if its rank is species aggregate or lower
213         * @param       infraSpecificEpithet  the string for the second epithet of
214         *                      <i>this</i> zoological taxon name if its rank is lower than species
215         * @param       combinationAuthorTeam  the author or the team who published <i>this</i> zoological taxon name
216         * @param       nomenclaturalReference  the nomenclatural reference where <i>this</i> zoological taxon name was published
217         * @param       nomenclMicroRef  the string with the details for precise location within the nomenclatural reference
218         * @param       homotypicalGroup  the homotypical group to which <i>this</i> zoological taxon name belongs
219         * @see         #NewInstance(Rank)
220         * @see         #NewInstance(Rank, HomotypicalGroup)
221         * @see         #ZoologicalName(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
222         * @see         eu.etaxonomy.cdm.strategy.cache.name.ZooNameDefaultCacheStrategy
223         */
224        public static ZoologicalName NewInstance(Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
225                return new ZoologicalName(rank, genusOrUninomial, infraGenericEpithet, specificEpithet, infraSpecificEpithet, combinationAuthorTeam, nomenclaturalReference, nomenclMicroRef, homotypicalGroup);
226        }       
227       
228       
229        /**
230         * Returns a zoological taxon name based on parsing a string representing
231         * all elements (according to the {@link NomenclaturalCode#ICZN() ICZN}) of a zoological taxon name (where
232         * the scientific name is an uninomial) including authorship but without
233         * nomenclatural reference.
234         *
235         * @param       fullNameString  the string to be parsed
236         * @return                                      the new zoological taxon name
237         */
238        public static ZoologicalName PARSED_NAME(String fullNameString){
239                return PARSED_NAME(fullNameString, Rank.GENUS());
240        }
241       
242        /**
243         * Returns a zoological taxon name based on parsing a string representing
244         * all elements (according to the {@link NomenclaturalCode#ICZN() ICZN})) of a zoological taxon name including
245         * authorship but without nomenclatural reference. The parsing result
246         * depends on the given rank of the zoological taxon name to be created.
247         *
248         * @param       fullNameString  the string to be parsed
249         * @param   rank                        the rank of the taxon name
250         * @return                                      the new zoological taxon name
251         */
252        public static ZoologicalName PARSED_NAME(String fullNameString, Rank rank){
253                if (nameParser == null){
254                        nameParser  = new NonViralNameParserImpl();
255                }
256                return (ZoologicalName)nameParser.parseFullName(fullNameString, NomenclaturalCode.ICZN, rank);
257        }
258       
259        /**
260         * Returns the {@link NomenclaturalCode nomenclatural code} that governs
261         * the construction of <i>this</i> zoological taxon name, that is the
262         * International Code of Zoological Nomenclature. This method overrides
263         * the getNomeclaturalCode method from {@link NonViralName NonViralName}.
264         *
265         * @return  the nomenclatural code for animals
266         * @see         NonViralName#isCodeCompliant()
267         * @see         NonViralName#getNomenclaturalCode()
268         * @see         TaxonNameBase#getHasProblem()
269         */
270        @Override
271        public NomenclaturalCode getNomenclaturalCode(){
272                return NomenclaturalCode.ICZN;
273        }
274       
275//*************** ***************************
276       
277        private static Map<String, java.lang.reflect.Field> allFields = null;
278        @Override
279    protected Map<String, java.lang.reflect.Field> getAllFields(){
280        if (allFields == null){
281                        allFields = CdmUtils.getAllFields(this.getClass(), CdmBase.class, false, false, false, true);
282                }
283        return allFields;
284    }
285       
286/* ***************** GETTER / SETTER ***************************/
287       
288       
289       
290        /**
291         * Returns the breed name string for <i>this</i> animal (zoological taxon name).
292         *
293         * @return  the string containing the breed name for <i>this</i> zoological taxon name
294         */
295        public String getBreed(){
296                return this.breed;
297        }
298        /**
299         * @see  #getBreed()
300         */
301        public void setBreed(String breed){
302                this.breed = breed;
303        }
304
305        /**
306         * Returns the publication year (as an integer) for <i>this</i> zoological taxon
307         * name. If the publicationYear attribute is null and a nomenclatural
308         * reference exists the year could be computed from the
309         * {@link eu.etaxonomy.cdm.reference.INomenclaturalReference nomenclatural reference}.
310         *
311         * @return  the integer representing the publication year for <i>this</i> zoological taxon name
312         * @see         #getOriginalPublicationYear()
313         */
314        public Integer getPublicationYear() {
315                return publicationYear;
316        }
317        /**
318         * @see  #getPublicationYear()
319         */
320        public void setPublicationYear(Integer publicationYear) {
321                this.publicationYear = publicationYear;
322        }
323
324        /**
325         * Returns the publication year (as an integer) of the original validly
326         * published species epithet for <i>this</i> zoological taxon name. This only
327         * applies for zoological taxon names that are no {@link TaxonNameBase#isOriginalCombination() original combinations}.
328         * If the originalPublicationYear attribute is null the year could be taken
329         * from the publication year of the corresponding original name (basionym)
330         * or from the {@link eu.etaxonomy.cdm.reference.INomenclaturalReference nomenclatural reference} of the basionym
331         * if it exists.
332         *
333         * @return  the integer representing the publication year of the original
334         *                      species epithet corresponding to <i>this</i> zoological taxon name
335         * @see         #getPublicationYear()
336         */
337        public Integer getOriginalPublicationYear() {
338                return originalPublicationYear;
339        }
340        /**
341         * @see  #getOriginalPublicationYear()
342         */
343        public void setOriginalPublicationYear(Integer originalPublicationYear) {
344                this.originalPublicationYear = originalPublicationYear;
345        }
346       
347       
348//*********************** CLONE ********************************************************/
349       
350        /**
351         * Clones <i>this</i> zoological name. This is a shortcut that enables to create
352         * a new instance that differs only slightly from <i>this</i> zoological name by
353         * modifying only some of the attributes.
354         *
355         * @see eu.etaxonomy.cdm.model.name.NonViralName#clone()
356         * @see java.lang.Object#clone()
357         */
358        @Override
359        public Object clone() {
360                ZoologicalName result = (ZoologicalName)super.clone();
361                //no changes to: breed, publicationYear, originalPublicationYear
362                return result;
363        }
364}
Note: See TracBrowser for help on using the browser.