(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / Media.java
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.common;
11
12
13 import eu.etaxonomy.cdm.model.agent.Agent;
14 import eu.etaxonomy.cdm.model.agent.Team;
15 import org.apache.log4j.Logger;
16 import org.hibernate.annotations.Cascade;
17 import org.hibernate.annotations.CascadeType;
18
19 import java.util.*;
20 import javax.persistence.*;
21
22 /**
23 * @author m.doering
24 * @version 1.0
25 * @created 08-Nov-2007 13:06:34
26 */
27 @Entity
28 @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
29 public class Media extends AnnotatableEntity {
30 public Media() {
31 super();
32 // TODO Auto-generated constructor stub
33 }
34
35 static Logger logger = Logger.getLogger(Media.class);
36 private MultilanguageSet title = new MultilanguageSet();
37 //creation date of the media (not of the record)
38 private Calendar mediaCreated;
39 private MultilanguageSet description = new MultilanguageSet();
40 //A single medium such as a picture can have multiple representations in files. Common are multiple resolutions or file
41 //formats for images for example
42 private Set<MediaInstance> instances = new HashSet();
43 private Set<Rights> rights = new HashSet();
44 private Agent artist;
45
46 @OneToMany
47 @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
48 public Set<MediaInstance> getInstances(){
49 return this.instances;
50 }
51 protected void setInstances(Set<MediaInstance> instances){
52 this.instances = instances;
53 }
54 public void addInstance(MediaInstance instance){
55 this.instances.add(instance);
56 }
57 public void removeInstance(MediaInstance instance){
58 this.instances.remove(instance);
59 }
60
61
62 @ManyToOne
63 @Cascade({CascadeType.SAVE_UPDATE})
64 public Agent getArtist(){
65 return this.artist;
66 }
67 public void setArtist(Agent artist){
68 this.artist = artist;
69 }
70
71
72 @ManyToMany
73 @Cascade({CascadeType.SAVE_UPDATE})
74 public Set<Rights> getRights(){
75 return this.rights;
76 }
77 protected void setRights(Set<Rights> rights){
78 this.rights = rights;
79 }
80 public void addRights(Rights rights){
81 this.rights.add(rights);
82 }
83 public void removeRights(Rights rights){
84 this.rights.remove(rights);
85 }
86
87
88 public MultilanguageSet getTitle(){
89 return this.title;
90 }
91 public void setTitle(MultilanguageSet title){
92 this.title = title;
93 }
94
95 @Temporal(TemporalType.DATE)
96 public Calendar getMediaCreated(){
97 return this.mediaCreated;
98 }
99 public void setMediaCreated(Calendar mediaCreated){
100 this.mediaCreated = mediaCreated;
101 }
102
103
104 public MultilanguageSet getDescription(){
105 return this.description;
106 }
107 protected void setDescription(MultilanguageSet description){
108 this.description = description;
109 }
110 public void addDescription(LanguageString description){
111 this.description.add(description);
112 }
113 public void addDescription(String text, Language lang){
114 this.description.add(text, lang);
115 }
116 public void removeDescription(Language lang){
117 this.description.remove(lang);
118 }
119
120 }