-/**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-
-package eu.etaxonomy.cdm.model.description;
-
-
-import eu.etaxonomy.cdm.model.common.VersionableEntity;
-import org.apache.log4j.Logger;
-
-import java.util.*;
-
-import javax.persistence.*;
-
-/**
- * @author m.doering
- * @version 1.0
- * @created 08-Nov-2007 13:06:54
- */
-@Entity
-public class StatisticalMeasurementValue extends VersionableEntity {
- static Logger logger = Logger.getLogger(StatisticalMeasurementValue.class);
- private float value;
- private Set<Modifier> modifiers = new HashSet();
- private StatisticalMeasure type;
-
-
- /**
- * Factory method
- * @return
- */
- public static StatisticalMeasurementValue NewInstance(){
- return new StatisticalMeasurementValue();
- }
-
- /**
- * Constructor
- */
- protected StatisticalMeasurementValue(){
- super();
- }
-
- @ManyToOne
- public StatisticalMeasure getType(){
- return this.type;
- }
- public void setType(StatisticalMeasure type){
- this.type = type;
- }
-
-
- public float getValue(){
- return this.value;
- }
- public void setValue(float value){
- this.value = value;
- }
-
-
- @OneToMany
- public Set<Modifier> getModifiers() {
- return modifiers;
- }
- protected void setModifiers(Set<Modifier> modifiers) {
- this.modifiers = modifiers;
- }
- public void addModifier(Modifier modifier) {
- this.modifiers.add(modifier);
- }
- public void removeModifier(Modifier modifier) {
- this.modifiers.remove(modifier);
- }
-
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+\r
+package eu.etaxonomy.cdm.model.description;\r
+\r
+\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import javax.persistence.Entity;\r
+import javax.persistence.FetchType;\r
+import javax.persistence.ManyToMany;\r
+import javax.persistence.ManyToOne;\r
+import javax.persistence.OneToMany;\r
+import javax.validation.constraints.NotNull;\r
+import javax.xml.bind.annotation.XmlAccessType;\r
+import javax.xml.bind.annotation.XmlAccessorType;\r
+import javax.xml.bind.annotation.XmlElement;\r
+import javax.xml.bind.annotation.XmlElementWrapper;\r
+import javax.xml.bind.annotation.XmlIDREF;\r
+import javax.xml.bind.annotation.XmlRootElement;\r
+import javax.xml.bind.annotation.XmlSchemaType;\r
+import javax.xml.bind.annotation.XmlType;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.hibernate.envers.Audited;\r
+import org.hibernate.search.annotations.Indexed;\r
+\r
+import eu.etaxonomy.cdm.model.common.VersionableEntity;\r
+\r
+/**\r
+ * This class represents the assignment of numerical values to {@link Feature features}\r
+ * corresponding to {@link QuantitativeData quantitative data}. A statistical measurement\r
+ * value instance constitutes an atomized part of an information piece\r
+ * (quantitative data) so that several statistical measurement value instances\r
+ * may belong to one quantitative data instance.\r
+ * <P>\r
+ * This class corresponds to CharacterMeasureDataType according\r
+ * to the SDD schema.\r
+ * \r
+ * @author m.doering\r
+ * @version 1.0\r
+ * @created 08-Nov-2007 13:06:54\r
+ */\r
+@XmlAccessorType(XmlAccessType.FIELD)\r
+@XmlType(name = "StatisticalMeasureValue")\r
+@XmlRootElement(name = "StatisticalMeasureValue")\r
+@Entity\r
+@Indexed(index = "eu.etaxonomy.cdm.model.description.DescriptionElementBase")\r
+@Audited\r
+public class StatisticalMeasurementValue extends VersionableEntity implements IModifiable, Cloneable{\r
+ private static final long serialVersionUID = -3576311887760351982L;\r
+ private static final Logger logger = Logger.getLogger(StatisticalMeasurementValue.class);\r
+ \r
+ @XmlElement(name = "Value")\r
+ private float value;\r
+ \r
+ @XmlElementWrapper(name = "Modifiers")\r
+ @XmlElement(name = "Modifier")\r
+ @XmlIDREF\r
+ @XmlSchemaType(name = "IDREF")\r
+ @ManyToMany(fetch = FetchType.LAZY)\r
+// @NotNull // avoids creating a UNIQUE key for this field -> not needed for ManyToMany\r
+ private Set<Modifier> modifiers = new HashSet<Modifier>();\r
+ \r
+ @XmlElement(name = "StatisticalMeasureType")\r
+ @XmlIDREF\r
+ @XmlSchemaType(name = "IDREF")\r
+ @ManyToOne(fetch = FetchType.LAZY)\r
+ private StatisticalMeasure type;\r
+\r
+\r
+ /** \r
+ * Class constructor: creates a new empty statistical measurement value\r
+ * instance.\r
+ */\r
+ protected StatisticalMeasurementValue(){\r
+ super();\r
+ }\r
+ \r
+ /** \r
+ * Creates a new empty statistical measurement value instance.\r
+ */\r
+ public static StatisticalMeasurementValue NewInstance(){\r
+ return new StatisticalMeasurementValue();\r
+ }\r
+ \r
+ /** \r
+ * Returns the type of {@link StatisticalMeasure statistical measure} used in\r
+ * <i>this</i> statistical measurement value.\r
+ */\r
+ public StatisticalMeasure getType(){\r
+ return this.type;\r
+ }\r
+ /** \r
+ * @see #getType()\r
+ */\r
+ public void setType(StatisticalMeasure type){\r
+ this.type = type;\r
+ }\r
+\r
+\r
+ /** \r
+ * Returns the numerical value used to describe the {@link Feature feature}\r
+ * corresponding to the {@link QuantitativeData quantitative data} <i>this</i>\r
+ * statistical measurement value belongs to.\r
+ */\r
+ public float getValue(){\r
+ return this.value;\r
+ }\r
+ /** \r
+ * @see #getValue()\r
+ */\r
+ public void setValue(float value){\r
+ this.value = value;\r
+ }\r
+ \r
+ \r
+ /** \r
+ * Returns the set of {@link Modifier modifiers} used to qualify the validity\r
+ * or probability of <i>this</i> statistical measurement value.\r
+ * This is only metainformation.\r
+ */\r
+ public Set<Modifier> getModifiers() {\r
+ return modifiers;\r
+ }\r
+\r
+ /**\r
+ * Adds a {@link Modifier modifier} to the set of {@link #getModifiers() modifiers}\r
+ * used to qualify the validity of <i>this</i> statistical measurement value.\r
+ * \r
+ * @param modifier the modifier to be added to <i>this</i> statistical measurement value\r
+ * @see #getModifiers()\r
+ */\r
+ public void addModifier(Modifier modifier) {\r
+ this.modifiers.add(modifier);\r
+ }\r
+ /** \r
+ * Removes one element from the set of {@link #getModifiers() modifiers}\r
+ * used to qualify the validity of <i>this</i> statistical measurement value.\r
+ *\r
+ * @param modifier the modifier which should be removed\r
+ * @see #getModifiers()\r
+ * @see #addModifier(Modifier)\r
+ */\r
+ public void removeModifier(Modifier modifier) {\r
+ this.modifiers.remove(modifier);\r
+ }\r
+ \r
+\r
+//*********************************** CLONE *****************************************/\r
+\r
+ /** \r
+ * Clones <i>this</i> statistical measurement value. This is a shortcut that enables to create\r
+ * a new instance that differs only slightly from <i>this</i> statistical measurement value by\r
+ * modifying only some of the attributes.\r
+ * \r
+ * @see eu.etaxonomy.cdm.model.common.VersionableEntity#clone()\r
+ * @see java.lang.Object#clone()\r
+ */\r
+ @Override\r
+ public Object clone() {\r
+\r
+ try {\r
+ StatisticalMeasurementValue result = (StatisticalMeasurementValue)super.clone();\r
+ \r
+ //modifiers\r
+ result.modifiers = new HashSet<Modifier>();\r
+ for (Modifier modifier : getModifiers()){\r
+ result.modifiers.add(modifier);\r
+ }\r
+ \r
+ return result;\r
+ //no changes to: value, type\r
+ } catch (CloneNotSupportedException e) {\r
+ logger.warn("Object does not implement cloneable");\r
+ e.printStackTrace();\r
+ return null;\r
+ }\r
+ }\r
+\r
}
\ No newline at end of file