2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.name
;
13 import java
.beans
.PropertyChangeEvent
;
14 import java
.beans
.PropertyChangeListener
;
15 import java
.util
.ArrayList
;
16 import java
.util
.Collections
;
17 import java
.util
.HashSet
;
18 import java
.util
.List
;
22 import javax
.persistence
.Entity
;
23 import javax
.persistence
.FetchType
;
24 import javax
.persistence
.ManyToOne
;
25 import javax
.persistence
.OneToMany
;
26 import javax
.persistence
.Transient
;
27 import javax
.validation
.constraints
.NotNull
;
28 import javax
.validation
.constraints
.Pattern
;
29 import javax
.validation
.constraints
.Size
;
30 import javax
.xml
.bind
.annotation
.XmlAccessType
;
31 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
32 import javax
.xml
.bind
.annotation
.XmlElement
;
33 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
34 import javax
.xml
.bind
.annotation
.XmlIDREF
;
35 import javax
.xml
.bind
.annotation
.XmlRootElement
;
36 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
37 import javax
.xml
.bind
.annotation
.XmlType
;
39 import org
.apache
.log4j
.Logger
;
40 import org
.hibernate
.annotations
.Cascade
;
41 import org
.hibernate
.annotations
.CascadeType
;
42 import org
.hibernate
.annotations
.Target
;
43 import org
.hibernate
.envers
.Audited
;
44 import org
.hibernate
.search
.annotations
.Analyze
;
45 import org
.hibernate
.search
.annotations
.Analyzer
;
46 import org
.hibernate
.search
.annotations
.Field
;
47 import org
.hibernate
.search
.annotations
.Fields
;
48 import org
.hibernate
.search
.annotations
.Index
;
49 import org
.hibernate
.search
.annotations
.Indexed
;
50 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
51 import org
.hibernate
.search
.annotations
.Store
;
52 import org
.hibernate
.validator
.constraints
.NotEmpty
;
53 import org
.springframework
.beans
.factory
.annotation
.Configurable
;
55 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
56 import eu
.etaxonomy
.cdm
.model
.agent
.INomenclaturalAuthor
;
57 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
58 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
59 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
;
60 import eu
.etaxonomy
.cdm
.model
.reference
.INomenclaturalReference
;
61 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
62 import eu
.etaxonomy
.cdm
.strategy
.cache
.name
.CacheUpdate
;
63 import eu
.etaxonomy
.cdm
.strategy
.cache
.name
.INonViralNameCacheStrategy
;
64 import eu
.etaxonomy
.cdm
.strategy
.cache
.name
.NonViralNameDefaultCacheStrategy
;
65 import eu
.etaxonomy
.cdm
.strategy
.match
.Match
;
66 import eu
.etaxonomy
.cdm
.strategy
.match
.Match
.ReplaceMode
;
67 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
68 import eu
.etaxonomy
.cdm
.strategy
.merge
.Merge
;
69 import eu
.etaxonomy
.cdm
.strategy
.merge
.MergeMode
;
70 import eu
.etaxonomy
.cdm
.validation
.Level2
;
71 import eu
.etaxonomy
.cdm
.validation
.Level3
;
72 import eu
.etaxonomy
.cdm
.validation
.annotation
.CorrectEpithetsForRank
;
73 import eu
.etaxonomy
.cdm
.validation
.annotation
.MustHaveAuthority
;
74 import eu
.etaxonomy
.cdm
.validation
.annotation
.NoDuplicateNames
;
75 import eu
.etaxonomy
.cdm
.validation
.annotation
.NullOrNotEmpty
;
78 * The taxon name class for all non viral taxa. Parenthetical authorship is derived
79 * from basionym relationship. The scientific name including author strings and
80 * maybe year can be stored as a string in the inherited {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.
81 * The year itself is an information obtained from the {@link eu.etaxonomy.cdm.model.reference.Reference#getYear() nomenclatural reference}.
82 * The scientific name string without author strings and year can be stored in the {@link #getNameCache() nameCache} attribute.
84 * This class corresponds partially to: <ul>
85 * <li> TaxonName according to the TDWG ontology
86 * <li> ScientificName and CanonicalName according to the TCS
87 * <li> ScientificName according to the ABCD schema
92 * @created 08-Nov-2007 13:06:39
94 @XmlAccessorType(XmlAccessType
.FIELD
)
95 @XmlType(name
= "NonViralName", propOrder
= {
98 "infraGenericEpithet",
100 "infraSpecificEpithet",
101 "combinationAuthorTeam",
102 "exCombinationAuthorTeam",
103 "basionymAuthorTeam",
104 "exBasionymAuthorTeam",
106 "protectedAuthorshipCache",
107 "protectedNameCache",
108 "hybridParentRelations",
109 "hybridChildRelations",
115 @XmlRootElement(name
= "NonViralName")
117 @Indexed(index
= "eu.etaxonomy.cdm.model.name.TaxonNameBase")
120 @CorrectEpithetsForRank(groups
= Level2
.class)
121 @MustHaveAuthority(groups
= Level2
.class)
122 @NoDuplicateNames(groups
= Level3
.class)
123 public class NonViralName
<T
extends NonViralName
> extends TaxonNameBase
<T
, INonViralNameCacheStrategy
> implements Cloneable
{
124 private static final long serialVersionUID
= 4441110073881088033L;
125 private static final Logger logger
= Logger
.getLogger(NonViralName
.class);
127 @XmlElement(name
= "NameCache")
129 @Field(name
= "nameCache_tokenized"),
130 @Field(store
= Store
.YES
, index
= Index
.YES
, analyze
= Analyze
.YES
)
132 @Analyzer (impl
= org
.apache
.lucene
.analysis
.KeywordAnalyzer
.class)
133 @Match(value
=MatchMode
.CACHE
, cacheReplaceMode
=ReplaceMode
.DEFINED
,
134 cacheReplacedProperties
={"genusOrUninomial", "infraGenericEpithet", "specificEpithet", "infraSpecificEpithet"} )
135 @NotEmpty(groups
= Level2
.class) // implicitly NotNull
137 private String nameCache
;
139 @XmlElement(name
= "ProtectedNameCache")
140 @CacheUpdate(value
="nameCache")
141 protected boolean protectedNameCache
;
143 @XmlElement(name
= "GenusOrUninomial")
144 @Field(analyze
= Analyze
.YES
,indexNullAs
=Field
.DEFAULT_NULL_TOKEN
)
145 @Match(MatchMode
.EQUAL_REQUIRED
)
146 @CacheUpdate("nameCache")
148 @Pattern(regexp
= "[A-Z][a-z\\u00E4\\u00EB\\u00EF\\u00F6\\u00FC\\-]+", groups
=Level2
.class, message
="{eu.etaxonomy.cdm.model.name.NonViralName.allowedCharactersForUninomial.message}")
150 @NotEmpty(groups
= Level3
.class) //TODO shouldn't this be only @NotNull as @NullOrNotEmpty already checks for not being empty.
151 private String genusOrUninomial
;
153 @XmlElement(name
= "InfraGenericEpithet")
154 @Field(analyze
= Analyze
.YES
,indexNullAs
=Field
.DEFAULT_NULL_TOKEN
)
155 @CacheUpdate("nameCache")
159 @Pattern(regexp
= "[a-z\\u00E4\\u00EB\\u00EF\\u00F6\\u00FC\\-]+", groups
=Level2
.class,message
="{eu.etaxonomy.cdm.model.name.NonViralName.allowedCharactersForEpithet.message}")
160 private String infraGenericEpithet
;
162 @XmlElement(name
= "SpecificEpithet")
163 @Field(analyze
= Analyze
.YES
,indexNullAs
=Field
.DEFAULT_NULL_TOKEN
)
164 @CacheUpdate("nameCache")
168 @Pattern(regexp
= "[a-z\\u00E4\\u00EB\\u00EF\\u00F6\\u00FC\\-]+", groups
=Level2
.class, message
= "{eu.etaxonomy.cdm.model.name.NonViralName.allowedCharactersForEpithet.message}")
169 private String specificEpithet
;
171 @XmlElement(name
= "InfraSpecificEpithet")
172 @Field(analyze
= Analyze
.YES
,indexNullAs
=Field
.DEFAULT_NULL_TOKEN
)
173 @CacheUpdate("nameCache")
177 @Pattern(regexp
= "[a-z\\u00E4\\u00EB\\u00EF\\u00F6\\u00FC\\-]+", groups
=Level2
.class, message
= "{eu.etaxonomy.cdm.model.name.NonViralName.allowedCharactersForEpithet.message}")
178 private String infraSpecificEpithet
;
180 @XmlElement(name
= "CombinationAuthorTeam", type
= TeamOrPersonBase
.class)
182 @XmlSchemaType(name
= "IDREF")
183 @ManyToOne(fetch
= FetchType
.LAZY
)
184 @Target(TeamOrPersonBase
.class)
185 @Cascade(CascadeType
.SAVE_UPDATE
)
186 @CacheUpdate("authorshipCache")
188 private INomenclaturalAuthor combinationAuthorTeam
;
190 @XmlElement(name
= "ExCombinationAuthorTeam", type
= TeamOrPersonBase
.class)
192 @XmlSchemaType(name
= "IDREF")
193 @ManyToOne(fetch
= FetchType
.LAZY
)
194 @Target(TeamOrPersonBase
.class)
195 @Cascade(CascadeType
.SAVE_UPDATE
)
196 @CacheUpdate("authorshipCache")
198 private INomenclaturalAuthor exCombinationAuthorTeam
;
200 @XmlElement(name
= "BasionymAuthorTeam", type
= TeamOrPersonBase
.class)
202 @XmlSchemaType(name
= "IDREF")
203 @ManyToOne(fetch
= FetchType
.LAZY
)
204 @Target(TeamOrPersonBase
.class)
205 @Cascade(CascadeType
.SAVE_UPDATE
)
206 @CacheUpdate("authorshipCache")
208 private INomenclaturalAuthor basionymAuthorTeam
;
210 @XmlElement(name
= "ExBasionymAuthorTeam", type
= TeamOrPersonBase
.class)
212 @XmlSchemaType(name
= "IDREF")
213 @ManyToOne(fetch
= FetchType
.LAZY
)
214 @Target(TeamOrPersonBase
.class)
215 @Cascade(CascadeType
.SAVE_UPDATE
)
216 @CacheUpdate("authorshipCache")
218 private INomenclaturalAuthor exBasionymAuthorTeam
;
220 @XmlElement(name
= "AuthorshipCache")
222 @Field(name
= "authorshipCache_tokenized"),
223 @Field(analyze
= Analyze
.NO
)
225 @Match(value
=MatchMode
.CACHE
, cacheReplaceMode
=ReplaceMode
.DEFINED
,
226 cacheReplacedProperties
={"combinationAuthorTeam", "basionymAuthorTeam", "exCombinationAuthorTeam", "exBasionymAuthorTeam"} )
230 @Pattern(regexp
= "[A-Za-z0-9 \\u00E4\\u00EB\\u00EF\\u00F6\\u00FC\\-\\&\\,\\(\\)\\.]+", groups
=Level2
.class, message
= "{eu.etaxonomy.cdm.model.name.NonViralName.allowedCharactersForAuthority.message}")
231 private String authorshipCache
;
233 @XmlElement(name
= "ProtectedAuthorshipCache")
234 @CacheUpdate("authorshipCache")
235 protected boolean protectedAuthorshipCache
;
237 @XmlElementWrapper(name
= "HybridRelationsFromThisName")
238 @XmlElement(name
= "HybridRelationsFromThisName")
239 @OneToMany(mappedBy
="relatedFrom", fetch
= FetchType
.LAZY
, orphanRemoval
=true)
240 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.MERGE
})
241 @Merge(MergeMode
.RELATION
)
243 private Set
<HybridRelationship
> hybridParentRelations
= new HashSet
<HybridRelationship
>();
245 @XmlElementWrapper(name
= "HybridRelationsToThisName")
246 @XmlElement(name
= "HybridRelationsToThisName")
247 @OneToMany(mappedBy
="relatedTo", fetch
= FetchType
.LAZY
, orphanRemoval
=true) //a hybrid relation can be deleted automatically if the child is deleted.
248 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.MERGE
, CascadeType
.DELETE
})
249 @Merge(MergeMode
.RELATION
)
251 private Set
<HybridRelationship
> hybridChildRelations
= new HashSet
<HybridRelationship
>();
253 //if set: this name is a hybrid formula (a hybrid that does not have an own name) and no other hybrid flags may be set. A
254 //hybrid name may not have either an authorteam nor other name components.
255 @XmlElement(name
="IsHybridFormula")
256 @CacheUpdate("nameCache")
257 private boolean hybridFormula
= false;
259 @XmlElement(name
="IsMonomHybrid")
260 @CacheUpdate("nameCache")
261 private boolean monomHybrid
= false;
263 @XmlElement(name
="IsBinomHybrid")
264 @CacheUpdate("nameCache")
265 private boolean binomHybrid
= false;
267 @XmlElement(name
="IsTrinomHybrid")
268 @CacheUpdate("nameCache")
269 private boolean trinomHybrid
= false;
272 * Creates a new non viral taxon name instance
273 * only containing its {@link common.Rank rank} and
274 * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
276 * @param rank the rank to be assigned to <i>this</i> non viral taxon name
277 * @see #NewInstance(Rank, HomotypicalGroup)
278 * @see #NonViralName(Rank, HomotypicalGroup)
279 * @see #NonViralName()
280 * @see #NonViralName(Rank, String, String, String, String, TeamOrPersonBase, Reference, String, HomotypicalGroup)
281 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
282 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
283 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
285 public static NonViralName
NewInstance(Rank rank
){
286 return new NonViralName(rank
, null);
290 * Creates a new non viral taxon name instance
291 * only containing its {@link common.Rank rank},
292 * its {@link HomotypicalGroup homotypical group} and
293 * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
294 * The new non viral taxon name instance will be also added to the set of
295 * non viral taxon names belonging to this homotypical group.
297 * @param rank the rank to be assigned to <i>this</i> non viral taxon name
298 * @param homotypicalGroup the homotypical group to which <i>this</i> non viral taxon name belongs
299 * @see #NewInstance(Rank)
300 * @see #NonViralName(Rank, HomotypicalGroup)
301 * @see #NonViralName()
302 * @see #NonViralName(Rank, String, String, String, String, TeamOrPersonBase, Reference, String, HomotypicalGroup)
303 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
304 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
305 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
307 public static NonViralName
NewInstance(Rank rank
, HomotypicalGroup homotypicalGroup
){
308 return new NonViralName(rank
, homotypicalGroup
);
311 // ************************** CONSTRUCTORS *************/
313 //needed by hibernate
315 * Class constructor: creates a new non viral taxon name instance
316 * only containing the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
318 * @see #NonViralName(Rank, HomotypicalGroup)
319 * @see #NonViralName(Rank, String, String, String, String, TeamOrPersonBase, Reference, String, HomotypicalGroup)
320 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
321 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
322 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
324 protected NonViralName(){
326 setNameCacheStrategy();
330 * Class constructor: creates a new non viral taxon name instance
331 * only containing its {@link Rank rank},
332 * its {@link HomotypicalGroup homotypical group} and
333 * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
334 * The new non viral taxon name instance will be also added to the set of
335 * non viral taxon names belonging to this homotypical group.
337 * @param rank the rank to be assigned to <i>this</i> non viral taxon name
338 * @param homotypicalGroup the homotypical group to which <i>this</i> non viral taxon name belongs
339 * @see #NonViralName()
340 * @see #NonViralName(Rank, String, String, String, String, TeamOrPersonBase, Reference, String, HomotypicalGroup)
341 * @see #NewInstance(Rank, HomotypicalGroup)
342 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
343 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
344 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
346 protected NonViralName(Rank rank
, HomotypicalGroup homotypicalGroup
) {
347 super(rank
, homotypicalGroup
);
348 setNameCacheStrategy();
351 * Class constructor: creates a new non viral taxon name instance
352 * containing its {@link Rank rank},
353 * its {@link HomotypicalGroup homotypical group},
354 * its scientific name components, its {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author(team)},
355 * its {@link eu.etaxonomy.cdm.model.reference.Reference nomenclatural reference} and
356 * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
357 * The new non viral taxon name instance will be also added to the set of
358 * non viral taxon names belonging to this homotypical group.
360 * @param rank the rank to be assigned to <i>this</i> non viral taxon name
361 * @param genusOrUninomial the string for <i>this</i> non viral taxon name
362 * if its rank is genus or higher or for the genus part
363 * if its rank is lower than genus
364 * @param infraGenericEpithet the string for the first epithet of
365 * <i>this</i> non viral taxon name if its rank is lower than genus
366 * and higher than species aggregate
367 * @param specificEpithet the string for the first epithet of
368 * <i>this</i> non viral taxon name if its rank is species aggregate or lower
369 * @param infraSpecificEpithet the string for the second epithet of
370 * <i>this</i> non viral taxon name if its rank is lower than species
371 * @param combinationAuthorTeam the author or the team who published <i>this</i> non viral taxon name
372 * @param nomenclaturalReference the nomenclatural reference where <i>this</i> non viral taxon name was published
373 * @param nomenclMicroRef the string with the details for precise location within the nomenclatural reference
374 * @param homotypicalGroup the homotypical group to which <i>this</i> non viral taxon name belongs
375 * @see #NonViralName()
376 * @see #NonViralName(Rank, HomotypicalGroup)
377 * @see #NewInstance(Rank, HomotypicalGroup)
378 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
379 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
380 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
382 protected NonViralName(Rank rank
, String genusOrUninomial
, String infraGenericEpithet
, String specificEpithet
, String infraSpecificEpithet
, TeamOrPersonBase combinationAuthorTeam
, INomenclaturalReference nomenclaturalReference
, String nomenclMicroRef
, HomotypicalGroup homotypicalGroup
) {
383 super(rank
, homotypicalGroup
);
384 setNameCacheStrategy();
385 setGenusOrUninomial(genusOrUninomial
);
386 setInfraGenericEpithet (infraGenericEpithet
);
387 setSpecificEpithet(specificEpithet
);
388 setInfraSpecificEpithet(infraSpecificEpithet
);
389 setCombinationAuthorTeam(combinationAuthorTeam
);
390 setNomenclaturalReference(nomenclaturalReference
);
391 this.setNomenclaturalMicroReference(nomenclMicroRef
);
396 //**************************** METHODS **************************************/
399 private void setNameCacheStrategy(){
400 if (getClass() == NonViralName
.class){
401 this.cacheStrategy
= NonViralNameDefaultCacheStrategy
.NewInstance();
406 protected void initListener(){
407 PropertyChangeListener listener
= new PropertyChangeListener() {
409 public void propertyChange(PropertyChangeEvent e
) {
410 boolean protectedByLowerCache
= false;
412 if (fieldHasCacheUpdateProperty(e
.getPropertyName(), "authorshipCache")){
413 if (protectedAuthorshipCache
){
414 protectedByLowerCache
= true;
416 authorshipCache
= null;
421 if (fieldHasCacheUpdateProperty(e
.getPropertyName(), "nameCache")){
422 if (protectedNameCache
){
423 protectedByLowerCache
= true;
429 if (! fieldHasNoUpdateProperty(e
.getPropertyName(), "titleCache")){
430 if (isProtectedTitleCache()|| protectedByLowerCache
== true ){
431 protectedByLowerCache
= true;
437 if (! fieldHasNoUpdateProperty(e
.getPropertyName(), "fullTitleCache")){
438 if (isProtectedFullTitleCache()|| protectedByLowerCache
== true ){
439 protectedByLowerCache
= true;
441 fullTitleCache
= null;
446 addPropertyChangeListener(listener
); //didn't use this.addXXX to make lsid.AssemblerTest run in cdmlib-remote
449 private static Map
<String
, java
.lang
.reflect
.Field
> allFields
= null;
451 protected Map
<String
, java
.lang
.reflect
.Field
> getAllFields(){
452 if (allFields
== null){
453 allFields
= CdmUtils
.getAllFields(this.getClass(), CdmBase
.class, false, false, false, true);
459 * @param propertyName
463 private boolean fieldHasCacheUpdateProperty(String propertyName
, String cacheName
) {
464 java
.lang
.reflect
.Field field
;
466 field
= getAllFields().get(propertyName
);
468 CacheUpdate updateAnnotation
= field
.getAnnotation(CacheUpdate
.class);
469 if (updateAnnotation
!= null){
470 for (String value
: updateAnnotation
.value()){
471 if (cacheName
.equals(value
)){
478 } catch (SecurityException e1
) {
483 private boolean fieldHasNoUpdateProperty(String propertyName
, String cacheName
) {
484 java
.lang
.reflect
.Field field
;
485 //do not update fields with the same name
486 if (cacheName
.equals(propertyName
)){
489 //evaluate annotation
491 field
= getAllFields().get(propertyName
);
493 CacheUpdate updateAnnotation
= field
.getAnnotation(CacheUpdate
.class);
494 if (updateAnnotation
!= null){
495 for (String value
: updateAnnotation
.noUpdate()){
496 if (cacheName
.equals(value
)){
503 } catch (SecurityException e1
) {
510 * Returns the {@link eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor author (team)} that published <i>this</i> non viral
513 * @return the nomenclatural author (team) of <i>this</i> non viral taxon name
514 * @see eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor
515 * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase#getNomenclaturalTitle()
517 public INomenclaturalAuthor
getCombinationAuthorTeam(){
518 return this.combinationAuthorTeam
;
522 * @see #getCombinationAuthorTeam()
524 public void setCombinationAuthorTeam(INomenclaturalAuthor combinationAuthorTeam
){
525 this.combinationAuthorTeam
= combinationAuthorTeam
;
529 * Returns the {@link eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor author (team)} that contributed to
530 * the publication of <i>this</i> non viral taxon name as generally stated by
531 * the {@link #getCombinationAuthorTeam() combination author (team)} itself.<BR>
532 * An ex-author(-team) is an author(-team) to whom a taxon name was ascribed
533 * although it is not the author(-team) of a valid publication (for instance
534 * without the validating description or diagnosis in case of a name for a
535 * new taxon). The name of this ascribed authorship, followed by "ex", may
536 * be inserted before the name(s) of the publishing author(s) of the validly
537 * published name:<BR>
538 * <i>Lilium tianschanicum</i> was described by Grubov (1977) as a new species and
539 * its name was ascribed to Ivanova; since there is no indication that
540 * Ivanova provided the validating description, the name may be cited as
541 * <i>Lilium tianschanicum</i> N. A. Ivanova ex Grubov or <i>Lilium tianschanicum</i> Grubov.
543 * The presence of an author (team) of <i>this</i> non viral taxon name is a
544 * condition for the existence of an ex author (team) for <i>this</i> same name.
546 * @return the nomenclatural ex author (team) of <i>this</i> non viral taxon name
547 * @see #getCombinationAuthorTeam()
548 * @see eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor
549 * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase#getNomenclaturalTitle()
551 public INomenclaturalAuthor
getExCombinationAuthorTeam(){
552 return this.exCombinationAuthorTeam
;
556 * @see #getExCombinationAuthorTeam()
558 public void setExCombinationAuthorTeam(INomenclaturalAuthor exCombinationAuthorTeam
){
559 this.exCombinationAuthorTeam
= exCombinationAuthorTeam
;
563 * Returns the {@link eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor author (team)} that published the original combination
564 * on which <i>this</i> non viral taxon name is nomenclaturally based. Such an
565 * author (team) can only exist if <i>this</i> non viral taxon name is a new
566 * combination due to a taxonomical revision.
568 * @return the nomenclatural basionym author (team) of <i>this</i> non viral taxon name
569 * @see #getCombinationAuthorTeam()
570 * @see eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor
571 * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase#getNomenclaturalTitle()
573 public INomenclaturalAuthor
getBasionymAuthorTeam(){
574 return basionymAuthorTeam
;
578 * @see #getBasionymAuthorTeam()
580 public void setBasionymAuthorTeam(INomenclaturalAuthor basionymAuthorTeam
) {
581 this.basionymAuthorTeam
= basionymAuthorTeam
;
585 * Returns the {@link eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor author (team)} that contributed to
586 * the publication of the original combination <i>this</i> non viral taxon name is
587 * based on. This should have been generally stated by
588 * the {@link #getBasionymAuthorTeam() basionym author (team)} itself.
589 * The presence of a basionym author (team) of <i>this</i> non viral taxon name is a
590 * condition for the existence of an ex basionym author (team)
591 * for <i>this</i> same name.
593 * @return the nomenclatural ex basionym author (team) of <i>this</i> non viral taxon name
594 * @see #getBasionymAuthorTeam()
595 * @see #getExCombinationAuthorTeam()
596 * @see #getCombinationAuthorTeam()
597 * @see eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor
598 * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase#getNomenclaturalTitle()
600 public INomenclaturalAuthor
getExBasionymAuthorTeam(){
601 return exBasionymAuthorTeam
;
605 * @see #getExBasionymAuthorTeam()
607 public void setExBasionymAuthorTeam(INomenclaturalAuthor exBasionymAuthorTeam
) {
608 this.exBasionymAuthorTeam
= exBasionymAuthorTeam
;
611 * Returns either the scientific name string (without authorship) for <i>this</i>
612 * non viral taxon name if its rank is genus or higher (monomial) or the string for
613 * the genus part of it if its {@link Rank rank} is lower than genus (bi- or trinomial).
614 * Genus or uninomial strings begin with an upper case letter.
616 * @return the string containing the suprageneric name, the genus name or the genus part of <i>this</i> non viral taxon name
617 * @see #getNameCache()
619 public String
getGenusOrUninomial() {
620 return genusOrUninomial
;
624 * @see #getGenusOrUninomial()
626 public void setGenusOrUninomial(String genusOrUninomial
) {
627 this.genusOrUninomial
= genusOrUninomial
;
631 * Returns the genus subdivision epithet string (infrageneric part) for
632 * <i>this</i> non viral taxon name if its {@link Rank rank} is infrageneric (lower than genus and
633 * higher than species aggregate: binomial). Genus subdivision epithet
634 * strings begin with an upper case letter.
636 * @return the string containing the infrageneric part of <i>this</i> non viral taxon name
637 * @see #getNameCache()
639 public String
getInfraGenericEpithet(){
640 return this.infraGenericEpithet
;
644 * @see #getInfraGenericEpithet()
646 public void setInfraGenericEpithet(String infraGenericEpithet
){
647 this.infraGenericEpithet
= infraGenericEpithet
;
651 * Returns the species epithet string for <i>this</i> non viral taxon name if its {@link Rank rank} is
652 * species aggregate or lower (bi- or trinomial). Species epithet strings
653 * begin with a lower case letter.
655 * @return the string containing the species epithet of <i>this</i> non viral taxon name
656 * @see #getNameCache()
658 public String
getSpecificEpithet(){
659 return this.specificEpithet
;
663 * @see #getSpecificEpithet()
665 public void setSpecificEpithet(String specificEpithet
){
666 this.specificEpithet
= specificEpithet
;
670 * Returns the species subdivision epithet string (infraspecific part) for
671 * <i>this</i> non viral taxon name if its {@link Rank rank} is infraspecific
672 * (lower than species: trinomial). Species subdivision epithet strings
673 * begin with a lower case letter.
675 * @return the string containing the infraspecific part of <i>this</i> non viral taxon name
676 * @see #getNameCache()
678 public String
getInfraSpecificEpithet(){
679 return this.infraSpecificEpithet
;
683 * @see #getInfraSpecificEpithet()
685 public void setInfraSpecificEpithet(String infraSpecificEpithet
){
686 this.infraSpecificEpithet
= infraSpecificEpithet
;
690 * Generates and returns the string with the scientific name of <i>this</i>
691 * non viral taxon name including author strings and maybe year according to
692 * the strategy defined in
693 * {@link eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy INonViralNameCacheStrategy}.
694 * This string may be stored in the inherited
695 * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.
696 * This method overrides the generic and inherited
697 * TaxonNameBase#generateTitle() method.
699 * @return the string with the composed name of <i>this</i> non viral taxon name with authorship (and maybe year)
700 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
701 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
702 * @see TaxonNameBase#generateTitle()
705 // public String generateTitle(){
706 // if (cacheStrategy == null){
707 // logger.warn("No CacheStrategy defined for nonViralName: " + this.getUuid());
710 // return cacheStrategy.getTitleCache(this);
715 public String
generateFullTitle(){
716 if (cacheStrategy
== null){
717 logger
.warn("No CacheStrategy defined for nonViralName: " + this.getUuid());
720 return cacheStrategy
.getFullTitleCache(this);
725 * Generates the composed name string of <i>this</i> non viral taxon name without author
726 * strings or year according to the strategy defined in
727 * {@link eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy INonViralNameCacheStrategy}.
728 * The result might be stored in {@link #getNameCache() nameCache} if the
729 * flag {@link #isProtectedNameCache() protectedNameCache} is not set.
731 * @return the string with the composed name of <i>this</i> non viral taxon name without authors or year
732 * @see #getNameCache()
734 protected String
generateNameCache(){
735 if (cacheStrategy
== null){
736 logger
.warn("No CacheStrategy defined for taxonName: " + this.toString());
739 return cacheStrategy
.getNameCache(this);
744 * Returns or generates the nameCache (scientific name
745 * without author strings and year) string for <i>this</i> non viral taxon name. If the
746 * {@link #isProtectedNameCache() protectedNameCache} flag is not set (False)
747 * the string will be generated according to a defined strategy,
748 * otherwise the value of the actual nameCache string will be returned.
750 * @return the string which identifies <i>this</i> non viral taxon name (without authors or year)
751 * @see #generateNameCache()
754 public String
getNameCache() {
755 if (protectedNameCache
){
756 return this.nameCache
;
758 // is title dirty, i.e. equal NULL?
759 if (nameCache
== null){
760 this.nameCache
= generateNameCache();
766 * Assigns a nameCache string to <i>this</i> non viral taxon name and protects it from being overwritten.
767 * Sets the protectedNameCache flag to <code>true</code>.
769 * @param nameCache the string which identifies <i>this</i> non viral taxon name (without authors or year)
770 * @see #getNameCache()
772 public void setNameCache(String nameCache
){
773 setNameCache(nameCache
, true);
777 * Assigns a nameCache string to <i>this</i> non viral taxon name and protects it from being overwritten.
778 * Sets the protectedNameCache flag to <code>true</code>.
780 * @param nameCache the string which identifies <i>this</i> non viral taxon name (without authors or year)
781 * @param protectedNameCache if true teh protectedNameCache is set to <code>true</code> or otherwise set to
783 * @see #getNameCache()
785 public void setNameCache(String nameCache
, boolean protectedNameCache
){
786 this.nameCache
= nameCache
;
787 this.setProtectedNameCache(protectedNameCache
);
791 * Returns the boolean value of the flag intended to protect (true)
792 * or not (false) the {@link #getNameCache() nameCache} (scientific name without author strings and year)
793 * string of <i>this</i> non viral taxon name.
795 * @return the boolean value of the protectedNameCache flag
796 * @see #getNameCache()
798 public boolean isProtectedNameCache() {
799 return protectedNameCache
;
803 * @see #isProtectedNameCache()
805 public void setProtectedNameCache(boolean protectedNameCache
) {
806 this.protectedNameCache
= protectedNameCache
;
811 * Generates and returns a concatenated and formated authorteams string
812 * including basionym and combination authors of <i>this</i> non viral taxon name
813 * according to the strategy defined in
814 * {@link eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy#getAuthorshipCache(NonViralName) INonViralNameCacheStrategy}.
816 * @return the string with the concatenated and formated authorteams for <i>this</i> non viral taxon name
817 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy#getAuthorshipCache(NonViralName)
819 public String
generateAuthorship(){
820 if (cacheStrategy
== null){
821 logger
.warn("No CacheStrategy defined for nonViralName: " + this.getUuid());
824 return ((INonViralNameCacheStrategy
<T
>)cacheStrategy
).getAuthorshipCache((T
)this);
829 * Returns the concatenated and formated authorteams string including
830 * basionym and combination authors of <i>this</i> non viral taxon name.
831 * If the protectedAuthorshipCache flag is set this method returns the
832 * string stored in the the authorshipCache attribute, otherwise it
833 * generates the complete authorship string, returns it and stores it in
834 * the authorshipCache attribute.
836 * @return the string with the concatenated and formated authorteams for <i>this</i> non viral taxon name
837 * @see #generateAuthorship()
840 public String
getAuthorshipCache() {
841 if (protectedAuthorshipCache
){
842 return this.authorshipCache
;
844 if (this.authorshipCache
== null ){
845 this.authorshipCache
= generateAuthorship();
847 //TODO get is Dirty of authors, make better if possible
848 this.setAuthorshipCache(generateAuthorship(), protectedAuthorshipCache
); //throw change event to inform higher caches
851 return authorshipCache
;
856 * Updates the authorship cache if any changes appeared in the authors nomenclatural caches.
857 * Deletes the titleCache and the fullTitleCache if not protected and if any change has happened
860 private void updateAuthorshipCache() {
861 //updates the authorship cache if necessary and via the listener updates all higher caches
862 if (protectedAuthorshipCache
== false){
863 String oldCache
= this.authorshipCache
;
864 String newCache
= this.getAuthorshipCache();
865 if ( (oldCache
== null && newCache
!= null) || CdmUtils
.nullSafeEqual(oldCache
,newCache
)){
866 this.setAuthorshipCache(this.getAuthorshipCache(), false);
872 * Assigns an authorshipCache string to <i>this</i> non viral taxon name. Sets the isProtectedAuthorshipCache
873 * flag to <code>true</code>.
875 * @param authorshipCache the string which identifies the complete authorship of <i>this</i> non viral taxon name
876 * @see #getAuthorshipCache()
878 public void setAuthorshipCache(String authorshipCache
) {
879 setAuthorshipCache(authorshipCache
, true);
884 public String
getFullTitleCache(){
885 updateAuthorshipCache();
886 return super.getFullTitleCache();
890 public String
getTitleCache(){
891 if(!protectedTitleCache
) {
892 updateAuthorshipCache();
895 return super.getTitleCache();
900 * Assigns an authorshipCache string to <i>this</i> non viral taxon name.
902 * @param authorshipCache the string which identifies the complete authorship of <i>this</i> non viral taxon name
903 * @param protectedAuthorshipCache if true the isProtectedAuthorshipCache flag is set to <code>true</code>, otherwise
904 * the flag is set to <code>false</code>.
905 * @see #getAuthorshipCache()
907 public void setAuthorshipCache(String authorshipCache
, boolean protectedAuthorshipCache
) {
908 this.authorshipCache
= authorshipCache
;
909 this.setProtectedAuthorshipCache(protectedAuthorshipCache
);
913 public void setTitleCache(String titleCache
, boolean protectCache
){
914 super.setTitleCache(titleCache
, protectCache
);
918 * Returns the boolean value "false" since the components of <i>this</i> taxon name
919 * cannot follow the rules of a corresponding {@link NomenclaturalCode nomenclatural code}
920 * which is not defined for this class. The nomenclature code depends on
921 * the concrete name subclass ({@link BacterialName BacterialName},
922 * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName} or
923 * {@link ZoologicalName ZoologicalName} to which <i>this</i> non viral taxon name belongs.
924 * This method overrides the isCodeCompliant method from the abstract
925 * {@link TaxonNameBase#isCodeCompliant() TaxonNameBase} class.
928 * @see TaxonNameBase#isCodeCompliant()
932 public boolean isCodeCompliant() {
934 logger
.warn("is CodeCompliant not yet implemented");
939 * @see eu.etaxonomy.cdm.model.name.TaxonNameBase#getNomeclaturalCode()
942 * Returns null as {@link NomenclaturalCode nomenclatural code} that governs
943 * the construction of <i>this</i> non viral taxon name since there is no specific
944 * nomenclatural code defined. The real implementention takes place in the
945 * subclasses {@link BacterialName BacterialName},
946 * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName} and
947 * {@link ZoologicalName ZoologicalName}.
948 * This method overrides the getNomeclaturalCode method from {@link TaxonNameBase TaxonNameBase}.
951 * @see #isCodeCompliant()
952 * @see TaxonNameBase#getHasProblem()
956 public NomenclaturalCode
getNomenclaturalCode() {
957 logger
.warn("Non Viral Name has no specific Code defined. Use subclasses");
962 * Returns the boolean value of the flag intended to protect (true)
963 * or not (false) the {@link #getAuthorshipCache() authorshipCache} (complete authorship string)
964 * of <i>this</i> non viral taxon name.
966 * @return the boolean value of the protectedAuthorshipCache flag
967 * @see #getAuthorshipCache()
969 public boolean isProtectedAuthorshipCache() {
970 return protectedAuthorshipCache
;
974 * @see #isProtectedAuthorshipCache()
975 * @see #getAuthorshipCache()
977 public void setProtectedAuthorshipCache(boolean protectedAuthorshipCache
) {
978 this.protectedAuthorshipCache
= protectedAuthorshipCache
;
983 * Returns the boolean value of the flag indicating whether the name of <i>this</i>
984 * botanical taxon name is a hybrid formula (true) or not (false). A hybrid
985 * named by a hybrid formula (composed with its parent names by placing the
986 * multiplication sign between them) does not have an own published name
987 * and therefore has neither an {@link NonViralName#getAuthorshipCache() autorship}
988 * nor other name components. If this flag is set no other hybrid flags may
991 * @return the boolean value of the isHybridFormula flag
992 * @see #isMonomHybrid()
993 * @see #isBinomHybrid()
994 * @see #isTrinomHybrid()
996 public boolean isHybridFormula(){
997 return this.hybridFormula
;
1001 * @see #isHybridFormula()
1003 public void setHybridFormula(boolean hybridFormula
){
1004 this.hybridFormula
= hybridFormula
;
1008 * Returns the boolean value of the flag indicating whether <i>this</i> botanical
1009 * taxon name is the name of an intergeneric hybrid (true) or not (false).
1010 * In this case the multiplication sign is placed before the scientific
1011 * name. If this flag is set no other hybrid flags may be set.
1013 * @return the boolean value of the isMonomHybrid flag
1014 * @see #isHybridFormula()
1015 * @see #isBinomHybrid()
1016 * @see #isTrinomHybrid()
1018 public boolean isMonomHybrid(){
1019 return this.monomHybrid
;
1023 * @see #isMonomHybrid()
1024 * @see #isBinomHybrid()
1025 * @see #isTrinomHybrid()
1027 public void setMonomHybrid(boolean monomHybrid
){
1028 this.monomHybrid
= monomHybrid
;
1032 * Returns the boolean value of the flag indicating whether <i>this</i> botanical
1033 * taxon name is the name of an interspecific hybrid (true) or not (false).
1034 * In this case the multiplication sign is placed before the species
1035 * epithet. If this flag is set no other hybrid flags may be set.
1037 * @return the boolean value of the isBinomHybrid flag
1038 * @see #isHybridFormula()
1039 * @see #isMonomHybrid()
1040 * @see #isTrinomHybrid()
1042 public boolean isBinomHybrid(){
1043 return this.binomHybrid
;
1047 * @see #isBinomHybrid()
1048 * @see #isMonomHybrid()
1049 * @see #isTrinomHybrid()
1051 public void setBinomHybrid(boolean binomHybrid
){
1052 this.binomHybrid
= binomHybrid
;
1056 * Returns the boolean value of the flag indicating whether <i>this</i> botanical
1057 * taxon name is the name of an infraspecific hybrid (true) or not (false).
1058 * In this case the term "notho-" (optionally abbreviated "n-") is used as
1059 * a prefix to the term denoting the infraspecific rank of <i>this</i> botanical
1060 * taxon name. If this flag is set no other hybrid flags may be set.
1062 * @return the boolean value of the isTrinomHybrid flag
1063 * @see #isHybridFormula()
1064 * @see #isMonomHybrid()
1065 * @see #isBinomHybrid()
1067 public boolean isTrinomHybrid(){
1068 return this.trinomHybrid
;
1072 * @see #isTrinomHybrid()
1073 * @see #isBinomHybrid()
1074 * @see #isMonomHybrid()
1076 public void setTrinomHybrid(boolean trinomHybrid
){
1077 this.trinomHybrid
= trinomHybrid
;
1082 * Returns the set of all {@link HybridRelationship hybrid relationships}
1083 * in which <i>this</i> taxon name is involved as a {@link common.RelationshipBase#getRelatedFrom() parent}.
1085 * @see #getHybridRelationships()
1086 * @see #getChildRelationships()
1087 * @see HybridRelationshipType
1089 public Set
<HybridRelationship
> getHybridParentRelations() {
1090 if(hybridParentRelations
== null) {
1091 this.hybridParentRelations
= new HashSet
<HybridRelationship
>();
1093 return hybridParentRelations
;
1096 private void setHybridParentRelations(Set
<HybridRelationship
> hybridParentRelations
) {
1097 this.hybridParentRelations
= hybridParentRelations
;
1102 * Returns the set of all {@link HybridRelationship hybrid relationships}
1103 * in which <i>this</i> taxon name is involved as a {@link common.RelationshipBase#getRelatedTo() child}.
1105 * @see #getHybridRelationships()
1106 * @see #getParentRelationships()
1107 * @see HybridRelationshipType
1109 public Set
<HybridRelationship
> getHybridChildRelations() {
1110 if(hybridChildRelations
== null) {
1111 this.hybridChildRelations
= new HashSet
<HybridRelationship
>();
1113 return hybridChildRelations
;
1116 private void setHybridChildRelations(Set
<HybridRelationship
> hybridChildRelations
) {
1117 this.hybridChildRelations
= hybridChildRelations
;
1121 * Returns the set of all {@link HybridRelationship hybrid relationships}
1122 * in which <i>this</i> taxon name is involved as a {@link common.RelationshipBase#getRelatedFrom() parent}.
1123 * @see #getHybridParentRelations()
1124 * @see #getHybridRelationships()
1125 * @see #getChildRelationships()
1126 * @see HybridRelationshipType
1127 * @deprecated use {@link #getHybridParentRelations()} instead. Will be removed in higher versions.
1131 public Set
<HybridRelationship
> getParentRelationships() {
1132 return getHybridParentRelations();
1136 * Returns the hybrid child relationships ordered by relationship type, or if equal
1137 * by title cache of the related names.
1138 * @see #getHybridParentRelations()
1141 public List
<HybridRelationship
> getOrderedChildRelationships(){
1142 List
<HybridRelationship
> result
= new ArrayList
<HybridRelationship
>();
1143 result
.addAll(this.hybridChildRelations
);
1144 Collections
.sort(result
);
1145 Collections
.reverse(result
);
1152 * @see #getHybridChildRelations()
1153 * @deprecated use {@link #getHybridChildRelations()} instead. Will be removed in higher versions.
1157 public Set
<HybridRelationship
> getChildRelationships() {
1158 return this.getHybridChildRelations();
1162 * Adds the given {@link HybridRelationship hybrid relationship} to the set
1163 * of {@link #getHybridRelationships() hybrid relationships} of both non-viral names
1164 * involved in this hybrid relationship. One of both non-viral names
1165 * must be <i>this</i> non-viral name otherwise no addition will be carried
1166 * out. The {@link eu.etaxonomy.cdm.model.common.RelationshipBase#getRelatedTo() child
1167 * non viral taxon name} must be a hybrid, which means that one of its four hybrid flags must be set.
1169 * @param relationship the hybrid relationship to be added
1170 * @see #isHybridFormula()
1171 * @see #isMonomHybrid()
1172 * @see #isBinomHybrid()
1173 * @see #isTrinomHybrid()
1174 * @see #getHybridRelationships()
1175 * @see #getParentRelationships()
1176 * @see #getChildRelationships()
1177 * @see #addRelationship(RelationshipBase)
1178 * @throws IllegalArgumentException
1180 protected void addHybridRelationship(HybridRelationship rel
) {
1181 if (rel
!=null && rel
.getHybridName().equals(this)){
1182 this.hybridChildRelations
.add(rel
);
1183 }else if(rel
!=null && rel
.getParentName().equals(this)){
1184 this.hybridParentRelations
.add(rel
);
1186 throw new IllegalArgumentException("Hybrid relationship is either null or the relationship does not reference this name");
1193 * Does the same as the addHybridRelationship method if the given
1194 * {@link common.RelationshipBase relation} is also a {@link HybridRelationship hybrid relationship}.
1195 * Otherwise this method does the same as the overwritten {@link TaxonNameBase#addRelationship(RelationshipBase) addRelationship}
1196 * method from TaxonNameBase.
1198 * @param relation the relationship to be added to some of <i>this</i> taxon name's relationships sets
1199 * @see #addHybridRelationship(HybridRelationship)
1200 * @see TaxonNameBase#addRelationship(RelationshipBase)
1201 * @see TaxonNameBase#addNameRelationship(NameRelationship)
1202 * @deprecated to be used by RelationshipBase only
1205 @Deprecated //to be used by RelationshipBase only
1206 public void addRelationship(RelationshipBase relation
) {
1207 if (relation
instanceof HybridRelationship
){
1208 addHybridRelationship((HybridRelationship
)relation
);
1210 super.addRelationship(relation
);
1215 * Creates a new {@link HybridRelationship#HybridRelationship(BotanicalName, BotanicalName, HybridRelationshipType, String) hybrid relationship}
1216 * to <i>this</i> botanical name. A HybridRelationship may be of type
1217 * "is first/second parent" or "is male/female parent". By invoking this
1218 * method <i>this</i> botanical name becomes a hybrid child of the parent
1221 * @param parentName the botanical name of the parent for this new hybrid name relationship
1222 * @param type the type of this new name relationship
1223 * @param ruleConsidered the string which specifies the rule on which this name relationship is based
1225 * @see #addHybridChild(BotanicalName, HybridRelationshipType,String )
1226 * @see #getRelationsToThisName()
1227 * @see #getNameRelations()
1228 * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
1229 * @see #addNameRelationship(NameRelationship)
1231 public HybridRelationship
addHybridParent(NonViralName parentName
, HybridRelationshipType type
, String ruleConsidered
){
1232 return new HybridRelationship(this, parentName
, type
, ruleConsidered
);
1236 * Creates a new {@link HybridRelationship#HybridRelationship(BotanicalName, BotanicalName, HybridRelationshipType, String) hybrid relationship}
1237 * to <i>this</i> botanical name. A HybridRelationship may be of type
1238 * "is first/second parent" or "is male/female parent". By invoking this
1239 * method <i>this</i> botanical name becomes a parent of the hybrid child
1242 * @param childName the botanical name of the child for this new hybrid name relationship
1243 * @param type the type of this new name relationship
1244 * @param ruleConsidered the string which specifies the rule on which this name relationship is based
1246 * @see #addHybridParent(BotanicalName, HybridRelationshipType,String )
1247 * @see #getRelationsToThisName()
1248 * @see #getNameRelations()
1249 * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
1250 * @see #addNameRelationship(NameRelationship)
1252 public HybridRelationship
addHybridChild(NonViralName childName
, HybridRelationshipType type
, String ruleConsidered
){
1253 return new HybridRelationship(childName
, this, type
, ruleConsidered
);
1258 * Removes one {@link HybridRelationship hybrid relationship} from the set of
1259 * {@link #getHybridRelationships() hybrid relationships} in which <i>this</i> botanical taxon name
1260 * is involved. The hybrid relationship will also be removed from the set
1261 * belonging to the second botanical taxon name involved.
1263 * @param relationship the hybrid relationship which should be deleted from the corresponding sets
1264 * @see #getHybridRelationships()
1266 public void removeHybridRelationship(HybridRelationship hybridRelation
) {
1267 if (hybridRelation
== null) {
1271 NonViralName parent
= hybridRelation
.getParentName();
1272 NonViralName child
= hybridRelation
.getHybridName();
1274 hybridRelation
.setHybridName(null);
1275 hybridRelation
.setParentName(null);
1277 if (parent
!= null) {
1278 parent
.removeHybridRelationship(hybridRelation
);
1281 if (child
!= null) {
1282 child
.removeHybridRelationship(hybridRelation
);
1285 this.hybridChildRelations
.remove(hybridRelation
);
1286 this.hybridParentRelations
.remove(hybridRelation
);
1290 public void removeHybridChild(NonViralName child
) {
1291 Set
<HybridRelationship
> hybridRelationships
= new HashSet
<HybridRelationship
>();
1292 hybridRelationships
.addAll(this.getChildRelationships());
1293 hybridRelationships
.addAll(this.getParentRelationships());
1294 for(HybridRelationship hybridRelationship
: hybridRelationships
) {
1295 // remove name relationship from this side
1296 if (hybridRelationship
.getParentName().equals(this) && hybridRelationship
.getHybridName().equals(child
)) {
1297 this.removeHybridRelationship(hybridRelationship
);
1302 public void removeHybridParent(NonViralName parent
) {
1303 Set
<HybridRelationship
> hybridRelationships
= new HashSet
<HybridRelationship
>();
1304 hybridRelationships
.addAll(this.getChildRelationships());
1305 hybridRelationships
.addAll(this.getParentRelationships());
1306 for(HybridRelationship hybridRelationship
: hybridRelationships
) {
1307 // remove name relationship from this side
1308 if (hybridRelationship
.getParentName().equals(parent
) && hybridRelationship
.getHybridName().equals(this)) {
1309 this.removeHybridRelationship(hybridRelationship
);
1315 * Needs to be implemented by those classes that handle autonyms (e.g. botanical names).
1318 public boolean isAutonym(){
1324 // * Returns the boolean value indicating whether <i>this</i> names rank is Rank "unranked"
1325 // * (uuid = 'a965befb-70a9-4747-a18f-624456c65223') but most likely it is an infrageneric rank
1326 // * due to existing atomized data for the genus epithet and the infrageneric epithet but missing
1327 // * specific epithet.
1328 // * Returns false if <i>this</i> names rank is null.
1330 // * @see #isSupraGeneric()
1331 // * @see #isGenus()
1332 // * @see #isSpeciesAggregate()
1333 // * @see #isSpecies()
1334 // * @see #isInfraSpecific()
1337 // public boolean isInfragenericUnranked() {
1338 // Rank rank = this.getRank();
1339 // if (rank == null || ! rank.equals(Rank.UNRANKED())){
1342 // if (StringUtils.isBlank(this.getSpecificEpithet()) && StringUtils.isBlank(this.getInfraSpecificEpithet()) ){
1351 * Tests if the given name has any authors.
1352 * @return false if no author ((ex)combination or (ex)basionym) exists, true otherwise
1354 public boolean hasAuthors() {
1355 return (this.getCombinationAuthorTeam() != null ||
1356 this.getExCombinationAuthorTeam() != null ||
1357 this.getBasionymAuthorTeam() != null ||
1358 this.getExBasionymAuthorTeam() != null);
1362 * Shortcut. Returns the combination authors title cache. Returns null if no combination author exists.
1365 public String
computeCombinationAuthorNomenclaturalTitle() {
1366 return computeNomenclaturalTitle(this.getCombinationAuthorTeam());
1370 * Shortcut. Returns the basionym authors title cache. Returns null if no basionym author exists.
1373 public String
computeBasionymAuthorNomenclaturalTitle() {
1374 return computeNomenclaturalTitle(this.getBasionymAuthorTeam());
1379 * Shortcut. Returns the ex-combination authors title cache. Returns null if no ex-combination author exists.
1382 public String
computeExCombinationAuthorNomenclaturalTitle() {
1383 return computeNomenclaturalTitle(this.getExCombinationAuthorTeam());
1387 * Shortcut. Returns the ex-basionym authors title cache. Returns null if no exbasionym author exists.
1390 public String
computeExBasionymAuthorNomenclaturalTitle() {
1391 return computeNomenclaturalTitle(this.getExBasionymAuthorTeam());
1394 private String
computeNomenclaturalTitle(INomenclaturalAuthor author
){
1395 if (author
== null){
1398 return author
.getNomenclaturalTitle();
1402 //*********************** CLONE ********************************************************/
1405 * Clones <i>this</i> non-viral name. This is a shortcut that enables to create
1406 * a new instance that differs only slightly from <i>this</i> non-viral name by
1407 * modifying only some of the attributes.
1409 * @see eu.etaxonomy.cdm.model.name.TaxonNameBase#clone()
1410 * @see java.lang.Object#clone()
1413 public Object
clone() {
1414 NonViralName result
= (NonViralName
)super.clone();
1416 //HybridChildRelations
1417 result
.hybridChildRelations
= new HashSet
<HybridRelationship
>();
1418 for (HybridRelationship hybridRelationship
: getHybridChildRelations()){
1419 HybridRelationship newChildRelationship
= (HybridRelationship
)hybridRelationship
.clone();
1420 newChildRelationship
.setRelatedTo(result
);
1421 result
.hybridChildRelations
.add(newChildRelationship
);
1424 //HybridParentRelations
1425 result
.hybridParentRelations
= new HashSet
<HybridRelationship
>();
1426 for (HybridRelationship hybridRelationship
: getHybridParentRelations()){
1427 HybridRelationship newParentRelationship
= (HybridRelationship
)hybridRelationship
.clone();
1428 newParentRelationship
.setRelatedFrom(result
);
1429 result
.hybridParentRelations
.add(newParentRelationship
);
1433 if (! protectedNameCache
){
1434 result
.nameCache
= null;
1438 if (! protectedAuthorshipCache
){
1439 result
.authorshipCache
= null;
1442 //no changes to: basionamyAuthorTeam, combinationAuthorTeam, exBasionymAuthorTeam, exCombinationAuthorTeam
1443 //genusOrUninomial, infraGenericEpithet, specificEpithet, infraSpecificEpithet,
1444 //protectedAuthorshipCache, protectedNameCache
1445 //binomHybrid, monomHybrid, trinomHybrid, hybridFormula,