Project

General

Profile

Download (3.79 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.util.ArrayList;
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.XmlTransient;
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.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
	private static final Logger logger = Logger.getLogger(MediaRepresentationPart.class);
53

    
54
	// where the media file is stored
55
	@XmlElement(name = "URI")
56
	private String uri;
57

    
58
	// in bytes
59
	@XmlElement(name = "Size")
60
	private Integer size;
61

    
62
	// the MediaRepresentation of this MediaRepresentationPart
63
	@XmlElement(name = "MediaRepresentation")
64
	@XmlIDREF
65
	@XmlSchemaType(name = "IDREF")
66
	@ManyToOne(fetch = FetchType.LAZY)
67
	@JoinColumn(name = "representation_id", nullable = false, updatable = false, insertable = false)
68
	@Cascade(CascadeType.SAVE_UPDATE)
69
	private MediaRepresentation mediaRepresentation;
70

    
71
	/**
72
	 * Factory method
73
	 * 
74
	 * @return
75
	 */
76
	public static MediaRepresentationPart NewInstance(String uri, Integer size) {
77
		logger.debug("NewInstance");
78
		MediaRepresentationPart result = new MediaRepresentationPart(uri, size);
79
		return result;
80
	}
81

    
82
	/**
83
	 * 
84
	 */
85
	protected MediaRepresentationPart() {
86
		super();
87
	}
88

    
89
	/**
90
	 * 
91
	 */
92
	protected MediaRepresentationPart(String uri, Integer size) {
93
		this();
94
		this.setUri(uri);
95
		this.setSize(size);
96
	}
97

    
98
	/*************** getter /setter *************************************/
99

    
100
	public MediaRepresentation getMediaRepresentation() {
101
		return this.mediaRepresentation;
102
	}
103

    
104
	@Deprecated
105
	// use only for bidirectional and hibernate
106
	protected void setMediaRepresentation(
107
			MediaRepresentation mediaRepresentation) {
108
		this.mediaRepresentation = mediaRepresentation;
109
	}
110

    
111
	public String getUri() {
112
		return this.uri;
113
	}
114

    
115
	/**
116
	 * 
117
	 * @param uri
118
	 *            uri
119
	 */
120
	public void setUri(String uri) {
121
		this.uri = uri;
122
	}
123

    
124
	/**
125
	 * @return
126
	 */
127
	public Integer getSize() {
128
		return this.size;
129
	}
130

    
131
	/**
132
	 * @param size
133
	 *            size
134
	 */
135
	public void setSize(Integer size) {
136
		this.size = size;
137
	}
138
	
139
//************************* CLONE **************************/
140
		/* (non-Javadoc)
141
	 * @see java.lang.Object#clone()
142
	 */
143
	@Override
144
	public Object clone() throws CloneNotSupportedException{
145
		MediaRepresentationPart result = (MediaRepresentationPart)super.clone();
146

    
147
		//media representation
148
		result.setMediaRepresentation(null);
149
		
150
		//no changes to: size, ure
151
		return result;
152
	}
153

    
154
	
155
}
(8-8/13)