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.
9 package eu
.etaxonomy
.cdm
.model
.agent
;
11 import javax
.persistence
.Entity
;
12 import javax
.persistence
.Transient
;
13 import javax
.validation
.constraints
.Size
;
14 import javax
.xml
.bind
.annotation
.XmlAccessType
;
15 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
16 import javax
.xml
.bind
.annotation
.XmlElement
;
17 import javax
.xml
.bind
.annotation
.XmlTransient
;
18 import javax
.xml
.bind
.annotation
.XmlType
;
20 import org
.apache
.log4j
.Logger
;
21 import org
.hibernate
.envers
.Audited
;
22 import org
.hibernate
.search
.annotations
.Field
;
23 import org
.hibernate
.search
.annotations
.Index
;
24 import org
.hibernate
.search
.annotations
.Indexed
;
26 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
27 import eu
.etaxonomy
.cdm
.strategy
.cache
.agent
.INomenclaturalAuthorCacheStrategy
;
28 import eu
.etaxonomy
.cdm
.validation
.annotation
.NullOrNotEmpty
;
32 * The abstract class for such {@link AgentBase agents} ({@link Person persons} or {@link Team teams}) who might also be used
33 * for authorship of {@link eu.etaxonomy.cdm.model.reference.Reference references} or of {@link eu.etaxonomy.cdm.model.name.TaxonNameBase taxon names}.
37 * @created 17-APR-2008
39 @XmlAccessorType(XmlAccessType
.FIELD
)
40 @XmlType(name
= "TeamOrPersonBase", propOrder
= {
44 @Indexed(index
= "eu.etaxonomy.cdm.model.agent.AgentBase")
46 public abstract class TeamOrPersonBase
<T
extends TeamOrPersonBase
<?
>> extends AgentBase
<INomenclaturalAuthorCacheStrategy
<T
>> implements INomenclaturalAuthor
{
47 private static final long serialVersionUID
= 5216821307314001961L;
48 public static final Logger logger
= Logger
.getLogger(TeamOrPersonBase
.class);
50 @XmlElement(name
="NomenclaturalTitle")
51 @Field(index
=Index
.TOKENIZED
)
54 protected String nomenclaturalTitle
;
58 protected boolean isGeneratingTitleCache
= false;
61 * Returns the identification string (nomenclatural abbreviation) used in
62 * nomenclature for this {@link Person person} or this {@link Team team}.
64 * @see INomenclaturalAuthor#getNomenclaturalTitle()
67 public String
getNomenclaturalTitle() {
68 String result
= nomenclaturalTitle
;
69 if (CdmUtils
.isEmpty(nomenclaturalTitle
) && (isGeneratingTitleCache
== false)){
70 result
= getTitleCache();
76 * @see #getNomenclaturalTitle()
78 public void setNomenclaturalTitle(String nomenclaturalTitle
) {
79 this.nomenclaturalTitle
= nomenclaturalTitle
;
83 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
86 @Transient //TODO a.kohlbecker remove??
87 public String
getTitleCache() {
88 isGeneratingTitleCache
= true;
89 String result
= super.getTitleCache();
90 result
= replaceEmptyTitleByNomTitle(result
);
91 isGeneratingTitleCache
= false;
99 protected String
replaceEmptyTitleByNomTitle(String result
) {
100 if (CdmUtils
.isEmpty(result
)){
101 result
= nomenclaturalTitle
;
103 if (CdmUtils
.isEmpty(result
)){
104 result
= super.getTitleCache();