merge-update from trunk
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / taxon / TaxonBase.java
index 0b0f368595cfe684359d578dfab91636828c7107..87b5b5da63fdf5d3b079309ee4dd3ef2c4bf5b49 100644 (file)
@@ -30,8 +30,14 @@ import org.hibernate.annotations.CascadeType;
 import org.hibernate.annotations.Index;
 import org.hibernate.annotations.Table;
 import org.hibernate.envers.Audited;
+import org.hibernate.search.annotations.ClassBridge;
+import org.hibernate.search.annotations.ClassBridges;
 import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Store;
 
+import eu.etaxonomy.cdm.hibernate.search.AcceptedTaxonBridge;
+import eu.etaxonomy.cdm.hibernate.search.ClassInfoBridge;
+import eu.etaxonomy.cdm.model.common.IPublishable;
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
@@ -63,16 +69,27 @@ import eu.etaxonomy.cdm.validation.annotation.TaxonNameCannotBeAcceptedAndSynony
     "name",
     "sec",
     "doubtful",
-    "publish",
     "appendedPhrase",
-    "useNameCache"
+    "useNameCache",
+    "publish"
 })
 @Entity
 @Audited
 //@PreFilter("hasPermission(filterObject, 'edit')")
 @Table(appliesTo="TaxonBase", indexes = { @Index(name = "taxonBaseTitleCacheIndex", columnNames = { "titleCache" }) })
 @TaxonNameCannotBeAcceptedAndSynonym(groups = Level3.class)
-public abstract class TaxonBase<S extends IIdentifiableEntityCacheStrategy> extends IdentifiableEntity<S> implements Cloneable {
+@ClassBridges({
+    @ClassBridge(name="classInfo",
+            index = org.hibernate.search.annotations.Index.YES,
+            store = Store.YES,
+            impl = ClassInfoBridge.class),
+    @ClassBridge(name="accTaxon", // TODO rename to acceptedTaxon, since we are usually not using abbreviations for field names
+            index = org.hibernate.search.annotations.Index.YES,
+            store = Store.YES,
+            impl = AcceptedTaxonBridge.class),
+    @ClassBridge(impl = eu.etaxonomy.cdm.hibernate.search.NomenclaturalSortOrderBrigde.class)
+})
+public abstract class TaxonBase<S extends IIdentifiableEntityCacheStrategy> extends IdentifiableEntity<S> implements  IPublishable, Cloneable {
     private static final long serialVersionUID = -3589185949928938529L;
     private static final Logger logger = Logger.getLogger(TaxonBase.class);
 
@@ -93,9 +110,7 @@ public abstract class TaxonBase<S extends IIdentifiableEntityCacheStrategy> exte
     //The assignment to the Taxon or to the Synonym class is not definitive
     @XmlAttribute(name = "isDoubtful")
     private boolean doubtful;
-    
-    @XmlAttribute(name = "publish")
-    private boolean publish = true;
+
 
     @XmlElement(name = "Name", required = true)
     @XmlIDREF
@@ -122,6 +137,9 @@ public abstract class TaxonBase<S extends IIdentifiableEntityCacheStrategy> exte
 
     @XmlAttribute(name= "UseNameCache")
     private boolean useNameCache = false;
+    
+    @XmlAttribute(name = "publish")
+    private boolean publish = true;
 
 
 // ************* CONSTRUCTORS *************/
@@ -218,7 +236,7 @@ public abstract class TaxonBase<S extends IIdentifiableEntityCacheStrategy> exte
 
     /**
      * Returns the boolean value indicating whether the assignment of <i>this</i>
-     * (abstract) taxon to the {@link Taxon Taxon} or to the {@link Synonym Synonym} class 
+     * (abstract) taxon to the {@link Taxon Taxon} or to the {@link Synonym Synonym} class
      * is definitive (false) or not (true). If this flag is set the use of <i>this</i> (abstract)
      * taxon as an "accepted/correct" name or as a (junior) "synonym" might
      * still change in the course of taxonomical working process.
@@ -234,20 +252,22 @@ public abstract class TaxonBase<S extends IIdentifiableEntityCacheStrategy> exte
     }
     
 
-       /**
-        * Returns the boolean value indicating if this taxon should be withheld (<code>publish=false</code>) or not 
-        * (<code>publish=true</code>) during any publication process to the general public.
-        * This publish flag implementation is preliminary and may be replaced by a more general 
-        * implementation of READ rights in future.<BR>
-        * The default value is <code>true</code>.
-        */
-       public boolean isPublish() {
-               return publish;
-       }
-
-       public void setPublish(boolean publish) {
-               this.publish = publish;
-       }
+    /**
+     * Returns the boolean value indicating if this taxon should be withheld (<code>publish=false</code>) or not
+     * (<code>publish=true</code>) during any publication process to the general public.
+     * This publish flag implementation is preliminary and may be replaced by a more general
+     * implementation of READ rights in future.<BR>
+     * The default value is <code>true</code>.
+     */
+    @Override
+    public boolean isPublish() {
+        return publish;
+    }
+
+    @Override
+    public void setPublish(boolean publish) {
+        this.publish = publish;
+    }
 
     /**
      * Returns the {@link eu.etaxonomy.cdm.model.reference.Reference reference} of <i>this</i> (abstract) taxon.
@@ -298,7 +318,7 @@ public abstract class TaxonBase<S extends IIdentifiableEntityCacheStrategy> exte
     public void setUseNameCache(boolean useNameCache) {
         this.useNameCache = useNameCache;
     }
-    
+
     @Transient
     public abstract boolean isOrphaned();
 //*********************** CLONE ********************************************************/