Project

General

Profile

« Previous | Next » 

Revision 2d370ced

Added by Andreas Müller over 7 years ago

ref #6366 move cultivar attributes and functions to TaxonNameBase

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/CultivarPlantName.java
9 9

  
10 10
package eu.etaxonomy.cdm.model.name;
11 11

  
12
import java.util.Map;
13

  
14
import javax.persistence.Column;
15 12
import javax.persistence.Entity;
16 13
import javax.xml.bind.annotation.XmlAccessType;
17 14
import javax.xml.bind.annotation.XmlAccessorType;
18
import javax.xml.bind.annotation.XmlElement;
19 15
import javax.xml.bind.annotation.XmlRootElement;
20 16
import javax.xml.bind.annotation.XmlType;
21 17

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

  
28
import eu.etaxonomy.cdm.common.CdmUtils;
29
import eu.etaxonomy.cdm.model.common.CdmBase;
30

  
31 23
/**
32 24
 * The taxon name class for cultivars (cultivated plants). The only possible
33 25
 * {@link Rank ranks} for cultivars are CULTIVAR, GREX, CONVAR, CULTIVAR_GROUP,
......
37 29
 * ABCD schema.
38 30
 *
39 31
 * @author m.doering
40
 * @version 1.0
41 32
 * @created 08-Nov-2007 13:06:18
42 33
 */
43 34
@XmlAccessorType(XmlAccessType.FIELD)
44
@XmlType(name = "", propOrder = {
45
    "cultivarName"
46
})
35
@XmlType(name = "", propOrder = {})
47 36
@XmlRootElement(name = "CultivarPlantName")
48 37
@Entity
49 38
@Indexed(index = "eu.etaxonomy.cdm.model.name.TaxonNameBase")
50 39
@Audited
51 40
@Configurable
52 41
public class CultivarPlantName
53
        extends BotanicalName
54
        implements ICultivarPlantName{
42
        extends BotanicalName {
55 43
    private static final long serialVersionUID = -7948375817971980004L;
56 44

  
57 45
    @SuppressWarnings("unused")
58 46
	private static final Logger logger = Logger.getLogger(CultivarPlantName.class);
59 47

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

  
67 49
	// ************* CONSTRUCTORS *************/
68 50
	/**
......
93 75
		super(rank, homotypicalGroup);
94 76
	}
95 77

  
96
	//********* METHODS **************************************/
97

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

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

  
130
//***********************
131

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

  
141 79
//*************************
142 80

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

  
157
	/**
158
	 * @see  #getCultivarName()
159
	 */
160
	@Override
161
    public void setCultivarName(String cultivarName){
162
		this.cultivarName = StringUtils.isBlank(cultivarName) ? null : cultivarName;
163
	}
164

  
165 81

  
166 82
	/**
167 83
	 * Returns the {@link NomenclaturalCode nomenclatural code} that governs
......
192 108
	@Override
193 109
	public Object clone() {
194 110
		BotanicalName result = (BotanicalName)super.clone();
195
		//no changes to: cultivarName
111
		//no changes to:
196 112
		return result;
197 113
	}
198 114

  

Also available in: Unified diff