Project

General

Profile

Download (47.9 KB) Statistics
| Branch: | Tag: | Revision:
1 9479da48 Andreas Müller
/**
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 1cfc54ab Andreas Müller
import java.lang.reflect.Method;
13 396aee74 Andreas Müller
import java.util.HashSet;
14 b24d580a Andreas Kohlbecker
import java.util.List;
15 396aee74 Andreas Müller
import java.util.Set;
16
17 33508d06 a.babadshanjan
import javax.persistence.Column;
18 396aee74 Andreas Müller
import javax.persistence.Entity;
19
import javax.persistence.FetchType;
20
import javax.persistence.Inheritance;
21
import javax.persistence.InheritanceType;
22
import javax.persistence.ManyToMany;
23
import javax.persistence.ManyToOne;
24
import javax.persistence.OneToMany;
25 b70a7f94 Andreas Kohlbecker
import javax.persistence.Transient;
26 827f3b3c a.babadshanjan
import javax.xml.bind.annotation.XmlAccessType;
27
import javax.xml.bind.annotation.XmlAccessorType;
28
import javax.xml.bind.annotation.XmlAttribute;
29
import javax.xml.bind.annotation.XmlElement;
30
import javax.xml.bind.annotation.XmlElementWrapper;
31 76b4a40f a.babadshanjan
import javax.xml.bind.annotation.XmlIDREF;
32 9d0d8d15 a.babadshanjan
import javax.xml.bind.annotation.XmlRootElement;
33 76b4a40f a.babadshanjan
import javax.xml.bind.annotation.XmlSchemaType;
34 827f3b3c a.babadshanjan
import javax.xml.bind.annotation.XmlType;
35 9479da48 Andreas Müller
36 396aee74 Andreas Müller
import org.apache.log4j.Logger;
37
import org.hibernate.annotations.Cascade;
38
import org.hibernate.annotations.CascadeType;
39
import org.hibernate.annotations.Index;
40
import org.hibernate.annotations.Table;
41 ee91bcd9 ben.clark
import org.hibernate.envers.Audited;
42 fd7ee7b1 ben.clark
import org.hibernate.search.annotations.Field;
43 ee91bcd9 ben.clark
import org.springframework.util.ReflectionUtils;
44 396aee74 Andreas Müller
45
import eu.etaxonomy.cdm.model.common.IParsable;
46
import eu.etaxonomy.cdm.model.common.IReferencedEntity;
47
import eu.etaxonomy.cdm.model.common.IRelated;
48
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
49
import eu.etaxonomy.cdm.model.common.RelationshipBase;
50
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
51
import eu.etaxonomy.cdm.model.occurrence.Specimen;
52
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
53
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
54
import eu.etaxonomy.cdm.model.reference.StrictReferenceBase;
55
import eu.etaxonomy.cdm.model.taxon.Synonym;
56
import eu.etaxonomy.cdm.model.taxon.Taxon;
57
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
58
import eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy;
59
60 9479da48 Andreas Müller
/**
61 975192f9 m.geoffroy
 * The upmost (abstract) class for scientific taxon names regardless of any
62 c3440568 m.geoffroy
 * particular {@link NomenclaturalCode nomenclature code}. The scientific taxon name does not depend
63 85629348 m.geoffroy
 * on the use made of it in a publication or a treatment
64 09887ea6 m.geoffroy
 * ({@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon concept respectively potential taxon})
65
 * as an {@link eu.etaxonomy.cdm.model.taxon.Taxon "accepted" respectively "correct" (taxon) name}
66
 * or as a {@link eu.etaxonomy.cdm.model.taxon.Synonym synonym}.
67 9e86cd74 m.geoffroy
 * <P>
68
 * This class corresponds partially to: <ul>
69
 * <li> TaxonName according to the TDWG ontology
70
 * <li> ScientificName and CanonicalName according to the TCS
71
 * <li> ScientificName according to the ABCD schema
72
 * </ul>
73 19e7a39e m.geoffroy
 * 
74 9479da48 Andreas Müller
 * @author m.doering
75
 * @version 1.0
76
 * @created 08-Nov-2007 13:06:57
77
 */
