package eu.etaxonomy.cdm.model.agent;
-import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
-import org.apache.log4j.Logger;
-import javax.persistence.*;
+import javax.persistence.Entity;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
+import org.apache.log4j.Logger;
+import org.hibernate.envers.Audited;
+import org.hibernate.search.annotations.Indexed;
+
+import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
+import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+
/**
* Represents an element of a controlled {@link eu.etaxonomy.cdm.model.common.TermVocabulary vocabulary} for different kinds of institutions.
* Each {@link DefinedTermBase element} belongs to one vocabulary.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "InstitutionType")
@Entity
-public class InstitutionType extends DefinedTermBase {
- static Logger logger = Logger.getLogger(InstitutionType.class);
+@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
+@Audited
+public class InstitutionType extends DefinedTermBase<InstitutionType> {
+ private static final long serialVersionUID = 8714866112728127219L;
+ public static final Logger logger = Logger.getLogger(InstitutionType.class);
+ protected static Map<UUID, InstitutionType> termMap = null;
+
// ************* CONSTRUCTORS *************/
/**
* Class constructor: creates a new empty institution type.
* @see #InstitutionType(String, String, String)
*/
public InstitutionType() {
- super();
- // TODO Auto-generated constructor stub
}
/**
*/
public InstitutionType(String term, String label, String labelAbbrev) {
super(term, label, labelAbbrev);
- // TODO Auto-generated constructor stub
}
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
+ */
+ @Override
+ public void resetTerms(){
+ termMap = null;
+ }
+
+
+ protected static InstitutionType getTermByUuid(UUID uuid){
+ if (termMap == null){
+ DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
+ vocabularyStore.initialize();
+ }
+ return (InstitutionType)termMap.get(uuid);
+ }
+
+
+
+ @Override
+ protected void setDefaultTerms(TermVocabulary<InstitutionType> termVocabulary){
+ termMap = new HashMap<UUID, InstitutionType>();
+ for (InstitutionType term : termVocabulary.getTerms()){
+ termMap.put(term.getUuid(), term);
+ }
+ }
}
\ No newline at end of file