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
;
13 import java
.util
.ArrayList
;
14 import java
.util
.List
;
16 import java
.util
.SortedSet
;
17 import java
.util
.TreeSet
;
19 import org
.apache
.log4j
.Logger
;
20 import org
.hibernate
.annotations
.Cascade
;
21 import org
.hibernate
.annotations
.CascadeType
;
23 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
24 import javax
.persistence
.*;
27 * metadata for an external file such as images, phylogenetic trees, or audio
28 * recordings available through the location attribute!
31 * @created 08-Nov-2007 13:06:34
34 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
35 public class MediaRepresentation
extends VersionableEntity
{
36 private static final Logger logger
= Logger
.getLogger(MediaRepresentation
.class);
37 //http://www.iana.org/assignments/media-types
38 private String mimeType
;
39 //the file suffix (e.g. jpg, tif, mov)
40 private String suffix
;
42 private List
<MediaRepresentationPart
> mediaRepresentationParts
= new ArrayList
<MediaRepresentationPart
>();
49 public static MediaRepresentation
NewInstance(String mimeType
, String suffix
){
50 MediaRepresentation result
= new MediaRepresentation();
51 result
.setMimeType(mimeType
);
52 result
.setSuffix(suffix
);
62 public static MediaRepresentation
NewInstance(){
63 return new MediaRepresentation();
68 protected MediaRepresentation(){
72 /*************** getter /setter *************************************/
75 public String
getMimeType(){
81 * @param mimeType mimeType
83 public void setMimeType(String mimeType
){
84 this.mimeType
= mimeType
;
88 public String
getSuffix(){
94 * @param mimeType mimeType
96 public void setSuffix(String suffix
){
101 public Media
getMedia() {
105 @Deprecated //use only for bidirectional and hibernate
106 protected void setMedia(Media media
) {
111 @OneToMany(mappedBy
="mediaRepresentation")
112 @org.hibernate
.annotations
.IndexColumn(name
="sortIndex")
113 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.DELETE
})
114 public List
<MediaRepresentationPart
> getParts(){
115 return this.mediaRepresentationParts
;
117 protected void setParts(List
<MediaRepresentationPart
> mediaRepresentationParts
){
118 this.mediaRepresentationParts
= mediaRepresentationParts
;
120 public void addRepresentationPart(MediaRepresentationPart mediaRepresentationPart
){
121 if (mediaRepresentationPart
!= null){
122 this.getParts().add(mediaRepresentationPart
);
123 mediaRepresentationPart
.setMediaRepresentation(this);
126 public void removeRepresentationPart(MediaRepresentationPart representationPart
){
127 this.getParts().remove(representationPart
);
128 if (representationPart
!= null){
129 representationPart
.setMediaRepresentation(null);