merge trunk to hibernate4
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / OriginalSourceBase.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.cdm.model.common;
11
12
13 import javax.persistence.Column;
14 import javax.persistence.Entity;
15 import javax.persistence.FetchType;
16 import javax.persistence.Inheritance;
17 import javax.persistence.InheritanceType;
18 import javax.persistence.JoinColumn;
19 import javax.xml.bind.annotation.XmlAccessType;
20 import javax.xml.bind.annotation.XmlAccessorType;
21 import javax.xml.bind.annotation.XmlElement;
22 import javax.xml.bind.annotation.XmlIDREF;
23 import javax.xml.bind.annotation.XmlRootElement;
24 import javax.xml.bind.annotation.XmlSchemaType;
25 import javax.xml.bind.annotation.XmlType;
26
27 import org.apache.commons.lang.StringUtils;
28 import org.apache.log4j.Logger;
29 import org.hibernate.annotations.Any;
30 import org.hibernate.annotations.Table;
31 import org.hibernate.envers.Audited;
32 import org.hibernate.envers.NotAudited;
33
34 import eu.etaxonomy.cdm.common.CdmUtils;
35
36 /**
37 * Abstract base class for classes implementing {@link eu.etaxonomy.cdm.model.common.IOriginalSource IOriginalSource}.
38 * @see eu.etaxonomy.cdm.model.common.IOriginalSource
39 *
40 * @author m.doering
41 * @version 1.0
42 * @created 08-Nov-2007 13:06:22
43 */
44
45 @XmlAccessorType(XmlAccessType.FIELD)
46 @XmlType(name = "OriginalSource", propOrder = {
47 "idInSource",
48 "idNamespace"
49 })
50 @XmlRootElement(name = "OriginalSource")
51 @Entity
52 @Audited
53 @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
54 @Table(appliesTo="OriginalSourceBase")
55 public abstract class OriginalSourceBase<T extends ISourceable> extends ReferencedEntityBase implements Cloneable, IOriginalSource<T> {
56 private static final long serialVersionUID = -1972959999261181462L;
57 @SuppressWarnings("unused")
58 private static final Logger logger = Logger.getLogger(OriginalSourceBase.class);
59
60 //The object's ID in the source, where the alternative string comes from
61 @XmlElement(name = "IdInSource")
62 private String idInSource;
63
64 @XmlElement(name = "IdNamespace")
65 private String idNamespace;
66
67 /**
68 * Constructor
69 */
70 protected OriginalSourceBase(){
71 super();
72 }
73
74 /* (non-Javadoc)
75 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdInSource()
76 */
77 public String getIdInSource(){
78 return this.idInSource;
79 }
80 /* (non-Javadoc)
81 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdInSource(java.lang.String)
82 */
83 public void setIdInSource(String idInSource){
84 this.idInSource = idInSource;
85 }
86
87
88 /* (non-Javadoc)
89 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdNamespace()
90 */
91 public String getIdNamespace() {
92 return idNamespace;
93 }
94
95 /* (non-Javadoc)
96 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdNamespace(java.lang.String)
97 */
98 public void setIdNamespace(String idNamespace) {
99 this.idNamespace = idNamespace;
100 }
101
102
103 //********************** CLONE ************************************************/
104
105 /* (non-Javadoc)
106 * @see java.lang.Object#clone()
107 */
108 @Override
109 public Object clone() throws CloneNotSupportedException{
110 OriginalSourceBase result = (OriginalSourceBase)super.clone();
111
112 //no changes to: idInSource, sourcedObj
113 return result;
114 }
115
116
117 //************************ toString ***************************************/
118 @Override
119 public String toString(){
120 if (StringUtils.isNotBlank(idInSource) || StringUtils.isNotBlank(idNamespace) ){
121 return "OriginalSource:" + CdmUtils.concat(":", idNamespace, idInSource);
122 }else{
123 return super.toString();
124 }
125 }
126 }