-/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-package eu.etaxonomy.cdm.model.agent;\r
-\r
-import javax.persistence.Entity;\r
-import javax.persistence.Transient;\r
-import javax.validation.constraints.Size;\r
-import javax.xml.bind.annotation.XmlAccessType;\r
-import javax.xml.bind.annotation.XmlAccessorType;\r
-import javax.xml.bind.annotation.XmlElement;\r
-import javax.xml.bind.annotation.XmlTransient;\r
-import javax.xml.bind.annotation.XmlType;\r
-\r
-import org.apache.commons.lang.StringUtils;\r
-import org.apache.log4j.Logger;\r
-import org.hibernate.envers.Audited;\r
-import org.hibernate.search.annotations.Field;\r
-import org.hibernate.search.annotations.Index;\r
-\r
-import eu.etaxonomy.cdm.strategy.cache.agent.INomenclaturalAuthorCacheStrategy;\r
-\r
-\r
-/**\r
- * The abstract class for such {@link AgentBase agents} ({@link Person persons} or {@link Team teams}) who might also be used\r
- * for authorship of {@link eu.etaxonomy.cdm.model.reference.Reference references} or of {@link eu.etaxonomy.cdm.model.name.TaxonNameBase taxon names}.\r
- *\r
- * @author a.mueller\r
- * @version 1.0\r
- * @created 17-APR-2008\r
- */\r
-@XmlAccessorType(XmlAccessType.FIELD)\r
-@XmlType(name = "TeamOrPersonBase", propOrder = {\r
- "nomenclaturalTitle",\r
- "collectorTitle"\r
-})\r
-@Entity\r
-@Audited\r
-public abstract class TeamOrPersonBase<T extends TeamOrPersonBase<?>> extends AgentBase<INomenclaturalAuthorCacheStrategy<T>> implements INomenclaturalAuthor {\r
- private static final long serialVersionUID = 5216821307314001961L;\r
- public static final Logger logger = Logger.getLogger(TeamOrPersonBase.class);\r
-\r
- @XmlElement(name="NomenclaturalTitle")\r
- @Field(index=Index.YES)\r
- //TODO Val #3379\r
-// @NullOrNotEmpty\r
- @Size(max = 255)\r
- protected String nomenclaturalTitle;\r
-\r
- //under construction #4311\r
- @XmlElement(name="CollectorTitle")\r
- @Field(index=Index.YES)\r
- @Size(max = 255)\r
- protected String collectorTitle;\r
-\r
-\r
- @Transient\r
- @XmlTransient\r
- protected boolean isGeneratingTitleCache = false; //state variable to avoid recursions when generating title cache and nomenclatural title\r
-\r
- /**\r
- * Returns the identification string (nomenclatural abbreviation) used in\r
- * nomenclature for this {@link Person person} or this {@link Team team}.\r
- *\r
- * @see INomenclaturalAuthor#getNomenclaturalTitle()\r
- */\r
- @Override\r
- @Transient\r
- public String getNomenclaturalTitle() {\r
- String result = nomenclaturalTitle;\r
- if (StringUtils.isBlank(nomenclaturalTitle) && (isGeneratingTitleCache == false)){\r
- result = getTitleCache();\r
- }\r
- return result;\r
- }\r
-\r
- /**\r
- * @see #getNomenclaturalTitle()\r
- */\r
- @Override\r
- public void setNomenclaturalTitle(String nomenclaturalTitle) {\r
- this.nomenclaturalTitle = StringUtils.isBlank(nomenclaturalTitle) ? null : nomenclaturalTitle;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()\r
- */\r
- @Override\r
- @Transient /*\r
- TODO is the transient annotation still needed, can't we remove this ??\r
- @Transient is an absolutely special case and thus leads to several\r
- special implementations in order to harmonize this exception again\r
- in other parts of the library:\r
- - eu.etaxonomy.cdm.remote.controller.AgentController.doGetTitleCache()\r
- - eu.etaxonomy.cdm.remote.json.processor.bean.TeamOrPersonBaseBeanProcessor\r
-\r
- [a.kohlbecker May 2011]\r
- */\r
- public String getTitleCache() {\r
- isGeneratingTitleCache = true;\r
- String result = super.getTitleCache();\r
- result = replaceEmptyTitleByNomTitle(result);\r
- isGeneratingTitleCache = false;\r
- return result;\r
- }\r
-\r
- /**\r
- * @param result\r
- * @return\r
- */\r
- protected String replaceEmptyTitleByNomTitle(String result) {\r
- if (StringUtils.isBlank(result)){\r
- result = nomenclaturalTitle;\r
- }\r
- if (StringUtils.isBlank(result)){\r
- result = super.getTitleCache();\r
- }\r
- return result;\r
- }\r
-\r
-\r
-}\r
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.model.agent;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Transient;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.hibernate.envers.Audited;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+
+import eu.etaxonomy.cdm.strategy.cache.agent.INomenclaturalAuthorCacheStrategy;
+
+
+/**
+ * The abstract class for such {@link AgentBase agents} ({@link Person persons} or {@link Team teams}) who might also be used
+ * for authorship of {@link eu.etaxonomy.cdm.model.reference.Reference references} or of {@link eu.etaxonomy.cdm.model.name.TaxonNameBase taxon names}.
+ *
+ * @author a.mueller
+ * @created 17-APR-2008
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "TeamOrPersonBase", propOrder = {
+ "nomenclaturalTitle",
+ "collectorTitle"
+})
+@Entity
+@Audited
+public abstract class TeamOrPersonBase<T extends TeamOrPersonBase<T>> extends AgentBase<INomenclaturalAuthorCacheStrategy<T>> implements INomenclaturalAuthor {
+ private static final long serialVersionUID = 5216821307314001961L;
+ public static final Logger logger = Logger.getLogger(TeamOrPersonBase.class);
+
+ @XmlElement(name="NomenclaturalTitle")
+ @Field(index=Index.YES)
+ //TODO Val #3379
+// @NullOrNotEmpty
+ @Column(length=255)
+ protected String nomenclaturalTitle;
+
+ //under construction #4311
+ @XmlElement(name="CollectorTitle")
+ @Field(index=Index.YES)
+ @Column(length=255)
+ protected String collectorTitle;
+
+
+ @Transient
+ @XmlTransient
+ protected boolean isGeneratingTitleCache = false; //state variable to avoid recursions when generating title cache and nomenclatural title
+
+ /**
+ * Returns the identification string (nomenclatural abbreviation) used in
+ * nomenclature for this {@link Person person} or this {@link Team team}.
+ *
+ * @see INomenclaturalAuthor#getNomenclaturalTitle()
+ */
+ @Override
+ @Transient
+ public String getNomenclaturalTitle() {
+ String result = nomenclaturalTitle;
+ if (StringUtils.isBlank(nomenclaturalTitle) && (isGeneratingTitleCache == false)){
+ result = getTitleCache();
+ }
+ return result;
+ }
+
+ /**
+ * @see #getNomenclaturalTitle()
+ */
+ @Override
+ public void setNomenclaturalTitle(String nomenclaturalTitle) {
+ this.nomenclaturalTitle = StringUtils.isBlank(nomenclaturalTitle) ? null : nomenclaturalTitle;
+ }
+
+
+ @Override
+ @Transient /*
+ TODO is the transient annotation still needed, can't we remove this ??
+ @Transient is an absolutely special case and thus leads to several
+ special implementations in order to harmonize this exception again
+ in other parts of the library:
+ - eu.etaxonomy.cdm.remote.controller.AgentController.doGetTitleCache()
+ - eu.etaxonomy.cdm.remote.json.processor.bean.TeamOrPersonBaseBeanProcessor
+
+ [a.kohlbecker May 2011]
+ */
+ public String getTitleCache() {
+ isGeneratingTitleCache = true;
+ String result = super.getTitleCache();
+ result = replaceEmptyTitleByNomTitle(result);
+ isGeneratingTitleCache = false;
+ return result;
+ }
+
+ /**
+ * @param result
+ * @return
+ */
+ protected String replaceEmptyTitleByNomTitle(String result) {
+ if (StringUtils.isBlank(result)){
+ result = nomenclaturalTitle;
+ }
+ if (StringUtils.isBlank(result)){
+ result = super.getTitleCache();
+ }
+ return result;
+ }
+
+
+}