(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / agent / Institution.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.agent;
11
12
13 import org.apache.log4j.Logger;
14 import org.hibernate.annotations.Cascade;
15 import org.hibernate.annotations.CascadeType;
16
17 import java.util.*;
18 import javax.persistence.*;
19
20 /**
21 * A public or private institution.
22 * It includes name, contact details and institution type.
23 * <p>
24 * See also the <a href="http://rs.tdwg.org/ontology/voc/Institution.rdf">TDWG Ontology</a>
25 *
26 * @author m.doering
27 * @version 1.0
28 * @created 08-Nov-2007 13:06:29
29 */
30 @Entity
31 public class Institution extends Agent {
32 static Logger logger = Logger.getLogger(Institution.class);
33 private String code;
34 private String name;
35 private Set<InstitutionType> types = new HashSet();
36 private Institution isPartOf;
37 private Contact contact;
38
39 /**
40 * Class constructor
41 */
42 public Institution() {
43 super();
44 // TODO Auto-generated constructor stub
45 }
46
47 @ManyToOne
48 @Cascade({CascadeType.SAVE_UPDATE})
49 public Contact getContact(){
50 return this.contact;
51 }
52 /**
53 * Assigns a {@link Contact contact} to this institution.
54 *
55 * @param contact the contact which should be assigned to this institution
56 */
57 public void setContact(Contact contact){
58 this.contact = contact;
59 }
60
61 @ManyToMany
62 public Set<InstitutionType> getTypes(){
63 return this.types;
64 }
65
66 /**
67 * Adds a new institutional type from the corresponding vocabulary
68 * to describe better this institution or circumscribe its activities.
69 *
70 * @param t any type of institution relevant for describing this institution
71 * @see InstitutionType
72 */
73 public void addType(InstitutionType t){
74 this.types.add(t);
75 }
76
77 /**
78 * Removes one element from the set of institution types for this institution.
79 *
80 * @param t the institution type describing this institution or its activities
81 * which should be deleted
82 * @see #addType(InstitutionType)
83 */
84 public void removeType(InstitutionType t){
85 this.types.remove(t);
86 }
87 protected void setTypes(Set<InstitutionType> types){
88 this.types = types;
89 }
90
91
92 @ManyToOne
93 @Cascade({CascadeType.SAVE_UPDATE})
94 public Institution getIsPartOf(){
95 return this.isPartOf;
96 }
97 /**
98 * Assigns a parent institution to this institution.
99 * This is for instance the case when a herbarium
100 * belongs to a museum (parent institution).
101 *
102 * @param isPartOf the institution to which this institution belongs
103 */
104 public void setIsPartOf(Institution isPartOf){
105 this.isPartOf = isPartOf;
106 }
107
108 public String getCode(){
109 return this.code;
110 }
111 /**
112 * Assigns a code (can also be an acronym or initials)
113 * by which this institution is known among experts.
114 *
115 * @param code the string which should be assigned as an identification code
116 * to this institution
117 */
118 public void setCode(String code){
119 this.code = code;
120 }
121
122
123 public String getName(){
124 return this.name;
125 }
126 /**
127 * Assigns a full name, as distinct from a code, an acronym or initials,
128 * by which this institution is generally known.
129 *
130 * @param name the string which should be assigned as a full name
131 * to this institution
132 */
133 public void setName(String name){
134 this.name = name;
135 }
136
137 @Override
138 /**
139 * Generates the complete identification string of this institution
140 * on the basis of all its attributes.
141 * This method overrides {@link common.IdentifiableEntity#generateTitle() generateTitle}.
142 * The result might be kept as {@link common.IdentifiableEntity#setTitleCache(String) titleCache} if the
143 * flag {@link common.IdentifiableEntity#protectedTitleCache protectedTitleCache} is not set.
144 *
145 * @return the string which contains the complete identification of this institution
146 */
147 public String generateTitle(){
148 return "";
149 }
150
151 }