78 827f3b3c a.babadshanjan
@XmlAccessorType(XmlAccessType.FIELD)
79 76b4a40f a.babadshanjan
@XmlType(name = "TaxonNameBase", propOrder = {
80 827f3b3c a.babadshanjan
    "appendedPhrase",
81
    "nomenclaturalMicroReference",
82 64c4a14d a.babadshanjan
    "nomenclaturalReference",
83 827f3b3c a.babadshanjan
    "rank",
84 33508d06 a.babadshanjan
    "fullTitleCache",
85
    "protectedFullTitleCache",
86 827f3b3c a.babadshanjan
    "homotypicalGroup",
87 ddae61ce a.babadshanjan
    "typeDesignations",
88 827f3b3c a.babadshanjan
    "relationsFromThisName",
89
    "relationsToThisName",
90 7baa835b a.babadshanjan
    "status",
91 ee91bcd9 ben.clark
    "descriptions",
92
    "taxonBases"
93 827f3b3c a.babadshanjan
})
94 9d0d8d15 a.babadshanjan
@XmlRootElement(name = "TaxonNameBase")
95 9479da48 Andreas Müller
@Entity
96 ee91bcd9 ben.clark
@Audited
97 9479da48 Andreas Müller
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
98 c281e68e Andreas Müller
@Table(appliesTo="TaxonNameBase", indexes = { @Index(name = "taxonNameBaseTitleCacheIndex", columnNames = { "titleCache" }) })
99 4208745a ben.clark
public abstract class TaxonNameBase<T extends TaxonNameBase<?,?>, S extends INameCacheStrategy> extends IdentifiableEntity<S> implements IReferencedEntity, IParsable, IRelated {
100 168723a2 a.babadshanjan
101 961ee94b Andreas Müller
	private static final long serialVersionUID = -4530368639601532116L;
102 b70a7f94 Andreas Kohlbecker
	private static final Logger logger = Logger.getLogger(TaxonNameBase.class);
103 827f3b3c a.babadshanjan
104 33508d06 a.babadshanjan
	@XmlElement(name = "FullTitleCache")
105 ee91bcd9 ben.clark
	@Column(length=330, name="fullTitleCache")
106 33508d06 a.babadshanjan
	private String fullTitleCache;
107
	
108
	//if true titleCache will not be automatically generated/updated
109
	@XmlElement(name = "ProtectedFullTitleCache")
110
	private boolean protectedFullTitleCache;
111
	
112 2595daef a.babadshanjan
    @XmlElementWrapper(name = "Descriptions")
113
    @XmlElement(name = "Description")
114 ee91bcd9 ben.clark
    @OneToMany(mappedBy="taxonName", fetch= FetchType.LAZY) 
115
	@Cascade({CascadeType.SAVE_UPDATE})
116 2595daef a.babadshanjan
	private Set<TaxonNameDescription> descriptions = new HashSet<TaxonNameDescription>();
117 71dcc146 Andreas Müller
	
118 76b4a40f a.babadshanjan
    @XmlElement(name = "AppendedPhrase")
119 fd7ee7b1 ben.clark
    @Field(index= org.hibernate.search.annotations.Index.TOKENIZED)
120 9479da48 Andreas Müller
	private String appendedPhrase;
121 827f3b3c a.babadshanjan
	
122 76b4a40f a.babadshanjan
    @XmlElement(name = "NomenclaturalMicroReference")
123 fd7ee7b1 ben.clark
    @Field(index= org.hibernate.search.annotations.Index.TOKENIZED)
124 9479da48 Andreas Müller
	private String nomenclaturalMicroReference;
125 827f3b3c a.babadshanjan
	
126
    @XmlAttribute
127 9479da48 Andreas Müller
	private boolean hasProblem = false;
128 827f3b3c a.babadshanjan
	
129 6680df00 Andreas Müller
    @XmlAttribute
130
    private int problemStarts = -1;
131
    
132
    @XmlAttribute
133
    private int problemEnds = -1;
134
    
135 dce4c9cb Andreas Müller
    @XmlElementWrapper(name = "TypeDesignations")
136
    @XmlElement(name = "TypeDesignation")
137 a2312bea a.babadshanjan
    @XmlIDREF
138
    @XmlSchemaType(name = "IDREF")
139 ee91bcd9 ben.clark
    @ManyToMany(fetch = FetchType.LAZY)
140
	//TODO @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE_ORPHAN})
141 1ea1c087 ben.clark
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
142 dce4c9cb Andreas Müller
	private Set<TypeDesignationBase> typeDesignations = new HashSet<TypeDesignationBase>();
143 827f3b3c a.babadshanjan
144 76b4a40f a.babadshanjan
    @XmlElement(name = "HomotypicalGroup")
145 dbff59db a.babadshanjan
    @XmlIDREF
146
    @XmlSchemaType(name = "IDREF")
147 ee91bcd9 ben.clark
    @ManyToOne(fetch = FetchType.LAZY)
148 1ea1c087 ben.clark
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
149 ee91bcd9 ben.clark
	private HomotypicalGroup homotypicalGroup;
150 827f3b3c a.babadshanjan
151
    @XmlElementWrapper(name = "RelationsFromThisName")
152
    @XmlElement(name = "RelationFromThisName")
153 ee91bcd9 ben.clark
    @OneToMany(mappedBy="relatedFrom", fetch= FetchType.LAZY)
154 ec1f7873 Andreas Müller
	//TODO @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE_ORPHAN}) => DELETE_ORPHAN does not work ( org.hibernate.HibernateException: Don't change the reference to a collection with cascade="all-delete-orphan": eu.etaxonomy.cdm.model.name.TaxonNameBase.relationsFromThisName)
155 1ea1c087 ben.clark
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
156 608eada2 Andreas Müller
	private Set<NameRelationship> relationsFromThisName = new HashSet<NameRelationship>();
157 827f3b3c a.babadshanjan
158
    @XmlElementWrapper(name = "RelationsToThisName")
159
    @XmlElement(name = "RelationToThisName")
160 76b4a40f a.babadshanjan
    @XmlIDREF
161 64c4a14d a.babadshanjan
    @XmlSchemaType(name = "IDREF")
162 ee91bcd9 ben.clark
    @OneToMany(mappedBy="relatedTo", fetch= FetchType.LAZY)
163 1ea1c087 ben.clark
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
164 608eada2 Andreas Müller
	private Set<NameRelationship> relationsToThisName = new HashSet<NameRelationship>();
165 827f3b3c a.babadshanjan
166 ee91bcd9 ben.clark
    @XmlElementWrapper(name = "NomenclaturalStatuses")
167 64c4a14d a.babadshanjan
    @XmlElement(name = "NomenclaturalStatus")
168 ee91bcd9 ben.clark
    @OneToMany(fetch= FetchType.LAZY)
169 1ea1c087 ben.clark
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
170 608eada2 Andreas Müller
	private Set<NomenclaturalStatus> status = new HashSet<NomenclaturalStatus>();
171 827f3b3c a.babadshanjan
172 ee91bcd9 ben.clark
    @XmlElementWrapper(name = "TaxonBases")
173
    @XmlElement(name = "TaxonBase")
174
    @XmlIDREF
175
    @XmlSchemaType(name = "IDREF")
176
    @OneToMany(mappedBy="name", fetch= FetchType.LAZY)
177 608eada2 Andreas Müller
	private Set<TaxonBase> taxonBases = new HashSet<TaxonBase>();
178 33508d06 a.babadshanjan
    
179 76b4a40f a.babadshanjan
    @XmlElement(name = "Rank")
180
	@XmlIDREF
181
	@XmlSchemaType(name = "IDREF")
182 4208745a ben.clark
	@ManyToOne(fetch = FetchType.EAGER)
183 9479da48 Andreas Müller
	private Rank rank;
184 827f3b3c a.babadshanjan
185 ee91bcd9 ben.clark
	@XmlElement(name = "NomenclaturalReference")
186 64c4a14d a.babadshanjan
    @XmlIDREF
187
    @XmlSchemaType(name = "IDREF")
188 ee91bcd9 ben.clark
    @ManyToOne(fetch = FetchType.LAZY)
189
	@Cascade({CascadeType.SAVE_UPDATE})
190
	private ReferenceBase nomenclaturalReference;
191 1cfc54ab Andreas Müller
	
192 2a486d28 Andreas Müller
// ************* CONSTRUCTORS *************/	
193 12655d36 m.geoffroy
	/** 
194 85629348 m.geoffroy
	 * Class constructor: creates a new empty taxon name.
195 12655d36 m.geoffroy
	 * 
196
	 * @see #TaxonNameBase(Rank)
197
	 * @see #TaxonNameBase(HomotypicalGroup)
198
	 * @see #TaxonNameBase(Rank, HomotypicalGroup)
199
	 */
200 9479da48 Andreas Müller
	public TaxonNameBase() {
201 ee91bcd9 ben.clark
		super();
202 9479da48 Andreas Müller
	}
203 12655d36 m.geoffroy
	/** 
204 85629348 m.geoffroy
	 * Class constructor: creates a new taxon name
205 09887ea6 m.geoffroy
	 * only containing its {@link Rank rank}.
206 12655d36 m.geoffroy
	 * 
207 b9d0e8d2 m.geoffroy
	 * @param  rank  the rank to be assigned to <i>this</i> taxon name
208 6a9737e8 m.geoffroy
	 * @see    		 #TaxonNameBase()
209
	 * @see    		 #TaxonNameBase(HomotypicalGroup)
210
	 * @see    		 #TaxonNameBase(Rank, HomotypicalGroup)
211 12655d36 m.geoffroy
	 */
212 9479da48 Andreas Müller
	public TaxonNameBase(Rank rank) {
213 b18c6379 Andreas Müller
		this(rank, null);
214
	}
215 12655d36 m.geoffroy
	/** 
216 85629348 m.geoffroy
	 * Class constructor: creates a new taxon name
217 9dac7f49 m.geoffroy
	 * only containing its {@link HomotypicalGroup homotypical group}.
218 85629348 m.geoffroy
	 * The new taxon name will be also added to the set of taxon names
219 740cb3b5 m.geoffroy
	 * belonging to this homotypical group.
220 12655d36 m.geoffroy
	 * 
221 b9d0e8d2 m.geoffroy
	 * @param  homotypicalGroup  the homotypical group to which <i>this</i> taxon name belongs
222 6a9737e8 m.geoffroy
	 * @see    					 #TaxonNameBase()
223
	 * @see    					 #TaxonNameBase(Rank)
224
	 * @see    					 #TaxonNameBase(Rank, HomotypicalGroup)
225 12655d36 m.geoffroy
	 */
226 b18c6379 Andreas Müller
	public TaxonNameBase(HomotypicalGroup homotypicalGroup) {
227
		this(null, homotypicalGroup);
228
	}
229 12655d36 m.geoffroy
	/** 
230 85629348 m.geoffroy
	 * Class constructor: creates a new taxon name
231 09887ea6 m.geoffroy
	 * only containing its {@link Rank rank} and
232 9dac7f49 m.geoffroy
	 * its {@link HomotypicalGroup homotypical group}.
233 740cb3b5 m.geoffroy
	 * The new taxon name will be also added to the set of taxon names
234
	 * belonging to this homotypical group.
235 12655d36 m.geoffroy
	 * 
236 6a9737e8 m.geoffroy
	 * @param  rank  			 the rank to be assigned to <i>this</i> taxon name
237 b9d0e8d2 m.geoffroy
	 * @param  homotypicalGroup  the homotypical group to which <i>this</i> taxon name belongs
238 6a9737e8 m.geoffroy
	 * @see    					 #TaxonNameBase()
239
	 * @see    					 #TaxonNameBase(Rank)
240
	 * @see    					 #TaxonNameBase(HomotypicalGroup)
241 12655d36 m.geoffroy
	 */
242 b18c6379 Andreas Müller
	public TaxonNameBase(Rank rank, HomotypicalGroup homotypicalGroup) {
243 9479da48 Andreas Müller
		super();
244
		this.setRank(rank);
245 b18c6379 Andreas Müller
		if (homotypicalGroup == null){
246
			homotypicalGroup = new HomotypicalGroup();
247
		}
248
		homotypicalGroup.addTypifiedName(this);
249 9479da48 Andreas Müller
	}
250 2a486d28 Andreas Müller
	
251
//********* METHODS **************************************/
252 9017e2de Andreas Müller
	
253 12655d36 m.geoffroy
	/**
254 b9d0e8d2 m.geoffroy
	 * Returns the boolean value "false" since the components of <i>this</i> taxon name
255 eb7e638a m.geoffroy
	 * cannot follow the rules of a corresponding {@link NomenclaturalCode nomenclatural code}
256
	 * which is not defined for this class. The nomenclature code depends on
257 12655d36 m.geoffroy
	 * the concrete name subclass ({@link BacterialName BacterialName},
258
	 * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName},
259
	 * {@link ZoologicalName ZoologicalName} or {@link ViralName ViralName}) 
260 eb7e638a m.geoffroy
	 * to which a taxon name belongs.
261 12655d36 m.geoffroy
	 *  
262 eb7e638a m.geoffroy
	 * @return  false
263 12655d36 m.geoffroy
	 */
264 b70a7f94 Andreas Kohlbecker
	@Transient
265 9479da48 Andreas Müller
	public abstract boolean isCodeCompliant();
266
	
267 33508d06 a.babadshanjan
	public abstract String generateFullTitle();
268 9479da48 Andreas Müller
269 b70a7f94 Andreas Kohlbecker
	@Transient
270 33508d06 a.babadshanjan
	public String getFullTitleCache(){
271
		if (protectedFullTitleCache){
272
			return this.fullTitleCache;			
273
		}
274
		if (fullTitleCache == null){
275 e3a02794 a.babadshanjan
			this.setFullTitleCache(generateFullTitle(), protectedFullTitleCache);
276 33508d06 a.babadshanjan
		}
277
		return fullTitleCache;
278
	}
279 b24d580a Andreas Kohlbecker
	
280
	@Transient
281
	public List<Object> getTaggedName(){
282
		return getCacheStrategy().getTaggedName(this);
283
	}
284 33508d06 a.babadshanjan
285
    public void setFullTitleCache(String fullTitleCache){
286
		setFullTitleCache(fullTitleCache, PROTECTED);
287
	}
288
	
289
	public void setFullTitleCache(String fullTitleCache, boolean protectCache){
290
		//TODO truncation of full title cache
291 c0bd32ce a.babadshanjan
		if (fullTitleCache != null && fullTitleCache.length() > 329){
292
			logger.warn("Truncation of full title cache: " + this.toString() + "/" + fullTitleCache);
293
			fullTitleCache = fullTitleCache.substring(0, 329) + "...";
294
		}
295 33508d06 a.babadshanjan
		this.fullTitleCache = fullTitleCache;
296
		this.setProtectedFullTitleCache(protectCache);
297
	}
298
	
299
	public boolean isProtectedFullTitleCache() {
300
		return protectedFullTitleCache;
301
	}
302
303
	public void setProtectedFullTitleCache(boolean protectedFullTitleCache) {
304
		this.protectedFullTitleCache = protectedFullTitleCache;
305
	}
306
	
307 12655d36 m.geoffroy
	/** 
308
	 * Returns the set of all {@link NameRelationship name relationships}
309 b9d0e8d2 m.geoffroy
	 * in which <i>this</i> taxon name is involved. A taxon name can be both source
310 12655d36 m.geoffroy
	 * in some name relationships or target in some others.
311
	 *  
312 09487e73 m.geoffroy
	 * @see    #getRelationsToThisName()
313
	 * @see    #getRelationsFromThisName()
314
	 * @see    #addNameRelationship(NameRelationship)
315 12655d36 m.geoffroy
	 * @see    #addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
316
	 * @see    #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
317
	 */
318 b70a7f94 Andreas Kohlbecker
	@Transient
319 9479da48 Andreas Müller
	public Set<NameRelationship> getNameRelations() {
320 6ecda5d2 m.doering
		Set<NameRelationship> rels = new HashSet<NameRelationship>();
321
		rels.addAll(getRelationsFromThisName());
322
		rels.addAll(getRelationsToThisName());
323
		return rels;
324
	}
325 b92a6173 a.babadshanjan
	
326 6ecda5d2 m.doering
	/**
327 b9d0e8d2 m.geoffroy
	 * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from <i>this</i> taxon name to another taxon name
328
	 * and adds it both to the set of {@link #getRelationsFromThisName() relations from <i>this</i> taxon name} and
329 12655d36 m.geoffroy
	 * to the set of {@link #getRelationsToThisName() relations to the other taxon name}.
330
	 * 
331
	 * @param toName		  the taxon name of the target for this new name relationship
332
	 * @param type			  the type of this new name relationship
333
	 * @param ruleConsidered  the string which specifies the rule on which this name relationship is based
334 09487e73 m.geoffroy
	 * @see    				  #getRelationsToThisName()
335
	 * @see    				  #getNameRelations()
336 12655d36 m.geoffroy
	 * @see    				  #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
337
	 * @see    				  #addNameRelationship(NameRelationship)
338 6ecda5d2 m.doering
	 */
339
	public void addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, String ruleConsidered){
340
		NameRelationship rel = new NameRelationship(toName, this, type, ruleConsidered);
341
	}
