added barcode to derived unit #1689
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / occurrence / DerivedUnitBase.java
index 36113cc00c4fb7e0be2c5e5f0b328d9d1a46d50f..f6f2120d767b386811ec29ecfea390d3cc2070c2 100644 (file)
@@ -30,9 +30,11 @@ import org.hibernate.search.annotations.Field;
 import org.hibernate.search.annotations.Index;
 import org.hibernate.search.annotations.Indexed;
 import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.validator.constraints.Length;
 
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
+import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
 
 /**
  * http://www.bgbm.org/biodivinf/docs/CollectionModel/ReprintTNR.pdf
@@ -50,7 +52,8 @@ import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
     "storedUnder",
     "derivationEvent",
     "accessionNumber",
-    "collectorsNumber"
+    "collectorsNumber",
+    "barcode"
 })
 @XmlRootElement(name = "DerivedUnitBase")
 @Entity
@@ -68,16 +71,28 @@ public abstract class DerivedUnitBase<S extends IIdentifiableEntityCacheStrategy
 
        @XmlElement(name = "CatalogNumber")
        @Field(index=Index.UN_TOKENIZED)
+       @NullOrNotEmpty
+       @Length(max = 255)
        private String catalogNumber;
        
        @XmlElement(name = "AccessionNumber")
        @Field(index=Index.UN_TOKENIZED)
+       @NullOrNotEmpty
+       @Length(max = 255)
        private String accessionNumber;
        
        @XmlElement(name = "CollectorsNumber")
        @Field(index=Index.UN_TOKENIZED)
+       @NullOrNotEmpty
+       @Length(max = 255)
        private String collectorsNumber;
        
+       @XmlElement(name = "Barcode")
+       @Field(index=Index.UN_TOKENIZED)
+       @NullOrNotEmpty
+       @Length(max = 255)
+       private String barcode;
+       
        @XmlElement(name = "StoredUnder")
        @XmlIDREF
        @XmlSchemaType(name = "IDREF")
@@ -120,7 +135,7 @@ public abstract class DerivedUnitBase<S extends IIdentifiableEntityCacheStrategy
         */
        protected DerivedUnitBase(GatheringEvent gatheringEvent) {
                this(new FieldObservation());
-               FieldObservation field = (FieldObservation) this.getOriginalUnit();
+               FieldObservation field = (FieldObservation)this.getOriginalUnit();
                field.setGatheringEvent(gatheringEvent);
        }
 
@@ -135,7 +150,7 @@ public abstract class DerivedUnitBase<S extends IIdentifiableEntityCacheStrategy
                }
                this.derivationEvent = derivedFrom;
                if (derivedFrom != null){
-                       derivedFrom.getDerivatives().add(this);
+                       derivedFrom.addDerivative(this);
                }
        }
        
@@ -144,14 +159,6 @@ public abstract class DerivedUnitBase<S extends IIdentifiableEntityCacheStrategy
                return this.getDerivedFrom().getOriginals();
        }
 
-       @Override
-       @Transient
-       public GatheringEvent getGatheringEvent() {
-               // FIXME: implement efficient way of getting original gathering event
-               // keep link to original gathering event for performance mainly.
-               return null;
-       }
-
        public Collection getCollection(){
                return this.collection;
        }
@@ -169,6 +176,13 @@ public abstract class DerivedUnitBase<S extends IIdentifiableEntityCacheStrategy
                this.catalogNumber = catalogNumber;
        }
        
+       public void setBarcode(String barcode) {
+               this.barcode = barcode;
+       }
+       public String getBarcode() {
+               return barcode;
+       }
+       
        public void setStoredUnder(TaxonNameBase storedUnder) {
                this.storedUnder = storedUnder;
        }
@@ -194,7 +208,7 @@ public abstract class DerivedUnitBase<S extends IIdentifiableEntityCacheStrategy
                return storedUnder;
        }
        
-       //*********** CLONE **********************************/ 
+//*********** CLONE **********************************/        
        
        /** 
         * Clones <i>this</i> derivedUnitBase. This is a shortcut that enables to
@@ -218,4 +232,5 @@ public abstract class DerivedUnitBase<S extends IIdentifiableEntityCacheStrategy
                //no changes to: accessionNumber, catalogNumber, collectorsNumber
                return result;
        }
+
 }