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.
10 package eu
.etaxonomy
.cdm
.model
.common
;
12 import javax
.persistence
.Entity
;
13 import javax
.persistence
.FetchType
;
14 import javax
.persistence
.ManyToOne
;
15 import javax
.xml
.bind
.annotation
.XmlAccessType
;
16 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
17 import javax
.xml
.bind
.annotation
.XmlElement
;
18 import javax
.xml
.bind
.annotation
.XmlIDREF
;
19 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
20 import javax
.xml
.bind
.annotation
.XmlType
;
22 import org
.apache
.commons
.lang
.StringUtils
;
23 import org
.apache
.log4j
.Logger
;
24 import org
.hibernate
.annotations
.Cascade
;
25 import org
.hibernate
.annotations
.CascadeType
;
26 import org
.hibernate
.envers
.Audited
;
28 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
35 @XmlAccessorType(XmlAccessType
.FIELD
)
36 @XmlType(name
= "Credit")
39 public class Credit
extends LanguageStringBase
implements Cloneable
{
40 private static final long serialVersionUID
= 5763391127298427701L;
41 @SuppressWarnings("unused")
42 private static final Logger logger
= Logger
.getLogger(Credit
.class);
44 // ********************** FACTORY **********************************************/
46 public static Credit
NewInstance(AgentBase agent
, String text
){
47 return NewInstance(agent
, text
, null, Language
.DEFAULT());
50 public static Credit
NewInstance(AgentBase agent
, String text
, String abbreviatedText
, Language language
){
51 Credit result
= new Credit(text
, language
);
52 result
.setAgent(agent
);
53 result
.setAbbreviatedText(abbreviatedText
);
57 // ********************** FACTORY **********************************************/
59 // owner etc as defined by the rightstype
60 @XmlElement(name
= "Agent")
62 @XmlSchemaType(name
= "IDREF")
63 @ManyToOne(fetch
= FetchType
.LAZY
)
64 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
65 private AgentBase
<?
> agent
;
67 @XmlElement(name
= "AbbreviatedText")
68 private String abbreviatedText
;
70 // ********************** CONSTRUCTOR **********************************************/
76 protected Credit(String text
, Language language
){
77 super(text
, language
);
80 //*********************** GETTER /SETTER *****************************/
85 public AgentBase
getAgent() {
88 public void setAgent(AgentBase agent
) {
94 * @return the abbreviatedText
96 public String
getAbbreviatedText() {
97 return abbreviatedText
;
99 public void setAbbreviatedText(String abbreviatedText
) {
100 this.abbreviatedText
= abbreviatedText
;
103 //************************* CLONE **************************/
106 public Object
clone() throws CloneNotSupportedException
{
107 Credit result
= (Credit
)super.clone();
108 //no changes to: agent
113 public String
toString() {
114 if (StringUtils
.isNotBlank(this.abbreviatedText
)){
115 return this.abbreviatedText
;
116 }else if (StringUtils
.isNotBlank(this.text
)){
119 return super.toString();