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