342 21f31bf8 Andreas Müller
	
343
	public void addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, ReferenceBase citation, String microCitation, String ruleConsidered){
344
		NameRelationship rel = new NameRelationship(toName, this, type, citation, microCitation, ruleConsidered);
345
	}
346
	
347 12655d36 m.geoffroy
	/**
348 b9d0e8d2 m.geoffroy
	 * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from another taxon name to <i>this</i> taxon name
349
	 * and adds it both to the set of {@link #getRelationsToThisName() relations to <i>this</i> taxon name} and
350 12655d36 m.geoffroy
	 * to the set of {@link #getRelationsFromThisName() relations from the other taxon name}.
351
	 * 
352
	 * @param fromName		  the taxon name of the source for this new name relationship
353
	 * @param type			  the type of this new name relationship
354
	 * @param ruleConsidered  the string which specifies the rule on which this name relationship is based
355 09487e73 m.geoffroy
	 * @see    				  #getRelationsFromThisName()
356
	 * @see    				  #getNameRelations()
357 12655d36 m.geoffroy
	 * @see    				  #addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
358
	 * @see    				  #addNameRelationship(NameRelationship)
359
	 */
360 4dd3e141 m.doering
	public void addRelationshipFromName(TaxonNameBase fromName, NameRelationshipType type, String ruleConsidered){
361
		NameRelationship rel = new NameRelationship(this, fromName, type, ruleConsidered);
362
	}
363 21f31bf8 Andreas Müller
	public void addRelationshipFromName(TaxonNameBase fromName, NameRelationshipType type, ReferenceBase citation, String microCitation, String ruleConsidered){
364
		NameRelationship rel = new NameRelationship(this, fromName, type, citation, microCitation, ruleConsidered);
365
	}
366
367 12655d36 m.geoffroy
	/**
368
	 * Adds an existing {@link NameRelationship name relationship} either to the set of
369 b9d0e8d2 m.geoffroy
	 * {@link #getRelationsToThisName() relations to <i>this</i> taxon name} or to the set of
370
	 * {@link #getRelationsFromThisName() relations from <i>this</i> taxon name}. If neither the
371
	 * source nor the target of the name relationship match with <i>this</i> taxon name
372 12655d36 m.geoffroy
	 * no addition will be carried out.
373
	 * 
374 b9d0e8d2 m.geoffroy
	 * @param rel  the name relationship to be added to one of <i>this</i> taxon name's name relationships sets
375 09487e73 m.geoffroy
	 * @see    	   #getNameRelations()
376 12655d36 m.geoffroy
	 * @see    	   #addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
377
	 * @see    	   #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
378
	 */
379 6ecda5d2 m.doering
	protected void addNameRelationship(NameRelationship rel) {
380
		if (rel!=null && rel.getToName().equals(this)){
381
			this.relationsToThisName.add(rel);
382
		}else if(rel!=null && rel.getFromName().equals(this)){
383
			this.relationsFromThisName.add(rel);			
384
		}else{
385
			//TODO: raise error???
386
		}
387 9479da48 Andreas Müller
	}
388 12655d36 m.geoffroy
	/** 
389
	 * Removes one {@link NameRelationship name relationship} from one of both sets of
390 b9d0e8d2 m.geoffroy
	 * {@link #getNameRelations() name relationships} in which <i>this</i> taxon name is involved.
391 09487e73 m.geoffroy
	 * The name relationship will also be removed from one of both sets belonging
392
	 * to the second taxon name involved. Furthermore the fromName and toName
393
	 * attributes of the name relationship object will be nullified. 
394 12655d36 m.geoffroy
	 *
395
	 * @param  nameRelation  the name relationship which should be deleted from one of both sets
396 6a9737e8 m.geoffroy
	 * @see    				 #getNameRelations()
397 12655d36 m.geoffroy
	 */
398 6ecda5d2 m.doering
	public void removeNameRelationship(NameRelationship nameRelation) {
399 b92a6173 a.babadshanjan
		
400
		TaxonNameBase fromName = nameRelation.getFromName();
401
		TaxonNameBase toName = nameRelation.getToName();
402
403
		if (nameRelation != null) {
404
			nameRelation.setToName(null);
405
			nameRelation.setFromName(null);
406
		}
407
		
408
		if (fromName != null) {
409
			fromName.removeNameRelationship(nameRelation);
410
		}
411
		
412
		if (toName != null) {
413
			toName.removeNameRelationship(nameRelation);
414
		}
415
		
416
		this.relationsToThisName.remove(nameRelation);
417
		this.relationsFromThisName.remove(nameRelation);
418
	}
419
		
420
	public void removeTaxonName(TaxonNameBase taxonName) {
421
		Set<NameRelationship> nameRelationships = new HashSet<NameRelationship>();
422
//		nameRelationships.addAll(this.getNameRelations());
423
		nameRelationships.addAll(this.getRelationsFromThisName());
424
		nameRelationships.addAll(this.getRelationsToThisName());
425
		for(NameRelationship nameRelationship : nameRelationships) {
426
			// remove name relationship from this side 
427
			if (nameRelationship.getFromName().equals(this) && nameRelationship.getToName().equals(taxonName)) {
428
				this.removeNameRelation(nameRelationship);
429
			}
430
		}
431
	}
432
	
433
	public void removeNameRelation(NameRelationship nameRelation) {
434
		nameRelation.setToName(null);
435
	
436
		TaxonNameBase name = nameRelation.getFromName();
437
		if (name != null){
438
			nameRelation.setFromName(null);
439
			name.removeNameRelation(nameRelation);
440
		}
441 6ecda5d2 m.doering
		this.relationsToThisName.remove(nameRelation);
442
		this.relationsFromThisName.remove(nameRelation);
443 9479da48 Andreas Müller
	}
444 6ecda5d2 m.doering
	
445
	
446 b3262b1b m.geoffroy
	/**
447
	 * Does exactly the same as the addNameRelationship method provided that
448
	 * the given relationship is a name relationship.
449
	 * 
450 b9d0e8d2 m.geoffroy
	 * @param relation  the relationship to be added to one of <i>this</i> taxon name's name relationships sets
451 b3262b1b m.geoffroy
	 * @see    	   		#addNameRelationship(NameRelationship)
452
	 * @see    	   		#getNameRelations()
453
	 * @see    	   		NameRelationship
454 09887ea6 m.geoffroy
	 * @see    	   		eu.etaxonomy.cdm.model.common.RelationshipBase
455 b3262b1b m.geoffroy
	 */
456 705e0850 Andreas Müller
	public void addRelationship(RelationshipBase relation) {
457
		if (relation instanceof NameRelationship){
458
			addNameRelationship((NameRelationship)relation);
459 d27ee9b1 Andreas Müller
			if (relation.getType() != null && 
460 bef42c31 Andreas Müller
						( relation.getType().equals(NameRelationshipType.BASIONYM()) ||
461
						  relation.getType().equals(NameRelationshipType.REPLACED_SYNONYM()) 
462
						 )){
463 d27ee9b1 Andreas Müller
				TaxonNameBase fromName = ((NameRelationship)relation).getFromName();
464
				TaxonNameBase toName = ((NameRelationship)relation).getToName();
465
				fromName.getHomotypicalGroup().merge(toName.getHomotypicalGroup());
466
			}		
467 705e0850 Andreas Müller
		}else{
468 d27ee9b1 Andreas Müller
			logger.warn("Relationship not of type NameRelationship!");
469 705e0850 Andreas Müller
			//TODO exception handling
470
		}
471 7ebeb288 Andreas Müller
	}
472
473
	
474 09487e73 m.geoffroy
	/** 
475
	 * Returns the set of all {@link NameRelationship name relationships}
476 b9d0e8d2 m.geoffroy
	 * in which <i>this</i> taxon name is involved as a source.
477 09487e73 m.geoffroy
	 *  
478
	 * @see    #getNameRelations()
479
	 * @see    #getRelationsToThisName()
480
	 * @see    #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
481
	 */
