Project

General

Profile

Download (4.57 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
package eu.etaxonomy.cdm.model.media;
10

    
11
import javax.persistence.Entity;
12
import javax.persistence.FetchType;
13
import javax.persistence.ManyToOne;
14
import javax.persistence.Table;
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.XmlRootElement;
20
import javax.xml.bind.annotation.XmlSchemaType;
21
import javax.xml.bind.annotation.XmlType;
22

    
23
import org.apache.log4j.Logger;
24
import org.hibernate.annotations.Cascade;
25
import org.hibernate.annotations.CascadeType;
26
import org.hibernate.annotations.Type;
27
import org.hibernate.envers.Audited;
28
import org.hibernate.search.annotations.Analyze;
29
import org.hibernate.search.annotations.Field;
30
import org.hibernate.search.annotations.FieldBridge;
31

    
32
import eu.etaxonomy.cdm.common.URI;
33
import eu.etaxonomy.cdm.hibernate.search.UriBridge;
34
import eu.etaxonomy.cdm.model.agent.AgentBase;
35
import eu.etaxonomy.cdm.model.common.Language;
36
import eu.etaxonomy.cdm.model.common.LanguageStringBase;
37

    
38
/**
39
 * Typically, rights information includes a statement about various property
40
 * rights associated with the resource, including intellectual property rights.
41
 * http://purl.org/dc/elements/1.1/rights  http://dublincore.org/documents/dcmi-
42
 * terms/
43
 * @author m.doering
44
 * @since 08-Nov-2007 13:06:49
45
 */
46
@XmlAccessorType(XmlAccessType.FIELD)
47
@XmlType(name = "Rights", propOrder = {
48
    "uri",
49
    "abbreviatedText",
50
    "type",
51
    "agent"
52
})
53
@XmlRootElement(name = "Rights")
54
@Entity
55
@Audited
56
@Table(name = "RightsInfo")  //to avoid conflicts with reserved database words
57
public class Rights extends LanguageStringBase {
58
	private static final long serialVersionUID = 4920749849951432284L;
59
	@SuppressWarnings("unused")
60
    private static final Logger logger = Logger.getLogger(Rights.class);
61

    
62
	//external location of copyright text
63
	@XmlElement(name = "URI")
64
	@Field(analyze = Analyze.NO)
65
    @FieldBridge(impl = UriBridge.class)
66
	@Type(type="uriUserType")
67
	private URI uri;
68

    
69
	@XmlElement(name = "AbbreviatedText")
70
	private String abbreviatedText;
71

    
72
	@XmlElement(name = "Type")
73
	@XmlIDREF
74
	@XmlSchemaType(name = "IDREF")
75
	@ManyToOne(fetch = FetchType.LAZY)
76
	private RightsType type;
77

    
78
	// owner etc as defined by the rights type
79
	@XmlElement(name = "Agent")
80
	@XmlIDREF
81
	@XmlSchemaType(name = "IDREF")
82
	@ManyToOne(fetch = FetchType.LAZY)
83
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
84
	private AgentBase<?> agent;
85

    
86
// ******************** FACTORY ***********************/
87

    
88
	public static Rights NewInstance() {
89
		return new Rights();
90
	}
91

    
92
	public static Rights NewInstance(String text, Language language) {
93
		return new Rights(text, language, null, null);
94
	}
95

    
96
    public static Rights NewInstance(RightsType type) {
97
        return new Rights(null, null, type, null);
98
    }
99

    
100
    public static Rights NewInstance(RightsType type, AgentBase agent) {
101
        return new Rights(null, null, type, agent);
102
    }
103

    
104
    public static Rights NewInstance(String text, Language language, RightsType type) {
105
        return new Rights(text, language, type, null);
106
    }
107

    
108
    public static Rights NewInstance(String text, Language language, RightsType type, AgentBase agent) {
109
        return new Rights(text, language, type, agent);
110
    }
111

    
112
//*********************** CONSTRUCTOR *************************/
113

    
114
	protected Rights() {
115
		super();
116
	}
117
    protected Rights(String text, Language language, RightsType type, AgentBase agent) {
118
        super(text, language);
119
        this.setType(type);
120
        this.setAgent(agent);
121
    }
122

    
123
//*********************** GETTER /SETTER *****************************/
124

    
125
	public RightsType getType(){
126
		return this.type;
127
	}
128

    
129
	public void setType(RightsType type){
130
		this.type = type;
131
	}
132

    
133
	public URI getUri(){
134
		return this.uri;
135
	}
136

    
137
	public void setUri(URI uri){
138
		this.uri = uri;
139
	}
140

    
141
	public String getAbbreviatedText(){
142
		return this.abbreviatedText;
143
	}
144

    
145
	public void setAbbreviatedText(String abbreviatedStatement){
146
		this.abbreviatedText = abbreviatedStatement;
147
	}
148

    
149
	public AgentBase getAgent() {
150
		return agent;
151
	}
152

    
153
	public void setAgent(AgentBase agent) {
154
		this.agent = agent;
155
	}
156

    
157
//************************* CLONE **************************/
158

    
159
	@Override
160
	public Rights clone() throws CloneNotSupportedException{
161
		Rights result = (Rights)super.clone();
162
		//no changes to: type, agent
163
		return result;
164
	}
165
}
(14-14/16)