ref #7075 first running version for ImageExcelImport
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / media / Rights.java
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.media;
11
12 import java.net.URI;
13
14 import javax.persistence.Entity;
15 import javax.persistence.FetchType;
16 import javax.persistence.ManyToOne;
17 import javax.persistence.Table;
18 import javax.xml.bind.annotation.XmlAccessType;
19 import javax.xml.bind.annotation.XmlAccessorType;
20 import javax.xml.bind.annotation.XmlElement;
21 import javax.xml.bind.annotation.XmlIDREF;
22 import javax.xml.bind.annotation.XmlRootElement;
23 import javax.xml.bind.annotation.XmlSchemaType;
24 import javax.xml.bind.annotation.XmlType;
25
26 import org.apache.log4j.Logger;
27 import org.hibernate.annotations.Cascade;
28 import org.hibernate.annotations.CascadeType;
29 import org.hibernate.annotations.Type;
30 import org.hibernate.envers.Audited;
31 import org.hibernate.search.annotations.Analyze;
32 import org.hibernate.search.annotations.Field;
33
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 * @created 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 implements Cloneable{
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 @Type(type="uriUserType")
66 private URI uri;
67
68 @XmlElement(name = "AbbreviatedText")
69 private String abbreviatedText;
70
71 @XmlElement(name = "Type")
72 @XmlIDREF
73 @XmlSchemaType(name = "IDREF")
74 @ManyToOne(fetch = FetchType.LAZY)
75 private RightsType type;
76
77 // owner etc as defined by the rights type
78 @XmlElement(name = "Agent")
79 @XmlIDREF
80 @XmlSchemaType(name = "IDREF")
81 @ManyToOne(fetch = FetchType.LAZY)
82 @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
83 private AgentBase<?> agent;
84
85 // ******************** FACTORY ***********************/
86
87 public static Rights NewInstance() {
88 return new Rights();
89 }
90
91 public static Rights NewInstance(String text, Language language) {
92 return new Rights(text, language, null, null);
93 }
94
95 public static Rights NewInstance(RightsType type) {
96 return new Rights(null, null, type, null);
97 }
98
99 public static Rights NewInstance(RightsType type, AgentBase agent) {
100 return new Rights(null, null, type, agent);
101 }
102
103 public static Rights NewInstance(String text, Language language, RightsType type) {
104 return new Rights(text, language, type, null);
105 }
106
107 public static Rights NewInstance(String text, Language language, RightsType type, AgentBase agent) {
108 return new Rights(text, language, type, agent);
109 }
110
111 //*********************** CONSTRUCTOR *************************/
112
113 protected Rights() {
114 super();
115 }
116 protected Rights(String text, Language language, RightsType type, AgentBase agent) {
117 super(text, language);
118 this.setType(type);
119 this.setAgent(agent);
120 }
121
122 //*********************** GETTER /SETTER *****************************/
123
124 public RightsType getType(){
125 return this.type;
126 }
127
128 public void setType(RightsType type){
129 this.type = type;
130 }
131
132 public URI getUri(){
133 return this.uri;
134 }
135
136 public void setUri(URI uri){
137 this.uri = uri;
138 }
139
140 public String getAbbreviatedText(){
141 return this.abbreviatedText;
142 }
143
144 public void setAbbreviatedText(String abbreviatedStatement){
145 this.abbreviatedText = abbreviatedStatement;
146 }
147
148 public AgentBase getAgent() {
149 return agent;
150 }
151
152 public void setAgent(AgentBase agent) {
153 this.agent = agent;
154 }
155
156 //************************* CLONE **************************/
157
158 @Override
159 public Object clone() throws CloneNotSupportedException{
160 Rights result = (Rights)super.clone();
161 //no changes to: type, agent
162 return result;
163 }
164 }