482 6ecda5d2 m.doering
	public Set<NameRelationship> getRelationsFromThisName() {
483
		return relationsFromThisName;
484 9479da48 Andreas Müller
	}
485 ee91bcd9 ben.clark
486 09487e73 m.geoffroy
	/** 
487
	 * Returns the set of all {@link NameRelationship name relationships}
488 b9d0e8d2 m.geoffroy
	 * in which <i>this</i> taxon name is involved as a target.
489 09487e73 m.geoffroy
	 *  
490
	 * @see    #getNameRelations()
491
	 * @see    #getRelationsFromThisName()
492
	 * @see    #addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
493
	 */
494 6ecda5d2 m.doering
	public Set<NameRelationship> getRelationsToThisName() {
495
		return relationsToThisName;
496 9479da48 Andreas Müller
	}
497
	
498 09487e73 m.geoffroy
	/** 
499
	 * Returns the set of {@link NomenclaturalStatus nomenclatural status} assigned
500 b9d0e8d2 m.geoffroy
	 * to <i>this</i> taxon name according to its corresponding nomenclature code.
501 09487e73 m.geoffroy
	 * This includes the {@link NomenclaturalStatusType type} of the nomenclatural status
502
	 * and the nomenclatural code rule considered.
503
	 *
504
	 * @see     NomenclaturalStatus
505
	 * @see     NomenclaturalStatusType
506
	 */
507 9479da48 Andreas Müller
	public Set<NomenclaturalStatus> getStatus() {
508
		return status;
509
	}
510 ee91bcd9 ben.clark
511 09487e73 m.geoffroy
	/** 
512
	 * Adds a new {@link NomenclaturalStatus nomenclatural status}
513 b9d0e8d2 m.geoffroy
	 * to <i>this</i> taxon name's set of nomenclatural status.
514 09487e73 m.geoffroy
	 *
515
	 * @param  nomStatus  the nomenclatural status to be added
516
	 * @see 			  #getStatus()
517
	 */
518 025f3199 Andreas Müller
	public void addStatus(NomenclaturalStatus nomStatus) {
519
		this.status.add(nomStatus);
520 9479da48 Andreas Müller
	}
521 ee91bcd9 ben.clark
	
522 09487e73 m.geoffroy
	/** 
523 b9d0e8d2 m.geoffroy
	 * Removes one element from the set of nomenclatural status of <i>this</i> taxon name.
524 09487e73 m.geoffroy
	 * Type and ruleConsidered attributes of the nomenclatural status object
525
	 * will be nullified.
526
	 *
527 b9d0e8d2 m.geoffroy
	 * @param  nomStatus  the nomenclatural status of <i>this</i> taxon name which should be deleted
528 09487e73 m.geoffroy
	 * @see     		  #getStatus()
529
	 */
530 025f3199 Andreas Müller
	public void removeStatus(NomenclaturalStatus nomStatus) {
531 09487e73 m.geoffroy
		//TODO to be implemented?
532
		logger.warn("not yet fully implemented?");
533 025f3199 Andreas Müller
		this.status.remove(nomStatus);
534 9479da48 Andreas Müller
	}
535
536 5c19d7f0 Andreas Müller
	
537
	/**
538 09887ea6 m.geoffroy
	 * Indicates whether <i>this</i> taxon name is a {@link NameRelationshipType#BASIONYM() basionym}
539
	 * or a {@link NameRelationshipType#REPLACED_SYNONYM() replaced synonym}
540 abc6aceb m.geoffroy
	 * of any other taxon name. Returns "true", if a basionym or a replaced 
541 09887ea6 m.geoffroy
	 * synonym {@link NameRelationship relationship} from <i>this</i> taxon name to another taxon name exists,
542 b9d0e8d2 m.geoffroy
	 * false otherwise (also in case <i>this</i> taxon name is the only one in the
543 09487e73 m.geoffroy
	 * homotypical group).
544 5c19d7f0 Andreas Müller
	 */
545 b70a7f94 Andreas Kohlbecker
	@Transient
546 5c19d7f0 Andreas Müller
	public boolean isOriginalCombination(){
547
		Set<NameRelationship> relationsFromThisName = this.getRelationsFromThisName();
548
		for (NameRelationship relation : relationsFromThisName) {
549
			if (relation.getType().equals(NameRelationshipType.BASIONYM()) ||
550
					relation.getType().equals(NameRelationshipType.REPLACED_SYNONYM())) {
551
				return true;
552
			}
553
		}
554
		return false;
555
	}
556
	
557 09487e73 m.geoffroy
	/**
558 09887ea6 m.geoffroy
	 * Returns the taxon name which is the {@link NameRelationshipType#BASIONYM() basionym} of <i>this</i> taxon name.
559 09487e73 m.geoffroy
	 * The basionym of a taxon name is its epithet-bringing synonym.
560 09887ea6 m.geoffroy
	 * For instance <i>Pinus abies</i> L. was published by Linnaeus and the botanist
561 b9d0e8d2 m.geoffroy
	 * Karsten transferred later <i>this</i> taxon to the genus Picea. Therefore,
562 09887ea6 m.geoffroy
	 * <i>Pinus abies</i> L. is the basionym of the new combination <i>Picea abies</i> (L.) H. Karst.
563 09487e73 m.geoffroy
	 */
564 b70a7f94 Andreas Kohlbecker
	@Transient
565 2a486d28 Andreas Müller
	public T getBasionym(){
566 6ecda5d2 m.doering
		//TODO: pick the right name relationships...
567 d27ee9b1 Andreas Müller
		logger.warn("get Basionym not yet implemented");
568 6ecda5d2 m.doering
		return null;
569 9479da48 Andreas Müller
	}
570 09487e73 m.geoffroy
	/**
571 09887ea6 m.geoffroy
	 * Assigns a taxon name as {@link NameRelationshipType#BASIONYM() basionym} of <i>this</i> taxon name.
572
	 * The basionym {@link NameRelationship relationship} will be added to <i>this</i> taxon name
573 09487e73 m.geoffroy
	 * and to the basionym. The basionym cannot have itself a basionym.
574 09887ea6 m.geoffroy
	 * The {@link HomotypicalGroup homotypical groups} of <i>this</i> taxon name and of the basionym
575
	 * will be {@link HomotypicalGroup#merge(HomotypicalGroup) merged}.
576
	 * 
577
	 * @param  basionym		the taxon name to be set as the basionym of <i>this</i> taxon name
578
	 * @see  				#getBasionym()
579
	 * @see  				#addBasionym(TaxonNameBase, String)
580 09487e73 m.geoffroy
	 */
581 d27ee9b1 Andreas Müller
	public void addBasionym(T basionym){
582 21f31bf8 Andreas Müller
		addBasionym(basionym, null, null, null);
583 6ecda5d2 m.doering
	}
584 09487e73 m.geoffroy
	/**
585 09887ea6 m.geoffroy
	 * Assigns a taxon name as {@link NameRelationshipType#BASIONYM() basionym} of <i>this</i> taxon name
586 09487e73 m.geoffroy
	 * and keeps the nomenclatural rule considered for it. The basionym
587 09887ea6 m.geoffroy
	 * {@link NameRelationship relationship} will be added to <i>this</i> taxon name and to the basionym.
588
	 * The basionym cannot have itself a basionym.
589
	 * The {@link HomotypicalGroup homotypical groups} of <i>this</i> taxon name and of the basionym
590
	 * will be {@link HomotypicalGroup#merge(HomotypicalGroup) merged}.
591
	 * 
592
	 * @param  basionym			the taxon name to be set as the basionym of <i>this</i> taxon name
593
	 * @param  ruleConsidered	the string identifying the nomenclatural rule
594
	 * @see  					#getBasionym()
595
	 * @see  					#addBasionym(TaxonNameBase)
596 09487e73 m.geoffroy
	 */
597 21f31bf8 Andreas Müller
	public void addBasionym(T basionym, ReferenceBase citation, String microcitation, String ruleConsidered){
598 d27ee9b1 Andreas Müller
		if (basionym != null){
599 21f31bf8 Andreas Müller
			basionym.addRelationshipToName(this, NameRelationshipType.BASIONYM(), citation, microcitation, ruleConsidered);
600 d27ee9b1 Andreas Müller
		}
601
	}
602
	
603 09887ea6 m.geoffroy
	/** 
604
	 * Removes the {@link NameRelationshipType#BASIONYM() basionym} {@link NameRelationship relationship} from the set of
605
	 * {@link #getRelationsToThisName() name relationships to} <i>this</i> taxon name. The same relationhip will be
606
	 * removed from the set of {@link #getRelationsFromThisName() name relationships from} the taxon name
607
	 * previously used as basionym.
608
	 *
609
	 * @see   #getBasionym()
610
	 * @see   #addBasionym(TaxonNameBase)
611
	 */
612 d27ee9b1 Andreas Müller
	public void removeBasionym(){
613
		//TODO implement
614
		logger.warn("not yet implemented");
615 9479da48 Andreas Müller
	}
616
	
617 8eebe79d m.geoffroy
	/** 
618 b9d0e8d2 m.geoffroy
	 * Returns the taxonomic {@link Rank rank} of <i>this</i> taxon name.
619 8eebe79d m.geoffroy
	 *
620
	 * @see 	Rank
621
	 */
622 9479da48 Andreas Müller
	public Rank getRank(){
623
		return this.rank;
624
	}
625 ee91bcd9 ben.clark
	
626 8eebe79d m.geoffroy
	/**
627
	 * @see  #getRank()
628
	 */
629 9479da48 Andreas Müller
	public void setRank(Rank rank){
630
		this.rank = rank;
631
	}
