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
.agent
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.hibernate
.annotations
.Cascade
;
15 import org
.hibernate
.annotations
.CascadeType
;
18 import javax
.persistence
.*;
19 import javax
.xml
.bind
.annotation
.XmlAccessType
;
20 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
21 import javax
.xml
.bind
.annotation
.XmlElement
;
22 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
23 import javax
.xml
.bind
.annotation
.XmlIDREF
;
24 import javax
.xml
.bind
.annotation
.XmlRootElement
;
25 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
26 import javax
.xml
.bind
.annotation
.XmlType
;
29 * This class represents public or private institutions.
30 * It includes name, contact details and institution type.
32 * This class corresponds to: <ul>
33 * <li> Institution according to the TDWG ontology
34 * <li> Institution according to the TCS
35 * <li> Organisation (Institution) according to the ABCD schema
40 * @created 08-Nov-2007 13:06:29
42 @XmlAccessorType(XmlAccessType
.FIELD
)
43 @XmlType(name
= "Institution", propOrder
= {
50 @XmlRootElement(name
= "Institution")
53 public class Institution
extends Agent
{
54 private static final long serialVersionUID
= -951321271656955808L;
55 public static final Logger logger
= Logger
.getLogger(Institution
.class);
57 @XmlElement(name
= "Code")
60 @XmlElement(name
= "Name")
63 @XmlElementWrapper(name
= "Types")
64 @XmlElement(name
= "Type")
66 //@XmlSchemaType(name = "IDREF")
67 private Set
<InstitutionType
> types
= new HashSet
<InstitutionType
>();
69 @XmlElement(name
= "IsPartOf")
71 @XmlSchemaType(name
= "IDREF")
72 private Institution isPartOf
;
74 @XmlElement(name
= "Contact")
75 private Contact contact
;
78 * Creates a new empty institution instance.
80 public static Institution
NewInstance(){
81 return new Institution();
88 public Institution() {
93 * Returns the {@link Contact contact} corresponding to <i>this</i> institution.
94 * It includes telecommunication data
95 * and electronic as well as multiple postal addresses.
98 @Cascade({CascadeType
.SAVE_UPDATE
})
99 public Contact
getContact(){
105 public void setContact(Contact contact
){
106 this.contact
= contact
;
110 * Returns the set of institution {@link InstitutionType types} (categories)
111 * used to describe or circumscribe <i>this</i> institution's activities.
112 * Institution types are items of a controlled {@link eu.etaxonomy.cdm.model.common.TermVocabulary vocabulary}.
114 * @return the set of institution types
115 * @see InstitutionType
117 @ManyToMany(fetch
= FetchType
.LAZY
)
118 public Set
<InstitutionType
> getTypes(){
123 * Adds a new institutional type (from the corresponding {@link eu.etaxonomy.cdm.model.common.TermVocabulary vocabulary})
124 * to the set of institution types of <i>this</i> institution.
126 * @param t any type of institution
128 * @see InstitutionType
130 public void addType(InstitutionType t
){
135 * Removes one element from the set of institution types for <i>this</i> institution.
137 * @param t the institution type which should be deleted
140 public void removeType(InstitutionType t
){
141 this.types
.remove(t
);
146 protected void setTypes(Set
<InstitutionType
> types
){
152 * Returns the parent institution of this institution.
153 * This is for instance the case when this institution is a herbarium
154 * belonging to a parent institution such as a museum.
157 @Cascade({CascadeType
.SAVE_UPDATE
})
158 public Institution
getIsPartOf(){
159 return this.isPartOf
;
162 * Assigns a parent institution to which this institution belongs.
164 * @param isPartOf the parent institution
165 * @see #getIsPartOf()
167 public void setIsPartOf(Institution isPartOf
){
168 this.isPartOf
= isPartOf
;
172 * Returns the string representing the code (can also be an acronym or initials)
173 * by which this institution is known among experts.
175 public String
getCode(){
181 public void setCode(String code
){
187 * Returns the full name, as distinct from a code, an acronym or initials,
188 * by which this institution is generally known.
190 public String
getName(){
196 public void setName(String name
){
201 * Generates the identification string for this institution.
202 * The string is based on its name and code as well as on the name and code of
203 * its parent institution, if existing.
204 * This method overrides {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle() generateTitle}.
205 * The result might be kept as {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#setTitleCache(String) titleCache} if the
206 * flag {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#protectedTitleCache protectedTitleCache} is not set.
208 * @return the identification string
211 public String
generateTitle(){