root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/MediaRepresentationPart.java

Revision 10919, 3.8 kB (checked in by a.mueller, 18 months ago)

merge 3.0.2 to trunk

  • Property svn:keywords set to Id
Line 
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
10package eu.etaxonomy.cdm.model.media;
11
12import java.net.URI;
13
14import javax.persistence.Entity;
15import javax.persistence.FetchType;
16import javax.persistence.JoinColumn;
17import javax.persistence.ManyToOne;
18import javax.xml.bind.annotation.XmlAccessType;
19import javax.xml.bind.annotation.XmlAccessorType;
20import javax.xml.bind.annotation.XmlElement;
21import javax.xml.bind.annotation.XmlIDREF;
22import javax.xml.bind.annotation.XmlSchemaType;
23import javax.xml.bind.annotation.XmlType;
24
25import org.apache.log4j.Logger;
26import org.hibernate.annotations.Cascade;
27import org.hibernate.annotations.CascadeType;
28import org.hibernate.annotations.Type;
29import org.hibernate.envers.Audited;
30
31import 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
50public 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, ure
153                return result;
154        }
155
156       
157}
Note: See TracBrowser for help on using the browser.