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
.common
;
11 import javax
.persistence
.Entity
;
12 import javax
.persistence
.FetchType
;
13 import javax
.persistence
.ManyToOne
;
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
.XmlIDREF
;
18 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
19 import javax
.xml
.bind
.annotation
.XmlType
;
21 import org
.apache
.logging
.log4j
.LogManager
;
22 import org
.apache
.logging
.log4j
.Logger
;
23 import org
.hibernate
.annotations
.Cascade
;
24 import org
.hibernate
.annotations
.CascadeType
;
25 import org
.hibernate
.envers
.Audited
;
27 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
33 @XmlAccessorType(XmlAccessType
.FIELD
)
34 @XmlType(name
= "Credit")
37 public class Credit
extends LanguageStringBase
{
39 private static final long serialVersionUID
= 5763391127298427701L;
40 @SuppressWarnings("unused")
41 private static final Logger logger
= LogManager
.getLogger();
43 // ********************** FACTORY **********************************************/
45 public static Credit
NewInstance(AgentBase agent
, TimePeriod timePeriod
, String text
){
46 return NewInstance(agent
, timePeriod
, text
, null, Language
.DEFAULT());
49 public static Credit
NewInstance(AgentBase agent
, TimePeriod timePeriod
, String text
, String abbreviatedText
, Language language
){
50 Credit result
= new Credit(text
, language
);
51 result
.setAgent(agent
);
52 result
.setAbbreviatedText(abbreviatedText
);
53 result
.setTimePeriod(timePeriod
);
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
;
68 @XmlElement(name
= "TimePeriod", type
= String
.class)
69 private TimePeriod timePeriod
= TimePeriod
.NewInstance();
71 @XmlElement(name
= "AbbreviatedText")
72 private String abbreviatedText
;
74 // ********************** CONSTRUCTOR **********************************************/
80 protected Credit(String text
, Language language
){
81 super(text
, language
);
84 //*********************** GETTER /SETTER *****************************/
86 public AgentBase
getAgent() {
89 public void setAgent(AgentBase agent
) {
93 public TimePeriod
getTimePeriod() {
96 public void setTimePeriod(TimePeriod timePeriod
) {
97 this.timePeriod
= timePeriod
;
100 public String
getAbbreviatedText() {
101 return abbreviatedText
;
103 public void setAbbreviatedText(String abbreviatedText
) {
104 this.abbreviatedText
= abbreviatedText
;
107 //************************* CLONE **************************/
110 public Credit
clone() throws CloneNotSupportedException
{
112 Credit result
= (Credit
)super.clone();
114 if (this.timePeriod
!= null) {
115 result
.timePeriod
= this.timePeriod
.clone();
118 //no changes to: agent
122 // ************************ STRING ****************************/
125 public String
toString() {
126 if (isNotBlank(this.abbreviatedText
)){
127 return this.abbreviatedText
;
128 }else if (isNotBlank(this.text
)){
131 return super.toString();