Fixed marshalling/unmarshalling of ReferenceBase, TypeDesignationBase, etc.
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / OriginalSource.java
index 072ec795a4e1e73faaedc409649fd42b4192ef80..0fae607de7021996846797a7dce839921a69e139 100644 (file)
@@ -12,6 +12,12 @@ package eu.etaxonomy.cdm.model.common;
 
 import javax.persistence.Entity;
 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.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
 
 import org.apache.log4j.Logger;
 
@@ -23,12 +29,25 @@ import org.apache.log4j.Logger;
  * @created 08-Nov-2007 13:06:22
  */
 
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "OriginalSource", propOrder = {
+    "idInSource",
+    "idNamespace"
+})
+@XmlRootElement(name = "OriginalSource")
 @Entity
 public class OriginalSource extends ReferencedEntityBase implements Cloneable{
+       
        static Logger logger = Logger.getLogger(OriginalSource.class);
+       
        //The object's ID in the source, where the alternative string comes from
+       @XmlElement(name = "IdInSource")
        private String idInSource;
+       
+       @XmlElement(name = "IdNamespace")
        private String idNamespace;
+       
+       @XmlTransient
        private IdentifiableEntity sourcedObj;
 
        /**
@@ -69,16 +88,14 @@ public class OriginalSource extends ReferencedEntityBase implements Cloneable{
                this.idInSource = idInSource;
        }
 
-       @Transient              
-       public IdentifiableEntity getSourcedObj() {
-               return sourcedObj;
-       }
-       public void setSourcedObj(IdentifiableEntity sourcedObj) {
-               this.sourcedObj = sourcedObj;
-       }
-
 
        /**
+        * Returns the id namespace. The id namespace is a String that further defines the origin of
+        * the original record. In the combination with the id it should be unique within one a source. 
+        * E.g. if a record comes from table ABC and has the id 345, 'ABC' is a suitable namespace and the 
+        * combination of 'ABC' and 345 is a unique id for this source. 
+        * The namespace is meant to distinguish import records that come from two different tables, elements, objects, ... 
+        * and end up in the same CDM class. In this case the id may not be enough to identify the original record. 
         * @return the idNamespace
         */
        public String getIdNamespace() {
@@ -92,12 +109,25 @@ public class OriginalSource extends ReferencedEntityBase implements Cloneable{
                this.idNamespace = idNamespace;
        }
 
+
+//     @ManyToOne
+//     @Cascade(CascadeType.SAVE_UPDATE)
+       @Transient //beacause IdentifiableEntity is MappedSuperclass
+       public IdentifiableEntity getSourcedObj() {
+               return sourcedObj;
+       }
+       public void setSourcedObj(IdentifiableEntity sourcedObj) {
+               this.sourcedObj = sourcedObj;
+       }
+
+
        
 //****************** CLONE ************************************************/
         
        /* (non-Javadoc)
         * @see java.lang.Object#clone()
         */
+       @Override
        public Object clone() throws CloneNotSupportedException{
                OriginalSource result = (OriginalSource)super.clone();