632
633 8eebe79d m.geoffroy
	/** 
634 09887ea6 m.geoffroy
	 * Returns the {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} of <i>this</i> taxon name.
635 8eebe79d m.geoffroy
	 * The nomenclatural reference is here meant to be the one publication
636 b9d0e8d2 m.geoffroy
	 * <i>this</i> taxon name was originally published in while fulfilling the formal
637 a7d9a8c1 m.geoffroy
	 * requirements as specified by the corresponding {@link NomenclaturalCode nomenclatural code}.
638 8eebe79d m.geoffroy
	 *
639 09887ea6 m.geoffroy
	 * @see 	eu.etaxonomy.cdm.model.reference.INomenclaturalReference
640
	 * @see 	eu.etaxonomy.cdm.model.reference.ReferenceBase
641 8eebe79d m.geoffroy
	 */
642 b70a7f94 Andreas Kohlbecker
	public ReferenceBase getNomenclaturalReference(){
643
		return this.nomenclaturalReference;
644 9479da48 Andreas Müller
	}
645 8eebe79d m.geoffroy
	/**
646 09887ea6 m.geoffroy
	 * Assigns a {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} to <i>this</i> taxon name.
647
	 * The corresponding {@link eu.etaxonomy.cdm.model.reference.ReferenceBase.isNomenclaturallyRelevant nomenclaturally relevant flag} will be set to true
648 8eebe79d m.geoffroy
	 * as it is obviously used for nomenclatural purposes.
649
	 *
650 b70a7f94 Andreas Kohlbecker
	 * @throws IllegalArgumentException if parameter <code>nomenclaturalReference</code> is not assignable from {@link INomenclaturalReference}
651 8eebe79d m.geoffroy
	 * @see  #getNomenclaturalReference()
652
	 */
653 b70a7f94 Andreas Kohlbecker
	public void setNomenclaturalReference(ReferenceBase nomenclaturalReference){
654
		if(nomenclaturalReference != null){
655
			if(!INomenclaturalReference.class.isAssignableFrom(nomenclaturalReference.getClass())){
656
				throw new IllegalArgumentException("Parameter nomenclaturalReference is not assignable from INomenclaturalReference");
657
			}
658
			this.nomenclaturalReference = (ReferenceBase)nomenclaturalReference;
659
		} else {
660
			this.nomenclaturalReference = null;
661
		}
662 9479da48 Andreas Müller
	}
663
664 8eebe79d m.geoffroy
	/** 
665 b9d0e8d2 m.geoffroy
	 * Returns the appended phrase string assigned to <i>this</i> taxon name.
666 8eebe79d m.geoffroy
	 * The appended phrase is a non-atomised addition to a name. It is
667
	 * not ruled by a nomenclatural code.
668
	 */
669 9479da48 Andreas Müller
	public String getAppendedPhrase(){
670
		return this.appendedPhrase;
671
	}
672 ee91bcd9 ben.clark
	
673 8eebe79d m.geoffroy
	/**
674
	 * @see  #getAppendedPhrase()
675
	 */
676 9479da48 Andreas Müller
	public void setAppendedPhrase(String appendedPhrase){
677
		this.appendedPhrase = appendedPhrase;
678
	}
679
680 8eebe79d m.geoffroy
	/** 
681 09887ea6 m.geoffroy
	 * Returns the details string of the {@link #getNomenclaturalReference() nomenclatural reference} assigned
682 b9d0e8d2 m.geoffroy
	 * to <i>this</i> taxon name. The details describe the exact localisation within
683 8eebe79d m.geoffroy
	 * the publication used as nomenclature reference. These are mostly
684
	 * (implicitly) pages but can also be figures or tables or any other
685
	 * element of a publication. A nomenclatural micro reference (details)
686
	 * requires the existence of a nomenclatural reference.
687
	 */
688
	//Details of the nomenclatural reference (protologue). 
689 9479da48 Andreas Müller
	public String getNomenclaturalMicroReference(){
690
		return this.nomenclaturalMicroReference;
691
	}
692 8eebe79d m.geoffroy
	/**
693
	 * @see  #getNomenclaturalMicroReference()
694
	 */
695 9479da48 Andreas Müller
	public void setNomenclaturalMicroReference(String nomenclaturalMicroReference){
696
		this.nomenclaturalMicroReference = nomenclaturalMicroReference;
697
	}
698
699 6680df00 Andreas Müller
	/* (non-Javadoc)
700
	 * @see eu.etaxonomy.cdm.model.common.IParsable#getHasProblem()
701 8eebe79d m.geoffroy
	 */
702 9479da48 Andreas Müller
	public boolean getHasProblem(){
703
		return this.hasProblem;
704
	}
705 6680df00 Andreas Müller
	
706
	/* (non-Javadoc)
707
	 * @see eu.etaxonomy.cdm.model.common.IParsable#setHasProblem(boolean)
708 8eebe79d m.geoffroy
	 */
709 9479da48 Andreas Müller
	public void setHasProblem(boolean hasProblem){
710
		this.hasProblem = hasProblem;
711
	}
712 6680df00 Andreas Müller
	
713
	/* (non-Javadoc)
714
	 * @see eu.etaxonomy.cdm.model.common.IParsable#hasProblem()
715 81c31b35 Andreas Müller
	 */
716
	public boolean hasProblem(){
717
		return getHasProblem();
718
	}
719 6680df00 Andreas Müller
	
720
	/* (non-Javadoc)
721
	 * @see eu.etaxonomy.cdm.model.common.IParsable#problemStarts()
722
	 */
723
	public int getProblemStarts(){
724
		return this.problemStarts;
725
	}
726
	
727
	/* (non-Javadoc)
728
	 * @see eu.etaxonomy.cdm.model.common.IParsable#setProblemStarts(int)
729
	 */
730
	public void setProblemStarts(int start) {
731
		this.problemStarts = start;
732
	}
733
	
734
	/* (non-Javadoc)
735
	 * @see eu.etaxonomy.cdm.model.common.IParsable#problemEnds()
736
	 */
737
	public int getProblemEnds(){
738
		return this.problemEnds;
739
	}
740
741
	/* (non-Javadoc)
742
	 * @see eu.etaxonomy.cdm.model.common.IParsable#setProblemEnds(int)
743
	 */
744
	public void setProblemEnds(int end) {
745
		this.problemEnds = end;
746
	}
747
748 dce4c9cb Andreas Müller
//*********************** TYPE DESIGNATION *********************************************//	
749
	
750 79263e24 m.geoffroy
	/** 
751 dce4c9cb Andreas Müller
	 * Returns the set of {@link TypeDesignationBase type designations} assigned
752
	 * to <i>this</i> taxon name.
753 79263e24 m.geoffroy
	 * @see     NameTypeDesignation
754
	 * @see     SpecimenTypeDesignation
755
	 */
756 dce4c9cb Andreas Müller
	public Set<TypeDesignationBase> getTypeDesignations() {
757
		return typeDesignations;
758 9479da48 Andreas Müller
	}
759 dce4c9cb Andreas Müller
	
760
	/** 
761 6a9737e8 m.geoffroy
	 * Removes one element from the set of {@link TypeDesignationBase type designations} assigned to
762
	 * <i>this</i> taxon name. The type designation itself will be nullified.
763 dce4c9cb Andreas Müller
	 *
764
	 * @param  typeDesignation  the type designation which should be deleted
765
	 */
766
	public void removeTypeDesignation(TypeDesignationBase typeDesignation) {
767
		logger.warn("not yet fully implemented: nullify the specimen type designation itself?");
768
		this.typeDesignations.remove(typeDesignation);
769
	}
770
	
771
	/** 
772
	 * Returns the set of {@link SpecimenTypeDesignation specimen type designations} assigned
773 6a9737e8 m.geoffroy
	 * to <i>this</i> taxon name. The {@link Rank rank} of <i>this</i> taxon name is generally
774
	 * "species" or below. The specimen type designations include all the
775
	 * specimens on which the typification of this name is based (which are
776 09887ea6 m.geoffroy
	 * exclusively used to typify taxon names belonging to the same
777 6a9737e8 m.geoffroy
	 * {@link HomotypicalGroup homotypical group} to which <i>this</i> taxon name
778
	 * belongs) and eventually the status of these designations.
779 dce4c9cb Andreas Müller
	 *
780
	 * @see     SpecimenTypeDesignation
781
	 * @see     NameTypeDesignation
782 6a9737e8 m.geoffroy
	 * @see     HomotypicalGroup
783 dce4c9cb Andreas Müller
	 */
784 b70a7f94 Andreas Kohlbecker
	@Transient
785 dce4c9cb Andreas Müller
	public Set<SpecimenTypeDesignation> getSpecimenTypeDesignationsOfHomotypicalGroup() {
786
		return this.getHomotypicalGroup().getSpecimenTypeDesignations();
787
	}
788
	
789
//*********************** NAME TYPE DESIGNATION *********************************************//	
790
	
791
	/** 
792
	 * Returns the set of {@link NameTypeDesignation name type designations} assigned
793
	 * to <i>this</i> taxon name the rank of which must be above "species".
794
	 * The name type designations include all the taxon names used to typify
795 d82717cb m.geoffroy
	 * <i>this</i> taxon name and eventually the rejected or conserved status
796 dce4c9cb Andreas Müller
	 * of these designations.
797
	 *
798
	 * @see     NameTypeDesignation
799
	 * @see     SpecimenTypeDesignation
800
	 */
801 b70a7f94 Andreas Kohlbecker
	@Transient
802 dce4c9cb Andreas Müller
	public Set<NameTypeDesignation> getNameTypeDesignations() {
803
		Set<NameTypeDesignation> result = new HashSet<NameTypeDesignation>();
804
		for (TypeDesignationBase typeDesignation : this.typeDesignations){
805
			if (typeDesignation instanceof NameTypeDesignation){
806
				result.add((NameTypeDesignation)typeDesignation);
807 c79406dd n.hoffmann
			}
808
		}
809 dce4c9cb Andreas Müller
		return result;
810 c79406dd n.hoffmann
	}
