-/**\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
-\r
-package eu.etaxonomy.cdm.model.common;\r
-\r
-import javax.persistence.Entity;\r
-import javax.persistence.FetchType;\r
-import javax.persistence.ManyToOne;\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.XmlIDREF;\r
-import javax.xml.bind.annotation.XmlSchemaType;\r
-import javax.xml.bind.annotation.XmlType;\r
-\r
-import org.apache.log4j.Logger;\r
-import org.hibernate.annotations.Cascade;\r
-import org.hibernate.annotations.CascadeType;\r
-import org.hibernate.envers.Audited;\r
-\r
-import eu.etaxonomy.cdm.model.agent.AgentBase;\r
-\r
-/**\r
- * @author a.mueller\r
- * @created 23.03.2009\r
- * @version 1.0\r
- */\r
-@XmlAccessorType(XmlAccessType.FIELD)\r
-@XmlType(name = "Credit")\r
-@Entity\r
-@Audited\r
-public class Credit extends LanguageStringBase implements Cloneable{\r
- private static final long serialVersionUID = 5763391127298427701L;\r
- @SuppressWarnings("unused")\r
- private static final Logger logger = Logger.getLogger(Credit.class);\r
- \r
- // owner etc as defined by the rightstype\r
- @XmlElement(name = "Agent")\r
- @XmlIDREF\r
- @XmlSchemaType(name = "IDREF")\r
- @ManyToOne(fetch = FetchType.LAZY)\r
- @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})\r
- private AgentBase<?> agent;\r
- \r
- @XmlElement(name = "AbbreviatedText")\r
- private String abbreviatedText;\r
- \r
- public static Credit NewInstance(AgentBase agent, String text){\r
- return NewInstance(agent, text, null, Language.DEFAULT());\r
- }\r
-\r
- public static Credit NewInstance(AgentBase agent, String text, String abbreviatedText, Language language){\r
- Credit result = new Credit(text, language);\r
- result.setAgent(agent);\r
- result.setAbbreviatedText(abbreviatedText);\r
- return result;\r
- }\r
-\r
- \r
- protected Credit(){\r
- super();\r
- }\r
- \r
- protected Credit(String text, Language language){\r
- super(text, language);\r
- }\r
-\r
-\r
-\r
- /**\r
- * @return the agent\r
- */\r
- public AgentBase getAgent() {\r
- return agent;\r
- }\r
-\r
-\r
-\r
- /**\r
- * @param agent the agent to set\r
- */\r
- public void setAgent(AgentBase agent) {\r
- this.agent = agent;\r
- }\r
-\r
-\r
-\r
- /**\r
- * @return the abbreviatedText\r
- */\r
- public String getAbbreviatedText() {\r
- return abbreviatedText;\r
- }\r
-\r
-\r
-\r
- /**\r
- * @param abbreviatedText the abbreviatedText to set\r
- */\r
- public void setAbbreviatedText(String abbreviatedText) {\r
- this.abbreviatedText = abbreviatedText;\r
- }\r
-\r
-//************************* CLONE **************************/\r
- \r
- /* (non-Javadoc)\r
- * @see java.lang.Object#clone()\r
- */\r
- @Override\r
- public Object clone() throws CloneNotSupportedException{\r
- Credit result = (Credit)super.clone();\r
- //no changes to: agent\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.common;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.ManyToOne;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlIDREF;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.CascadeType;
+import org.hibernate.envers.Audited;
+
+import eu.etaxonomy.cdm.model.agent.AgentBase;
+
+/**
+ * @author a.mueller
+ * @since 23.03.2009
+ * @version 1.0
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "Credit")
+@Entity
+@Audited
+public class Credit extends LanguageStringBase implements Cloneable{
+ private static final long serialVersionUID = 5763391127298427701L;
+ @SuppressWarnings("unused")
+ private static final Logger logger = LogManager.getLogger(Credit.class);
+
+// ********************** FACTORY **********************************************/
+
+ public static Credit NewInstance(AgentBase agent, String text){
+ return NewInstance(agent, text, null, Language.DEFAULT());
+ }
+
+ public static Credit NewInstance(AgentBase agent, String text, String abbreviatedText, Language language){
+ Credit result = new Credit(text, language);
+ result.setAgent(agent);
+ result.setAbbreviatedText(abbreviatedText);
+ return result;
+ }
+
+// ********************** FACTORY **********************************************/
+
+ // owner etc as defined by the rightstype
+ @XmlElement(name = "Agent")
+ @XmlIDREF
+ @XmlSchemaType(name = "IDREF")
+ @ManyToOne(fetch = FetchType.LAZY)
+ @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
+ private AgentBase<?> agent;
+
+ @XmlElement(name = "TimePeriod", type= String.class)
+ private TimePeriod timePeriod = TimePeriod.NewInstance();
+
+ @XmlElement(name = "AbbreviatedText")
+ private String abbreviatedText;
+
+// ********************** CONSTRUCTOR **********************************************/
+
+ protected Credit(){
+ super();
+ }
+
+ protected Credit(String text, Language language){
+ super(text, language);
+ }
+
+//*********************** GETTER /SETTER *****************************/
+
+ /**
+ * @return the agent
+ */
+ public AgentBase getAgent() {
+ return agent;
+ }
+ public void setAgent(AgentBase agent) {
+ this.agent = agent;
+ }
+
+
+ /**
+ * @return the abbreviatedText
+ */
+ public String getAbbreviatedText() {
+ return abbreviatedText;
+ }
+ public void setAbbreviatedText(String abbreviatedText) {
+ this.abbreviatedText = abbreviatedText;
+ }
+
+//************************* CLONE **************************/
+
+ @Override
+ public Credit clone() throws CloneNotSupportedException{
+
+ Credit result = (Credit)super.clone();
+
+ if (this.timePeriod != null) {
+ result.timePeriod = this.timePeriod.clone();
+ }
+
+ //no changes to: agent
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ if (isNotBlank(this.abbreviatedText)){
+ return this.abbreviatedText;
+ }else if (isNotBlank(this.text)){
+ return this.text;
+ }else{
+ return super.toString();
+ }
+ }
+
+}