Project

General

Profile

Download (3.62 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

    
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
 */
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
	protected MediaRepresentationPart(URI uri, Integer size) {
85
		this();
86
		this.setUri(uri);
87
		this.setSize(size);
88
	}
89

    
90
//*************** GETTER / SETTER *************************************/
91

    
92
	public MediaRepresentation getMediaRepresentation() {
93
		return this.mediaRepresentation;
94
	}
95

    
96
	/**
97
	 *  @deprecated for internal (bidirectional) use only
98
	 */
99
	@Deprecated
100
	protected void setMediaRepresentation(MediaRepresentation mediaRepresentation) {
101
		this.mediaRepresentation = mediaRepresentation;
102
	}
103

    
104
	//uri
105
	public URI getUri() {
106
		return this.uri;
107
	}
108
	public void setUri(URI uri) {
109
		this.uri = uri;
110
	}
111

    
112
	//size
113
	public Integer getSize() {
114
		return this.size;
115
	}
116
	public void setSize(Integer size) {
117
		this.size = size;
118
	}
119

    
120
//************************* CLONE **************************/
121

    
122
	@Override
123
	public Object clone() throws CloneNotSupportedException{
124
		MediaRepresentationPart result = (MediaRepresentationPart)super.clone();
125

    
126
		//media representation
127
		result.setMediaRepresentation(null);
128

    
129
		//no changes to: size, uri
130
		return result;
131
	}
132

    
133

    
134
}
(8-8/13)