811 ed85df08 Andreas Müller
	
812
	/** 
813
	 * Creates and adds a new {@link NameTypeDesignation name type designation}
814 09887ea6 m.geoffroy
	 * to <i>this</i> taxon name's set of type designations.
815 ed85df08 Andreas Müller
	 *
816 b9d0e8d2 m.geoffroy
	 * @param  typeSpecies				the taxon name to be used as type of <i>this</i> taxon name
817 ed85df08 Andreas Müller
	 * @param  citation					the reference for this new designation
818
	 * @param  citationMicroReference	the string with the details (generally pages) within the reference
819 7d954fd9 m.geoffroy
	 * @param  originalNameString		the taxon name string used in the reference to assert this designation
820 6a9737e8 m.geoffroy
	 * @param  isRejectedType			the boolean status for a rejected name type designation
821
	 * @param  isConservedType			the boolean status for a conserved name type designation
822
	 * @param  isLectoType				the boolean status for a lectotype name type designation
823 d82717cb m.geoffroy
	 * @param  isNotDesignated			the boolean status for a name type designation without name type
824
	 * @param  addToAllHomotypicNames	the boolean indicating whether the name type designation should be
825
	 * 									added to all taxon names of the homotypical group this taxon name belongs to
826 ed85df08 Andreas Müller
	 * @see 			  				#getNameTypeDesignations()
827 6a9737e8 m.geoffroy
	 * @see 			  				NameTypeDesignation
828 57883822 m.geoffroy
	 * @see 			  				TypeDesignationBase#isNotDesignated()
829 ed85df08 Andreas Müller
	 */
830 dce4c9cb Andreas Müller
	public void addNameTypeDesignation(TaxonNameBase typeSpecies, 
831
				ReferenceBase citation, 
832
				String citationMicroReference, 
833
				String originalNameString, 
834
				boolean isRejectedType, 
835
				boolean isConservedType, 
836
				boolean isLectoType, 
837
				boolean isNotDesignated, 
838
				boolean addToAllHomotypicNames) {
839 ec1f7873 Andreas Müller
		NameTypeDesignation nameTypeDesignation = new NameTypeDesignation(typeSpecies, citation, citationMicroReference, originalNameString, isRejectedType, isConservedType, isLectoType, isNotDesignated);
840 168723a2 a.babadshanjan
		nameTypeDesignation.setLectoType(isLectoType);
841 dce4c9cb Andreas Müller
		addTypeDesignation(nameTypeDesignation, addToAllHomotypicNames);
842 ed85df08 Andreas Müller
	}
843
	
844 dce4c9cb Andreas Müller
//*********************** SPECIMEN TYPE DESIGNATION *********************************************//	
845 ed85df08 Andreas Müller
	
846 61106138 m.geoffroy
	/** 
847
	 * Returns the set of {@link SpecimenTypeDesignation specimen type designations}
848 b9d0e8d2 m.geoffroy
	 * that typify <i>this</i> taxon name.
849 ed85df08 Andreas Müller
	 */
850 b70a7f94 Andreas Kohlbecker
	@Transient
851 dce4c9cb Andreas Müller
	public Set<SpecimenTypeDesignation> getSpecimenTypeDesignations() {
852
		Set<SpecimenTypeDesignation> result = new HashSet<SpecimenTypeDesignation>();
853
		for (TypeDesignationBase typeDesignation : this.typeDesignations){
854
			if (typeDesignation instanceof SpecimenTypeDesignation){
855
				result.add((SpecimenTypeDesignation)typeDesignation);
856
			}
857
		}
858
		return result;
859 66b77c3e m.geoffroy
	}
860 dce4c9cb Andreas Müller
861 66b77c3e m.geoffroy
	
862 79263e24 m.geoffroy
	/** 
863 d82717cb m.geoffroy
	 * Creates and adds a new {@link SpecimenTypeDesignation specimen type designation}
864 09887ea6 m.geoffroy
	 * to <i>this</i> taxon name's set of type designations.
865 79263e24 m.geoffroy
	 *
866 d82717cb m.geoffroy
	 * @param  typeSpecimen				the specimen to be used as a type for <i>this</i> taxon name
867 79263e24 m.geoffroy
	 * @param  status					the specimen type designation status
868
	 * @param  citation					the reference for this new specimen type designation
869
	 * @param  citationMicroReference	the string with the details (generally pages) within the reference
870
	 * @param  originalNameString		the taxon name used in the reference to assert this designation
871 57883822 m.geoffroy
	 * @param  isNotDesignated			the boolean status for a specimen type designation without specimen type
872 d82717cb m.geoffroy
	 * @param  addToAllHomotypicNames	the boolean indicating whether the specimen type designation should be
873
	 * 									added to all taxon names of the homotypical group the typified
874
	 * 									taxon name belongs to
875
	 * @see 			  				#getSpecimenTypeDesignations()
876 2d4607f2 a.babadshanjan
	 * @see 			  				SpecimenTypeDesignationStatus
877 d82717cb m.geoffroy
	 * @see 			  				SpecimenTypeDesignation
878 57883822 m.geoffroy
	 * @see 			  				TypeDesignationBase#isNotDesignated()
879 79263e24 m.geoffroy
	 */
880 dce4c9cb Andreas Müller
	public void addSpecimenTypeDesignation(Specimen typeSpecimen, 
881 2d4607f2 a.babadshanjan
				SpecimenTypeDesignationStatus status, 
882 dce4c9cb Andreas Müller
				ReferenceBase citation, 
883
				String citationMicroReference, 
884
				String originalNameString, 
885 57883822 m.geoffroy
				boolean isNotDesignated, 
886 dce4c9cb Andreas Müller
				boolean addToAllHomotypicNames) {
887 57883822 m.geoffroy
		SpecimenTypeDesignation specimenTypeDesignation = new SpecimenTypeDesignation(typeSpecimen, status, citation, citationMicroReference, originalNameString, isNotDesignated);
888 dce4c9cb Andreas Müller
		addTypeDesignation(specimenTypeDesignation, addToAllHomotypicNames);
889 9479da48 Andreas Müller
	}
890 ed85df08 Andreas Müller
	
891 dce4c9cb Andreas Müller
	private boolean addTypeDesignation(TypeDesignationBase typeDesignation, boolean addToAllNames){
892
		//at them moment typeDesignations are not persisted with the homotypical group
893
		//so explicit adding to the homotypical group is not necessary.
894
		if (typeDesignation != null){
895
			this.typeDesignations.add(typeDesignation);
896
			typeDesignation.addTypifiedName(this);
897
			
898
			if (addToAllNames){
899
				for (TaxonNameBase taxonName : this.getHomotypicalGroup().getTypifiedNames()){
900
					if (taxonName != this){
901
						taxonName.addTypeDesignation(typeDesignation, false);
902
					}
903
				}
904
			}
905
		}
906
		return true;
907 ed85df08 Andreas Müller
	}
908 dce4c9cb Andreas Müller
	
909 ed85df08 Andreas Müller
910 dce4c9cb Andreas Müller
	
911
//*********************** HOMOTYPICAL GROUP *********************************************//	
912 9479da48 Andreas Müller
913 dce4c9cb Andreas Müller
	
914 79263e24 m.geoffroy
	/** 
915
	 * Returns the {@link HomotypicalGroup homotypical group} to which
916 b9d0e8d2 m.geoffroy
	 * <i>this</i> taxon name belongs. A homotypical group represents all taxon names
917 d82717cb m.geoffroy
	 * that share the same types.
918 79263e24 m.geoffroy
	 *
919
	 * @see 	HomotypicalGroup
920
	 */
921 ee91bcd9 ben.clark
	
922 9479da48 Andreas Müller
	public HomotypicalGroup getHomotypicalGroup() {
923
		return homotypicalGroup;
924
	}
925 ee91bcd9 ben.clark
	
926
	/* 
927
	 * @see #getHomotypicalGroup()
928
	 */
929
	protected void setHomotypicalGroup(HomotypicalGroup homotypicalGroup) {
930
		this.homotypicalGroup = homotypicalGroup;
931 9479da48 Andreas Müller
	}
932
933 dce4c9cb Andreas Müller
// *************************************************************************//
934
	
935 b3262b1b m.geoffroy
	/** 
936
	 * @see #getNomenclaturalReference()
937
	 */
938 b70a7f94 Andreas Kohlbecker
	@Transient
939 9479da48 Andreas Müller
	public StrictReferenceBase getCitation(){
940 66b77c3e m.geoffroy
		//TODO What is the purpose of this method differing from the getNomenclaturalReference method? 
941 c19dfdc5 Andreas Müller
		logger.warn("getCitation not yet implemented");
942 9479da48 Andreas Müller
		return null;
943
	}
944
945 66b77c3e m.geoffroy
	/** 
946
	 * Returns the complete string containing the
947 09887ea6 m.geoffroy
	 * {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference#getNomenclaturalCitation() nomenclatural reference citation}
948
	 * and the {@link #getNomenclaturalMicroReference() details} assigned to <i>this</i> taxon name.
949 66b77c3e m.geoffroy
	 * 
950 b9d0e8d2 m.geoffroy
	 * @return  the string containing the nomenclatural reference of <i>this</i> taxon name
951 09887ea6 m.geoffroy
	 * @see		eu.etaxonomy.cdm.model.reference.INomenclaturalReference#getNomenclaturalCitation()
952 b3262b1b m.geoffroy
	 * @see		#getNomenclaturalReference()
953
	 * @see		#getNomenclaturalMicroReference()
954 66b77c3e m.geoffroy
	 */
955 b70a7f94 Andreas Kohlbecker
	@Transient
