Project

General

Profile

Download (6.76 KB) Statistics
| Branch: | Tag: | Revision:
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

    
10
package eu.etaxonomy.cdm.model.description;
11

    
12
import java.util.HashMap;
13
import java.util.Map;
14
import java.util.UUID;
15

    
16
import javax.persistence.Entity;
17
import javax.xml.bind.annotation.XmlAccessType;
18
import javax.xml.bind.annotation.XmlAccessorType;
19
import javax.xml.bind.annotation.XmlRootElement;
20
import javax.xml.bind.annotation.XmlTransient;
21
import javax.xml.bind.annotation.XmlType;
22

    
23
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
24
import org.hibernate.envers.Audited;
25

    
26
import eu.etaxonomy.cdm.model.common.Language;
27
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
28
import eu.etaxonomy.cdm.model.term.TermType;
29
import eu.etaxonomy.cdm.model.term.TermVocabulary;
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
 * @since 08-Nov-2007 13:06:54
38
 */
39
@XmlAccessorType(XmlAccessType.FIELD)
40
@XmlType(name = "StatisticalMeasure")
41
@XmlRootElement(name = "StatisticalMeasure")
42
@Entity
43
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
44
//@Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
45
@Audited
46
public class StatisticalMeasure extends DefinedTermBase<StatisticalMeasure> {
47

    
48
    private static final long serialVersionUID = 9168097283660941430L;
49
	@SuppressWarnings("unused")
50
	private static final Logger logger = LogManager.getLogger(StatisticalMeasure.class);
51

    
52
	protected static Map<UUID, StatisticalMeasure> termMap = null;
53

    
54

    
55
	private static final UUID uuidMin = UUID.fromString("2c8b42e5-154c-42bd-a301-03b483275dd6");
56
	private static final UUID uuidMax = UUID.fromString("8955815b-7d21-4149-b1b7-d37af3c2046c");
57
	private static final UUID uuidAverage = UUID.fromString("264c3979-d551-4795-9e25-24c6b533fbb1");
58
	private static final UUID uuidSampleSize = UUID.fromString("571f86ca-a44c-4484-9981-11fd82138a7a");
59
	private static final UUID uuidVariance = UUID.fromString("4d22cf5e-89ff-4de3-a9ae-12dbeda3faba");
60
	private static final UUID uuidTypicalLowerBoundary = UUID.fromString("8372a89a-35ad-4755-a881-7edae6c37c8f");
61
	private static final UUID uuidTypicalUpperBoundary = UUID.fromString("9eff88ba-b8e7-4631-9e55-a50bd16ba79d");
62
	private static final UUID uuidStandardDeviation = UUID.fromString("9ee4397e-3496-4fe1-9114-afc7d7bdc652");
63
    private static final UUID uuidExactValue = UUID.fromString("29736701-58c4-48b3-a9d7-41c74140cac7");
64
	//needed for Xper (later maybe integrated into model)
65
	public  static final UUID uuidStatisticalMeasureUnknownData = UUID.fromString("4bbd6e78-6d4e-4ec8-ac14-12f53aae049e");
66

    
67
	//********* FACTORY METHODS **************************************/
68
	/**
69
	 * Creates a new empty statistical measure instance.
70
	 *
71
	 * @see #NewInstance(String, String, String)
72
	 */
73
	public static StatisticalMeasure NewInstance(){
74
		return new StatisticalMeasure();
75
	}
76
	/**
77
	 * Creates a new statistical measure instance with a description
78
	 * (in the {@link Language#DEFAULT() default language}), a label and a label abbreviation.
79
	 *
80
	 * @param	term  		 the string (in the default language) describing the
81
	 * 						 new statistical measure to be created
82
	 * @param	label  		 the string identifying the new statistical measure
83
	 * 						 to be created
84
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
85
	 * 						 new statistical measure to be created
86
	 * @see 				 #NewInstance()
87
	 */
88
	public static StatisticalMeasure NewInstance(String term, String label, String labelAbbrev){
89
		return new StatisticalMeasure(term, label, labelAbbrev);
90
	}
91

    
92
//********************************** Constructor *******************************************************************/
93

    
94
	// ************* CONSTRUCTORS *************/
95
	/**
96
	 * Class constructor: creates a new empty statistical measure instance.
97
	 *
98
	 * @see #StatisticalMeasure(String, String, String)
99
	 */
100
	//for hibernate use only
101
	@Deprecated
102
	protected StatisticalMeasure() {
103
		super(TermType.StatisticalMeasure);
104
	}
105
	private StatisticalMeasure(String term, String label, String labelAbbrev) {
106
		super(TermType.StatisticalMeasure, term, label, labelAbbrev);
107
	}
108

    
109
//************************** METHODS ********************************
110

    
111
	public static final StatisticalMeasure MIN(){
112
		return getTermByUuid(uuidMin);
113
	}
114

    
115
	public static final StatisticalMeasure MAX(){
116
		return getTermByUuid(uuidMax);
117
	}
118

    
119
	public static final StatisticalMeasure AVERAGE(){
120
		return getTermByUuid(uuidAverage);
121
	}
122

    
123
	public static final StatisticalMeasure SAMPLE_SIZE(){
124
		return getTermByUuid(uuidSampleSize);
125
	}
126

    
127
	public static final StatisticalMeasure VARIANCE(){
128
		return getTermByUuid(uuidVariance);
129
	}
130

    
131
	public static final StatisticalMeasure TYPICAL_LOWER_BOUNDARY(){
132
		return getTermByUuid(uuidTypicalLowerBoundary);
133
	}
134

    
135
	public static final StatisticalMeasure TYPICAL_UPPER_BOUNDARY(){
136
		return getTermByUuid(uuidTypicalUpperBoundary);
137
	}
138

    
139
	public static final StatisticalMeasure STANDARD_DEVIATION(){
140
		return getTermByUuid(uuidStandardDeviation);
141
	}
142

    
143
    public static final StatisticalMeasure EXACT_VALUE(){
144
        return getTermByUuid(uuidExactValue);
145
    }
146

    
147
//***************************** IS_XXX ********************************************/
148

    
149
    @XmlTransient
150
    public boolean isMax() {
151
        return getUuid().equals(uuidMax);
152
    }
153

    
154
    @XmlTransient
155
    public boolean isMin() {
156
        return getUuid().equals(uuidMin);
157
    }
158
    @XmlTransient
159
    public boolean isAverage() {
160
        return getUuid().equals(uuidAverage);
161
    }
162
    @XmlTransient
163
    public boolean isTypicalLowerBoundary() {
164
        return getUuid().equals(uuidTypicalLowerBoundary);
165
    }
166
    @XmlTransient
167
    public boolean isTypicalUpperBoundary() {
168
        return getUuid().equals(uuidTypicalUpperBoundary);
169
    }
170
    @XmlTransient
171
    public boolean isExactValue() {
172
        return getUuid().equals(uuidExactValue);
173
    }
174

    
175
//***************************** TERM_MAP ********************************************/
176

    
177
	@Override
178
	protected void setDefaultTerms(TermVocabulary<StatisticalMeasure> termVocabulary) {
179
		termMap = new HashMap<>();
180
		for (StatisticalMeasure term : termVocabulary.getTerms()){
181
			termMap.put(term.getUuid(), term);
182
		}
183
	}
184

    
185
    @Override
186
    public void resetTerms(){
187
        termMap = null;
188
    }
189

    
190
    protected static StatisticalMeasure getTermByUuid(UUID uuid){
191
        if (termMap == null || termMap.isEmpty()){
192
            return getTermByClassAndUUID(StatisticalMeasure.class, uuid);
193
        } else {
194
            return termMap.get(uuid);
195
        }
196
    }
197
}
(29-29/38)