Revision 892efc69
Added by Andreas Kohlbecker almost 14 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/StatisticalMeasure.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.model.description; |
11 | 11 |
|
12 |
import java.util.HashMap; |
|
13 |
import java.util.Map; |
|
12 | 14 |
import java.util.UUID; |
13 | 15 |
|
14 | 16 |
import javax.persistence.Entity; |
... | ... | |
46 | 48 |
@SuppressWarnings("unused") |
47 | 49 |
private static final Logger logger = Logger.getLogger(StatisticalMeasure.class); |
48 | 50 |
|
51 |
protected static Map<UUID, StatisticalMeasure> termMap = null; |
|
52 |
|
|
53 |
|
|
49 | 54 |
private static final UUID uuidMin = UUID.fromString("2c8b42e5-154c-42bd-a301-03b483275dd6"); |
50 | 55 |
private static final UUID uuidMax = UUID.fromString("8955815b-7d21-4149-b1b7-d37af3c2046c"); |
51 | 56 |
private static final UUID uuidAverage = UUID.fromString("264c3979-d551-4795-9e25-24c6b533fbb1"); |
... | ... | |
54 | 59 |
private static final UUID uuidTypicalLowerBoundary = UUID.fromString("8372a89a-35ad-4755-a881-7edae6c37c8f"); |
55 | 60 |
private static final UUID uuidTypicalUpperBoundary = UUID.fromString("9eff88ba-b8e7-4631-9e55-a50bd16ba79d"); |
56 | 61 |
private static final UUID uuidStandardDeviation = UUID.fromString("9ee4397e-3496-4fe1-9114-afc7d7bdc652"); |
57 |
private static StatisticalMeasure STANDARD_DEVIATION; |
|
58 |
private static StatisticalMeasure TYPICAL_UPPER_BOUNDARY; |
|
59 |
private static StatisticalMeasure TYPICAL_LOWER_BOUNDARY; |
|
60 |
private static StatisticalMeasure VARIANCE; |
|
61 |
private static StatisticalMeasure SAMPLE_SIZE; |
|
62 |
private static StatisticalMeasure AVERAGE; |
|
63 |
private static StatisticalMeasure MAX; |
|
64 |
private static StatisticalMeasure MIN; |
|
65 | 62 |
|
66 | 63 |
// ************* CONSTRUCTORS *************/ |
67 | 64 |
/** |
... | ... | |
99 | 96 |
public static StatisticalMeasure NewInstance(String term, String label, String labelAbbrev){ |
100 | 97 |
return new StatisticalMeasure(term, label, labelAbbrev); |
101 | 98 |
} |
99 |
|
|
100 |
|
|
101 |
//************************** METHODS ******************************** |
|
102 |
|
|
103 |
protected static StatisticalMeasure getTermByUuid(UUID uuid){ |
|
104 |
if (termMap == null){ |
|
105 |
return null; //better return null then initialize the termMap in an unwanted way |
|
106 |
} |
|
107 |
return (StatisticalMeasure)termMap.get(uuid); |
|
108 |
} |
|
102 | 109 |
|
103 | 110 |
public static final StatisticalMeasure MIN(){ |
104 |
return MIN;
|
|
111 |
return getTermByUuid(uuidMin);
|
|
105 | 112 |
} |
106 | 113 |
|
107 | 114 |
public static final StatisticalMeasure MAX(){ |
108 |
return MAX;
|
|
115 |
return getTermByUuid(uuidMax);
|
|
109 | 116 |
} |
110 | 117 |
|
111 | 118 |
public static final StatisticalMeasure AVERAGE(){ |
112 |
return AVERAGE;
|
|
119 |
return getTermByUuid(uuidAverage);
|
|
113 | 120 |
} |
114 | 121 |
|
115 | 122 |
public static final StatisticalMeasure SAMPLE_SIZE(){ |
116 |
return SAMPLE_SIZE;
|
|
123 |
return getTermByUuid(uuidSampleSize);
|
|
117 | 124 |
} |
118 | 125 |
|
119 | 126 |
public static final StatisticalMeasure VARIANCE(){ |
120 |
return VARIANCE;
|
|
127 |
return getTermByUuid(uuidVariance);
|
|
121 | 128 |
} |
122 | 129 |
|
123 | 130 |
public static final StatisticalMeasure TYPICAL_LOWER_BOUNDARY(){ |
124 |
return TYPICAL_LOWER_BOUNDARY;
|
|
131 |
return getTermByUuid(uuidTypicalLowerBoundary);
|
|
125 | 132 |
} |
126 | 133 |
|
127 | 134 |
public static final StatisticalMeasure TYPICAL_UPPER_BOUNDARY(){ |
128 |
return TYPICAL_UPPER_BOUNDARY;
|
|
135 |
return getTermByUuid(uuidTypicalUpperBoundary);
|
|
129 | 136 |
} |
130 | 137 |
|
131 | 138 |
public static final StatisticalMeasure STANDARD_DEVIATION(){ |
132 |
return STANDARD_DEVIATION;
|
|
139 |
return getTermByUuid(uuidStandardDeviation);
|
|
133 | 140 |
} |
141 |
|
|
142 |
|
|
134 | 143 |
@Override |
135 | 144 |
protected void setDefaultTerms(TermVocabulary<StatisticalMeasure> termVocabulary) { |
136 |
StatisticalMeasure.AVERAGE = termVocabulary.findTermByUuid(StatisticalMeasure.uuidAverage); |
|
137 |
StatisticalMeasure.MAX = termVocabulary.findTermByUuid(StatisticalMeasure.uuidMax); |
|
138 |
StatisticalMeasure.MIN = termVocabulary.findTermByUuid(StatisticalMeasure.uuidMin); |
|
139 |
StatisticalMeasure.SAMPLE_SIZE = termVocabulary.findTermByUuid(StatisticalMeasure.uuidSampleSize); |
|
140 |
StatisticalMeasure.STANDARD_DEVIATION = termVocabulary.findTermByUuid(StatisticalMeasure.uuidStandardDeviation); |
|
141 |
StatisticalMeasure.TYPICAL_LOWER_BOUNDARY = termVocabulary.findTermByUuid(StatisticalMeasure.uuidTypicalLowerBoundary); |
|
142 |
StatisticalMeasure.TYPICAL_UPPER_BOUNDARY = termVocabulary.findTermByUuid(StatisticalMeasure.uuidTypicalUpperBoundary); |
|
143 |
StatisticalMeasure.VARIANCE = termVocabulary.findTermByUuid(StatisticalMeasure.uuidVariance); |
|
145 |
termMap = new HashMap<UUID, StatisticalMeasure>(); |
|
146 |
for (StatisticalMeasure term : termVocabulary.getTerms()){ |
|
147 |
termMap.put(term.getUuid(), (StatisticalMeasure)term); |
|
148 |
} |
|
144 | 149 |
} |
145 | 150 |
|
146 | 151 |
} |
Also available in: Unified diff
merging /branches/cdmlib/SPRINT-Chichorieae1/ to trunk