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

Revision 11066, 7.3 kB (checked in by a.mueller, 17 months ago)

Added clone() to all TaxonNameBase? classes (including some descriptive and common classes). #2170

  • 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.persistence.Transient;
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.common.CdmBase;
33import eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy;
34import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
35
36/**
37 * The taxon name class for viral taxa. The scientific name will be stored
38 * as a string (consisting eventually of several words even combined also with
39 * non alphabetical characters) in the inherited {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#setTitleCache(String) titleCache} attribute.
40 * Classification has no influence on the names of viral taxon names and no
41 * viral taxon must be taxonomically included in another viral taxon with
42 * higher rank. For examples see ICTVdb:
43 * "http://www.ncbi.nlm.nih.gov/ICTVdb/Ictv/vn_indxA.htm"
44 * <P>
45 * This class corresponds to: NameViral according to the ABCD schema.
46 *
47 * @author m.doering
48 * @version 1.0
49 * @created 08-Nov-2007 13:07:02
50 */
51@XmlAccessorType(XmlAccessType.FIELD)
52@XmlType(name = "", propOrder = {
53    "acronym"
54})
55@XmlRootElement(name = "ViralName")
56@Entity
57@Indexed(index = "eu.etaxonomy.cdm.model.name.TaxonNameBase")
58@Audited
59@Configurable
60public class ViralName extends TaxonNameBase<ViralName, INameCacheStrategy<ViralName>> implements Cloneable {
61        private static final long serialVersionUID = 4516625507432071817L;
62        private static final Logger logger = Logger.getLogger(ViralName.class);
63
64//    @XmlTransient
65//    @Transient
66//      protected INameCacheStrategy<ViralName> cacheStrategy;
67       
68        @XmlElement(name = "Acronym")
69        @Field(index=Index.TOKENIZED)
70        @NullOrNotEmpty
71        @Length(max = 255)
72        private String acronym;
73
74        // ************* CONSTRUCTORS *************/   
75       
76        protected ViralName(){
77                super();
78        }
79       
80        /**
81         * Class constructor: creates a new viral taxon name instance
82         * only containing its {@link Rank rank}.
83         *
84         * @param       rank  the rank to be assigned to <i>this</i> viral taxon name
85         * @see         TaxonNameBase#TaxonNameBase(Rank)
86         */
87        public ViralName(Rank rank) {
88                super(rank);
89        }
90
91//***********************       
92
93        private static Map<String, java.lang.reflect.Field> allFields = null;
94        @Override
95    protected Map<String, java.lang.reflect.Field> getAllFields(){
96        if (allFields == null){
97                        allFields = CdmUtils.getAllFields(this.getClass(), CdmBase.class, false, false, false, true);
98                }
99        return allFields;
100    }
101
102//*************************
103       
104        //********* METHODS **************************************/
105
106        /**
107         * Creates a new viral taxon name instance only containing its {@link Rank rank}.
108         *
109         * @param       rank  the rank to be assigned to <i>this</i> viral taxon name
110         * @see         #ViralName(Rank)
111         */
112        public static ViralName NewInstance(Rank rank){
113                return new ViralName(rank);
114        }
115
116        /**
117         * Returns the accepted acronym (an assigned abbreviation) string for <i>this</i>
118         * viral taxon name. For instance PCV stays for Peanut Clump Virus.
119         *
120         * @return  the string containing the accepted acronym of <i>this</i> viral taxon name
121         */
122        public String getAcronym(){
123                return this.acronym;
124        }
125        /**
126         * @see  #getAcronym()
127         */
128        public void setAcronym(String acronym){
129                this.acronym = acronym;
130        }
131
132        /**
133         * Generates and returns the string with the scientific name of <i>this</i>
134         * viral taxon name. This string may be stored in the inherited
135         * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.
136         * This method overrides the generic and inherited
137         * method from {@link TaxonNameBase TaxonNameBase} .
138         *
139         * @return  the string with the composed name of <i>this</i> viral taxon name with authorship (and maybe year)
140         * @see         eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
141         * @see         eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
142         * @see         TaxonNameBase#generateTitle()
143         */
144//      @Override
145//      public String generateTitle(){
146//              logger.warn("not yet implemented");
147//              return this.toString();
148//      }
149
150        @Override
151        public String generateFullTitle(){
152                logger.warn("not yet implemented");
153                return this.toString();
154        }
155       
156        /**
157         * Returns the boolean value "true" if the components of <i>this</i> viral taxon name
158         * follow the rules of the corresponding
159         * {@link NomenclaturalCode International Code of Virus Classification and Nomenclature},
160         * "false" otherwise.
161         * This method overrides and implements the isCodeCompliant method from
162         * the abstract {@link TaxonNameBase#isCodeCompliant() TaxonNameBase} class.
163         * 
164         * @return  the boolean value expressing the compliance of <i>this</i> viral taxon name to its nomenclatural code
165         * @see         TaxonNameBase#isCodeCompliant()
166         */
167        @Override
168        @Transient
169        public boolean isCodeCompliant() {
170                logger.warn("not yet implemented");
171                return false;
172        }
173       
174       
175        /**
176         * Returns the {@link NomenclaturalCode nomenclatural code} that governs
177         * the construction of <i>this</i> viral taxon name, that is the
178         * International Code of Virus Classification and Nomenclature.
179         * This method overrides the getNomeclaturalCode method from {@link TaxonNameBase TaxonNameBase}.
180         *
181         * @return  the nomenclatural code for viruses
182         * @see         #isCodeCompliant()
183         * @see         TaxonNameBase#getHasProblem()
184         * @see         TaxonNameBase#getNomenclaturalCode()
185         */
186        @Override
187        public NomenclaturalCode getNomenclaturalCode(){
188                return NomenclaturalCode.ICVCN;
189        }
190
191
192        /**
193         * Returns the {@link eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy cache strategy} used to generate
194         * several strings corresponding to <i>this</i> viral taxon name.
195         *
196         * @return  the cache strategy used for <i>this</i> viral taxon name
197         * @see         eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
198         * @see     eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
199         */
200//      @Override
201//      @Transient
202//      public INameCacheStrategy getCacheStrategy() {
203//              return cacheStrategy;
204//      }
205
206
207        /**
208         * @see  #getCacheStrategy()
209         */
210//      @Override
211//      public void setCacheStrategy(INameCacheStrategy cacheStrategy) {
212//              this.cacheStrategy = cacheStrategy;
213//      }
214
215       
216//*********************** CLONE ********************************************************/
217       
218        /**
219         * Clones <i>this</i> viral name. This is a shortcut that enables to create
220         * a new instance that differs only slightly from <i>this</i> viral name by
221         * modifying only some of the attributes.
222         *
223         * @see eu.etaxonomy.cdm.model.name.TaxonNameBase#clone()
224         * @see java.lang.Object#clone()
225         */
226        @Override
227        public Object clone() {
228                ViralName result = (ViralName)super.clone();
229                //no changes to: acronym
230                return result;
231        }
232}
Note: See TracBrowser for help on using the browser.