Project

General

Profile

Download (3.28 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9

    
10
package eu.etaxonomy.cdm.model.common;
11

    
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;
21

    
22
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
23
import org.hibernate.annotations.Cascade;
24
import org.hibernate.annotations.CascadeType;
25
import org.hibernate.envers.Audited;
26

    
27
import eu.etaxonomy.cdm.model.agent.AgentBase;
28

    
29
/**
30
 * @author a.mueller
31
 * @since 23.03.2009
32
 * @version 1.0
33
 */
34
@XmlAccessorType(XmlAccessType.FIELD)
35
@XmlType(name = "Credit")
36
@Entity
37
@Audited
38
public class Credit extends LanguageStringBase implements Cloneable{
39
	private static final long serialVersionUID = 5763391127298427701L;
40
	@SuppressWarnings("unused")
41
	private static final Logger logger = LogManager.getLogger(Credit.class);
42

    
43
// ********************** FACTORY **********************************************/
44

    
45
    public static Credit NewInstance(AgentBase agent, String text){
46
        return NewInstance(agent, text, null, Language.DEFAULT());
47
    }
48

    
49
    public static Credit NewInstance(AgentBase agent, String text, String abbreviatedText, Language language){
50
        Credit result = new Credit(text, language);
51
        result.setAgent(agent);
52
        result.setAbbreviatedText(abbreviatedText);
53
        return result;
54
    }
55

    
56
// ********************** FACTORY **********************************************/
57

    
58
	// owner etc as defined by the rightstype
59
	@XmlElement(name = "Agent")
60
	@XmlIDREF
61
	@XmlSchemaType(name = "IDREF")
62
	@ManyToOne(fetch = FetchType.LAZY)
63
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
64
	private AgentBase<?> agent;
65

    
66
	@XmlElement(name = "AbbreviatedText")
67
	private String abbreviatedText;
68

    
69
// ********************** CONSTRUCTOR **********************************************/
70

    
71
	protected Credit(){
72
		super();
73
	}
74

    
75
	protected Credit(String text, Language language){
76
		super(text, language);
77
	}
78

    
79
//*********************** GETTER /SETTER *****************************/
80

    
81
	/**
82
	 * @return the agent
83
	 */
84
	public AgentBase getAgent() {
85
		return agent;
86
	}
87
	public void setAgent(AgentBase agent) {
88
		this.agent = agent;
89
	}
90

    
91

    
92
	/**
93
	 * @return the abbreviatedText
94
	 */
95
	public String getAbbreviatedText() {
96
		return abbreviatedText;
97
	}
98
	public void setAbbreviatedText(String abbreviatedText) {
99
		this.abbreviatedText = abbreviatedText;
100
	}
101

    
102
//************************* CLONE **************************/
103

    
104
	@Override
105
	public Credit clone() throws CloneNotSupportedException{
106

    
107
	    Credit result = (Credit)super.clone();
108
		//no changes to: agent
109
		return result;
110
	}
111

    
112
    @Override
113
    public String toString() {
114
        if (isNotBlank(this.abbreviatedText)){
115
            return this.abbreviatedText;
116
        }else if (isNotBlank(this.text)){
117
            return this.text;
118
        }else{
119
            return super.toString();
120
        }
121
    }
122

    
123
}
(8-8/56)