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 java.net.URI;
|
12
|
|
13
|
import javax.persistence.Entity;
|
14
|
import javax.persistence.FetchType;
|
15
|
import javax.persistence.ManyToOne;
|
16
|
import javax.persistence.Table;
|
17
|
import javax.xml.bind.annotation.XmlAccessType;
|
18
|
import javax.xml.bind.annotation.XmlAccessorType;
|
19
|
import javax.xml.bind.annotation.XmlElement;
|
20
|
import javax.xml.bind.annotation.XmlIDREF;
|
21
|
import javax.xml.bind.annotation.XmlRootElement;
|
22
|
import javax.xml.bind.annotation.XmlSchemaType;
|
23
|
import javax.xml.bind.annotation.XmlType;
|
24
|
|
25
|
import org.apache.log4j.Logger;
|
26
|
import org.hibernate.annotations.Cascade;
|
27
|
import org.hibernate.annotations.CascadeType;
|
28
|
import org.hibernate.annotations.Type;
|
29
|
import org.hibernate.envers.Audited;
|
30
|
import org.hibernate.search.annotations.Analyze;
|
31
|
import org.hibernate.search.annotations.Field;
|
32
|
|
33
|
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
34
|
import eu.etaxonomy.cdm.model.common.Language;
|
35
|
import eu.etaxonomy.cdm.model.common.LanguageStringBase;
|
36
|
|
37
|
/**
|
38
|
* Typically, rights information includes a statement about various property
|
39
|
* rights associated with the resource, including intellectual property rights.
|
40
|
* http://purl.org/dc/elements/1.1/rights http://dublincore.org/documents/dcmi-
|
41
|
* terms/
|
42
|
* @author m.doering
|
43
|
* @since 08-Nov-2007 13:06:49
|
44
|
*/
|
45
|
@XmlAccessorType(XmlAccessType.FIELD)
|
46
|
@XmlType(name = "Rights", propOrder = {
|
47
|
"uri",
|
48
|
"abbreviatedText",
|
49
|
"type",
|
50
|
"agent"
|
51
|
})
|
52
|
@XmlRootElement(name = "Rights")
|
53
|
@Entity
|
54
|
@Audited
|
55
|
@Table(name = "RightsInfo") //to avoid conflicts with reserved database words
|
56
|
public class Rights extends LanguageStringBase {
|
57
|
private static final long serialVersionUID = 4920749849951432284L;
|
58
|
@SuppressWarnings("unused")
|
59
|
private static final Logger logger = Logger.getLogger(Rights.class);
|
60
|
|
61
|
//external location of copyright text
|
62
|
@XmlElement(name = "URI")
|
63
|
@Field(analyze = Analyze.NO)
|
64
|
@Type(type="uriUserType")
|
65
|
private URI uri;
|
66
|
|
67
|
@XmlElement(name = "AbbreviatedText")
|
68
|
private String abbreviatedText;
|
69
|
|
70
|
@XmlElement(name = "Type")
|
71
|
@XmlIDREF
|
72
|
@XmlSchemaType(name = "IDREF")
|
73
|
@ManyToOne(fetch = FetchType.LAZY)
|
74
|
private RightsType type;
|
75
|
|
76
|
// owner etc as defined by the rights type
|
77
|
@XmlElement(name = "Agent")
|
78
|
@XmlIDREF
|
79
|
@XmlSchemaType(name = "IDREF")
|
80
|
@ManyToOne(fetch = FetchType.LAZY)
|
81
|
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
|
82
|
private AgentBase<?> agent;
|
83
|
|
84
|
// ******************** FACTORY ***********************/
|
85
|
|
86
|
public static Rights NewInstance() {
|
87
|
return new Rights();
|
88
|
}
|
89
|
|
90
|
public static Rights NewInstance(String text, Language language) {
|
91
|
return new Rights(text, language, null, null);
|
92
|
}
|
93
|
|
94
|
public static Rights NewInstance(RightsType type) {
|
95
|
return new Rights(null, null, type, null);
|
96
|
}
|
97
|
|
98
|
public static Rights NewInstance(RightsType type, AgentBase agent) {
|
99
|
return new Rights(null, null, type, agent);
|
100
|
}
|
101
|
|
102
|
public static Rights NewInstance(String text, Language language, RightsType type) {
|
103
|
return new Rights(text, language, type, null);
|
104
|
}
|
105
|
|
106
|
public static Rights NewInstance(String text, Language language, RightsType type, AgentBase agent) {
|
107
|
return new Rights(text, language, type, agent);
|
108
|
}
|
109
|
|
110
|
//*********************** CONSTRUCTOR *************************/
|
111
|
|
112
|
protected Rights() {
|
113
|
super();
|
114
|
}
|
115
|
protected Rights(String text, Language language, RightsType type, AgentBase agent) {
|
116
|
super(text, language);
|
117
|
this.setType(type);
|
118
|
this.setAgent(agent);
|
119
|
}
|
120
|
|
121
|
//*********************** GETTER /SETTER *****************************/
|
122
|
|
123
|
public RightsType getType(){
|
124
|
return this.type;
|
125
|
}
|
126
|
|
127
|
public void setType(RightsType type){
|
128
|
this.type = type;
|
129
|
}
|
130
|
|
131
|
public URI getUri(){
|
132
|
return this.uri;
|
133
|
}
|
134
|
|
135
|
public void setUri(URI uri){
|
136
|
this.uri = uri;
|
137
|
}
|
138
|
|
139
|
public String getAbbreviatedText(){
|
140
|
return this.abbreviatedText;
|
141
|
}
|
142
|
|
143
|
public void setAbbreviatedText(String abbreviatedStatement){
|
144
|
this.abbreviatedText = abbreviatedStatement;
|
145
|
}
|
146
|
|
147
|
public AgentBase getAgent() {
|
148
|
return agent;
|
149
|
}
|
150
|
|
151
|
public void setAgent(AgentBase agent) {
|
152
|
this.agent = agent;
|
153
|
}
|
154
|
|
155
|
//************************* CLONE **************************/
|
156
|
|
157
|
@Override
|
158
|
public Rights clone() throws CloneNotSupportedException{
|
159
|
Rights result = (Rights)super.clone();
|
160
|
//no changes to: type, agent
|
161
|
return result;
|
162
|
}
|
163
|
}
|