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
|
|
25
|
import org.hibernate.envers.Audited;
|
26
|
import org.hibernate.envers.NotAudited;
|
27
|
|
28
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
29
|
|
30
|
/**
|
31
|
* This class represents an {@link eu.etaxonomy.cdm.model.common.IOriginalSource IOriginalSource}
|
32
|
* that can be used with {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity identifiable entity}.
|
33
|
*
|
34
|
* @see eu.etaxonomy.cdm.model.common.IOriginalSource
|
35
|
*
|
36
|
* @author a.mueller
|
37
|
* @created 18.09.2009
|
38
|
* @version 1.0
|
39
|
*/
|
40
|
@XmlType(name = "IdentifiableSource", propOrder = {
|
41
|
"sourcedObj"
|
42
|
})
|
43
|
@Entity
|
44
|
@Audited
|
45
|
public class IdentifiableSource extends OriginalSourceBase<IdentifiableEntity>{
|
46
|
private static final long serialVersionUID = -8487673428764273806L;
|
47
|
@SuppressWarnings("unused")
|
48
|
private static final Logger logger = Logger.getLogger(IdentifiableSource.class);
|
49
|
|
50
|
//********************************* FACTORY ********************************************************/
|
51
|
|
52
|
public static IdentifiableSource NewInstance(OriginalSourceType type){
|
53
|
return new IdentifiableSource(type);
|
54
|
}
|
55
|
|
56
|
public static IdentifiableSource NewDataImportInstance(String id){
|
57
|
IdentifiableSource result = new IdentifiableSource(OriginalSourceType.Import);
|
58
|
result.setIdInSource(id);
|
59
|
return result;
|
60
|
}
|
61
|
|
62
|
public static IdentifiableSource NewDataImportInstance(String id, String idNamespace){
|
63
|
IdentifiableSource result = NewDataImportInstance(id);
|
64
|
result.setIdNamespace(idNamespace);
|
65
|
return result;
|
66
|
}
|
67
|
|
68
|
public static IdentifiableSource NewDataImportInstance(String id, String idNamespace, Reference ref){
|
69
|
IdentifiableSource result = NewDataImportInstance(id, idNamespace);
|
70
|
result.setCitation(ref);
|
71
|
return result;
|
72
|
}
|
73
|
|
74
|
public static IdentifiableSource NewInstance(OriginalSourceType type, String id, String idNamespace, Reference citation, String microCitation){
|
75
|
IdentifiableSource result = NewInstance(type);
|
76
|
result.setIdInSource(id);
|
77
|
result.setIdNamespace(idNamespace);
|
78
|
result.setCitation(citation);
|
79
|
result.setCitationMicroReference(microCitation);
|
80
|
return result;
|
81
|
}
|
82
|
|
83
|
public static IdentifiableSource NewPrimarySourceInstance(Reference citation, String microCitation){
|
84
|
IdentifiableSource result = NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
|
85
|
result.setCitation(citation);
|
86
|
result.setCitationMicroReference(microCitation);
|
87
|
return result;
|
88
|
}
|
89
|
|
90
|
// ******************************** FIELDS ************************************/
|
91
|
|
92
|
@XmlElement(name = "SourcedObject")
|
93
|
@XmlIDREF
|
94
|
@XmlSchemaType(name = "IDREF")
|
95
|
@Any(metaDef = "CdmBase",
|
96
|
metaColumn=@Column(name = "sourcedObj_type"),
|
97
|
fetch = FetchType.LAZY,
|
98
|
optional = false)
|
99
|
@JoinColumn(name = "sourcedObj_id")
|
100
|
@NotAudited
|
101
|
private IdentifiableEntity<?> sourcedObj;
|
102
|
|
103
|
// ****************** CONSTRUCTOR ********************************/
|
104
|
|
105
|
//for hibernate only
|
106
|
private IdentifiableSource() {
|
107
|
}
|
108
|
|
109
|
private IdentifiableSource(OriginalSourceType type) {
|
110
|
super(type);
|
111
|
}
|
112
|
|
113
|
// ********************** GETTER /SETTER *****************************/
|
114
|
|
115
|
@Override
|
116
|
public IdentifiableEntity getSourcedObj() {
|
117
|
return sourcedObj;
|
118
|
}
|
119
|
|
120
|
@Override
|
121
|
public void setSourcedObj(IdentifiableEntity sourcedObj) {
|
122
|
this.sourcedObj = sourcedObj;
|
123
|
}
|
124
|
|
125
|
//*********************************** CLONE *********************************************************/
|
126
|
|
127
|
/**
|
128
|
* Clones this original source and sets the clones sourced object to 'sourceObj'
|
129
|
* @see java.lang.Object#clone()
|
130
|
*/
|
131
|
public IdentifiableSource clone(IdentifiableEntity sourcedObj) throws CloneNotSupportedException{
|
132
|
IdentifiableSource result = (IdentifiableSource)clone();
|
133
|
result.setSourcedObj(sourcedObj);
|
134
|
return result;
|
135
|
}
|
136
|
|
137
|
@Override
|
138
|
public Object clone() throws CloneNotSupportedException{
|
139
|
IdentifiableSource result = (IdentifiableSource)super.clone();
|
140
|
|
141
|
//no changes to: sourcedObj
|
142
|
return result;
|
143
|
}
|
144
|
|
145
|
|
146
|
}
|