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 java
.util
.HashSet
;
16 import javax
.persistence
.Column
;
17 import javax
.persistence
.Entity
;
18 import javax
.persistence
.FetchType
;
19 import javax
.persistence
.ManyToMany
;
20 import javax
.persistence
.ManyToOne
;
21 import javax
.xml
.bind
.annotation
.XmlAccessType
;
22 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
23 import javax
.xml
.bind
.annotation
.XmlElement
;
24 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
25 import javax
.xml
.bind
.annotation
.XmlIDREF
;
26 import javax
.xml
.bind
.annotation
.XmlRootElement
;
27 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
28 import javax
.xml
.bind
.annotation
.XmlType
;
30 import org
.apache
.logging
.log4j
.LogManager
;
31 import org
.apache
.logging
.log4j
.Logger
;
32 import org
.hibernate
.annotations
.Cascade
;
33 import org
.hibernate
.annotations
.CascadeType
;
34 import org
.hibernate
.envers
.Audited
;
35 import org
.hibernate
.search
.annotations
.Field
;
36 import org
.springframework
.beans
.factory
.annotation
.Configurable
;
38 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTerm
;
39 import eu
.etaxonomy
.cdm
.strategy
.cache
.agent
.InstitutionDefaultCacheStrategy
;
40 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IIdentifiableEntityCacheStrategy
;
43 * This class represents public or private institutions.
44 * It includes name, contact details and institution type.
46 * This class corresponds to: <ul>
47 * <li> Institution according to the TDWG ontology
48 * <li> Institution according to the TCS
49 * <li> Organisation (Institution) according to the ABCD schema
53 * @since 08-Nov-2007 13:06:29
55 @XmlAccessorType(XmlAccessType
.FIELD
)
56 @XmlType(name
= "Institution", propOrder
= {
62 @XmlRootElement(name
= "Institution")
64 // @Indexed disabled to reduce clutter in indexes, since this type is not used by any search
65 //@Indexed(index = "eu.etaxonomy.cdm.model.agent.AgentBase")
68 public class Institution
extends AgentBase
<IIdentifiableEntityCacheStrategy
<Institution
>> {
70 private static final long serialVersionUID
= -951321271656955808L;
71 private static final Logger logger
= LogManager
.getLogger();
73 @XmlElement(name
= "Code")
80 @XmlElement(name
= "Name")
87 @XmlElementWrapper(name
= "Types", nillable
= true)
88 @XmlElement(name
= "Type")
90 @XmlSchemaType(name
= "IDREF")
91 @ManyToMany(fetch
= FetchType
.LAZY
)
92 private Set
<DefinedTerm
> types
; //InstitutionTypes
94 @XmlElement(name
= "IsPartOf")
96 @XmlSchemaType(name
= "IDREF")
97 @ManyToOne(fetch
= FetchType
.LAZY
)
98 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
99 private Institution isPartOf
;
102 * Creates a new empty institution instance.
104 public static Institution
NewInstance(){
105 return new Institution();
109 * Creates a new empty institution instance.
111 public static Institution
NewNamedInstance(String name
){
112 Institution result
= new Institution();
113 result
.setName(name
);
117 //******************* CONSTRUCTOR ***********************/
122 protected Institution() {
127 protected void initDefaultCacheStrategy() {
128 this.cacheStrategy
= InstitutionDefaultCacheStrategy
.NewInstance();
131 //*************** Methods ******************************/
134 * Returns the set of institution types (categories)
135 * used to describe or circumscribe <i>this</i> institution's activities.
136 * Institution types are items of a controlled {@link eu.etaxonomy.cdm.model.term.TermVocabulary vocabulary}.
138 * @return the set of institution types
140 public Set
<DefinedTerm
> getTypes(){
142 this.types
= new HashSet
<>();
148 * Adds a new institutional type (from the corresponding {@link eu.etaxonomy.cdm.model.term.TermVocabulary vocabulary})
149 * to the set of institution types of <i>this</i> institution.
151 * @param t any type of institution
154 public void addType(DefinedTerm type
){
155 getTypes().add(type
);
159 * Removes one element from the set of institution types for <i>this</i> institution.
161 * @param t the institution type which should be deleted
164 public void removeType(DefinedTerm type
){
165 getTypes().remove(type
);
169 * Returns the parent institution of this institution.
170 * This is for instance the case when this institution is a herbarium
171 * belonging to a parent institution such as a museum.
173 public Institution
getIsPartOf(){
174 return this.isPartOf
;
178 * Assigns a parent institution to which this institution belongs.
180 * @param isPartOf the parent institution
181 * @see #getIsPartOf()
183 public void setIsPartOf(Institution parentInstitution
){
184 this.isPartOf
= parentInstitution
;
188 * Returns the string representing the code (can also be an acronym or initials)
189 * by which this institution is known among experts.
191 public String
getCode(){
197 public void setCode(String code
){
198 this.code
= isBlank(code
) ?
null : code
;
203 * Returns the full name, as distinct from a code, an acronym or initials,
204 * by which this institution is generally known.
206 public String
getName(){
212 public void setName(String name
){
213 this.name
= isBlank(name
) ?
null: name
;
216 //*********************** CLONE ********************************************************/
219 * Clones <i>this</i> Institution. This is a shortcut that enables to create
220 * a new instance that differs only slightly from <i>this</i> Institution.
222 * @see java.lang.Object#clone()
225 public Institution
clone() {
227 Institution result
= (Institution
) super.clone();
228 //no changes to code, isPartOf, name, types
230 }catch (CloneNotSupportedException e
){
231 logger
.warn("Object does not implement cloneable");