956 6680df00 Andreas Müller
	@Deprecated
957 9479da48 Andreas Müller
	public String getCitationString(){
958 c19dfdc5 Andreas Müller
		logger.warn("getCitationString not yet implemented");
959 9479da48 Andreas Müller
		return null;
960
	}
961
962 09887ea6 m.geoffroy
	/** 
963
	 * Not yet implemented
964
	 */
965 6680df00 Andreas Müller
	@Deprecated
966 9479da48 Andreas Müller
	public String[] getProblems(){
967 c19dfdc5 Andreas Müller
		logger.warn("getProblems not yet implemented");
968 9479da48 Andreas Müller
		return null;
969
	}
970
971
	/**
972 66b77c3e m.geoffroy
	 * Returns the string containing the publication date (generally only year)
973 09887ea6 m.geoffroy
	 * of the {@link #getNomenclaturalReference() nomenclatural reference} for <i>this</i> taxon name, null if there is
974 b3262b1b m.geoffroy
	 * no nomenclatural reference.
975 66b77c3e m.geoffroy
	 * 
976 b9d0e8d2 m.geoffroy
	 * @return  the string containing the publication date of <i>this</i> taxon name
977 09887ea6 m.geoffroy
	 * @see		eu.etaxonomy.cdm.model.reference.INomenclaturalReference#getYear()
978 9479da48 Andreas Müller
	 */
979 b70a7f94 Andreas Kohlbecker
	@Transient
980 b0b7280d Andreas Müller
	public String getReferenceYear(){
981
		if (this.getNomenclaturalReference() != null ){
982
			return this.getNomenclaturalReference().getYear();
983
		}else{
984
			return null;
985
		}
986 9479da48 Andreas Müller
	}
987
988 66b77c3e m.geoffroy
	/** 
989 09887ea6 m.geoffroy
	 * Returns the set of {@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon bases} that refer to <i>this</i> taxon name.
990 66b77c3e m.geoffroy
	 * In this context a taxon base means the use of a taxon name by a reference
991 09887ea6 m.geoffroy
	 * either as a {@link eu.etaxonomy.cdm.model.taxon.Taxon taxon} ("accepted/correct" name) or
992
	 * as a (junior) {@link eu.etaxonomy.cdm.model.taxon.Synonym synonym}.
993
	 * A taxon name can be used by several distinct {@link eu.etaxonomy.cdm.model.reference.ReferenceBase references} but only once
994 66b77c3e m.geoffroy
	 * within a taxonomic treatment (identified by one reference).
995
	 *
996
	 * @see	#getTaxa()
997
	 * @see	#getSynonyms()
998
	 */
999 608eada2 Andreas Müller
	public Set<TaxonBase> getTaxonBases() {
1000
		return this.taxonBases;
1001
	}
1002 ee91bcd9 ben.clark
	
1003 66b77c3e m.geoffroy
	/** 
1004 09887ea6 m.geoffroy
	 * Adds a new {@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon base}
1005 b9d0e8d2 m.geoffroy
	 * to the set of taxon bases using <i>this</i> taxon name.
1006 66b77c3e m.geoffroy
	 *
1007
	 * @param  taxonBase  the taxon base to be added
1008
	 * @see 			  #getTaxonBases()
1009 61106138 m.geoffroy
	 * @see 			  #removeTaxonBase(TaxonBase)
1010 66b77c3e m.geoffroy
	 */
1011 1cfc54ab Andreas Müller
	//TODO protected
1012
	public void addTaxonBase(TaxonBase taxonBase){
1013 ee91bcd9 ben.clark
		Method method = ReflectionUtils.findMethod(TaxonBase.class, "setName", new Class[] {TaxonNameBase.class});
1014
		ReflectionUtils.makeAccessible(method);
1015
		ReflectionUtils.invokeMethod(method, taxonBase, new Object[] {this});
1016 1cfc54ab Andreas Müller
		taxonBases.add(taxonBase);
1017
	}
1018 b3262b1b m.geoffroy
	/** 
1019 09887ea6 m.geoffroy
	 * Removes one element from the set of {@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon bases} that refer to <i>this</i> taxon name.
1020 b3262b1b m.geoffroy
	 *
1021
	 * @param  taxonBase	the taxon base which should be removed from the corresponding set
1022 09887ea6 m.geoffroy
	 * @see    				#getTaxonBases()
1023 b3262b1b m.geoffroy
	 * @see    				#addTaxonBase(TaxonBase)
1024
	 */
1025 c1c3a21a Andreas Müller
	public void removeTaxonBase(TaxonBase taxonBase){
1026 ee91bcd9 ben.clark
		Method method = ReflectionUtils.findMethod(TaxonBase.class, "setName", new Class[] {TaxonNameBase.class});
1027
		ReflectionUtils.makeAccessible(method);
1028
		ReflectionUtils.invokeMethod(method, taxonBase, new Object[] {null});
1029 d163fbf6 Andreas Müller
		taxonBases.remove(taxonBase);
1030 1cfc54ab Andreas Müller
	}
1031
	
1032 0d4d2092 m.doering
	/**
1033 09887ea6 m.geoffroy
	 * Returns the set of {@link eu.etaxonomy.cdm.model.taxon.Taxon taxa} ("accepted/correct" names according to any
1034 b9d0e8d2 m.geoffroy
	 * reference) that are based on <i>this</i> taxon name. This set is a subset of
1035 66b77c3e m.geoffroy
	 * the set returned by getTaxonBases(). 
1036
	 * 
1037 09887ea6 m.geoffroy
	 * @see	eu.etaxonomy.cdm.model.taxon.Taxon
1038 66b77c3e m.geoffroy
	 * @see	#getTaxonBases()
1039
	 * @see	#getSynonyms()
1040 0d4d2092 m.doering
	 */
1041 b70a7f94 Andreas Kohlbecker
	@Transient
1042 0d4d2092 m.doering
	public Set<Taxon> getTaxa(){
1043 608eada2 Andreas Müller
		Set<Taxon> result = new HashSet<Taxon>();
1044
		for (TaxonBase taxonBase : this.taxonBases){
1045
			if (taxonBase instanceof Taxon){
1046
				result.add((Taxon)taxonBase);
1047
			}
1048
		}
1049
		return result;
1050 0d4d2092 m.doering
	}
1051 608eada2 Andreas Müller
	
1052 0d4d2092 m.doering
	/**
1053 09887ea6 m.geoffroy
	 * Returns the set of {@link eu.etaxonomy.cdm.model.taxon.Synonym (junior) synonyms} (according to any
1054 b9d0e8d2 m.geoffroy
	 * reference) that are based on <i>this</i> taxon name. This set is a subset of
1055 66b77c3e m.geoffroy
	 * the set returned by getTaxonBases(). 
1056
	 * 
1057 09887ea6 m.geoffroy
	 * @see	eu.etaxonomy.cdm.model.taxon.Synonym
1058 66b77c3e m.geoffroy
	 * @see	#getTaxonBases()
1059
	 * @see	#getTaxa()
1060 0d4d2092 m.doering
	 */
1061 b70a7f94 Andreas Kohlbecker
	@Transient
1062 608eada2 Andreas Müller
	public Set<Synonym> getSynonyms() {
1063
		Set<Synonym> result = new HashSet<Synonym>();
1064
		for (TaxonBase taxonBase : this.taxonBases){
1065
			if (taxonBase instanceof Synonym){
1066
				result.add((Synonym)taxonBase);
1067
			}
1068
		}
1069
		return result;
1070 0d4d2092 m.doering
	}
1071 9118658f m.doering
	
1072 71dcc146 Andreas Müller
	
1073
// *********** DESCRIPTIONS *************************************	
1074
1075 0880a77c m.geoffroy
	/**
1076 09887ea6 m.geoffroy
	 * Returns the set of {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription taxon name descriptions} assigned
1077 b9d0e8d2 m.geoffroy
	 * to <i>this</i> taxon name. A taxon name description is a piece of information
1078 0880a77c m.geoffroy
	 * concerning the taxon name like for instance the content of its first
1079
	 * publication (protolog) or a picture of this publication.
1080
	 * 
1081
	 * @see	#addDescription(TaxonNameDescription)
1082
	 * @see	#removeDescription(TaxonNameDescription)
1083 09887ea6 m.geoffroy
	 * @see	eu.etaxonomy.cdm.model.description.TaxonNameDescription
1084 0880a77c m.geoffroy
	 */
1085 71dcc146 Andreas Müller
	public Set<TaxonNameDescription> getDescriptions() {
1086
		return descriptions;
1087
	}
1088 ee91bcd9 ben.clark
1089 0880a77c m.geoffroy
	/** 
1090 09887ea6 m.geoffroy
	 * Adds a new {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription taxon name description}
1091 b9d0e8d2 m.geoffroy
	 * to the set of taxon name descriptions assigned to <i>this</i> taxon name. The
1092 09887ea6 m.geoffroy
	 * content of the {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription#getTaxonName() taxonName attribute} of the
1093 b9d0e8d2 m.geoffroy
	 * taxon name description itself will be replaced with <i>this</i> taxon name.
1094 0880a77c m.geoffroy
	 *
1095
	 * @param  description  the taxon name description to be added
1096
	 * @see					#getDescriptions()
1097
	 * @see 			  	#removeDescription(TaxonNameDescription)
1098 71dcc146 Andreas Müller
	 */
1099
	public void addDescription(TaxonNameDescription description) {
1100 fd7ee7b1 ben.clark
		java.lang.reflect.Field field = ReflectionUtils.findField(TaxonNameDescription.class, "taxonName", TaxonNameBase.class);
1101 c49c125c Andreas Müller
		ReflectionUtils.makeAccessible(field);
1102
		ReflectionUtils.setField(field, description, this);
1103 71dcc146 Andreas Müller
		descriptions.add(description);
1104
	}
