package eu.etaxonomy.cdm.model.agent;
-import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
-import eu.etaxonomy.cdm.model.common.Keyword;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlIDREF;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
import org.apache.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
+import org.hibernate.envers.Audited;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.springframework.beans.factory.annotation.Configurable;
-import java.util.*;
-import javax.persistence.*;
+import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
+import eu.etaxonomy.cdm.strategy.cache.common.IdentifiableEntityDefaultCacheStrategy;
/**
- * A public or private institution.
+ * This class represents public or private institutions.
* It includes name, contact details and institution type.
- * <p>
- * See also the <a href="http://rs.tdwg.org/ontology/voc/Institution.rdf">TDWG Ontology</a>
+ * <P>
+ * This class corresponds to: <ul>
+ * <li> Institution according to the TDWG ontology
+ * <li> Institution according to the TCS
+ * <li> Organisation (Institution) according to the ABCD schema
+ * </ul>
*
* @author m.doering
* @version 1.0
* @created 08-Nov-2007 13:06:29
*/
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "Institution", propOrder = {
+ "code",
+ "name",
+ "types",
+ "isPartOf"
+})
+@XmlRootElement(name = "Institution")
@Entity
-public class Institution extends Agent {
- static Logger logger = Logger.getLogger(Institution.class);
+@Indexed(index = "eu.etaxonomy.cdm.model.agent.AgentBase")
+@Audited
+@Configurable
+public class Institution extends AgentBase<IIdentifiableEntityCacheStrategy<Institution>> {
+ private static final long serialVersionUID = -951321271656955808L;
+ public static final Logger logger = Logger.getLogger(Institution.class);
+
+ @XmlElement(name = "Code")
+ @Field(index=Index.TOKENIZED)
private String code;
+
+ @XmlElement(name = "Name")
+ @Field(index=Index.TOKENIZED)
private String name;
- private Set<InstitutionType> types = new HashSet();
+
+ @XmlElementWrapper(name = "Types")
+ @XmlElement(name = "Type")
+ @XmlIDREF
+ @XmlSchemaType(name = "IDREF")
+ @ManyToMany(fetch = FetchType.LAZY)
+ private Set<InstitutionType> types = new HashSet<InstitutionType>();
+
+ @XmlElement(name = "IsPartOf")
+ @XmlIDREF
+ @XmlSchemaType(name = "IDREF")
+ @ManyToOne(fetch = FetchType.LAZY)
+ @Cascade(CascadeType.SAVE_UPDATE)
private Institution isPartOf;
- private Contact contact;
+ /**
+ * Creates a new empty institution instance.
+ */
+ public static Institution NewInstance(){
+ return new Institution();
+ }
+
+
/**
- * Class constructor
+ * Class constructor.
*/
public Institution() {
super();
- // TODO Auto-generated constructor stub
+ this.cacheStrategy = new IdentifiableEntityDefaultCacheStrategy<Institution>();
}
- @ManyToOne
- @Cascade({CascadeType.SAVE_UPDATE})
- public Contact getContact(){
- return this.contact;
- }
/**
- * Assigns a {@link Contact contact} to this institution.
+ * Returns the set of institution {@link InstitutionType types} (categories)
+ * used to describe or circumscribe <i>this</i> institution's activities.
+ * Institution types are items of a controlled {@link eu.etaxonomy.cdm.model.common.TermVocabulary vocabulary}.
*
- * @param contact the contact which should be assigned to this institution
+ * @return the set of institution types
+ * @see InstitutionType
*/
- public void setContact(Contact contact){
- this.contact = contact;
- }
-
- @ManyToMany
public Set<InstitutionType> getTypes(){
return this.types;
}
+
/**
- * Adds a new institutional type from the corresponding vocabulary
- * to describe better this institution or circumscribe its activities.
+ * Adds a new institutional type (from the corresponding {@link eu.etaxonomy.cdm.model.common.TermVocabulary vocabulary})
+ * to the set of institution types of <i>this</i> institution.
*
- * @param t any type of institution relevant for describing this institution
+ * @param t any type of institution
+ * @see #getTypes()
* @see InstitutionType
*/
- public void addTypes(InstitutionType t){
+ public void addType(InstitutionType t){
this.types.add(t);
}
+
/**
- * Removes one element from the set of institution types for this institution.
+ * Removes one element from the set of institution types for <i>this</i> institution.
*
- * @param t the institution type describing this institution or its activities
- * which should be deleted
- * @see #addTypes(InstitutionType)
+ * @param t the institution type which should be deleted
+ * @see #getTypes()
*/
- public void removeTypes(InstitutionType t){
+ public void removeType(InstitutionType t){
this.types.remove(t);
}
- protected void setTypes(Set<InstitutionType> types){
- this.types = types;
- }
-
- @ManyToOne
- @Cascade({CascadeType.SAVE_UPDATE})
+ /**
+ * Returns the parent institution of this institution.
+ * This is for instance the case when this institution is a herbarium
+ * belonging to a parent institution such as a museum.
+ */
public Institution getIsPartOf(){
return this.isPartOf;
}
+
/**
- * Assigns a parent institution to this institution.
- * This is for instance the case when a herbarium
- * belongs to a museum (parent institution).
+ * Assigns a parent institution to which this institution belongs.
*
- * @param isPartOf the institution to which this institution belongs
+ * @param isPartOf the parent institution
+ * @see #getIsPartOf()
*/
public void setIsPartOf(Institution isPartOf){
this.isPartOf = isPartOf;
}
+ /**
+ * Returns the string representing the code (can also be an acronym or initials)
+ * by which this institution is known among experts.
+ */
public String getCode(){
return this.code;
}
/**
- * Assigns a code (can also be an acronym or initials)
- * by which this institution is known among experts.
- *
- * @param code the string which should be assigned as an identification code
- * to this institution
+ * @see #getCode()
*/
public void setCode(String code){
this.code = code;
}
+ /**
+ * Returns the full name, as distinct from a code, an acronym or initials,
+ * by which this institution is generally known.
+ */
public String getName(){
return this.name;
}
/**
- * Assigns a full name, as distinct from a code, an acronym or initials,
- * by which this institution is generally known.
- *
- * @param name the string which should be assigned as a full name
- * to this institution
+ * @see #getName()
*/
public void setName(String name){
this.name = name;
}
-
- @Override
- /**
- * Generates the complete identification string of this institution
- * on the basis of all its attributes.
- * This method overrides {@link common.IdentifiableEntity#generateTitle() generateTitle}.
- * The result might be kept as {@link common.IdentifiableEntity#setTitleCache(String) titleCache} if the
- * flag {@link common.IdentifiableEntity#protectedTitleCache protectedTitleCache} is not set.
- *
- * @return the string which contains the complete identification of this institution
- */
- public String generateTitle(){
- return "";
- }
-
}
\ No newline at end of file