Project

General

Profile

Download (6.86 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
import java.util.Map;
13

    
14
import org.apache.log4j.Logger;
15
import org.hibernate.envers.Audited;
16
import org.hibernate.search.annotations.Indexed;
17
import org.hibernate.validator.constraints.Length;
18
import org.springframework.beans.factory.annotation.Configurable;
19

    
20
import eu.etaxonomy.cdm.common.CdmUtils;
21
import eu.etaxonomy.cdm.model.common.CdmBase;
22
import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
23

    
24
import javax.persistence.*;
25
import javax.xml.bind.annotation.XmlAccessType;
26
import javax.xml.bind.annotation.XmlAccessorType;
27
import javax.xml.bind.annotation.XmlElement;
28
import javax.xml.bind.annotation.XmlRootElement;
29
import javax.xml.bind.annotation.XmlType;
30

    
31
/**
32
 * The taxon name class for cultivars (cultivated plants). The only possible
33
 * {@link Rank ranks} for cultivars are CULTIVAR, GREX, CONVAR, CULTIVAR_GROUP,
34
 * GRAFT_CHIMAERA or DENOMINATION_CLASS.
35
 * <P>
36
 * This class corresponds partially to: NameBotanical according to the
37
 * ABCD schema.
38
 * 
39
 * @author m.doering
40
 * @version 1.0
41
 * @created 08-Nov-2007 13:06:18
42
 */
43
@XmlAccessorType(XmlAccessType.FIELD)
44
@XmlType(name = "", propOrder = {
45
    "cultivarName"
46
})
47
@XmlRootElement(name = "CultivarPlantName")
48
@Entity
49
@Indexed(index = "eu.etaxonomy.cdm.model.name.TaxonNameBase")
50
@Audited
51
@Configurable
52
public class CultivarPlantName extends BotanicalName implements Cloneable{
53
	@SuppressWarnings("unused")
54
	private static final Logger logger = Logger.getLogger(CultivarPlantName.class);
55
	
56
	//the characteristical name of the cultivar
57
    @XmlElement(name = "CultivarName", required = true)
58
    @NullOrNotEmpty
59
    @Length(max = 255)
60
	private String cultivarName;
61

    
62
	// ************* CONSTRUCTORS *************/	
63
	/** 
64
	 * Class constructor: creates a new cultivar taxon name instance
65
	 * only containing the {@link eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy default cache strategy}.
66
	 * 
67
	 * @see #CultivarPlantName(Rank, HomotypicalGroup)
68
	 * @see eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy
69
	 */
70
	public CultivarPlantName(){
71
		super();
72
	}
73

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

    
107
	/** 
108
	 * Creates a new cultivar taxon name instance
109
	 * only containing its {@link Rank rank},
110
	 * its {@link HomotypicalGroup homotypical group} and 
111
 	 * the {@link eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy default cache strategy}.
112
	 * The new cultivar taxon name instance will be also added to the set of
113
	 * cultivar taxon names belonging to this homotypical group.
114
	 * 
115
	 * @param  rank  the rank to be assigned to <i>this</i> cultivar taxon name
116
	 * @param  homotypicalGroup  the homotypical group to which <i>this</i> cultivar taxon name belongs
117
	 * @see    #NewInstance(Rank)
118
	 * @see    #CultivarPlantName(Rank, HomotypicalGroup)
119
	 * @see    eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy
120
	 */
121
	public static CultivarPlantName NewInstance(Rank rank, HomotypicalGroup homotypicalGroup){
122
		return new CultivarPlantName(rank, homotypicalGroup);
123
	}
124
	
125
//*********************** 	
126

    
127
	private static Map<String, java.lang.reflect.Field> allFields = null;
128
	@Override
129
    protected Map<String, java.lang.reflect.Field> getAllFields(){
130
    	if (allFields == null){
131
			allFields = CdmUtils.getAllFields(this.getClass(), CdmBase.class, false, false, false, true);
132
		}
133
    	return allFields;
134
    }
135

    
136
//************************* 
137
	
138
	/** 
139
	 * Returns the characteristical cultivar name part string assigned to <i>this</i>
140
	 * cultivar taxon name. In the scientific name "Clematis alpina 'Ruby'" for
141
	 * instance this characteristical string is "Ruby". This part of the name is
142
	 * governed by the International Code for the Nomenclature of Cultivated
143
	 * Plants and the string should include neither quotes nor + signs
144
	 * (these elements of the name cache string will be generated by the
145
	 * {@link eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy default cache strategy}).
146
	 */
147
	public String getCultivarName(){
148
		return this.cultivarName;
149
	}
150

    
151
	/**
152
	 * @see  #getCultivarName()
153
	 */
154
	public void setCultivarName(String cultivarName){
155
		this.cultivarName = cultivarName;
156
	}
157
	
158
	
159
	/**
160
	 * Returns the {@link NomenclaturalCode nomenclatural code} that governs
161
	 * the construction of <i>this</i> cultivar taxon name, that is the
162
	 * International Code of Nomenclature for Cultivated Plants. This method
163
	 * overrides the getNomeclaturalCode method from {@link NonViralName#getNomeclaturalCode() NonViralName}.
164
	 *
165
	 * @return  the nomenclatural code for cultivated plants
166
	 * @see  	NonViralName#isCodeCompliant()
167
	 * @see  	TaxonNameBase#getHasProblem()
168
	 */
169
	@Override
170
	public NomenclaturalCode getNomenclaturalCode(){
171
		return NomenclaturalCode.ICNCP;
172
	}
173
	
174
	
175
//*********************** CLONE ********************************************************/
176
	
177
	/** 
178
	 * Clones <i>this</i> cultivar plant name. This is a shortcut that enables to create
179
	 * a new instance that differs only slightly from <i>this</i> cultivar plant name by
180
	 * modifying only some of the attributes.
181
	 * 
182
	 * @see eu.etaxonomy.cdm.model.name.BotanicalName#clone()
183
	 * @see java.lang.Object#clone()
184
	 */
185
	@Override
186
	public Object clone() {
187
		BotanicalName result = (BotanicalName)super.clone();
188
		//no changes to: cultivarName
189
		return result;
190
	}
191

    
192
}
(3-3/26)