(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NonViralName.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.cdm.model.name;
11
12
13 import javax.persistence.Entity;
14 import javax.persistence.ManyToOne;
15 import javax.persistence.Transient;
16 import javax.xml.bind.annotation.XmlAccessType;
17 import javax.xml.bind.annotation.XmlAccessorType;
18 import javax.xml.bind.annotation.XmlElement;
19 import javax.xml.bind.annotation.XmlIDREF;
20 import javax.xml.bind.annotation.XmlRootElement;
21 import javax.xml.bind.annotation.XmlSchemaType;
22 import javax.xml.bind.annotation.XmlTransient;
23 import javax.xml.bind.annotation.XmlType;
24
25 import org.apache.log4j.Logger;
26 import org.hibernate.annotations.Cascade;
27 import org.hibernate.annotations.CascadeType;
28 import org.hibernate.annotations.Target;
29
30 import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
31 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
32 import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
33 import eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy;
34 import eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy;
35
36 /**
37 * The taxon name class for all non viral taxa. Parenthetical authorship is derived
38 * from basionym relationship. The scientific name including author strings and
39 * maybe year can be stored as a string in the inherited {@link common.IdentifiableEntity#getTitleCache() titleCache} attribute.
40 * The year itself is an information obtained from the {@link reference.INomenclaturalReference#getYear() nomenclatural reference}.
41 * The scientific name string without author strings and year can be stored in the {@link #getNameCache() nameCache} attribute.
42 *
43 * @author m.doering
44 * @version 1.0
45 * @created 08-Nov-2007 13:06:39
46 */
47 @XmlAccessorType(XmlAccessType.FIELD)
48 @XmlType(name = "", propOrder = {
49 "nameCache",
50 "genusOrUninomial",
51 "infraGenericEpithet",
52 "specificEpithet",
53 "infraSpecificEpithet",
54 "combinationAuthorTeam",
55 "exCombinationAuthorTeam",
56 "basionymAuthorTeam",
57 "exBasionymAuthorTeam",
58 "authorshipCache",
59 "protectedAuthorshipCache",
60 "protectedNameCache"
61 // "cacheStrategy"
62 })
63 @XmlRootElement(name = "NonViralName")
64 @Entity
65 public class NonViralName<T extends NonViralName> extends TaxonNameBase<NonViralName, INonViralNameCacheStrategy> {
66
67 private static final Logger logger = Logger.getLogger(NonViralName.class);
68
69 @XmlElement(name = "NameCache")
70 private String nameCache;
71
72 @XmlElement(name = "GenusOrUninomial")
73 private String genusOrUninomial;
74
75 @XmlElement(name = "InfraGenericEpithet")
76 private String infraGenericEpithet;
77
78 @XmlElement(name = "SpecificEpithet")
79 private String specificEpithet;
80
81 @XmlElement(name = "InfraSpecificEpithet")
82 private String infraSpecificEpithet;
83
84 @XmlElement(name = "CombinationAuthorTeam", type = TeamOrPersonBase.class)
85 @XmlIDREF
86 @XmlSchemaType(name = "IDREF")
87 private INomenclaturalAuthor combinationAuthorTeam;
88
89 @XmlElement(name = "CombinationAuthorTeam", type = TeamOrPersonBase.class)
90 @XmlIDREF
91 @XmlSchemaType(name = "IDREF")
92 private INomenclaturalAuthor exCombinationAuthorTeam;
93
94 @XmlElement(name = "CombinationAuthorTeam", type = TeamOrPersonBase.class)
95 @XmlIDREF
96 @XmlSchemaType(name = "IDREF")
97 private INomenclaturalAuthor basionymAuthorTeam;
98
99 @XmlElement(name = "CombinationAuthorTeam", type = TeamOrPersonBase.class)
100 @XmlIDREF
101 @XmlSchemaType(name = "IDREF")
102 private INomenclaturalAuthor exBasionymAuthorTeam;
103
104 @XmlElement(name = "AuthorshipCache")
105 private String authorshipCache;
106
107 @XmlElement(name = "ProtectedAuthorshipCache")
108 protected boolean protectedAuthorshipCache;
109
110 @XmlElement(name = "ProtectedNameCache")
111 protected boolean protectedNameCache;
112
113 @XmlTransient
114 //@XmlAnyElement
115 protected INonViralNameCacheStrategy cacheStrategy;
116
117 // ************* CONSTRUCTORS *************/
118
119 //needed by hibernate
120 /**
121 * Class constructor: creates a new non viral taxon name instance
122 * only containing the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
123 *
124 * @see #NonViralName(Rank, HomotypicalGroup)
125 * @see #NonViralName(Rank, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
126 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
127 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
128 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
129 */
130 protected NonViralName(){
131 super();
132 setNameCacheStrategy();
133 }
134
135 /**
136 * Class constructor: creates a new non viral taxon name instance
137 * only containing its {@link common.Rank rank},
138 * its {@link HomotypicalGroup homotypical group} and
139 * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
140 * The new non viral taxon name instance will be also added to the set of
141 * non viral taxon names belonging to this homotypical group.
142 *
143 * @param rank the rank to be assigned to this non viral taxon name
144 * @param homotypicalGroup the homotypical group to which this non viral taxon name belongs
145 * @see #NonViralName()
146 * @see #NonViralName(Rank, String, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
147 * @see #NewInstance(Rank, HomotypicalGroup)
148 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
149 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
150 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
151 */
152 protected NonViralName(Rank rank, HomotypicalGroup homotypicalGroup) {
153 super(rank, homotypicalGroup);
154 setNameCacheStrategy();
155 }
156 /**
157 * Class constructor: creates a new non viral taxon name instance
158 * containing its {@link common.Rank rank},
159 * its {@link HomotypicalGroup homotypical group},
160 * its scientific name components, its {@link agent.TeamOrPersonBase author(team)},
161 * its {@link reference.INomenclaturalReference nomenclatural reference} and
162 * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
163 * The new non viral taxon name instance will be also added to the set of
164 * non viral taxon names belonging to this homotypical group.
165 *
166 * @param rank the rank to be assigned to this non viral taxon name
167 * @param genusOrUninomial the string for this taxon name
168 * if its rank is genus or higher or for the genus part
169 * if its rank is lower than genus
170 * @param infraGenericEpithet the string for the first epithet of
171 * this non viral taxon name if its rank is lower than genus
172 * and higher than species aggregate
173 * @param specificEpithet the string for the first epithet of
174 * this non viral taxon name if its rank is species aggregate or lower
175 * @param infraSpecificEpithet the string for the second epithet of
176 * this non viral taxon name if its rank is lower than species
177 * @param combinationAuthorTeam the author or the team who published this non viral taxon name
178 * @param nomenclaturalReference the nomenclatural reference where this non viral taxon name was published
179 * @param nomenclMicroRef the string with the details for precise location within the nomenclatural reference
180 * @param homotypicalGroup the homotypical group to which this non viral taxon name belongs
181 * @see #NonViralName()
182 * @see #NonViralName(Rank, HomotypicalGroup)
183 * @see #NewInstance(Rank, HomotypicalGroup)
184 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
185 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
186 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
187 */
188 protected NonViralName(Rank rank, String genusOrUninomial, String infraGenericEpithet, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) {
189 super(rank, homotypicalGroup);
190 setNameCacheStrategy();
191 setGenusOrUninomial(genusOrUninomial);
192 setInfraGenericEpithet (infraGenericEpithet);
193 setSpecificEpithet(specificEpithet);
194 setInfraSpecificEpithet(infraSpecificEpithet);
195 setCombinationAuthorTeam(combinationAuthorTeam);
196 setNomenclaturalReference(nomenclaturalReference);
197 this.setNomenclaturalMicroReference(nomenclMicroRef);
198 }
199
200 //********* METHODS **************************************/
201 /**
202 * Creates a new non viral taxon name instance
203 * only containing its {@link common.Rank rank} and
204 * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
205 *
206 * @param rank the rank to be assigned to this non viral taxon name
207 * @see #NewInstance(Rank, HomotypicalGroup)
208 * @see #NonViralName(Rank, HomotypicalGroup)
209 * @see #NonViralName()
210 * @see #NonViralName(Rank, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
211 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
212 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
213 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
214 */
215 public static NonViralName NewInstance(Rank rank){
216 return new NonViralName(rank, null);
217 }
218
219 /**
220 * Creates a new non viral taxon name instance
221 * only containing its {@link common.Rank rank},
222 * its {@link HomotypicalGroup homotypical group} and
223 * the {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy default cache strategy}.
224 * The new non viral taxon name instance will be also added to the set of
225 * non viral taxon names belonging to this homotypical group.
226 *
227 * @param rank the rank to be assigned to this non viral taxon name
228 * @param homotypicalGroup the homotypical group to which this non viral taxon name belongs
229 * @see #NewInstance(Rank)
230 * @see #NonViralName(Rank, HomotypicalGroup)
231 * @see #NonViralName()
232 * @see #NonViralName(Rank, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup)
233 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
234 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
235 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
236 */
237 public static NonViralName NewInstance(Rank rank, HomotypicalGroup homotypicalGroup){
238 return new NonViralName(rank, homotypicalGroup);
239 }
240
241 private void setNameCacheStrategy(){
242 if (getClass() == NonViralName.class){
243 this.cacheStrategy = NonViralNameDefaultCacheStrategy.NewInstance();
244 }
245
246 }
247
248 //TODO for PROTOTYPE
249 /**
250 * Returns the {@link eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy cache strategy} used to generate
251 * several strings corresponding to this non viral taxon name
252 * (in particular taxon name caches and author strings).
253 *
254 * @return the cache strategy used for this non viral taxon name
255 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy
256 * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy
257 * @see eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy
258 */
259 @Transient
260 @Override
261 public INonViralNameCacheStrategy getCacheStrategy() {
262 return cacheStrategy;
263 }
264 /**
265 * @see #getCacheStrategy()
266 */
267 @Override
268 public void setCacheStrategy(INonViralNameCacheStrategy cacheStrategy) {
269 this.cacheStrategy = cacheStrategy;
270 }
271
272
273
274 /**
275 * Returns the {@link agent.INomenclaturalAuthor author (team)} that published this non viral
276 * taxon name.
277 *
278 * @return the nomenclatural author (team) of this non viral taxon name
279 * @see agent.INomenclaturalAuthor
280 * @see agent.TeamOrPersonBase#getNomenclaturalTitle()
281 */
282 @ManyToOne
283 @Cascade({CascadeType.SAVE_UPDATE})
284 @Target(TeamOrPersonBase.class)
285 public INomenclaturalAuthor getCombinationAuthorTeam(){
286 return this.combinationAuthorTeam;
287 }
288 /**
289 * @see #getCombinationAuthorTeam()
290 */
291 public void setCombinationAuthorTeam(INomenclaturalAuthor combinationAuthorTeam){
292 this.combinationAuthorTeam = combinationAuthorTeam;
293 }
294
295 /**
296 * Returns the {@link agent.INomenclaturalAuthor author (team)} that contributed to
297 * the publication of this non viral taxon name as generally stated by
298 * the {@link #getCombinationAuthorTeam() combination author (team)} itself.
299 * The presence of an author (team) of this non viral taxon name is a
300 * condition for the existence of an ex author (team) for this same name.
301 *
302 * @return the nomenclatural ex author (team) of this non viral taxon name
303 * @see #getCombinationAuthorTeam()
304 * @see agent.INomenclaturalAuthor
305 * @see agent.TeamOrPersonBase#getNomenclaturalTitle()
306 */
307 @ManyToOne
308 @Cascade({CascadeType.SAVE_UPDATE})
309 @Target(TeamOrPersonBase.class)
310 public INomenclaturalAuthor getExCombinationAuthorTeam(){
311 return this.exCombinationAuthorTeam;
312 }
313 /**
314 * @see #getExCombinationAuthorTeam()
315 */
316 public void setExCombinationAuthorTeam(INomenclaturalAuthor exCombinationAuthorTeam){
317 this.exCombinationAuthorTeam = exCombinationAuthorTeam;
318 }
319
320 /**
321 * Returns the {@link agent.INomenclaturalAuthor author (team)} that published the original combination
322 * on which this non viral taxon name is nomenclaturally based. Such an
323 * author (team) can only exist if this non viral taxon name is a new
324 * combination due to a taxonomical revision.
325 *
326 * @return the nomenclatural basionym author (team) of this non viral taxon name
327 * @see #getCombinationAuthorTeam()
328 * @see agent.INomenclaturalAuthor
329 * @see agent.TeamOrPersonBase#getNomenclaturalTitle()
330 */
331 @ManyToOne
332 @Cascade({CascadeType.SAVE_UPDATE})
333 @Target(TeamOrPersonBase.class)
334 public INomenclaturalAuthor getBasionymAuthorTeam(){
335 return basionymAuthorTeam;
336 }
337 /**
338 * @see #getBasionymAuthorTeam()
339 */
340 public void setBasionymAuthorTeam(INomenclaturalAuthor basionymAuthorTeam) {
341 this.basionymAuthorTeam = basionymAuthorTeam;
342 }
343
344 /**
345 * Returns the {@link agent.INomenclaturalAuthor author (team)} that contributed to
346 * the publication of the original combination this non viral taxon name is
347 * based on. This should have been generally stated by
348 * the {@link #getCombinationAuthorTeam() basionym author (team)} itself.
349 * The presence of a basionym author (team) of this non viral taxon name is a
350 * condition for the existence of an ex basionym author (team)
351 * for this same name.
352 *
353 * @return the nomenclatural ex basionym author (team) of this non viral taxon name
354 * @see #getBasionymAuthorTeam()
355 * @see #getCombinationAuthorTeam()
356 * @see agent.INomenclaturalAuthor
357 * @see agent.TeamOrPersonBase#getNomenclaturalTitle()
358 */
359 @ManyToOne
360 @Cascade({CascadeType.SAVE_UPDATE})
361 @Target(TeamOrPersonBase.class)
362 public INomenclaturalAuthor getExBasionymAuthorTeam(){
363 return exBasionymAuthorTeam;
364 }
365 /**
366 * @see #getExBasionymAuthorTeam()
367 */
368 public void setExBasionymAuthorTeam(INomenclaturalAuthor exBasionymAuthorTeam) {
369 this.exBasionymAuthorTeam = exBasionymAuthorTeam;
370 }
371 /**
372 * Returns either the scientific name string (without authorship) for this
373 * non viral taxon name if its rank is genus or higher (monomial) or the string for
374 * the genus part of it if its {@link Rank rank} is lower than genus (bi- or trinomial).
375 * Genus or uninomial strings begin with an upper case letter.
376 *
377 * @return the string containing the suprageneric name, the genus name or the genus part of this non viral taxon name
378 * @see #getNameCache()
379 */
380 public String getGenusOrUninomial() {
381 return genusOrUninomial;
382 }
383
384 /**
385 * @see #getGenusOrUninomial()
386 */
387 public void setGenusOrUninomial(String genusOrUninomial) {
388 this.genusOrUninomial = genusOrUninomial;
389 }
390
391 /**
392 * Returns the genus subdivision epithet string (infrageneric part) for
393 * this non viral taxon name if its {@link Rank rank} is infrageneric (lower than genus and
394 * higher than species aggregate: binomial). Genus subdivision epithet
395 * strings begin with an upper case letter.
396 *
397 * @return the string containing the infrageneric part of this non viral taxon name
398 * @see #getNameCache()
399 */
400 public String getInfraGenericEpithet(){
401 return this.infraGenericEpithet;
402 }
403
404 /**
405 * @see #getInfraGenericEpithet()
406 */
407 public void setInfraGenericEpithet(String infraGenericEpithet){
408 this.infraGenericEpithet = infraGenericEpithet;
409 }
410
411 /**
412 * Returns the species epithet string for this non viral taxon name if its {@link Rank rank} is
413 * species aggregate or lower (bi- or trinomial). Species epithet strings
414 * begin with a lower case letter.
415 *
416 * @return the string containing the species epithet of this non viral taxon name
417 * @see #getNameCache()
418 */
419 public String getSpecificEpithet(){
420 return this.specificEpithet;
421 }
422
423 /**
424 * @see #getSpecificEpithet()
425 */
426 public void setSpecificEpithet(String specificEpithet){
427 this.specificEpithet = specificEpithet;
428 }
429
430 /**
431 * Returns the species subdivision epithet string (infraspecific part) for
432 * this non viral taxon name if its {@link Rank rank} is infraspecific
433 * (lower than species: trinomial). Species subdivision epithet strings
434 * begin with a lower case letter.
435 *
436 * @return the string containing the infraspecific part of this non viral taxon name
437 * @see #getNameCache()
438 */
439 public String getInfraSpecificEpithet(){
440 return this.infraSpecificEpithet;
441 }
442
443 /**
444 * @see #getInfraSpecificEpithet()
445 */
446 public void setInfraSpecificEpithet(String infraSpecificEpithet){
447 this.infraSpecificEpithet = infraSpecificEpithet;
448 }
449
450 /**
451 * Generates and returns the string with the scientific name of this
452 * non viral taxon name including author strings and maybe year according to
453 * the strategy defined in
454 * {@link eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy INonViralNameCacheStrategy}.
455 * This string may be stored in the inherited
456 * {@link common.IdentifiableEntity#getTitleCache() titleCache} attribute.
457 * This method overrides the generic and inherited
458 * TaxonNameBase#generateTitle() method.
459 *
460 * @return the string with the composed name of this non viral taxon name with authorship (and maybe year)
461 * @see common.IdentifiableEntity#generateTitle()
462 * @see common.IdentifiableEntity#getTitleCache()
463 * @see TaxonNameBase#generateTitle()
464 */
465 @Override
466 public String generateTitle(){
467 if (cacheStrategy == null){
468 logger.warn("No CacheStrategy defined for nonViralName: " + this.getUuid());
469 return null;
470 }else{
471 return cacheStrategy.getTitleCache(this);
472 }
473 }
474
475 /**
476 * Generates the composed name string of this non viral taxon name without author
477 * strings or year according to the strategy defined in
478 * {@link eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy INonViralNameCacheStrategy}.
479 * The result might be stored in {@link #getNameCache() nameCache} if the
480 * flag {@link #isProtectedNameCache() protectedNameCache} is not set.
481 *
482 * @return the string with the composed name of this non viral taxon name without authors or year
483 * @see #getNameCache()
484 */
485 protected String generateNameCache(){
486 if (cacheStrategy == null){
487 logger.warn("No CacheStrategy defined for taxonName: " + this.toString());
488 return null;
489 }else{
490 return cacheStrategy.getNameCache(this);
491 }
492 }
493
494 /**
495 * Returns or generates the nameCache (scientific name
496 * without author strings and year) string for this non viral taxon name. If the
497 * {@link #isProtectedNameCache() protectedNameCache} flag is not set (False)
498 * the string will be generated according to a defined strategy,
499 * otherwise the value of the actual nameCache string will be returned.
500 *
501 * @return the string which identifies this non viral taxon name (without authors or year)
502 * @see #generateNameCache()
503 */
504 public String getNameCache() {
505 if (protectedNameCache){
506 return this.nameCache;
507 }
508 // is title dirty, i.e. equal NULL?
509 if (nameCache == null){
510 this.nameCache = generateNameCache();
511 }
512 return nameCache;
513 }
514
515 /**
516 * Assigns a nameCache string to this non viral taxon name and protects it from being overwritten.
517 *
518 * @param nameCache the string which identifies this non viral taxon name (without authors or year)
519 * @see #getNameCache()
520 */
521 public void setNameCache(String nameCache){
522 this.nameCache = nameCache;
523 this.setProtectedTitleCache(false);
524 this.setProtectedNameCache(true);
525 }
526
527 /**
528 * Returns the boolean value of the flag intended to protect (true)
529 * or not (false) the {@link #getNameCache() nameCache} (scientific name without author strings and year)
530 * string of this non viral taxon name.
531 *
532 * @return the boolean value of the protectedNameCache flag
533 * @see #getNameCache()
534 */
535 public boolean isProtectedNameCache() {
536 return protectedNameCache;
537 }
538
539 /**
540 * @see #isProtectedNameCache()
541 */
542 public void setProtectedNameCache(boolean protectedNameCache) {
543 this.protectedNameCache = protectedNameCache;
544 }
545
546
547 /**
548 * Generates and returns a concatenated and formated authorteams string
549 * including basionym and combination authors of this non viral taxon name
550 * according to the strategy defined in
551 * {@link eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy#getAuthorshipCache(NonViralName) INonViralNameCacheStrategy}.
552 *
553 * @return the string with the concatenated and formated authorteams for this non viral taxon name
554 * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy#getAuthorshipCache(NonViralName)
555 */
556 public String generateAuthorship(){
557 if (cacheStrategy == null){
558 logger.warn("No CacheStrategy defined for nonViralName: " + this.getUuid());
559 return null;
560 }else{
561 return ((INonViralNameCacheStrategy<T>)cacheStrategy).getAuthorshipCache((T)this);
562 }
563 }
564
565 /**
566 * Returns the concatenated and formated authorteams string including
567 * basionym and combination authors of this non viral taxon name.
568 * If the protectedAuthorshipCache flag is set this method returns the
569 * string stored in the the authorshipCache attribute, otherwise it
570 * generates the complete authorship string, returns it and stores it in
571 * the authorshipCache attribute.
572 *
573 * @return the string with the concatenated and formated authorteams for this non viral taxon name
574 * @see #generateAuthorship()
575 */
576 public String getAuthorshipCache() {
577 if (protectedAuthorshipCache){
578 return this.authorshipCache;
579 }
580 // is title dirty, i.e. equal NULL?
581 if (authorshipCache == null){
582 this.authorshipCache = generateAuthorship();
583 }else{
584 //TODO get is Dirty of authors
585 this.authorshipCache = generateAuthorship();
586 }
587 return authorshipCache;
588 }
589
590 /**
591 * Assigns an authorshipCache string to this non viral taxon name.
592 *
593 * @param authorshipCache the string which identifies the complete authorship of this non viral taxon name
594 * @see #getAuthorshipCache()
595 */
596 public void setAuthorshipCache(String authorshipCache) {
597 this.authorshipCache = authorshipCache;
598 }
599
600
601
602 /**
603 * Returns the boolean value "false" since the components of this taxon name
604 * cannot follow the rules of a corresponding {@link NomenclaturalCode nomenclatural code}
605 * which is not defined for this class. The nomenclature code depends on
606 * the concrete name subclass ({@link BacterialName BacterialName},
607 * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName} or
608 * {@link ZoologicalName ZoologicalName} to which this non viral taxon name belongs.
609 * This method overrides the isCodeCompliant method from the abstract
610 * {@link TaxonNameBase#isCodeCompliant() TaxonNameBase} class.
611 *
612 * @return false
613 * @see TaxonNameBase#isCodeCompliant()
614 */
615 @Override
616 @Transient
617 public boolean isCodeCompliant() {
618 //FIXME
619 logger.warn("is CodeCompliant not yet implemented");
620 return false;
621 }
622
623 /* (non-Javadoc)
624 * @see eu.etaxonomy.cdm.model.name.TaxonNameBase#getNomeclaturalCode()
625 */
626 /**
627 * Returns null as {@link NomenclaturalCode nomenclatural code} that governs
628 * the construction of this non viral taxon name since there is no specific
629 * nomenclatural code defined. The real implementention takes place in the
630 * subclasses {@link BacterialName BacterialName},
631 * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName} and
632 * {@link ZoologicalName ZoologicalName}.
633 * This method overrides the getNomeclaturalCode method from {@link TaxonNameBase#getNomeclaturalCode() TaxonNameBase}.
634 *
635 * @return null
636 * @see #isCodeCompliant()
637 * @see TaxonNameBase#getHasProblem()
638 */
639 @Transient
640 @Override
641 public NomenclaturalCode getNomenclaturalCode() {
642 logger.warn("Non Viral Name has no specific Code defined. Use subclasses");
643 return null;
644 }
645
646 /**
647 * Returns the boolean value of the flag intended to protect (true)
648 * or not (false) the {@link #getAuthorshipCache() authorshipCache} (complete authorship string)
649 * of this non viral taxon name.
650 *
651 * @return the boolean value of the protectedAuthorshipCache flag
652 * @see #getAuthorshipCache()
653 */
654 public boolean isProtectedAuthorshipCache() {
655 return protectedAuthorshipCache;
656 }
657
658 /**
659 * @see #isProtectedAuthorshipCache()
660 * @see #getAuthorshipCache()
661 */
662 public void setProtectedAuthorshipCache(boolean protectedAuthorshipCache) {
663 this.protectedAuthorshipCache = protectedAuthorshipCache;
664 }
665
666
667
668
669 }