package eu.etaxonomy.cdm.model.description;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.UUID;
import javax.persistence.Entity;
import javax.persistence.FetchType;
-import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import org.apache.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.envers.Audited;
+import org.hibernate.search.annotations.Indexed;
import eu.etaxonomy.cdm.model.common.TermBase;
* nothing in common with the possible hierarchical structure of features
* depending on their grade of precision.
*
- * @see IdentificationKey
+ * @see MediaKey
* @author m.doering
* @version 1.0
* @created 08-Nov-2007 13:06:16
})
@XmlRootElement(name = "FeatureTree")
@Entity
+@Indexed(index = "eu.etaxonomy.cdm.model.description.FeatureTree")
@Audited
public class FeatureTree extends TermBase {
- /**
- *
- */
private static final long serialVersionUID = -6713834139003172735L;
-
@SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(FeatureTree.class);
//private Set<FeatureNode> nodes = new HashSet<FeatureNode>();
@XmlElement(name = "Root")
@OneToOne(fetch = FetchType.LAZY)
- @Cascade({CascadeType.SAVE_UPDATE})
+ @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
private FeatureNode root;
@XmlElement(name = "IsDescriptionSeparated")
protected FeatureTree() {
super();
root = FeatureNode.NewInstance();
+ root.setFeatureTree(this);
}
/**
result.addAll(root.getChildren());
return result;
}
-
+
+ /**
+ * Computes a set of distinct features that are present in this feature tree
+ *
+ * @return
+ */
+ @Transient
+ public Set<Feature> getDistinctFeatures(){
+ Set<Feature> features = new HashSet<Feature>();
+
+ return root.getDistinctFeaturesRecursive(features);
+ }
+
}
\ No newline at end of file