2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.description
;
13 import java
.util
.ArrayList
;
14 import java
.util
.HashMap
;
15 import java
.util
.HashSet
;
18 import javax
.persistence
.Entity
;
19 import javax
.persistence
.FetchType
;
20 import javax
.persistence
.ManyToOne
;
21 import javax
.persistence
.OneToMany
;
22 import javax
.validation
.constraints
.NotNull
;
23 import javax
.xml
.bind
.annotation
.XmlAccessType
;
24 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
25 import javax
.xml
.bind
.annotation
.XmlElement
;
26 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
27 import javax
.xml
.bind
.annotation
.XmlIDREF
;
28 import javax
.xml
.bind
.annotation
.XmlRootElement
;
29 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
30 import javax
.xml
.bind
.annotation
.XmlType
;
32 import org
.apache
.log4j
.Logger
;
33 import org
.hibernate
.envers
.Audited
;
34 import org
.hibernate
.search
.annotations
.Indexed
;
36 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
37 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
38 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
41 * This class represents the assignment of numerical values to {@link Feature features}
42 * corresponding to {@link QuantitativeData quantitative data}. A statistical measurement
43 * value instance constitutes an atomized part of an information piece
44 * (quantitative data) so that several statistical measurement value instances
45 * may belong to one quantitative data instance.
47 * This class corresponds to CharacterMeasureDataType according
52 * @created 08-Nov-2007 13:06:54
54 @XmlAccessorType(XmlAccessType
.FIELD
)
55 @XmlType(name
= "StatisticalMeasureValue")
56 @XmlRootElement(name
= "StatisticalMeasureValue")
58 @Indexed(index
= "eu.etaxonomy.cdm.model.description.DescriptionElementBase")
60 public class StatisticalMeasurementValue
extends VersionableEntity
implements IModifiable
, Cloneable
{
61 private static final long serialVersionUID
= -3576311887760351982L;
62 @SuppressWarnings("unused")
63 private static final Logger logger
= Logger
.getLogger(StatisticalMeasurementValue
.class);
65 @XmlElement(name
= "Value")
68 @XmlElementWrapper(name
= "Modifiers")
69 @XmlElement(name
= "Modifier")
71 @XmlSchemaType(name
= "IDREF")
72 @OneToMany(fetch
= FetchType
.LAZY
)
73 @NotNull // avoids creating a UNIQUE key for this field
74 private Set
<Modifier
> modifiers
= new HashSet
<Modifier
>();
76 @XmlElement(name
= "StatisticalMeasureType")
78 @XmlSchemaType(name
= "IDREF")
79 @ManyToOne(fetch
= FetchType
.LAZY
)
80 private StatisticalMeasure type
;
84 * Class constructor: creates a new empty statistical measurement value
87 protected StatisticalMeasurementValue(){
92 * Creates a new empty statistical measurement value instance.
94 public static StatisticalMeasurementValue
NewInstance(){
95 return new StatisticalMeasurementValue();
99 * Returns the type of {@link StatisticalMeasure statistical measure} used in
100 * <i>this</i> statistical measurement value.
102 public StatisticalMeasure
getType(){
108 public void setType(StatisticalMeasure type
){
114 * Returns the numerical value used to describe the {@link Feature feature}
115 * corresponding to the {@link QuantitativeData quantitative data} <i>this</i>
116 * statistical measurement value belongs to.
118 public float getValue(){
124 public void setValue(float value
){
130 * Returns the set of {@link Modifier modifiers} used to qualify the validity
131 * or probability of <i>this</i> statistical measurement value.
132 * This is only metainformation.
134 public Set
<Modifier
> getModifiers() {
139 * Adds a {@link Modifier modifier} to the set of {@link #getModifiers() modifiers}
140 * used to qualify the validity of <i>this</i> statistical measurement value.
142 * @param modifier the modifier to be added to <i>this</i> statistical measurement value
143 * @see #getModifiers()
145 public void addModifier(Modifier modifier
) {
146 this.modifiers
.add(modifier
);
149 * Removes one element from the set of {@link #getModifiers() modifiers}
150 * used to qualify the validity of <i>this</i> statistical measurement value.
152 * @param modifier the modifier which should be removed
153 * @see #getModifiers()
154 * @see #addModifier(Modifier)
156 public void removeModifier(Modifier modifier
) {
157 this.modifiers
.remove(modifier
);
161 //*********************************** CLONE *****************************************/
164 * Clones <i>this</i> statistical measurement value. This is a shortcut that enables to create
165 * a new instance that differs only slightly from <i>this</i> statistical measurement value by
166 * modifying only some of the attributes.
168 * @see eu.etaxonomy.cdm.model.common.VersionableEntity#clone()
169 * @see java.lang.Object#clone()
172 public Object
clone() {
175 StatisticalMeasurementValue result
= (StatisticalMeasurementValue
)super.clone();
178 result
.modifiers
= new HashSet
<Modifier
>();
179 for (Modifier modifier
: getModifiers()){
180 result
.modifiers
.add(modifier
);
184 //no changes to: value, type
185 } catch (CloneNotSupportedException e
) {
186 logger
.warn("Object does not implement cloneable");