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
|
* @since 09.06.2008
|
40
|
*/
|
41
|
@XmlAccessorType(XmlAccessType.FIELD)
|
42
|
@XmlType(name = "MediaRepresentationPart", propOrder = {
|
43
|
"uri",
|
44
|
"size",
|
45
|
"mediaRepresentation"
|
46
|
})
|
47
|
@Entity
|
48
|
@Audited
|
49
|
public class MediaRepresentationPart extends VersionableEntity implements Cloneable{
|
50
|
private static final long serialVersionUID = -1674422508643785796L;
|
51
|
@SuppressWarnings("unused")
|
52
|
private static final Logger logger = Logger.getLogger(MediaRepresentationPart.class);
|
53
|
|
54
|
// where the media file is stored
|
55
|
@XmlElement(name = "URI")
|
56
|
@Type(type="uriUserType")
|
57
|
private URI uri;
|
58
|
|
59
|
// in bytes
|
60
|
@XmlElement(name = "Size")
|
61
|
private Integer size;
|
62
|
|
63
|
// the MediaRepresentation of this MediaRepresentationPart
|
64
|
@XmlElement(name = "MediaRepresentation")
|
65
|
@XmlIDREF
|
66
|
@XmlSchemaType(name = "IDREF")
|
67
|
@ManyToOne(fetch = FetchType.LAZY)
|
68
|
@JoinColumn(name = "representation_id", nullable = false, updatable = false, insertable = false)
|
69
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
70
|
private MediaRepresentation mediaRepresentation;
|
71
|
|
72
|
|
73
|
// *************** FACTORY METHOD *********************************/
|
74
|
|
75
|
public static MediaRepresentationPart NewInstance(URI uri, Integer size) {
|
76
|
MediaRepresentationPart result = new MediaRepresentationPart(uri, size);
|
77
|
return result;
|
78
|
}
|
79
|
|
80
|
|
81
|
protected MediaRepresentationPart() {
|
82
|
super();
|
83
|
}
|
84
|
|
85
|
protected MediaRepresentationPart(URI uri, Integer size) {
|
86
|
this();
|
87
|
this.setUri(uri);
|
88
|
this.setSize(size);
|
89
|
}
|
90
|
|
91
|
//*************** GETTER / SETTER *************************************/
|
92
|
|
93
|
public MediaRepresentation getMediaRepresentation() {
|
94
|
return this.mediaRepresentation;
|
95
|
}
|
96
|
|
97
|
/**
|
98
|
* @deprecated for internal (bidirectional) use only
|
99
|
*/
|
100
|
@Deprecated
|
101
|
protected void setMediaRepresentation(MediaRepresentation mediaRepresentation) {
|
102
|
this.mediaRepresentation = mediaRepresentation;
|
103
|
}
|
104
|
|
105
|
//uri
|
106
|
public URI getUri() {
|
107
|
return this.uri;
|
108
|
}
|
109
|
|
110
|
public void setUri(URI uri) {
|
111
|
this.uri = uri;
|
112
|
}
|
113
|
|
114
|
//size
|
115
|
public Integer getSize() {
|
116
|
return this.size;
|
117
|
}
|
118
|
public void setSize(Integer size) {
|
119
|
this.size = size;
|
120
|
}
|
121
|
|
122
|
//************************* CLONE **************************/
|
123
|
|
124
|
@Override
|
125
|
public Object clone() throws CloneNotSupportedException{
|
126
|
MediaRepresentationPart result = (MediaRepresentationPart)super.clone();
|
127
|
|
128
|
//media representation
|
129
|
result.setMediaRepresentation(null);
|
130
|
|
131
|
//no changes to: size, uri
|
132
|
return result;
|
133
|
}
|
134
|
}
|