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<InstitutionType>();
|
36
|
private Institution isPartOf;
|
37
|
private Contact contact;
|
38
|
|
39
|
/**
|
40
|
* Factory method
|
41
|
* @return
|
42
|
*/
|
43
|
public static Institution NewInstance(){
|
44
|
return new Institution();
|
45
|
}
|
46
|
|
47
|
|
48
|
/**
|
49
|
* Class constructor
|
50
|
*/
|
51
|
public Institution() {
|
52
|
super();
|
53
|
}
|
54
|
|
55
|
/**
|
56
|
* Returns the {@link Contact contact} corresponding to this institution.
|
57
|
* It includes telecommunication data
|
58
|
* and electronic as well as multiple postal addresses.
|
59
|
*/
|
60
|
@ManyToOne
|
61
|
@Cascade({CascadeType.SAVE_UPDATE})
|
62
|
public Contact getContact(){
|
63
|
return this.contact;
|
64
|
}
|
65
|
/**
|
66
|
* @see #getContact()
|
67
|
*/
|
68
|
public void setContact(Contact contact){
|
69
|
this.contact = contact;
|
70
|
}
|
71
|
|
72
|
/**
|
73
|
* Returns the set of institution {@link InstitutionType types} (categories)
|
74
|
* used to describe or circumscribe this institution's activities.
|
75
|
* Institution types are items of a controlled {@link common.TermVocabulary vocabulary}.
|
76
|
*
|
77
|
* @return the set of institution types
|
78
|
* @see InstitutionType
|
79
|
*/
|
80
|
@ManyToMany
|
81
|
public Set<InstitutionType> getTypes(){
|
82
|
return this.types;
|
83
|
}
|
84
|
|
85
|
/**
|
86
|
* Adds a new institutional type (from the corresponding {@link common.TermVocabulary vocabulary})
|
87
|
* to the set of institution types of this institution.
|
88
|
*
|
89
|
* @param t any type of institution
|
90
|
* @see #getTypes()
|
91
|
* @see InstitutionType
|
92
|
*/
|
93
|
public void addType(InstitutionType t){
|
94
|
this.types.add(t);
|
95
|
}
|
96
|
|
97
|
/**
|
98
|
* Removes one element from the set of institution types for this institution.
|
99
|
*
|
100
|
* @param t the institution type which should be deleted
|
101
|
* @see #getTypes()
|
102
|
*/
|
103
|
public void removeType(InstitutionType t){
|
104
|
this.types.remove(t);
|
105
|
}
|
106
|
/**
|
107
|
* @see #getTypes()
|
108
|
*/
|
109
|
protected void setTypes(Set<InstitutionType> types){
|
110
|
this.types = types;
|
111
|
}
|
112
|
|
113
|
|
114
|
/**
|
115
|
* Returns the parent institution of this institution.
|
116
|
* This is for instance the case when this institution is a herbarium
|
117
|
* belonging to a parent institution such as a museum.
|
118
|
*/
|
119
|
@ManyToOne
|
120
|
@Cascade({CascadeType.SAVE_UPDATE})
|
121
|
public Institution getIsPartOf(){
|
122
|
return this.isPartOf;
|
123
|
}
|
124
|
/**
|
125
|
* Assigns a parent institution to which this institution belongs.
|
126
|
*
|
127
|
* @param isPartOf the parent institution
|
128
|
* @see #getIsPartOf()
|
129
|
*/
|
130
|
public void setIsPartOf(Institution isPartOf){
|
131
|
this.isPartOf = isPartOf;
|
132
|
}
|
133
|
|
134
|
/**
|
135
|
* Returns the string representing the code (can also be an acronym or initials)
|
136
|
* by which this institution is known among experts.
|
137
|
*/
|
138
|
public String getCode(){
|
139
|
return this.code;
|
140
|
}
|
141
|
/**
|
142
|
* @see #getCode()
|
143
|
*/
|
144
|
public void setCode(String code){
|
145
|
this.code = code;
|
146
|
}
|
147
|
|
148
|
|
149
|
/**
|
150
|
* Returns the full name, as distinct from a code, an acronym or initials,
|
151
|
* by which this institution is generally known.
|
152
|
*/
|
153
|
public String getName(){
|
154
|
return this.name;
|
155
|
}
|
156
|
/**
|
157
|
* @see #getName()
|
158
|
*/
|
159
|
public void setName(String name){
|
160
|
this.name = name;
|
161
|
}
|
162
|
|
163
|
@Override
|
164
|
/**
|
165
|
* Generates the identification string for this institution.
|
166
|
* The string is based on its name and code as well as on the name and code of
|
167
|
* its parent institution, if existing.
|
168
|
* This method overrides {@link common.IdentifiableEntity#generateTitle() generateTitle}.
|
169
|
* The result might be kept as {@link common.IdentifiableEntity#setTitleCache(String) titleCache} if the
|
170
|
* flag {@link common.IdentifiableEntity#protectedTitleCache protectedTitleCache} is not set.
|
171
|
*
|
172
|
* @return the identification string
|
173
|
*/
|
174
|
public String generateTitle(){
|
175
|
return "";
|
176
|
}
|
177
|
|
178
|
}
|