Project

General

Profile

Download (6.94 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 javax.persistence.Column;
15
import javax.persistence.Entity;
16
import javax.xml.bind.annotation.XmlAccessType;
17
import javax.xml.bind.annotation.XmlAccessorType;
18
import javax.xml.bind.annotation.XmlElement;
19
import javax.xml.bind.annotation.XmlRootElement;
20
import javax.xml.bind.annotation.XmlType;
21

    
22
import org.apache.commons.lang.StringUtils;
23
import org.apache.log4j.Logger;
24
import org.hibernate.envers.Audited;
25
import org.hibernate.search.annotations.Indexed;
26
import org.springframework.beans.factory.annotation.Configurable;
27

    
28
import eu.etaxonomy.cdm.common.CdmUtils;
29
import eu.etaxonomy.cdm.model.common.CdmBase;
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
    private static final long serialVersionUID = -7948375817971980004L;
54

    
55
    @SuppressWarnings("unused")
56
	private static final Logger logger = Logger.getLogger(CultivarPlantName.class);
57

    
58
	//the characteristical name of the cultivar
59
    @XmlElement(name = "CultivarName", required = true)
60
    //TODO Val #3379
61
//    @NullOrNotEmpty
62
    @Column(length=255)
63
	private String cultivarName;
64

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

    
77
	/**
78
	 * Class constructor: creates a new cultivar taxon name instance
79
	 * only containing its {@link Rank rank},
80
	 * its {@link HomotypicalGroup homotypical group} and
81
	 * the {@link eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy default cache strategy}.
82
	 * The new cultivar taxon name instance will be also added to the set of
83
	 * cultivar taxon names belonging to this homotypical group.
84
	 *
85
	 * @param	rank  the rank to be assigned to <i>this</i> cultivar taxon name
86
	 * @param	homotypicalGroup  the homotypical group to which <i>this</i> cultivar taxon name belongs
87
	 * @see 	#CultivarPlantName()
88
	 * @see 	eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy
89
	 */
90
	protected CultivarPlantName(Rank rank, HomotypicalGroup homotypicalGroup) {
91
		super(rank, homotypicalGroup);
92
	}
93

    
94
	//********* METHODS **************************************/
95

    
96
	/**
97
	 * Creates a new cultivar taxon name instance
98
	 * only containing its {@link Rank rank} and
99
	 * the {@link eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy default cache strategy}.
100
	 *
101
	 * @param	rank	the rank to be assigned to <i>this</i> cultivar taxon name
102
	 * @see 			#CultivarPlantName(Rank, HomotypicalGroup)
103
	 * @see 			#NewInstance(Rank, HomotypicalGroup)
104
	 * @see 			eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy
105
	 */
106
	public static CultivarPlantName NewInstance(Rank rank){
107
		return new CultivarPlantName(rank, null);
108
	}
109

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

    
128
//***********************
129

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

    
139
//*************************
140

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

    
154
	/**
155
	 * @see  #getCultivarName()
156
	 */
157
	public void setCultivarName(String cultivarName){
158
		this.cultivarName = StringUtils.isBlank(cultivarName) ? null : cultivarName;
159
	}
160

    
161

    
162
	/**
163
	 * Returns the {@link NomenclaturalCode nomenclatural code} that governs
164
	 * the construction of <i>this</i> cultivar taxon name, that is the
165
	 * International Code of Nomenclature for Cultivated Plants. This method
166
	 * overrides the getNomenclaturalCode method from {@link NonViralName#getNomenclaturalCode() NonViralName}.
167
	 *
168
	 * @return  the nomenclatural code for cultivated plants
169
	 * @see  	NonViralName#isCodeCompliant()
170
	 * @see  	TaxonNameBase#getHasProblem()
171
	 */
172
	@Override
173
	public NomenclaturalCode getNomenclaturalCode(){
174
		return NomenclaturalCode.ICNCP;
175
	}
176

    
177

    
178
//*********************** CLONE ********************************************************/
179

    
180
	/**
181
	 * Clones <i>this</i> cultivar plant name. This is a shortcut that enables to create
182
	 * a new instance that differs only slightly from <i>this</i> cultivar plant name by
183
	 * modifying only some of the attributes.
184
	 *
185
	 * @see eu.etaxonomy.cdm.model.name.BotanicalName#clone()
186
	 * @see java.lang.Object#clone()
187
	 */
188
	@Override
189
	public Object clone() {
190
		BotanicalName result = (BotanicalName)super.clone();
191
		//no changes to: cultivarName
192
		return result;
193
	}
194

    
195
}
(3-3/28)