root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/Scope.java

Revision 10455, 3.6 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.description;
11
12
13import java.util.HashMap;
14import java.util.Map;
15import java.util.UUID;
16
17import javax.persistence.Entity;
18import javax.xml.bind.annotation.XmlAccessType;
19import javax.xml.bind.annotation.XmlAccessorType;
20import javax.xml.bind.annotation.XmlRootElement;
21import javax.xml.bind.annotation.XmlType;
22
23import org.apache.log4j.Logger;
24import org.hibernate.envers.Audited;
25import org.hibernate.search.annotations.Indexed;
26
27import eu.etaxonomy.cdm.model.common.Language;
28import eu.etaxonomy.cdm.model.common.TermVocabulary;
29
30/**
31 * The class representing restrictions for the validity of
32 * {@link TaxonDescription taxon descriptions}. This could include not only {@link Stage life stage}
33 * or {@link Sex sex} but also for instance particular organism parts or seasons.
34 *
35 * @author m.doering
36 * @version 1.0
37 * @created 08-Nov-2007 13:06:50
38 */
39@XmlAccessorType(XmlAccessType.FIELD)
40@XmlType(name = "Scope")
41@XmlRootElement(name = "Scope")
42@Entity
43@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
44@Audited
45public class Scope extends Modifier {
46        private static final long serialVersionUID = 4479960075363470677L;
47        @SuppressWarnings("unused")
48        private static final Logger logger = Logger.getLogger(Scope.class);
49       
50        protected static Map<UUID, Scope> termMap = null;
51       
52        // ************* CONSTRUCTORS *************/   
53
54        /**
55         * Class constructor: creates a new empty scope instance.
56         *
57         * @see #Scope(String, String, String)
58         */
59        public Scope() {
60        }
61
62        /**
63         * Class constructor: creates a new scope instance with a description (in the {@link Language#DEFAULT() default language}),
64         * a label and a label abbreviation.
65         *
66         * @param       term             the string (in the default language) describing the
67         *                                               new scope to be created
68         * @param       label            the string identifying the new scope to be created
69         * @param       labelAbbrev  the string identifying (in abbreviated form) the
70         *                                               new scope to be created
71         * @see                                  #Scope()
72         */
73        protected Scope(String term, String label, String labelAbbrev) {
74                super(term, label, labelAbbrev);
75        }
76
77       
78        //********* METHODS **************************************/
79
80        /**
81         * Creates a new empty scope instance.
82         *
83         * @see #NewInstance(String, String, String)
84         */
85        public static Scope NewInstance(){
86                return new Scope();
87        }
88       
89        /**
90         * Creates a new scope instance with a description (in the {@link Language#DEFAULT() default language}),
91         * a label and a label abbreviation.
92         *
93         * @param       term             the string (in the default language) describing the
94         *                                               new scope to be created
95         * @param       label            the string identifying the new scope to be created
96         * @param       labelAbbrev  the string identifying (in abbreviated form) the
97         *                                               new scope to be created
98         * @see                                  #NewInstance()
99         */
100        public static Scope NewInstance(String term, String label, String labelAbbrev){
101                return new Scope(term, label, labelAbbrev);
102        }
103       
104
105       
106//************************** METHODS ********************************
107       
108        /* (non-Javadoc)
109         * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
110         */
111        @Override
112        public void resetTerms(){
113                termMap = null;
114        }
115
116       
117        @Override
118        protected void setDefaultTerms(TermVocabulary<Modifier> termVocabulary) {
119                termMap = new HashMap<UUID, Scope>();
120                for (Modifier term : termVocabulary.getTerms()){
121                        termMap.put(term.getUuid(), (Scope)term);  //TODO casting
122                }
123        }
124}
Note: See TracBrowser for help on using the browser.