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
|
import javax.persistence.Entity;
|
13
|
import javax.xml.bind.annotation.XmlType;
|
14
|
|
15
|
import org.apache.logging.log4j.LogManager;
|
16
|
import org.apache.logging.log4j.Logger;
|
17
|
import org.hibernate.envers.Audited;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.reference.ICdmTarget;
|
20
|
import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
|
21
|
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
|
22
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
23
|
|
24
|
/**
|
25
|
* This class represents an {@link eu.etaxonomy.cdm.model.reference.IOriginalSource IOriginalSource}
|
26
|
* that can be used with {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity identifiable entity}.
|
27
|
*
|
28
|
* @see eu.etaxonomy.cdm.model.reference.IOriginalSource
|
29
|
*
|
30
|
* @author a.mueller
|
31
|
* @since 18.09.2009
|
32
|
*/
|
33
|
@XmlType(name = "IdentifiableSource", propOrder = {
|
34
|
})
|
35
|
@Entity
|
36
|
@Audited
|
37
|
public class IdentifiableSource
|
38
|
extends OriginalSourceBase
|
39
|
implements ICheckEmpty{
|
40
|
|
41
|
private static final long serialVersionUID = -8487673428764273806L;
|
42
|
@SuppressWarnings("unused")
|
43
|
private static final Logger logger = LogManager.getLogger(IdentifiableSource.class);
|
44
|
|
45
|
//********************************* FACTORY ********************************************************/
|
46
|
|
47
|
public static IdentifiableSource NewInstance(OriginalSourceType type){
|
48
|
return new IdentifiableSource(type);
|
49
|
}
|
50
|
|
51
|
public static IdentifiableSource NewDataImportInstance(String id){
|
52
|
IdentifiableSource result = new IdentifiableSource(OriginalSourceType.Import);
|
53
|
result.setIdInSource(id);
|
54
|
return result;
|
55
|
}
|
56
|
|
57
|
public static IdentifiableSource NewDataImportInstance(String id, String idNamespace){
|
58
|
IdentifiableSource result = NewDataImportInstance(id);
|
59
|
result.setIdNamespace(idNamespace);
|
60
|
return result;
|
61
|
}
|
62
|
|
63
|
public static IdentifiableSource NewDataImportInstance(String id, String idNamespace, Reference ref){
|
64
|
IdentifiableSource result = NewDataImportInstance(id, idNamespace);
|
65
|
result.setCitation(ref);
|
66
|
return result;
|
67
|
}
|
68
|
|
69
|
public static IdentifiableSource NewInstance(OriginalSourceType type, String id, String idNamespace, Reference
|
70
|
reference, String microReference){
|
71
|
IdentifiableSource result = NewInstance(type);
|
72
|
result.setIdInSource(id);
|
73
|
result.setIdNamespace(idNamespace);
|
74
|
result.setCitation(reference);
|
75
|
result.setCitationMicroReference(microReference);
|
76
|
return result;
|
77
|
}
|
78
|
|
79
|
public static IdentifiableSource NewInstance(OriginalSourceType type, String id, String idNamespace, Reference
|
80
|
reference, String microReference, String originalInfo){
|
81
|
IdentifiableSource result = NewInstance(type, id, idNamespace, reference, microReference);
|
82
|
result.setOriginalInfo(originalInfo);
|
83
|
return result;
|
84
|
}
|
85
|
|
86
|
public static IdentifiableSource NewInstance(OriginalSourceType type, String id, String idNamespace, Reference
|
87
|
reference, String microReference, String originalInfo, ICdmTarget target){
|
88
|
IdentifiableSource result = NewInstance(type, id, idNamespace, reference,
|
89
|
microReference, originalInfo);
|
90
|
result.setCdmSource(target);
|
91
|
return result;
|
92
|
}
|
93
|
|
94
|
public static IdentifiableSource NewPrimarySourceInstance(Reference citation, String microCitation){
|
95
|
IdentifiableSource result = NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
|
96
|
result.setCitation(citation);
|
97
|
result.setCitationMicroReference(microCitation);
|
98
|
return result;
|
99
|
}
|
100
|
|
101
|
public static IdentifiableSource NewPrimaryMediaSourceInstance(Reference citation, String microCitation){
|
102
|
IdentifiableSource result = NewInstance(OriginalSourceType.PrimaryMediaSource);
|
103
|
result.setCitation(citation);
|
104
|
result.setCitationMicroReference(microCitation);
|
105
|
return result;
|
106
|
}
|
107
|
|
108
|
public static IdentifiableSource NewAggregationSourceInstance(){
|
109
|
IdentifiableSource result = NewInstance(OriginalSourceType.Aggregation);
|
110
|
return result;
|
111
|
}
|
112
|
|
113
|
// ******************************** FIELDS ************************************/
|
114
|
|
115
|
|
116
|
|
117
|
// ****************** CONSTRUCTOR ********************************/
|
118
|
|
119
|
//for hibernate only
|
120
|
protected IdentifiableSource() {
|
121
|
}
|
122
|
|
123
|
private IdentifiableSource(OriginalSourceType type) {
|
124
|
super(type);
|
125
|
}
|
126
|
|
127
|
// ********************** GETTER /SETTER *****************************/
|
128
|
|
129
|
@Override
|
130
|
public boolean checkEmpty(){
|
131
|
return this.checkEmpty(false);
|
132
|
}
|
133
|
|
134
|
@Override
|
135
|
public boolean checkEmpty(boolean excludeType){
|
136
|
//nothing to do
|
137
|
return super.checkEmpty(excludeType);
|
138
|
}
|
139
|
//*********************************** CLONE *********************************************************/
|
140
|
|
141
|
|
142
|
@Override
|
143
|
public IdentifiableSource clone() throws CloneNotSupportedException{
|
144
|
IdentifiableSource result = (IdentifiableSource)super.clone();
|
145
|
|
146
|
//no changes
|
147
|
return result;
|
148
|
}
|
149
|
}
|