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

Revision 10455, 5.3 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
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.XmlRootElement;
20import javax.xml.bind.annotation.XmlType;
21
22import org.apache.log4j.Logger;
23import org.hibernate.envers.Audited;
24import org.hibernate.search.annotations.Indexed;
25
26import eu.etaxonomy.cdm.model.common.DefinedTermBase;
27import eu.etaxonomy.cdm.model.common.Language;
28import eu.etaxonomy.cdm.model.common.TermVocabulary;
29
30/**
31/**
32 * This class represents terms describing different statistical measures (such
33 * as "sample size", "minimum" or "average") for {@link Feature features} that can be
34 * described with numerical values (like for instance weights or temperature).
35 *
36 * @author m.doering
37 * @version 1.0
38 * @created 08-Nov-2007 13:06:54
39 */
40@XmlAccessorType(XmlAccessType.FIELD)
41@XmlType(name = "StatisticalMeasure")
42@XmlRootElement(name = "StatisticalMeasure")
43@Entity
44@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
45@Audited
46public class StatisticalMeasure extends DefinedTermBase<StatisticalMeasure> {
47        private static final long serialVersionUID = 9168097283660941430L;
48        @SuppressWarnings("unused")
49        private static final Logger logger = Logger.getLogger(StatisticalMeasure.class);
50       
51        protected static Map<UUID, StatisticalMeasure> termMap = null;         
52
53       
54        private static final UUID uuidMin = UUID.fromString("2c8b42e5-154c-42bd-a301-03b483275dd6");
55        private static final UUID uuidMax = UUID.fromString("8955815b-7d21-4149-b1b7-d37af3c2046c");
56        private static final UUID uuidAverage = UUID.fromString("264c3979-d551-4795-9e25-24c6b533fbb1");
57        private static final UUID uuidSampleSize = UUID.fromString("571f86ca-a44c-4484-9981-11fd82138a7a");
58        private static final UUID uuidVariance = UUID.fromString("4d22cf5e-89ff-4de3-a9ae-12dbeda3faba");
59        private static final UUID uuidTypicalLowerBoundary = UUID.fromString("8372a89a-35ad-4755-a881-7edae6c37c8f");
60        private static final UUID uuidTypicalUpperBoundary = UUID.fromString("9eff88ba-b8e7-4631-9e55-a50bd16ba79d");
61        private static final UUID uuidStandardDeviation = UUID.fromString("9ee4397e-3496-4fe1-9114-afc7d7bdc652");
62
63        // ************* CONSTRUCTORS *************/   
64        /**
65         * Class constructor: creates a new empty statistical measure instance.
66         *
67         * @see #StatisticalMeasure(String, String, String)
68         */
69        public StatisticalMeasure() {
70        }
71        public StatisticalMeasure(String term, String label, String labelAbbrev) {
72                super(term, label, labelAbbrev);
73        }
74
75        //********* METHODS **************************************/
76        /**
77         * Creates a new empty statistical measure instance.
78         *
79         * @see #NewInstance(String, String, String)
80         */
81        public static StatisticalMeasure NewInstance(){
82                return new StatisticalMeasure();
83        }
84        /**
85         * Creates a new statistical measure instance with a description
86         * (in the {@link Language#DEFAULT() default language}), a label and a label abbreviation.
87         *
88         * @param       term             the string (in the default language) describing the
89         *                                               new statistical measure to be created
90         * @param       label            the string identifying the new statistical measure
91         *                                               to be created
92         * @param       labelAbbrev  the string identifying (in abbreviated form) the
93         *                                               new statistical measure to be created
94         * @see                                  #NewInstance()
95         */
96        public static StatisticalMeasure NewInstance(String term, String label, String labelAbbrev){
97                return new StatisticalMeasure(term, label, labelAbbrev);
98        }       
99       
100       
101//************************** METHODS ********************************
102       
103        /* (non-Javadoc)
104         * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
105         */
106        @Override
107        public void resetTerms(){
108                termMap = null;
109        }
110
111       
112       
113        protected static StatisticalMeasure getTermByUuid(UUID uuid){
114                if (termMap == null){
115                        return null;  //better return null then initialize the termMap in an unwanted way
116                }
117                return (StatisticalMeasure)termMap.get(uuid);
118        }
119
120        public static final StatisticalMeasure MIN(){
121                return getTermByUuid(uuidMin);
122        }
123
124        public static final StatisticalMeasure MAX(){
125                return getTermByUuid(uuidMax);
126        }
127
128        public static final StatisticalMeasure AVERAGE(){
129                return getTermByUuid(uuidAverage);
130        }
131
132        public static final StatisticalMeasure SAMPLE_SIZE(){
133                return getTermByUuid(uuidSampleSize);
134        }
135
136        public static final StatisticalMeasure VARIANCE(){
137                return getTermByUuid(uuidVariance);
138        }
139
140        public static final StatisticalMeasure TYPICAL_LOWER_BOUNDARY(){
141                return getTermByUuid(uuidTypicalLowerBoundary);
142        }
143
144        public static final StatisticalMeasure TYPICAL_UPPER_BOUNDARY(){
145                return getTermByUuid(uuidTypicalUpperBoundary);
146        }
147
148        public static final StatisticalMeasure STANDARD_DEVIATION(){
149                return getTermByUuid(uuidStandardDeviation);
150        }
151       
152       
153        @Override
154        protected void setDefaultTerms(TermVocabulary<StatisticalMeasure> termVocabulary) {
155                termMap = new HashMap<UUID, StatisticalMeasure>();
156                for (StatisticalMeasure term : termVocabulary.getTerms()){
157                        termMap.put(term.getUuid(), (StatisticalMeasure)term);
158                }
159        }
160       
161}
Note: See TracBrowser for help on using the browser.