cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/IdentifyableMediaEntity.java -text
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/ImageFile.java -text
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/Media.java -text
-cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/MediaInstance.java -text
+cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/MediaRepresentation.java -text
+cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/MediaRepresentationPart.java -text
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/MovieFile.java -text
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/ReferencedMedia.java -text
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/Rights.java -text
import org.apache.log4j.Logger;
-import eu.etaxonomy.cdm.model.description.FeatureNode;
-
import javax.persistence.*;
/**
* @created 08-Nov-2007 13:06:11
*/
@Entity
-public class AudioFile extends MediaInstance {
+public class AudioFile extends MediaRepresentationPart {
private static final Logger logger = Logger.getLogger(AudioFile.class);
//length of recording in seconds
import org.apache.log4j.Logger;
-
-import java.util.*;
import javax.persistence.*;
/**
* @created 08-Nov-2007 13:06:28
*/
@Entity
-public class ImageFile extends MediaInstance {
+public class ImageFile extends MediaRepresentationPart {
static Logger logger = Logger.getLogger(ImageFile.class);
//image height in pixel
private int height;
import eu.etaxonomy.cdm.model.agent.Agent;
-import eu.etaxonomy.cdm.model.agent.Team;
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.model.common.LanguageString;
private MultilanguageSet description = new MultilanguageSet();
//A single medium such as a picture can have multiple representations in files. Common are multiple resolutions or file
//formats for images for example
- private Set<MediaInstance> instances = new HashSet<MediaInstance>();
+ private Set<MediaRepresentation> representations = new HashSet<MediaRepresentation>();
private Set<Rights> rights = new HashSet<Rights>();
private Agent artist;
@OneToMany(mappedBy="media")
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
- public Set<MediaInstance> getInstances(){
- return this.instances;
+ public Set<MediaRepresentation> getRepresentations(){
+ return this.representations;
}
- protected void setInstances(Set<MediaInstance> instances){
- this.instances = instances;
+ protected void setRepresentations(Set<MediaRepresentation> representations){
+ this.representations = representations;
}
- public void addInstance(MediaInstance instance){
- this.instances.add(instance);
+ public void addRepresentation(MediaRepresentation representation){
+ if (representation != null){
+ this.getRepresentations().add(representation);
+ representation.setMedia(this);
+ }
}
- public void removeInstance(MediaInstance instance){
- this.instances.remove(instance);
+ public void removeRepresentation(MediaRepresentation representation){
+ this.getRepresentations().remove(representation);
+ if (representation != null){
+ representation.setMedia(null);
+ }
+
}
+++ /dev/null
-/**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-
-package eu.etaxonomy.cdm.model.media;
-
-
-import org.apache.log4j.Logger;
-
-import com.sun.activation.registries.MimeTypeFile;
-
-import eu.etaxonomy.cdm.model.common.VersionableEntity;
-
-import java.util.*;
-
-import javax.activation.MimeType;
-import javax.persistence.*;
-
-/**
- * metadata for an external file such as images, phylogenetic trees, or audio
- * recordings available through the location attribute!
- * @author m.doering
- * @version 1.0
- * @created 08-Nov-2007 13:06:34
- */
-@Entity
-@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
-public class MediaInstance extends VersionableEntity {
- private static final Logger logger = Logger.getLogger(MediaInstance.class);
- //http://www.iana.org/assignments/media-types
- private String mimeType;
- //where the media file is stored
- private String uri;
- //in bytes
- private Integer size;
- private Media media;
-
-
- /**
- * Factory method
- * @return
- */
- public static MediaInstance NewInstance(String uri, String mimeType, Integer size){
- MediaInstance result = new MediaInstance();
- result.setUri(uri);
- result.setMimeType(mimeType);
- result.setSize(size);
- return result;
- }
-
-
-
- /**
- * Factory method
- * @return
- */
- public static MediaInstance NewInstance(){
- return new MediaInstance();
- }
-
-
-
- protected MediaInstance(){
- super();
- }
-
-
- public String getMimeType(){
- return this.mimeType;
- }
-
- /**
- *
- * @param mimeType mimeType
- */
- public void setMimeType(String mimeType){
- this.mimeType = mimeType;
- }
-
- public String getUri(){
- return this.uri;
- }
-
- /**
- *
- * @param uri uri
- */
- public void setUri(String uri){
- this.uri = uri;
- }
-
-
- /**
- * @return
- */
- public Integer getSize(){
- return this.size;
- }
- /**
- * @param size size
- */
- public void setSize(Integer size){
- this.size = size;
- }
-
- @ManyToOne
- public Media getMedia() {
- return media;
- }
-
- public void setMedia(Media media) {
- this.media = media;
- }
-
-}
\ No newline at end of file
--- /dev/null
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.cdm.model.media;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.log4j.Logger;
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.CascadeType;
+
+import eu.etaxonomy.cdm.model.common.VersionableEntity;
+import javax.persistence.*;
+
+/**
+ * metadata for an external file such as images, phylogenetic trees, or audio
+ * recordings available through the location attribute!
+ * @author m.doering
+ * @version 1.0
+ * @created 08-Nov-2007 13:06:34
+ */
+@Entity
+@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
+public class MediaRepresentation extends VersionableEntity {
+ private static final Logger logger = Logger.getLogger(MediaRepresentation.class);
+ //http://www.iana.org/assignments/media-types
+ private String mimeType;
+ //the file suffix (e.g. jpg, tif, mov)
+ private String suffix;
+ private Media media;
+ private List<MediaRepresentationPart> mediaRepresentationParts = new ArrayList<MediaRepresentationPart>();
+
+
+ /**
+ * Factory method
+ * @return
+ */
+ public static MediaRepresentation NewInstance(String mimeType, String suffix){
+ MediaRepresentation result = new MediaRepresentation();
+ result.setMimeType(mimeType);
+ result.setSuffix(suffix);
+ return result;
+ }
+
+
+
+ /**
+ * Factory method
+ * @return
+ */
+ public static MediaRepresentation NewInstance(){
+ return new MediaRepresentation();
+ }
+
+
+
+ protected MediaRepresentation(){
+ super();
+ }
+
+/*************** getter /setter *************************************/
+
+
+ public String getMimeType(){
+ return this.mimeType;
+ }
+
+ /**
+ *
+ * @param mimeType mimeType
+ */
+ public void setMimeType(String mimeType){
+ this.mimeType = mimeType;
+ }
+
+
+ public String getSuffix(){
+ return this.suffix;
+ }
+
+ /**
+ *
+ * @param mimeType mimeType
+ */
+ public void setSuffix(String suffix){
+ this.suffix = suffix;
+ }
+
+ @ManyToOne
+ public Media getMedia() {
+ return media;
+ }
+
+ @Deprecated //use only for bidirectional and hibernate
+ protected void setMedia(Media media) {
+ this.media = media;
+ }
+
+
+ @OneToMany(mappedBy="mediaRepresentation")
+ @org.hibernate.annotations.IndexColumn(name="sortIndex")
+ @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
+ public List<MediaRepresentationPart> getParts(){
+ return this.mediaRepresentationParts;
+ }
+ protected void setParts(List<MediaRepresentationPart> mediaRepresentationParts){
+ this.mediaRepresentationParts = mediaRepresentationParts;
+ }
+ public void addRepresentationPart(MediaRepresentationPart mediaRepresentationPart){
+ if (mediaRepresentationPart != null){
+ this.getParts().add(mediaRepresentationPart);
+ mediaRepresentationPart.setMediaRepresentation(this);
+ }
+ }
+ public void removeRepresentationPart(MediaRepresentationPart representationPart){
+ this.getParts().remove(representationPart);
+ if (representationPart != null){
+ representationPart.setMediaRepresentation(null);
+ }
+ }
+
+
+
+
+}
\ No newline at end of file
--- /dev/null
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+\r
+package eu.etaxonomy.cdm.model.media;\r
+import javax.persistence.Entity;\r
+import javax.persistence.ManyToOne;\r
+import org.apache.log4j.Logger;\r
+import eu.etaxonomy.cdm.model.common.VersionableEntity;\r
+\r
+/**\r
+ * @author a.mueller\r
+ * @created 09.06.2008\r
+ * @version 1.0\r
+ */\r
+@Entity\r
+public class MediaRepresentationPart extends VersionableEntity{\r
+ private static final Logger logger = Logger.getLogger(MediaRepresentationPart.class);\r
+\r
+ //sorting index\r
+ private int sortIndex;\r
+ //where the media file is stored\r
+ private String uri;\r
+ //in bytes\r
+ private Integer size;\r
+ //the MEdiaRepresentation this MediaRepresentation\r
+ private MediaRepresentation mediaRepresentation;\r
+\r
+ /**\r
+ * Factory method\r
+ * @return\r
+ */\r
+ public static MediaRepresentationPart NewInstance(String uri, Integer size){\r
+ MediaRepresentationPart result = new MediaRepresentationPart();\r
+ result.setUri(uri);\r
+ result.setSize(size);\r
+ return result;\r
+ }\r
+ \r
+ \r
+ /**\r
+ * \r
+ */\r
+ public MediaRepresentationPart() {\r
+ super();\r
+ }\r
+ \r
+/*************** getter /setter *************************************/\r
+ \r
+ \r
+ @ManyToOne\r
+ public MediaRepresentation getMediaRepresentation() {\r
+ return this.mediaRepresentation;\r
+ }\r
+\r
+ @Deprecated //use only for bidirectional and hibernate\r
+ protected void setMediaRepresentation(MediaRepresentation mediaRepresentation) {\r
+ this.mediaRepresentation = mediaRepresentation;\r
+ }\r
+ \r
+\r
+ public String getUri(){\r
+ return this.uri;\r
+ }\r
+\r
+ /**\r
+ * \r
+ * @param uri uri\r
+ */\r
+ public void setUri(String uri){\r
+ this.uri = uri;\r
+ }\r
+\r
+ \r
+ /**\r
+ * @return\r
+ */\r
+ public Integer getSize(){\r
+ return this.size;\r
+ }\r
+ /** \r
+ * @param size size\r
+ */\r
+ public void setSize(Integer size){\r
+ this.size = size;\r
+ }\r
+\r
+\r
+ /**\r
+ * @return the sortIndex\r
+ */\r
+ public int getSortIndex() {\r
+ return sortIndex;\r
+ }\r
+\r
+\r
+ /**\r
+ * @param sortIndex the sortIndex to set\r
+ */\r
+ public void setSortIndex(int sortIndex) {\r
+ this.sortIndex = sortIndex;\r
+ }\r
+}\r
import org.apache.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
-
-import java.util.*;
import javax.persistence.*;
/**
import eu.etaxonomy.cdm.model.agent.Institution;\r
import eu.etaxonomy.cdm.model.agent.Person;\r
import eu.etaxonomy.cdm.model.common.Annotation;\r
-import eu.etaxonomy.cdm.model.common.Language;\r
import eu.etaxonomy.cdm.model.common.OriginalSource;\r
import eu.etaxonomy.cdm.model.location.NamedArea;\r
import eu.etaxonomy.cdm.model.location.NamedAreaType;\r
import eu.etaxonomy.cdm.model.location.WaterbodyOrCountry;\r
import eu.etaxonomy.cdm.model.media.Media;\r
-import eu.etaxonomy.cdm.model.media.MediaInstance;\r
+import eu.etaxonomy.cdm.model.media.MediaRepresentation;\r
+import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;\r
import eu.etaxonomy.cdm.model.name.BotanicalName;\r
import eu.etaxonomy.cdm.model.occurrence.Collection;\r
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;\r
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;\r
import eu.etaxonomy.cdm.model.occurrence.FieldObservation;\r
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;\r
-import eu.etaxonomy.cdm.model.occurrence.Observation;\r
import eu.etaxonomy.cdm.model.occurrence.Specimen;\r
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;\r
import eu.etaxonomy.cdm.model.reference.Database;\r
specimen.addAnnotation(Annotation.NewDefaultLanguageInstance(annotation));\r
\r
\r
- \r
Media media = Media.NewInstance();\r
String uri = "http://131.130.131.9/database/img/imgBrowser.php?ID=50599";\r
String mimeType = null;\r
Integer size = null;\r
- MediaInstance mediaInstance = MediaInstance.NewInstance(uri, mimeType, size);\r
- media.addInstance(mediaInstance);\r
+ MediaRepresentation mediaRepresentation = MediaRepresentation.NewInstance(mimeType, "jpg");\r
+ media.addRepresentation(mediaRepresentation);\r
+ \r
+ MediaRepresentationPart mediaRepresentationPart = MediaRepresentationPart.NewInstance(uri, size);\r
+ mediaRepresentation.addRepresentationPart(mediaRepresentationPart);\r
specimen.addMedia(media);\r
\r
//Original ID\r