Added Cascade.MERGE for some, not all relationships where Cascade.SAVE_UPDATE exists...
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / agent / Address.java
index 03bd68ac04c341f790ff1e60f5e212858302d0c7..64ee919e2d0b3a041cb717108f75d3a75773c0be 100644 (file)
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
 import org.apache.log4j.Logger;
 import javax.xml.bind.annotation.XmlType;
 
 import org.apache.log4j.Logger;
+import org.hibernate.envers.Audited;
 
 import eu.etaxonomy.cdm.model.common.VersionableEntity;
 import eu.etaxonomy.cdm.model.location.Point;
 
 import eu.etaxonomy.cdm.model.common.VersionableEntity;
 import eu.etaxonomy.cdm.model.location.Point;
@@ -41,27 +42,22 @@ import eu.etaxonomy.cdm.model.location.WaterbodyOrCountry;
  * @created 08-Nov-2007 13:06:09
  */
 @XmlAccessorType(XmlAccessType.FIELD)
  * @created 08-Nov-2007 13:06:09
  */
 @XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {
+@XmlType(name = "Address", propOrder = {
     "pobox",
     "street",
     "postcode",
     "locality",
     "region",
     "country",
     "pobox",
     "street",
     "postcode",
     "locality",
     "region",
     "country",
-    "location",
-    "contact"
+    "location"
 })
 @XmlRootElement(name = "Address")
 @Entity
 })
 @XmlRootElement(name = "Address")
 @Entity
-//@Audited
+@Audited
 public class Address extends VersionableEntity {
 public class Address extends VersionableEntity {
-       
-       /**
-        * 
-        */
        private static final long serialVersionUID = 682106303069088972L;
        private static final long serialVersionUID = 682106303069088972L;
-
-       static Logger logger = Logger.getLogger(Address.class);
+       @SuppressWarnings("unused")
+       private static final Logger logger = Logger.getLogger(Address.class);
        
     @XmlElement(name = "POBox")
        private String pobox;
        
     @XmlElement(name = "POBox")
        private String pobox;
@@ -81,55 +77,17 @@ public class Address extends VersionableEntity {
     @XmlElement(name = "Country")
     @XmlIDREF
     @XmlSchemaType(name = "IDREF")
     @XmlElement(name = "Country")
     @XmlIDREF
     @XmlSchemaType(name = "IDREF")
+    @ManyToOne(fetch = FetchType.LAZY)
        private WaterbodyOrCountry country;
     
     @XmlElement(name = "Location")
        private Point location;
        private WaterbodyOrCountry country;
     
     @XmlElement(name = "Location")
        private Point location;
-    
-       //Bidirectional only private
-    @XmlElement(name = "Contact")
-       private Contact contact;
-       
-       
-       /** 
-        * Returns the {@link Contact contact} (of a {@link Person person} or of an {@link Institution institution})
-        * to which <i>this</i> address belongs.
-        * Both kinds of agents cannot have more than one contact, but a contact may include
-        * several postal addresses. 
-        *
-        * @return      the contact <i>this</i> postal address belongs to
-        * @see     Contact
-        */
-       @ManyToOne
-       public Contact getContact() {
-               return contact;
-       }
-
-
-       /** 
-        * Adds <i>this</i> postal address to the set of addresses of a {@link Contact contact}.
-        * The same address instance cannot be assigned to different persons
-        * or institutions (if they do have the same postal address several
-        * address instances must be created). If <i>this</i> address already belongs to a
-        * contact this method shifts it from this contact to a new one.
-        * Therefore <i>this</i> address will be removed from the set of addresses of the old
-        * contact and added to the set of the new one. 
-        *
-        * @param  newContact  the new contact to which <i>this</i> postal address should belong
-        * @see                Contact#addAddress(Address)
-        * @see                Contact#removeAddress(Address)
-        */
-       protected void setContact(Contact newContact) {
-               this.contact = newContact;
-       }
-
        
        /**
         * Returns the {@link WaterbodyOrCountry country} involved in <i>this</i> postal address.
         * 
         * @return      the country 
         */
        
        /**
         * Returns the {@link WaterbodyOrCountry country} involved in <i>this</i> postal address.
         * 
         * @return      the country 
         */
-       @ManyToOne(fetch = FetchType.LAZY)
        public WaterbodyOrCountry getCountry(){
                return this.country;
        }
        public WaterbodyOrCountry getCountry(){
                return this.country;
        }