2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.media
;
12 import javax
.persistence
.Entity
;
13 import javax
.persistence
.FetchType
;
14 import javax
.persistence
.JoinColumn
;
15 import javax
.persistence
.ManyToOne
;
16 import javax
.xml
.bind
.annotation
.XmlAccessType
;
17 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
18 import javax
.xml
.bind
.annotation
.XmlElement
;
19 import javax
.xml
.bind
.annotation
.XmlIDREF
;
20 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
21 import javax
.xml
.bind
.annotation
.XmlType
;
23 import org
.apache
.log4j
.Logger
;
24 import org
.hibernate
.annotations
.Cascade
;
25 import org
.hibernate
.annotations
.CascadeType
;
26 import org
.hibernate
.envers
.Audited
;
28 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
31 * A media representation part is a resource that can be referenced by an URI.
32 * It represents a part of or the entire media. <br>
33 * E.g. a jpg file or a website
39 @XmlAccessorType(XmlAccessType
.FIELD
)
40 @XmlType(name
= "MediaRepresentationPart", propOrder
= {
47 public class MediaRepresentationPart
extends VersionableEntity
implements Cloneable
{
48 private static final long serialVersionUID
= -1674422508643785796L;
49 private static final Logger logger
= Logger
.getLogger(MediaRepresentationPart
.class);
51 // where the media file is stored
52 @XmlElement(name
= "URI")
56 @XmlElement(name
= "Size")
59 // the MediaRepresentation of this MediaRepresentationPart
60 @XmlElement(name
= "MediaRepresentation")
62 @XmlSchemaType(name
= "IDREF")
63 @ManyToOne(fetch
= FetchType
.LAZY
)
64 @JoinColumn(name
= "representation_id", nullable
= false, updatable
= false, insertable
= false)
65 @Cascade(CascadeType
.SAVE_UPDATE
)
66 private MediaRepresentation mediaRepresentation
;
73 public static MediaRepresentationPart
NewInstance(String uri
, Integer size
) {
74 MediaRepresentationPart result
= new MediaRepresentationPart(uri
, size
);
81 protected MediaRepresentationPart() {
88 protected MediaRepresentationPart(String uri
, Integer size
) {
94 /*************** getter /setter *************************************/
96 public MediaRepresentation
getMediaRepresentation() {
97 return this.mediaRepresentation
;
101 // use only for bidirectional and hibernate
102 protected void setMediaRepresentation(
103 MediaRepresentation mediaRepresentation
) {
104 this.mediaRepresentation
= mediaRepresentation
;
107 public String
getUri() {
116 public void setUri(String uri
) {
123 public Integer
getSize() {
131 public void setSize(Integer size
) {
135 //************************* CLONE **************************/
137 * @see java.lang.Object#clone()
140 public Object
clone() throws CloneNotSupportedException
{
141 MediaRepresentationPart result
= (MediaRepresentationPart
)super.clone();
143 //media representation
144 result
.setMediaRepresentation(null);
146 //no changes to: size, ure