1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.model.common;
|
12
|
|
13
|
import javax.persistence.Column;
|
14
|
import javax.persistence.Entity;
|
15
|
import javax.persistence.FetchType;
|
16
|
import javax.persistence.JoinColumn;
|
17
|
import javax.xml.bind.annotation.XmlElement;
|
18
|
import javax.xml.bind.annotation.XmlIDREF;
|
19
|
import javax.xml.bind.annotation.XmlSchemaType;
|
20
|
import javax.xml.bind.annotation.XmlType;
|
21
|
|
22
|
import org.apache.log4j.Logger;
|
23
|
import org.hibernate.annotations.Any;
|
24
|
import org.hibernate.envers.Audited;
|
25
|
import org.hibernate.envers.NotAudited;
|
26
|
|
27
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
28
|
|
29
|
/**
|
30
|
* This class represents an {@link eu.etaxonomy.cdm.model.common.IOriginalSource IOriginalSource}
|
31
|
* that can be used with {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity identifiable entity}.
|
32
|
*
|
33
|
* @see eu.etaxonomy.cdm.model.common.IOriginalSource
|
34
|
*
|
35
|
* @author a.mueller
|
36
|
* @created 18.09.2009
|
37
|
* @version 1.0
|
38
|
*/
|
39
|
@XmlType(name = "IdentifiableSource", propOrder = {
|
40
|
"sourcedObj"
|
41
|
})
|
42
|
@Entity
|
43
|
@Audited
|
44
|
public class IdentifiableSource extends OriginalSourceBase<IdentifiableEntity>{
|
45
|
private static final long serialVersionUID = -8487673428764273806L;
|
46
|
@SuppressWarnings("unused")
|
47
|
private static final Logger logger = Logger.getLogger(IdentifiableSource.class);
|
48
|
|
49
|
|
50
|
/**
|
51
|
* Factory method
|
52
|
* @return
|
53
|
*/
|
54
|
public static IdentifiableSource NewInstance(){
|
55
|
return new IdentifiableSource();
|
56
|
}
|
57
|
|
58
|
public static IdentifiableSource NewInstance(String id){
|
59
|
IdentifiableSource result = new IdentifiableSource();
|
60
|
result.setIdInSource(id);
|
61
|
return result;
|
62
|
}
|
63
|
|
64
|
public static IdentifiableSource NewInstance(String id, String idNamespace){
|
65
|
IdentifiableSource result = NewInstance(id);
|
66
|
result.setIdNamespace(idNamespace);
|
67
|
return result;
|
68
|
}
|
69
|
|
70
|
public static IdentifiableSource NewInstance(String id, String idNamespace, Reference citation, String microCitation){
|
71
|
IdentifiableSource result = NewInstance(id, idNamespace);
|
72
|
result.setCitation(citation);
|
73
|
result.setCitationMicroReference(microCitation);
|
74
|
return result;
|
75
|
}
|
76
|
|
77
|
public static IdentifiableSource NewInstance(Reference citation, String microCitation){
|
78
|
IdentifiableSource result = NewInstance();
|
79
|
result.setCitation(citation);
|
80
|
result.setCitationMicroReference(microCitation);
|
81
|
return result;
|
82
|
}
|
83
|
|
84
|
@XmlElement(name = "SourcedObject")
|
85
|
@XmlIDREF
|
86
|
@XmlSchemaType(name = "IDREF")
|
87
|
@Any(metaDef = "CdmBase",
|
88
|
metaColumn=@Column(name = "sourcedObj_type"),
|
89
|
fetch = FetchType.LAZY,
|
90
|
optional = false)
|
91
|
@JoinColumn(name = "sourcedObj_id")
|
92
|
@NotAudited
|
93
|
private IdentifiableEntity sourcedObj;
|
94
|
|
95
|
|
96
|
/* (non-Javadoc)
|
97
|
* @see eu.etaxonomy.cdm.model.common.IOriginalSource#getSourcedObj()
|
98
|
*/
|
99
|
public IdentifiableEntity getSourcedObj() {
|
100
|
return sourcedObj;
|
101
|
}
|
102
|
|
103
|
/* (non-Javadoc)
|
104
|
* @see eu.etaxonomy.cdm.model.common.IOriginalSource#setSourcedObj(eu.etaxonomy.cdm.model.common.IdentifiableEntity)
|
105
|
*/
|
106
|
public void setSourcedObj(IdentifiableEntity sourcedObj) {
|
107
|
this.sourcedObj = sourcedObj;
|
108
|
}
|
109
|
|
110
|
//*********************************** CLONE *********************************************************/
|
111
|
|
112
|
/**
|
113
|
* Clones this original source and sets the clones sourced object to 'sourceObj'
|
114
|
* @see java.lang.Object#clone()
|
115
|
*/
|
116
|
public IdentifiableSource clone(IdentifiableEntity sourcedObj) throws CloneNotSupportedException{
|
117
|
IdentifiableSource result = (IdentifiableSource)clone();
|
118
|
result.setSourcedObj(sourcedObj);
|
119
|
return result;
|
120
|
}
|
121
|
|
122
|
/* (non-Javadoc)
|
123
|
* @see eu.etaxonomy.cdm.model.common.OriginalSourceBase#clone()
|
124
|
* @see java.lang.Object#clone()
|
125
|
*/
|
126
|
@Override
|
127
|
public Object clone() throws CloneNotSupportedException{
|
128
|
IdentifiableSource result = (IdentifiableSource)super.clone();
|
129
|
|
130
|
//no changes to: sourcedObj
|
131
|
return result;
|
132
|
}
|
133
|
|
134
|
|
135
|
}
|