/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import org.hibernate.envers.Audited;
import eu.etaxonomy.cdm.model.common.VersionableEntity;
-import eu.etaxonomy.cdm.model.location.Point;
import eu.etaxonomy.cdm.model.location.Country;
+import eu.etaxonomy.cdm.model.location.Point;
/**
* This class represents atomized postal addresses.
* <li> Address according to the TCS
* <li> Address according to the ABCD schema
* </ul>
- *
+ *
* @author m.doering
- * @version 1.0
* @created 08-Nov-2007 13:06:09
*/
@XmlAccessorType(XmlAccessType.FIELD)
private static final long serialVersionUID = 682106303069088972L;
@SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(Address.class);
-
+
public static Address NewInstance(){
return new Address();
}
-
+
public static Address NewInstance(Country country,
String locality, String pobox, String postcode,
String region, String street, Point location) {
}
private Address(){
-
+
}
-
+
private Address(Country country, String locality, Point location,
String pobox, String postcode, String region, String street) {
super();
@XmlElement(name = "POBox")
private String pobox;
-
+
@XmlElement(name = "Street")
private String street;
-
+
@XmlElement(name = "Postcode")
private String postcode;
-
+
@XmlElement(name = "Locality", required = true)
private String locality;
-
+
@XmlElement(name = "Region")
private String region;
-
+
@XmlElement(name = "Country")
@XmlIDREF
@XmlSchemaType(name = "IDREF")
@ManyToOne(fetch = FetchType.LAZY)
private Country country;
-
+
@XmlElement(name = "Location")
private Point location;
-
+
/**
* Returns the {@link Country country} involved in <i>this</i> postal address.
- *
- * @return the country
+ *
+ * @return the country
*/
public Country getCountry(){
return this.country;
/**
* Returns the geophysical {@link Point location} (coordinates) of <i>this</i> postal address.
* The location can be useful for instance to visualize the address on a map.
- *
+ *
* @return the point corresponding to <i>this</i> address
* @see eu.etaxonomy.cdm.model.location.Point
*/
/**
* Returns a string corresponding to the post office box
* involved in <i>this</i> postal address.
- *
- * @return the post office box string
+ *
+ * @return the post office box string
*/
public String getPobox(){
return this.pobox;
/**
* Returns the street name and number involved in <i>this</i> postal address.
* Street numbers are part of the street string.
- *
- * @return the string composed of street name and number
+ *
+ * @return the string composed of street name and number
*/
public String getStreet(){
return this.street;
/**
* Returns the post code number involved in <i>this</i> postal address.
- *
+ *
* @return the post code number string
*/
public String getPostcode(){
/**
* Returns the town (possibly with locality or suburb) involved in <i>this</i> postal address.
- *
+ *
* @return the string representing a town
*/
public String getLocality(){
* @see #getLocality()
*/
public void setLocality(String locality){
- this.locality = locality == "" ? null: locality;
+ this.locality = locality == "" ? null: locality;
}
/**
* Returns the region or state involved in <i>this</i> postal address.
- *
+ *
* @return the string representing a region or a state
*/
public String getRegion(){
public void setRegion(String region){
this.region = region == "" ? null: region;
}
-
+
//************************ CLONE ************************ //
- /**
+ /**
* Clones this Address.
* Set fields for nextVersion, previousVersion, updated, updatedBy and createdBy are set to <tt>null</tt>
* The id is set to 0.
@Override
public Object clone() throws CloneNotSupportedException{
Address result = (Address)super.clone();
-
+
//no changes to: -
return result;
}
-
+
}
@XmlElement(name = "EmailAddress")
@ElementCollection(fetch = FetchType.LAZY)
@Column(name = "contact_emailaddresses_element")
- private List<String> emailAddresses;
+ private List<String> emailAddresses = new ArrayList<>();
@XmlElementWrapper(name = "URLs", nillable = true)
@XmlElement(name = "URL")
@XmlSchemaType(name = "anyURI")
@ElementCollection(fetch = FetchType.LAZY)
@Column(name = "contact_urls_element" /*, length=330 */) //length >255 does not work in InnoDB AUD tables for Key length of (REV, id, url) key
- private final List<String> urls = new ArrayList<String>();
+ private final List<String> urls = new ArrayList<>();
@XmlElementWrapper(name = "PhoneNumbers", nillable = true)
@XmlElement(name = "PhoneNumber")
@ElementCollection(fetch = FetchType.LAZY)
@Column(name = "contact_phonenumbers_element")
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE})
- private List<String> phoneNumbers;
+ private List<String> phoneNumbers = new ArrayList<>();
@XmlElementWrapper(name = "FaxNumbers", nillable = true)
@XmlElement(name = "FaxNumber")
@ElementCollection(fetch = FetchType.LAZY)
@Column(name = "contact_faxnumbers_element")
- private List<String> faxNumbers;
+ private List<String> faxNumbers = new ArrayList<>();
@XmlElementWrapper(name = "Addresses", nillable = true)
@XmlElement(name = "Address")
@OneToMany(fetch = FetchType.LAZY, orphanRemoval=true)
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
- protected Set<Address> addresses = new HashSet<Address>();
+ protected Set<Address> addresses = new HashSet<>();
public static Contact NewInstance() {
return new Contact();
return result;
}
-
+// ************************ CONSTRUCTOR **************************/
/**
* Class constructor.
*/
public Contact() {
}
+// ************************ MERGE /MATCH ***************************/
public void merge(Contact contact2) throws MergeException{
if (contact2 != null){
for (Address address : contact2.getAddresses()){
try {
if (this.addresses == null){
- this.addresses = new HashSet<Address>();
+ this.addresses = new HashSet<>();
}
this.addresses.add((Address)address.clone());
} catch (CloneNotSupportedException e) {
*/
public List<String> getEmailAddresses(){
if(this.emailAddresses == null) {
- this.emailAddresses = new ArrayList<String>();
+ this.emailAddresses = new ArrayList<>();
}
return this.emailAddresses;
}
*/
public List<String> getPhoneNumbers(){
if(this.phoneNumbers == null) {
- this.phoneNumbers = new ArrayList<String>();
+ this.phoneNumbers = new ArrayList<>();
}
return this.phoneNumbers;
}
*/
public List<String> getFaxNumbers(){
if(this.faxNumbers == null) {
- this.faxNumbers = new ArrayList<String>();
+ this.faxNumbers = new ArrayList<>();
}
return this.faxNumbers;
}
public Object clone() {
try{
Contact result = (Contact) super.clone();
- result.addresses = new HashSet<Address>();
+ result.addresses = new HashSet<>();
for (Address adr : this.addresses){
result.addAddress((Address)adr.clone());
}
*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/ \r
+*/\r
\r
package eu.etaxonomy.cdm.model.common;\r
\r
import java.util.StringTokenizer;\r
\r
import javax.persistence.Embeddable;\r
+import javax.persistence.Transient;\r
\r
import com.ibm.lsid.MalformedLSIDException;\r
\r
/**\r
- * This class is copied from com.ibm.lsid.LSID, I needed to re-implement this since \r
+ * This class is copied from com.ibm.lsid.LSID, I needed to re-implement this since\r
* the domain objects are required to be Serializable\r
- * \r
- * \r
+ *\r
+ *\r
* @author Ben Szekely (<a href="mailto:bhszekel@us.ibm.com">bhszekel@us.ibm.com</a>)\r
* @author ben.clark\r
* @see com.ibm.lsid.client.LSID\r
private static final long serialVersionUID = -3568951541851092269L;\r
\r
private String lsid;\r
- \r
+\r
private String authority;\r
- \r
+\r
private String namespace;\r
- \r
+\r
private String object;\r
- \r
+\r
private String revision;\r
- \r
+\r
private LSID() { }\r
- \r
+\r
/**\r
* Construct a new LSID with the String representation.\r
* @param String The lsid String respresentation\r
\r
try {\r
authority = st.nextToken().toLowerCase();\r
- } \r
+ }\r
catch (NoSuchElementException e) {\r
throw new MalformedLSIDException(e, "authority not found: [" + lsid + "]");\r
}\r
if (st.hasMoreTokens()) {\r
revision = st.nextToken();\r
}\r
- \r
+\r
this.lsid = "urn:lsid:" + this.authority + ":" + this.namespace + ":" + this.object + (this.revision != null ? ":" + this.revision : "");\r
}\r
- \r
+\r
/**\r
* Construct a new LSID with the given components\r
* @param String the authority\r
this.namespace = namespace;//.toLowerCase();\r
this.object = object;//.toLowerCase();\r
if (revision != null)\r
- this.revision = revision;//.toLowerCase();\r
+ {\r
+ this.revision = revision;//.toLowerCase();\r
+ }\r
lsid = "urn:lsid:" + this.authority + ":" + this.namespace + ":" + this.object + (this.revision != null ? ":" + this.revision : "");\r
- } \r
- \r
+ }\r
+\r
/**\r
- * Returns the lsid \r
+ * Returns the lsid\r
* @return String The lsid String representation\r
*/\r
public String getLsid() {\r
return lsid;\r
}\r
\r
- \r
+\r
\r
/**\r
* Returns the authority component of the LSID\r
public String getRevision() {\r
return revision;\r
}\r
- \r
+\r
public static boolean isLsid(String strLsid){\r
try {\r
//TODO use algorithm rather than exceptions\r
* return the string representation\r
* @return String\r
*/\r
- public String toString() {\r
+ @Override\r
+ public String toString() {\r
return lsid;\r
}\r
- \r
+\r
/**\r
* Two LSIDs are equal their string representations are equal disregarding case.\r
*/\r
- public boolean equals(Object lsid) {\r
+ @Override\r
+ public boolean equals(Object lsid) {\r
if(this == lsid) {\r
return true;\r
} else if (lsid != null && lsid instanceof LSID) {\r
/**
* @author m.doering
- * @version 1.0
* @created 08-Nov-2007 13:06:44
*/
@XmlAccessorType(XmlAccessType.FIELD)
return result;
}
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
@Override
public String toString(){
String result = "";
\r
// ********************* CONSTRUCTOR ********************/\r
\r
- private SequenceString(){};\r
+ private SequenceString(){}\r
\r
// ********************* GETTER / SETTER ********************/\r
\r
return new DefaultMatchStrategy(matchClazz);
}
-// protected Map<String, MatchMode> matchModeMap = new HashMap<String, MatchMode>();
protected MatchMode defaultMatchMode = MatchMode.EQUAL;
protected MatchMode defaultCollectionMatchMode = MatchMode.IGNORE;
protected MatchMode defaultMatchMatchMode = MatchMode.MATCH;