Project

General

Profile

Download (4.63 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.logging.log4j.LogManager;import org.apache.logging.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

    
59
	private static final long serialVersionUID = 4920749849951432284L;
60
	@SuppressWarnings("unused")
61
    private static final Logger logger = LogManager.getLogger(Rights.class);
62

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

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

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

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

    
87
// ******************** FACTORY ***********************/
88

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

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

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

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

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

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

    
113
//*********************** CONSTRUCTOR *************************/
114

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

    
124
//*********************** GETTER /SETTER *****************************/
125

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

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

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

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

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

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

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

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

    
158
//************************* CLONE **************************/
159

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