1 |
57606ee3
|
Andreas Müller
|
/**
|
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 |
ece46ca8
|
Andreas Kohlbecker
|
import javax.persistence.Column;
|
14 |
57606ee3
|
Andreas Müller
|
import javax.persistence.Entity;
|
15 |
ece46ca8
|
Andreas Kohlbecker
|
import javax.persistence.FetchType;
|
16 |
57606ee3
|
Andreas Müller
|
import javax.persistence.Inheritance;
|
17 |
|
|
import javax.persistence.InheritanceType;
|
18 |
ece46ca8
|
Andreas Kohlbecker
|
import javax.persistence.JoinColumn;
|
19 |
57606ee3
|
Andreas Müller
|
import javax.xml.bind.annotation.XmlAccessType;
|
20 |
|
|
import javax.xml.bind.annotation.XmlAccessorType;
|
21 |
|
|
import javax.xml.bind.annotation.XmlElement;
|
22 |
ece46ca8
|
Andreas Kohlbecker
|
import javax.xml.bind.annotation.XmlIDREF;
|
23 |
57606ee3
|
Andreas Müller
|
import javax.xml.bind.annotation.XmlRootElement;
|
24 |
ece46ca8
|
Andreas Kohlbecker
|
import javax.xml.bind.annotation.XmlSchemaType;
|
25 |
57606ee3
|
Andreas Müller
|
import javax.xml.bind.annotation.XmlType;
|
26 |
|
|
|
27 |
892efc69
|
Andreas Kohlbecker
|
import org.apache.commons.lang.StringUtils;
|
28 |
57606ee3
|
Andreas Müller
|
import org.apache.log4j.Logger;
|
29 |
ece46ca8
|
Andreas Kohlbecker
|
import org.hibernate.annotations.Any;
|
30 |
57606ee3
|
Andreas Müller
|
import org.hibernate.annotations.Table;
|
31 |
|
|
import org.hibernate.envers.Audited;
|
32 |
ece46ca8
|
Andreas Kohlbecker
|
import org.hibernate.envers.NotAudited;
|
33 |
57606ee3
|
Andreas Müller
|
|
34 |
892efc69
|
Andreas Kohlbecker
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
35 |
|
|
|
36 |
57606ee3
|
Andreas Müller
|
/**
|
37 |
052be4c2
|
Andreas Müller
|
* Abstract base class for classes implementing {@link eu.etaxonomy.cdm.model.common.IOriginalSource IOriginalSource}.
|
38 |
|
|
* @see eu.etaxonomy.cdm.model.common.IOriginalSource
|
39 |
57606ee3
|
Andreas Müller
|
*
|
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 |
ece46ca8
|
Andreas Kohlbecker
|
/*@XmlElement(name = "SourcedObject")
|
68 |
|
|
@XmlIDREF
|
69 |
|
|
@XmlSchemaType(name = "IDREF")
|
70 |
|
|
@Any(metaDef = "CdmBase",
|
71 |
|
|
metaColumn=@Column(name = "sourcedObj_type"),
|
72 |
|
|
fetch = FetchType.LAZY,
|
73 |
|
|
optional = false)
|
74 |
|
|
@JoinColumn(name = "sourcedObj_id")
|
75 |
|
|
@NotAudited
|
76 |
|
|
protected IdentifiableEntity sourcedObj;*/
|
77 |
57606ee3
|
Andreas Müller
|
|
78 |
|
|
/**
|
79 |
|
|
* Constructor
|
80 |
|
|
*/
|
81 |
|
|
protected OriginalSourceBase(){
|
82 |
|
|
super();
|
83 |
|
|
}
|
84 |
|
|
|
85 |
892efc69
|
Andreas Kohlbecker
|
/* (non-Javadoc)
|
86 |
|
|
* @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdInSource()
|
87 |
|
|
*/
|
88 |
57606ee3
|
Andreas Müller
|
public String getIdInSource(){
|
89 |
|
|
return this.idInSource;
|
90 |
|
|
}
|
91 |
|
|
/* (non-Javadoc)
|
92 |
|
|
* @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdInSource(java.lang.String)
|
93 |
|
|
*/
|
94 |
|
|
public void setIdInSource(String idInSource){
|
95 |
|
|
this.idInSource = idInSource;
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
/* (non-Javadoc)
|
100 |
|
|
* @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdNamespace()
|
101 |
|
|
*/
|
102 |
|
|
public String getIdNamespace() {
|
103 |
|
|
return idNamespace;
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
/* (non-Javadoc)
|
107 |
|
|
* @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdNamespace(java.lang.String)
|
108 |
|
|
*/
|
109 |
|
|
public void setIdNamespace(String idNamespace) {
|
110 |
|
|
this.idNamespace = idNamespace;
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
|
114 |
892efc69
|
Andreas Kohlbecker
|
//********************** CLONE ************************************************/
|
115 |
57606ee3
|
Andreas Müller
|
|
116 |
|
|
/* (non-Javadoc)
|
117 |
|
|
* @see java.lang.Object#clone()
|
118 |
|
|
*/
|
119 |
|
|
@Override
|
120 |
|
|
public Object clone() throws CloneNotSupportedException{
|
121 |
|
|
OriginalSourceBase result = (OriginalSourceBase)super.clone();
|
122 |
|
|
|
123 |
|
|
//no changes to: idInSource, sourcedObj
|
124 |
|
|
return result;
|
125 |
|
|
}
|
126 |
892efc69
|
Andreas Kohlbecker
|
|
127 |
57606ee3
|
Andreas Müller
|
|
128 |
892efc69
|
Andreas Kohlbecker
|
//************************ toString ***************************************/
|
129 |
|
|
@Override
|
130 |
|
|
public String toString(){
|
131 |
|
|
if (StringUtils.isNotBlank(idInSource) || StringUtils.isNotBlank(idNamespace) ){
|
132 |
|
|
return "OriginalSource:" + CdmUtils.concat(":", idNamespace, idInSource);
|
133 |
|
|
}else{
|
134 |
|
|
return super.toString();
|
135 |
|
|
}
|
136 |
57606ee3
|
Andreas Müller
|
}
|
137 |
|
|
}
|