root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/InstitutionType.java

Revision 10455, 3.2 kB (checked in by a.mueller, 20 months ago)

reset for defined terms

  • Property svn:keywords set to Id
Line 
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
10package eu.etaxonomy.cdm.model.agent;
11
12import java.util.HashMap;
13import java.util.Map;
14import java.util.UUID;
15
16import javax.persistence.Entity;
17import javax.xml.bind.annotation.XmlAccessType;
18import javax.xml.bind.annotation.XmlAccessorType;
19import javax.xml.bind.annotation.XmlType;
20
21import org.apache.log4j.Logger;
22import org.hibernate.envers.Audited;
23import org.hibernate.search.annotations.Indexed;
24
25import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
26import eu.etaxonomy.cdm.model.common.DefinedTermBase;
27import eu.etaxonomy.cdm.model.common.TermVocabulary;
28
29/**
30 * Represents an element of a controlled {@link eu.etaxonomy.cdm.model.common.TermVocabulary vocabulary} for different kinds of institutions.
31 * Each {@link DefinedTermBase element} belongs to one vocabulary.
32 * <p>
33 * This class corresponds to: InstitutionTypeTerm according to the TDWG ontology.
34 *
35 * @author m.doering
36 * @version 1.0
37 * @created 08-Nov-2007 13:06:30
38 */
39@XmlAccessorType(XmlAccessType.FIELD)
40@XmlType(name = "InstitutionType")
41@Entity
42@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
43@Audited
44public class InstitutionType extends DefinedTermBase<InstitutionType> {
45        private static final long serialVersionUID = 8714866112728127219L;
46        public static final Logger logger = Logger.getLogger(InstitutionType.class);
47
48        protected static Map<UUID, InstitutionType> termMap = null;     
49       
50        // ************* CONSTRUCTORS *************/   
51        /**
52         * Class constructor: creates a new empty institution type.
53         *
54         * @see #InstitutionType(String, String, String)
55         */
56        public InstitutionType() {
57        }
58
59        /**
60         * Class constructor using a description (in the {@link eu.etaxonomy.cdm.model.common.Language#DEFAULT() default language}),
61         * a label and a label abbreviation.
62         *
63         * @param       term             the string describing this new vocabulary element
64         * @param       label            the string which identifies this new vocabulary element
65         * @param       labelAbbrev  the string identifying (in abbreviated form) this
66         *                                               new vocabulary element
67         * @see                          #InstitutionType()
68         * @see                          eu.etaxonomy.cdm.model.common.Representation
69         * @see                          eu.etaxonomy.cdm.model.common.TermBase#TermBase(String, String, String)
70         */
71        public InstitutionType(String term, String label, String labelAbbrev) {
72                super(term, label, labelAbbrev);
73        }
74
75       
76        /* (non-Javadoc)
77         * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
78         */
79        @Override
80        public void resetTerms(){
81                termMap = null;
82        }
83
84       
85        protected static InstitutionType getTermByUuid(UUID uuid){
86                if (termMap == null){
87                        DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
88                        vocabularyStore.initialize();
89                }
90                return (InstitutionType)termMap.get(uuid);
91        }
92
93       
94       
95        @Override
96        protected void setDefaultTerms(TermVocabulary<InstitutionType> termVocabulary){
97                termMap = new HashMap<UUID, InstitutionType>();
98                for (InstitutionType term : termVocabulary.getTerms()){
99                        termMap.put(term.getUuid(), term); 
100                }
101        }
102}
Note: See TracBrowser for help on using the browser.