1105 0880a77c m.geoffroy
	/** 
1106 09887ea6 m.geoffroy
	 * Removes one element from the set of {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription taxon name descriptions} assigned
1107
	 * to <i>this</i> taxon name. The content of the {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription#getTaxonName() taxonName attribute}
1108 0880a77c m.geoffroy
	 * of the description itself will be set to "null".
1109
	 *
1110
	 * @param  description  the taxon name description which should be removed
1111
	 * @see     		  	#getDescriptions()
1112
	 * @see     		  	#addDescription(TaxonNameDescription)
1113 09887ea6 m.geoffroy
	 * @see 			  	eu.etaxonomy.cdm.model.description.TaxonNameDescription#getTaxonName()
1114 0880a77c m.geoffroy
	 */
1115 71dcc146 Andreas Müller
	public void removeDescription(TaxonNameDescription description) {
1116 fd7ee7b1 ben.clark
		java.lang.reflect.Field field = ReflectionUtils.findField(TaxonNameDescription.class, "taxonName", TaxonNameBase.class);
1117 c49c125c Andreas Müller
		ReflectionUtils.makeAccessible(field);
1118
		ReflectionUtils.setField(field, description, null);
1119 71dcc146 Andreas Müller
		descriptions.remove(description);
1120
	}
1121
	
1122 95449e99 Andreas Müller
// ***********
1123 66b77c3e m.geoffroy
	/**
1124
	 * Returns the boolean value indicating whether a given taxon name belongs
1125 b9d0e8d2 m.geoffroy
	 * to the same {@link HomotypicalGroup homotypical group} as <i>this</i> taxon name (true)
1126 66b77c3e m.geoffroy
	 * or not (false). Returns "true" only if the homotypical groups of both
1127
	 * taxon names exist and if they are identical. 
1128
	 *
1129
	 * @param	homoTypicName  the taxon name the homotypical group of which is to be checked
1130
	 * @return  			   the boolean value of the check
1131
	 * @see     			   HomotypicalGroup
1132
	 */
1133 b70a7f94 Andreas Kohlbecker
	@Transient
1134 95449e99 Andreas Müller
	public boolean isHomotypic(TaxonNameBase homoTypicName) {
1135
		if (homoTypicName == null) {
1136
			return false;
1137
		}
1138
		HomotypicalGroup homotypicGroup = homoTypicName.getHomotypicalGroup();
1139
		if (homotypicGroup == null || this.getHomotypicalGroup() == null) {
1140
			return false;
1141
		}
1142
		if (homotypicGroup.equals(this.getHomotypicalGroup())) {
1143
			return true;
1144
		}
1145
		return false;
1146
	}
1147
	
1148
//*********  Rank comparison shortcuts   ********************//
1149 4cc4f6f7 m.geoffroy
	/**
1150 b9d0e8d2 m.geoffroy
	 * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of <i>this</i>
1151 4cc4f6f7 m.geoffroy
	 * taxon name is higher than the genus rank (true) or not (false).
1152
	 * Suprageneric non viral names are monomials.
1153 bef42c31 Andreas Müller
	 * Returns false if rank is null.
1154 4cc4f6f7 m.geoffroy
	 * 
1155
	 * @see  #isGenus()
1156
	 * @see  #isInfraGeneric()
1157
	 * @see  #isSpecies()
1158
	 * @see  #isInfraSpecific()
1159
	 */
1160 b70a7f94 Andreas Kohlbecker
	@Transient
1161 451c6005 m.doering
	public boolean isSupraGeneric() {
1162 bef42c31 Andreas Müller
		if (rank == null){
1163
			return false;
1164
		}
1165 451c6005 m.doering
		return getRank().isSupraGeneric();
1166
	}
1167 4cc4f6f7 m.geoffroy
	/**
1168 b9d0e8d2 m.geoffroy
	 * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of <i>this</i>
1169 4cc4f6f7 m.geoffroy
	 * taxon name is the genus rank (true) or not (false). Non viral names with
1170 10a54497 m.geoffroy
	 * genus rank are monomials. Returns false if rank is null.
1171 4cc4f6f7 m.geoffroy
	 *
1172
	 * @see  #isSupraGeneric()
1173
	 * @see  #isInfraGeneric()
1174
	 * @see  #isSpecies()
1175
	 * @see  #isInfraSpecific()
1176
	 */
1177 b70a7f94 Andreas Kohlbecker
	@Transient
1178 451c6005 m.doering
	public boolean isGenus() {
1179 bef42c31 Andreas Müller
		if (rank == null){
1180
			return false;
1181
		}
1182 451c6005 m.doering
		return getRank().isGenus();
1183
	}
1184 4cc4f6f7 m.geoffroy
	/**
1185 b9d0e8d2 m.geoffroy
	 * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of <i>this</i>
1186 10a54497 m.geoffroy
	 * taxon name is higher than the species rank and lower than the
1187
	 * genus rank (true) or not (false). Infrageneric non viral names are
1188
	 * binomials. Returns false if rank is null.
1189 4cc4f6f7 m.geoffroy
	 *
1190
	 * @see  #isSupraGeneric()
1191
	 * @see  #isGenus()
1192
	 * @see  #isSpecies()
1193
	 * @see  #isInfraSpecific()
1194
	 */
1195 b70a7f94 Andreas Kohlbecker
	@Transient
1196 451c6005 m.doering
	public boolean isInfraGeneric() {
1197 bef42c31 Andreas Müller
		if (rank == null){
1198
			return false;
1199
		}
1200 451c6005 m.doering
		return getRank().isInfraGeneric();
1201
	}
1202 4cc4f6f7 m.geoffroy
	/**
1203 b9d0e8d2 m.geoffroy
	 * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of <i>this</i>
1204 10a54497 m.geoffroy
	 * taxon name is the species rank (true) or not (false). Non viral names
1205 4cc4f6f7 m.geoffroy
	 * with species rank are binomials.
1206 bef42c31 Andreas Müller
	 * Returns false if rank is null.
1207 4cc4f6f7 m.geoffroy
	 *
1208
	 * @see  #isSupraGeneric()
1209
	 * @see  #isGenus()
1210
	 * @see  #isInfraGeneric()
1211
	 * @see  #isInfraSpecific()
1212
	 */
1213 b70a7f94 Andreas Kohlbecker
	@Transient
1214 451c6005 m.doering
	public boolean isSpecies() {
1215 bef42c31 Andreas Müller
		if (rank == null){
1216
			return false;
1217
		}
1218 451c6005 m.doering
		return getRank().isSpecies();
1219
	}
1220 4cc4f6f7 m.geoffroy
	/**
1221 b9d0e8d2 m.geoffroy
	 * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of <i>this</i>
1222 4cc4f6f7 m.geoffroy
	 * taxon name is lower than the species rank (true) or not (false).
1223
	 * Infraspecific non viral names are trinomials.
1224 bef42c31 Andreas Müller
	 * Returns false if rank is null.
1225 4cc4f6f7 m.geoffroy
	 *
1226
	 * @see  #isSupraGeneric()
1227
	 * @see  #isGenus()
1228
	 * @see  #isInfraGeneric()
1229
	 * @see  #isSpecies()
1230
	 */
1231 b70a7f94 Andreas Kohlbecker
	@Transient
1232 451c6005 m.doering
	public boolean isInfraSpecific() {
1233 bef42c31 Andreas Müller
		if (rank == null){
1234
			return false;
1235
		}
1236 451c6005 m.doering
		return getRank().isInfraSpecific();
1237
	}
1238 5c19d7f0 Andreas Müller
	
1239 7ebeb288 Andreas Müller
	
1240 4cc4f6f7 m.geoffroy
	/**
1241 eb7e638a m.geoffroy
	 * Returns null as the {@link NomenclaturalCode nomenclatural code} that governs
1242 b9d0e8d2 m.geoffroy
	 * the construction of <i>this</i> taxon name since there is no specific
1243 eb7e638a m.geoffroy
	 * nomenclatural code defined. The real implementention takes place in the
1244
	 * subclasses {@link ViralName ViralName}, {@link BacterialName BacterialName},
1245
	 * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName} and
1246
	 * {@link ZoologicalName ZoologicalName}. Each taxon name is governed by one
1247 4cc4f6f7 m.geoffroy
	 * and only one nomenclatural code. 
1248
	 *
1249 eb7e638a m.geoffroy
	 * @return  null
1250 b3262b1b m.geoffroy
	 * @see  	#isCodeCompliant()
1251
	 * @see  	#getHasProblem()
1252 4cc4f6f7 m.geoffroy
	 */
1253 bef42c31 Andreas Müller
	abstract public NomenclaturalCode getNomenclaturalCode();
1254 d50a2c5d Andreas Müller
	/* (non-Javadoc)
1255
	 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
1256
	 */
1257 b3262b1b m.geoffroy
	/**
1258 b9d0e8d2 m.geoffroy
	 * Generates and returns the string with the scientific name of <i>this</i>
1259 7e759003 m.geoffroy
	 * taxon name (only non viral taxon names can be generated from their
1260
	 * components). This string may be stored in the inherited
1261 09887ea6 m.geoffroy
	 * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.
1262 b3262b1b m.geoffroy
	 * This method overrides the generic and inherited
1263 09887ea6 m.geoffroy
	 * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle() method} from
1264
	 * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity IdentifiableEntity}.
1265 b3262b1b m.geoffroy
	 *
1266
	 * @return  the string with the composed name of this non viral taxon name with authorship (and maybe year)
1267 09887ea6 m.geoffroy
	 * @see  	eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
1268
	 * @see  	eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
1269 b3262b1b m.geoffroy
	 */
1270 4208745a ben.clark
//	@Override
1271
//	public abstract String generateTitle();
1272 dadf5cd0 Andreas Kohlbecker
}