Project

General

Profile

Download (6.49 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.HashSet;
13
import java.util.Set;
14

    
15
import javax.persistence.Entity;
16
import javax.persistence.FetchType;
17
import javax.persistence.ManyToOne;
18
import javax.persistence.OneToMany;
19
import javax.xml.bind.annotation.XmlAccessType;
20
import javax.xml.bind.annotation.XmlAccessorType;
21
import javax.xml.bind.annotation.XmlElement;
22
import javax.xml.bind.annotation.XmlElementWrapper;
23
import javax.xml.bind.annotation.XmlIDREF;
24
import javax.xml.bind.annotation.XmlRootElement;
25
import javax.xml.bind.annotation.XmlSchemaType;
26
import javax.xml.bind.annotation.XmlType;
27

    
28
import org.apache.log4j.Logger;
29
import org.hibernate.annotations.Cascade;
30
import org.hibernate.annotations.CascadeType;
31
import org.hibernate.envers.Audited;
32

    
33
/**
34
 * This class represents information pieces expressed in numerical data
35
 * (in opposition to {@link CategoricalData categorical data} on one side and to literal data on
36
 * the other side). Only {@link TaxonDescription taxon descriptions} and
37
 * {@link SpecimenDescription specimen descriptions} may contain quantitative data.<BR>
38
 * The "length of leaves" {@link Feature feature} for instance can be measured in inches.
39
 * If the length of leaves of a particular tree is described as
40
 * "typically between 3 and 5 inches" and "at the utmost 8 inches" then three
41
 * {@link StatisticalMeasurementValue statistical measurement value} instances
42
 * must be assigned to an instance of the present class
43
 * (with the {@link MeasurementUnit measurement unit} set to "inch"):<ul>
44
 * <li> the first one with the value "3" and the {@link StatisticalMeasure statistical measure}
45
 * "typical lower boundary",
46
 * <li> the second one with the value "5" and the statistical measure
47
 * "typical upper boundary"
48
 * <li> the third one with the value "8" and the statistical measure "maximum"
49
 * </ul> 
50
 * <P>
51
 * This class corresponds partially to CodedDescriptionType according to
52
 * the SDD schema.
53
 * 
54
 * @author m.doering
55
 * @version 1.0
56
 * @created 08-Nov-2007 13:06:46
57
 */
58
@XmlAccessorType(XmlAccessType.FIELD)
59
@XmlType(name = "QuantitativeData", propOrder = {
60
    "unit",
61
    "statisticalValues"
62
})
63
@XmlRootElement(name = "QuantitativeData")
64
@Entity
65
@Audited
66
public class QuantitativeData extends DescriptionElementBase {
67
	private static final long serialVersionUID = -2755806455420051488L;
68
	@SuppressWarnings("unused")
69
	private static final Logger logger = Logger.getLogger(QuantitativeData.class);
70
	
71
	@XmlElement(name = "MeasurementUnit")
72
	@XmlIDREF
73
	@XmlSchemaType(name = "IDREF")
74
	@ManyToOne(fetch = FetchType.LAZY)
75
	private MeasurementUnit unit;
76
	
77
	@XmlElementWrapper(name = "StatisticalValues")
78
	@XmlElement(name = "StatisticalValue")
79
	@OneToMany(fetch = FetchType.LAZY)
80
	@Cascade({CascadeType.SAVE_UPDATE})
81
	private Set<StatisticalMeasurementValue> statisticalValues = new HashSet<StatisticalMeasurementValue>();
82
	
83
	/** 
84
	 * Class constructor: creates a new empty quantitative data instance.
85
	 */
86
	protected QuantitativeData(){
87
		super(null);
88
	}
89
	
90
	/** 
91
	 * Creates a new empty quantitative data instance.
92
	 */
93
	public static QuantitativeData NewInstance(){
94
		return new QuantitativeData();
95
	}
96
	
97
	/** 
98
	 * Returns the set of {@link StatisticalMeasurementValue statistical measurement values} describing
99
	 * the {@link Feature feature} corresponding to <i>this</i> quantitative data.
100
	 */
101
	public Set<StatisticalMeasurementValue> getStatisticalValues() {
102
		return statisticalValues;
103
	}
104

    
105
	/**
106
	 * Adds a {@link StatisticalMeasurementValue statistical measurement value} to the set of
107
	 * {@link #getStatisticalValues() statistical measurement values} describing
108
	 * the {@link Feature feature} corresponding to <i>this</i> quantitative data.
109
	 * 
110
	 * @param statisticalValue	the statistical measurement value to be added to
111
	 * 							<i>this</i> quantitative data
112
	 * @see    	   				#getStatisticalValues()
113
	 */
114
	public void addStatisticalValue(
115
			StatisticalMeasurementValue statisticalValue) {
116
		this.statisticalValues.add(statisticalValue);
117
	}
118
	/** 
119
	 * Removes one element from the set of {@link #getStatisticalValues() statistical measurement values}
120
	 * describing the {@link Feature feature} corresponding to <i>this</i> quantitative data.
121
	 *
122
	 * @param  statisticalValue	the statistical measurement value which should be removed
123
	 * @see     				#getStatisticalValues()
124
	 * @see     				#addStatisticalValue(StatisticalMeasurementValue)
125
	 */
126
	public void removeStatisticalValue(
127
			StatisticalMeasurementValue statisticalValue) {
128
		this.statisticalValues.remove(statisticalValue);
129
	}
130

    
131
	
132
	/** 
133
	 * Returns the {@link MeasurementUnit measurement unit} used in <i>this</i>
134
	 * quantitative data.
135
	 */
136
	public MeasurementUnit getUnit(){
137
		return this.unit;
138
	}
139
	/**
140
	 * @see	#getUnit() 
141
	 */
142
	public void setUnit(MeasurementUnit unit){
143
		this.unit = unit;
144
	}
145

    
146
	/** 
147
	 * Returns the numerical value of the one {@link StatisticalMeasurementValue statistical measurement value}
148
	 * with the corresponding {@link StatisticalMeasure statistical measure} "minimum" and
149
	 * belonging to <i>this</i> quantitative data. Returns "0" if no such
150
	 * statistical measurement value instance exists. 
151
	 */
152
	public float getMin(){
153
		return 0;
154
	}
155

    
156
	/** 
157
	 * Returns the numerical value of the one {@link StatisticalMeasurementValue statistical measurement value}
158
	 * with the corresponding {@link StatisticalMeasure statistical measure} "maximum" and
159
	 * belonging to <i>this</i> quantitative data. Returns "0" if no such
160
	 * statistical measurement value instance exists. 
161
	 */
162
	public float getMax(){
163
		return 0;
164
	}
165

    
166
	/** 
167
	 * Returns the numerical value of the one {@link StatisticalMeasurementValue statistical measurement value}
168
	 * with the corresponding {@link StatisticalMeasure statistical measure}
169
	 * "typical lower boundary" and belonging to <i>this</i> quantitative data.
170
	 * Returns "0" if no such statistical measurement value instance exists. 
171
	 */
172
	public float getTypicalLowerBoundary(){
173
		return 0;
174
	}
175

    
176
	/** 
177
	 * Returns the numerical value of the one {@link StatisticalMeasurementValue statistical measurement value}
178
	 * with the corresponding {@link StatisticalMeasure statistical measure}
179
	 * "typical upper boundary" and belonging to <i>this</i> quantitative data.
180
	 * Returns "0" if no such statistical measurement value instance exists. 
181
	 */
182
	public float getTypicalUpperBoundary(){
183
		return 0;
184
	}
185

    
186
}
(16-16/31)