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.JoinColumn;
|
17
|
import javax.persistence.ManyToOne;
|
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.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
|
|
31
|
import eu.etaxonomy.cdm.model.common.VersionableEntity;
|
32
|
|
33
|
/**
|
34
|
* A media representation part is a resource that can be referenced by an URI.
|
35
|
* It represents a part of or the entire media. <br>
|
36
|
* E.g. a jpg file or a website
|
37
|
*
|
38
|
* @author a.mueller
|
39
|
* @created 09.06.2008
|
40
|
* @version 1.0
|
41
|
*/
|
42
|
@XmlAccessorType(XmlAccessType.FIELD)
|
43
|
@XmlType(name = "MediaRepresentationPart", propOrder = {
|
44
|
"uri",
|
45
|
"size",
|
46
|
"mediaRepresentation"
|
47
|
})
|
48
|
@Entity
|
49
|
@Audited
|
50
|
public class MediaRepresentationPart extends VersionableEntity implements Cloneable{
|
51
|
private static final long serialVersionUID = -1674422508643785796L;
|
52
|
@SuppressWarnings("unused")
|
53
|
private static final Logger logger = Logger.getLogger(MediaRepresentationPart.class);
|
54
|
|
55
|
// where the media file is stored
|
56
|
@XmlElement(name = "URI")
|
57
|
@Type(type="uriUserType")
|
58
|
private URI uri;
|
59
|
|
60
|
// in bytes
|
61
|
@XmlElement(name = "Size")
|
62
|
private Integer size;
|
63
|
|
64
|
// the MediaRepresentation of this MediaRepresentationPart
|
65
|
@XmlElement(name = "MediaRepresentation")
|
66
|
@XmlIDREF
|
67
|
@XmlSchemaType(name = "IDREF")
|
68
|
@ManyToOne(fetch = FetchType.LAZY)
|
69
|
@JoinColumn(name = "representation_id", nullable = false, updatable = false, insertable = false)
|
70
|
@Cascade(CascadeType.SAVE_UPDATE)
|
71
|
private MediaRepresentation mediaRepresentation;
|
72
|
|
73
|
/**
|
74
|
* Factory method
|
75
|
*
|
76
|
* @return
|
77
|
*/
|
78
|
public static MediaRepresentationPart NewInstance(URI uri, Integer size) {
|
79
|
MediaRepresentationPart result = new MediaRepresentationPart(uri, size);
|
80
|
return result;
|
81
|
}
|
82
|
|
83
|
/**
|
84
|
*
|
85
|
*/
|
86
|
protected MediaRepresentationPart() {
|
87
|
super();
|
88
|
}
|
89
|
|
90
|
/**
|
91
|
*
|
92
|
*/
|
93
|
protected MediaRepresentationPart(URI uri, Integer size) {
|
94
|
this();
|
95
|
this.setUri(uri);
|
96
|
this.setSize(size);
|
97
|
}
|
98
|
|
99
|
/*************** getter /setter *************************************/
|
100
|
|
101
|
public MediaRepresentation getMediaRepresentation() {
|
102
|
return this.mediaRepresentation;
|
103
|
}
|
104
|
|
105
|
/**
|
106
|
* @deprecated for internal (bidirectional) use only
|
107
|
*/
|
108
|
@Deprecated
|
109
|
protected void setMediaRepresentation(MediaRepresentation mediaRepresentation) {
|
110
|
this.mediaRepresentation = mediaRepresentation;
|
111
|
}
|
112
|
|
113
|
public URI getUri() {
|
114
|
return this.uri;
|
115
|
}
|
116
|
|
117
|
/**
|
118
|
*
|
119
|
* @param uri
|
120
|
* uri
|
121
|
*/
|
122
|
public void setUri(URI uri) {
|
123
|
this.uri = uri;
|
124
|
}
|
125
|
|
126
|
/**
|
127
|
* @return
|
128
|
*/
|
129
|
public Integer getSize() {
|
130
|
return this.size;
|
131
|
}
|
132
|
|
133
|
/**
|
134
|
* @param size
|
135
|
* size
|
136
|
*/
|
137
|
public void setSize(Integer size) {
|
138
|
this.size = size;
|
139
|
}
|
140
|
|
141
|
//************************* CLONE **************************/
|
142
|
/* (non-Javadoc)
|
143
|
* @see java.lang.Object#clone()
|
144
|
*/
|
145
|
@Override
|
146
|
public Object clone() throws CloneNotSupportedException{
|
147
|
MediaRepresentationPart result = (MediaRepresentationPart)super.clone();
|
148
|
|
149
|
//media representation
|
150
|
result.setMediaRepresentation(null);
|
151
|
|
152
|
//no changes to: size, uri
|
153
|
return result;
|
154
|
}
|
155
|
|
156
|
|
157
|
}
|