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
|
//********************************* FACTORY ********************************************************/
|
50
|
|
51
|
public static IdentifiableSource NewInstance(OriginalSourceType type){
|
52
|
return new IdentifiableSource(type);
|
53
|
}
|
54
|
|
55
|
public static IdentifiableSource NewDataImportInstance(String id){
|
56
|
IdentifiableSource result = new IdentifiableSource(OriginalSourceType.Import);
|
57
|
result.setIdInSource(id);
|
58
|
return result;
|
59
|
}
|
60
|
|
61
|
public static IdentifiableSource NewDataImportInstance(String id, String idNamespace){
|
62
|
IdentifiableSource result = NewDataImportInstance(id);
|
63
|
result.setIdNamespace(idNamespace);
|
64
|
return result;
|
65
|
}
|
66
|
|
67
|
public static IdentifiableSource NewDataImportInstance(String id, String idNamespace, Reference ref){
|
68
|
IdentifiableSource result = NewDataImportInstance(id, idNamespace);
|
69
|
result.setCitation(ref);
|
70
|
return result;
|
71
|
}
|
72
|
|
73
|
public static IdentifiableSource NewInstance(OriginalSourceType type, String id, String idNamespace, Reference citation, String microCitation){
|
74
|
IdentifiableSource result = NewInstance(type);
|
75
|
result.setIdInSource(id);
|
76
|
result.setIdNamespace(idNamespace);
|
77
|
result.setCitation(citation);
|
78
|
result.setCitationMicroReference(microCitation);
|
79
|
return result;
|
80
|
}
|
81
|
|
82
|
public static IdentifiableSource NewPrimarySourceInstance(Reference citation, String microCitation){
|
83
|
IdentifiableSource result = NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
|
84
|
result.setCitation(citation);
|
85
|
result.setCitationMicroReference(microCitation);
|
86
|
return result;
|
87
|
}
|
88
|
|
89
|
// ******************************** FIELDS ************************************/
|
90
|
|
91
|
@XmlElement(name = "SourcedObject")
|
92
|
@XmlIDREF
|
93
|
@XmlSchemaType(name = "IDREF")
|
94
|
@Any(metaDef = "CdmBase",
|
95
|
metaColumn=@Column(name = "sourcedObj_type"),
|
96
|
fetch = FetchType.LAZY,
|
97
|
optional = false)
|
98
|
@JoinColumn(name = "sourcedObj_id")
|
99
|
@NotAudited
|
100
|
|
101
|
// @org.hibernate.annotations.AnyMetaDef(name = "OriginalSource" ,
|
102
|
// metaType="string",
|
103
|
// idType="integer",
|
104
|
// metaValues={
|
105
|
// @MetaValue(value = "eu.etaxonomy.cdm.model.common.IdentifiableEntity", targetEntity = IdentifiableEntity.class),
|
106
|
// @MetaValue(value = "eu.etaxonomy.cdm.model.description.DescriptionElementBase", targetEntity = DescriptionElementBase.class),
|
107
|
// })
|
108
|
private IdentifiableEntity<?> sourcedObj;
|
109
|
|
110
|
// ****************** CONSTRUCTOR ********************************/
|
111
|
|
112
|
//for hibernate only
|
113
|
private IdentifiableSource() {
|
114
|
}
|
115
|
|
116
|
private IdentifiableSource(OriginalSourceType type) {
|
117
|
super(type);
|
118
|
}
|
119
|
|
120
|
// ********************** GETTER /SETTER *****************************/
|
121
|
|
122
|
@Override
|
123
|
public IdentifiableEntity getSourcedObj() {
|
124
|
return sourcedObj;
|
125
|
}
|
126
|
|
127
|
@Override
|
128
|
public void setSourcedObj(IdentifiableEntity sourcedObj) {
|
129
|
this.sourcedObj = sourcedObj;
|
130
|
}
|
131
|
|
132
|
//*********************************** CLONE *********************************************************/
|
133
|
|
134
|
/**
|
135
|
* Clones this original source and sets the clones sourced object to 'sourceObj'
|
136
|
* @see java.lang.Object#clone()
|
137
|
*/
|
138
|
public IdentifiableSource clone(IdentifiableEntity sourcedObj) throws CloneNotSupportedException{
|
139
|
IdentifiableSource result = (IdentifiableSource)clone();
|
140
|
result.setSourcedObj(sourcedObj);
|
141
|
return result;
|
142
|
}
|
143
|
|
144
|
@Override
|
145
|
public Object clone() throws CloneNotSupportedException{
|
146
|
IdentifiableSource result = (IdentifiableSource)super.clone();
|
147
|
|
148
|
//no changes to: sourcedObj
|
149
|
return result;
|
150
|
}
|
151
|
|
152
|
|
153
|
}
|