1 |
9479da48
|
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 |
f7f4a80d
|
Andreas Müller
|
import java.net.URI;
|
13 |
ee91bcd9
|
ben.clark
|
import java.util.HashSet;
|
14 |
|
|
import java.util.List;
|
15 |
|
|
import java.util.Map;
|
16 |
|
|
import java.util.Set;
|
17 |
|
|
import java.util.UUID;
|
18 |
9479da48
|
Andreas Müller
|
|
19 |
ee91bcd9
|
ben.clark
|
import javax.persistence.Entity;
|
20 |
|
|
import javax.persistence.FetchType;
|
21 |
|
|
import javax.persistence.Inheritance;
|
22 |
|
|
import javax.persistence.InheritanceType;
|
23 |
0a6f2f53
|
Andreas Müller
|
import javax.persistence.ManyToMany;
|
24 |
ee91bcd9
|
ben.clark
|
import javax.persistence.ManyToOne;
|
25 |
|
|
import javax.persistence.OneToMany;
|
26 |
b70a7f94
|
Andreas Kohlbecker
|
import javax.persistence.Transient;
|
27 |
70440a7d
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlAccessType;
|
28 |
|
|
import javax.xml.bind.annotation.XmlAccessorType;
|
29 |
|
|
import javax.xml.bind.annotation.XmlElement;
|
30 |
|
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
31 |
c4c118de
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlIDREF;
|
32 |
70440a7d
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlRootElement;
|
33 |
c4c118de
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlSchemaType;
|
34 |
c9866164
|
ben.clark
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
35 |
|
|
import javax.xml.bind.annotation.XmlTransient;
|
36 |
70440a7d
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlType;
|
37 |
9479da48
|
Andreas Müller
|
|
38 |
ee91bcd9
|
ben.clark
|
import org.apache.log4j.Logger;
|
39 |
|
|
import org.hibernate.annotations.Cascade;
|
40 |
|
|
import org.hibernate.annotations.CascadeType;
|
41 |
|
|
import org.hibernate.envers.Audited;
|
42 |
|
|
|
43 |
|
|
import au.com.bytecode.opencsv.CSVWriter;
|
44 |
c9866164
|
ben.clark
|
import eu.etaxonomy.cdm.model.agent.InstitutionType;
|
45 |
|
|
import eu.etaxonomy.cdm.model.description.Feature;
|
46 |
|
|
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
|
47 |
|
|
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
|
48 |
|
|
import eu.etaxonomy.cdm.model.description.TextFormat;
|
49 |
|
|
import eu.etaxonomy.cdm.model.location.NamedAreaType;
|
50 |
|
|
import eu.etaxonomy.cdm.model.location.ReferenceSystem;
|
51 |
ee91bcd9
|
ben.clark
|
import eu.etaxonomy.cdm.model.media.Media;
|
52 |
e0212247
|
n.hoffmann
|
import eu.etaxonomy.cdm.model.media.RightsTerm;
|
53 |
c9866164
|
ben.clark
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
54 |
|
|
import eu.etaxonomy.cdm.model.occurrence.DerivationEventType;
|
55 |
|
|
import eu.etaxonomy.cdm.model.occurrence.PreservationMethod;
|
56 |
ee91bcd9
|
ben.clark
|
|
57 |
fbd23d1d
|
Andreas Müller
|
|
58 |
9479da48
|
Andreas Müller
|
/**
|
59 |
10a54497
|
m.geoffroy
|
* walkaround for enumerations, base type according to TDWG. For linear ordering
|
60 |
9479da48
|
Andreas Müller
|
* use partOf relation and BreadthFirst. Default iterator order should therefore
|
61 |
|
|
* be BreadthFirst (not DepthFirst)
|
62 |
|
|
* @author m.doering
|
63 |
|
|
* @version 1.0
|
64 |
|
|
* @created 08-Nov-2007 13:06:19
|
65 |
|
|
*/
|
66 |
70440a7d
|
a.babadshanjan
|
@XmlAccessorType(XmlAccessType.FIELD)
|
67 |
|
|
@XmlType(name = "DefinedTermBase", propOrder = {
|
68 |
|
|
"media",
|
69 |
|
|
"vocabulary"
|
70 |
|
|
})
|
71 |
|
|
@XmlRootElement(name = "DefinedTermBase")
|
72 |
c9866164
|
ben.clark
|
@XmlSeeAlso({
|
73 |
|
|
AnnotationType.class,
|
74 |
|
|
DerivationEventType.class,
|
75 |
|
|
ExtensionType.class,
|
76 |
|
|
Feature.class,
|
77 |
|
|
InstitutionType.class,
|
78 |
|
|
Language.class,
|
79 |
|
|
MarkerType.class,
|
80 |
|
|
MeasurementUnit.class,
|
81 |
|
|
NamedAreaType.class,
|
82 |
|
|
NomenclaturalCode.class,
|
83 |
|
|
PreservationMethod.class,
|
84 |
|
|
ReferenceSystem.class,
|
85 |
e0212247
|
n.hoffmann
|
RightsTerm.class,
|
86 |
c9866164
|
ben.clark
|
StatisticalMeasure.class,
|
87 |
828f8b96
|
a.babadshanjan
|
TextFormat.class
|
88 |
c9866164
|
ben.clark
|
})
|
89 |
9479da48
|
Andreas Müller
|
@Entity
|
90 |
ee91bcd9
|
ben.clark
|
@Audited
|
91 |
9479da48
|
Andreas Müller
|
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
|
92 |
0d656d7a
|
Andreas Müller
|
public abstract class DefinedTermBase<T extends DefinedTermBase> extends TermBase implements ILoadableTerm<T>, IDefinedTerm<T> {
|
93 |
0d575644
|
Andreas Müller
|
private static final long serialVersionUID = 2931811562248571531L;
|
94 |
|
|
private static final Logger logger = Logger.getLogger(DefinedTermBase.class);
|
95 |
0d656d7a
|
Andreas Müller
|
|
96 |
c9866164
|
ben.clark
|
// @XmlElement(name = "KindOf")
|
97 |
|
|
// @XmlIDREF
|
98 |
|
|
// @XmlSchemaType(name = "IDREF")
|
99 |
|
|
@XmlTransient
|
100 |
ee91bcd9
|
ben.clark
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = DefinedTermBase.class)
|
101 |
|
|
@Cascade(CascadeType.SAVE_UPDATE)
|
102 |
b9adfb4e
|
ben.clark
|
private T kindOf;
|
103 |
|
|
/**
|
104 |
|
|
* FIXME - Hibernate retuns this as a collection of CGLibProxy$$DefinedTermBase objects
|
105 |
|
|
* which can't be cast to instances of T - can we explicitly initialize these terms using
|
106 |
|
|
* Hibernate.initialize(), does this imply a distinct load, and find methods in the dao?
|
107 |
|
|
*/
|
108 |
c9866164
|
ben.clark
|
// @XmlElementWrapper(name = "Generalizations")
|
109 |
|
|
// @XmlElement(name = "GeneralizationOf")
|
110 |
|
|
// @XmlIDREF
|
111 |
|
|
// @XmlSchemaType(name = "IDREF")
|
112 |
|
|
@XmlTransient
|
113 |
ee91bcd9
|
ben.clark
|
@OneToMany(fetch=FetchType.LAZY, mappedBy = "kindOf", targetEntity = DefinedTermBase.class)
|
114 |
|
|
@Cascade({CascadeType.SAVE_UPDATE})
|
115 |
b9adfb4e
|
ben.clark
|
private Set<T> generalizationOf = new HashSet<T>();
|
116 |
70440a7d
|
a.babadshanjan
|
|
117 |
c9866164
|
ben.clark
|
// @XmlElement(name = "PartOf")
|
118 |
|
|
// @XmlIDREF
|
119 |
|
|
// @XmlSchemaType(name = "IDREF")
|
120 |
|
|
@XmlTransient
|
121 |
ee91bcd9
|
ben.clark
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = DefinedTermBase.class)
|
122 |
|
|
@Cascade(CascadeType.SAVE_UPDATE)
|
123 |
72f6d412
|
Andreas Kohlbecker
|
protected T partOf;
|
124 |
70440a7d
|
a.babadshanjan
|
|
125 |
b9adfb4e
|
ben.clark
|
/**
|
126 |
|
|
* FIXME - Hibernate retuns this as a collection of CGLibProxy$$DefinedTermBase objects
|
127 |
|
|
* which can't be cast to instances of T - can we explicitly initialize these terms using
|
128 |
|
|
* Hibernate.initialize(), does this imply a distinct load, and find methods in the dao?
|
129 |
|
|
*/
|
130 |
c9866164
|
ben.clark
|
// @XmlElementWrapper(name = "Includes")
|
131 |
|
|
// @XmlElement(name = "Include")
|
132 |
|
|
// @XmlIDREF
|
133 |
|
|
// @XmlSchemaType(name = "IDREF")
|
134 |
|
|
@XmlTransient
|
135 |
ee91bcd9
|
ben.clark
|
@OneToMany(fetch=FetchType.LAZY, mappedBy = "partOf", targetEntity = DefinedTermBase.class)
|
136 |
|
|
@Cascade({CascadeType.SAVE_UPDATE})
|
137 |
|
|
private Set<T> includes = new HashSet<T>();
|
138 |
70440a7d
|
a.babadshanjan
|
|
139 |
|
|
@XmlElementWrapper(name = "Media")
|
140 |
|
|
@XmlElement(name = "Medium")
|
141 |
0ae18eec
|
a.babadshanjan
|
@XmlIDREF
|
142 |
|
|
@XmlSchemaType(name = "IDREF")
|
143 |
0a6f2f53
|
Andreas Müller
|
@ManyToMany(fetch = FetchType.LAZY)
|
144 |
ee91bcd9
|
ben.clark
|
@Cascade({CascadeType.SAVE_UPDATE})
|
145 |
9479da48
|
Andreas Müller
|
private Set<Media> media = new HashSet<Media>();
|
146 |
70440a7d
|
a.babadshanjan
|
|
147 |
3e57e2a8
|
a.babadshanjan
|
@XmlElement(name = "TermVocabulary")
|
148 |
c4c118de
|
a.babadshanjan
|
@XmlIDREF
|
149 |
|
|
@XmlSchemaType(name = "IDREF")
|
150 |
ee91bcd9
|
ben.clark
|
@ManyToOne(fetch=FetchType.LAZY)
|
151 |
|
|
@Cascade(CascadeType.SAVE_UPDATE)
|
152 |
f6765014
|
ben.clark
|
protected TermVocabulary<T> vocabulary;
|
153 |
9479da48
|
Andreas Müller
|
|
154 |
8cc82a87
|
Andreas Müller
|
//***************************** CONSTRUCTOR *******************************************/
|
155 |
|
|
|
156 |
9479da48
|
Andreas Müller
|
public DefinedTermBase() {
|
157 |
|
|
super();
|
158 |
|
|
}
|
159 |
41b23b4e
|
Andreas Müller
|
public DefinedTermBase(String term, String label, String labelAbbrev) {
|
160 |
|
|
super(term, label, labelAbbrev);
|
161 |
9479da48
|
Andreas Müller
|
}
|
162 |
|
|
|
163 |
8cc82a87
|
Andreas Müller
|
//******************************* METHODS ******************************************************/
|
164 |
|
|
|
165 |
|
|
public abstract void resetTerms();
|
166 |
9479da48
|
Andreas Müller
|
|
167 |
8cc82a87
|
Andreas Müller
|
protected abstract void setDefaultTerms(TermVocabulary<T> termVocabulary);
|
168 |
|
|
|
169 |
|
|
|
170 |
9479da48
|
Andreas Müller
|
/* (non-Javadoc)
|
171 |
8bc5f53a
|
Andreas Müller
|
* @see eu.etaxonomy.cdm.model.common.ILoadableTerm#readCsvLine(java.util.List)
|
172 |
9479da48
|
Andreas Müller
|
*/
|
173 |
f6765014
|
ben.clark
|
public T readCsvLine(Class<T> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms) {
|
174 |
|
|
try {
|
175 |
|
|
T newInstance = termClass.newInstance();
|
176 |
9cc4226b
|
Katja Luther
|
return readCsvLine(newInstance, csvLine, Language.CSV_LANGUAGE());
|
177 |
f6765014
|
ben.clark
|
} catch (Exception e) {
|
178 |
|
|
logger.error(e);
|
179 |
|
|
for(StackTraceElement ste : e.getStackTrace()) {
|
180 |
|
|
logger.error(ste);
|
181 |
|
|
}
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
return null;
|
185 |
9479da48
|
Andreas Müller
|
}
|
186 |
1016f650
|
Andreas Müller
|
|
187 |
f6765014
|
ben.clark
|
protected static <TERM extends DefinedTermBase> TERM readCsvLine(TERM newInstance, List<String> csvLine, Language lang) {
|
188 |
|
|
newInstance.setUuid(UUID.fromString(csvLine.get(0)));
|
189 |
f7f4a80d
|
Andreas Müller
|
newInstance.setUri( URI.create(csvLine.get(1)));
|
190 |
f6765014
|
ben.clark
|
String label = csvLine.get(2).trim();
|
191 |
|
|
String text = csvLine.get(3);
|
192 |
|
|
String abbreviatedLabel = csvLine.get(4);
|
193 |
|
|
newInstance.addRepresentation(Representation.NewInstance(text, label, abbreviatedLabel, lang) );
|
194 |
|
|
return newInstance;
|
195 |
9479da48
|
Andreas Müller
|
}
|
196 |
|
|
|
197 |
|
|
/* (non-Javadoc)
|
198 |
8bc5f53a
|
Andreas Müller
|
* @see eu.etaxonomy.cdm.model.common.ILoadableTerm#writeCsvLine(au.com.bytecode.opencsv.CSVWriter)
|
199 |
9479da48
|
Andreas Müller
|
*/
|
200 |
f6765014
|
ben.clark
|
public void writeCsvLine(CSVWriter writer, T term) {
|
201 |
9479da48
|
Andreas Müller
|
String [] line = new String[4];
|
202 |
f6765014
|
ben.clark
|
line[0] = term.getUuid().toString();
|
203 |
f7f4a80d
|
Andreas Müller
|
line[1] = term.getUri().toString();
|
204 |
f6765014
|
ben.clark
|
line[2] = term.getLabel();
|
205 |
|
|
line[3] = term.getDescription();
|
206 |
9479da48
|
Andreas Müller
|
writer.writeNext(line);
|
207 |
|
|
}
|
208 |
|
|
|
209 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
210 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getByUuid(java.util.UUID)
|
211 |
|
|
*/
|
212 |
b70a7f94
|
Andreas Kohlbecker
|
@Transient
|
213 |
f6765014
|
ben.clark
|
public T getByUuid(UUID uuid){
|
214 |
|
|
return this.vocabulary.findTermByUuid(uuid);
|
215 |
|
|
}
|
216 |
|
|
|
217 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
218 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getKindOf()
|
219 |
|
|
*/
|
220 |
b9adfb4e
|
ben.clark
|
public T getKindOf(){
|
221 |
17a0cbe8
|
ben.clark
|
return (T)DefinedTermBase.deproxy(this.kindOf, this.getClass());
|
222 |
9479da48
|
Andreas Müller
|
}
|
223 |
2e5415fa
|
Andreas Müller
|
|
224 |
b9adfb4e
|
ben.clark
|
public void setKindOf(T kindOf){
|
225 |
9479da48
|
Andreas Müller
|
this.kindOf = kindOf;
|
226 |
|
|
}
|
227 |
|
|
|
228 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
229 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getGeneralizationOf()
|
230 |
|
|
*/
|
231 |
b9adfb4e
|
ben.clark
|
public Set<T> getGeneralizationOf(){
|
232 |
9479da48
|
Andreas Müller
|
return this.generalizationOf;
|
233 |
|
|
}
|
234 |
7ef24b51
|
ben.clark
|
|
235 |
c9866164
|
ben.clark
|
protected void setGeneralizationOf(Set<T> value) {
|
236 |
|
|
this.generalizationOf = value;
|
237 |
|
|
}
|
238 |
|
|
|
239 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
240 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#addGeneralizationOf(T)
|
241 |
|
|
*/
|
242 |
b9adfb4e
|
ben.clark
|
public void addGeneralizationOf(T generalization) {
|
243 |
7ef24b51
|
ben.clark
|
generalization.setKindOf(this);
|
244 |
|
|
this.generalizationOf.add(generalization);
|
245 |
|
|
}
|
246 |
|
|
|
247 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
248 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#removeGeneralization(T)
|
249 |
|
|
*/
|
250 |
b9adfb4e
|
ben.clark
|
public void removeGeneralization(T generalization) {
|
251 |
7ef24b51
|
ben.clark
|
if(generalizationOf.contains(generalization)){
|
252 |
|
|
generalization.setKindOf(null);
|
253 |
|
|
this.generalizationOf.remove(generalization);
|
254 |
|
|
}
|
255 |
|
|
}
|
256 |
9479da48
|
Andreas Müller
|
|
257 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
258 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getPartOf()
|
259 |
|
|
*/
|
260 |
b9adfb4e
|
ben.clark
|
public T getPartOf(){
|
261 |
17a0cbe8
|
ben.clark
|
return (T)DefinedTermBase.deproxy(this.partOf, this.getClass());
|
262 |
9479da48
|
Andreas Müller
|
}
|
263 |
ee91bcd9
|
ben.clark
|
|
264 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
265 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#setPartOf(T)
|
266 |
|
|
*/
|
267 |
b9adfb4e
|
ben.clark
|
public void setPartOf(T partOf){
|
268 |
9479da48
|
Andreas Müller
|
this.partOf = partOf;
|
269 |
|
|
}
|
270 |
|
|
|
271 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
272 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getIncludes()
|
273 |
|
|
*/
|
274 |
b9adfb4e
|
ben.clark
|
public Set<T> getIncludes(){
|
275 |
9479da48
|
Andreas Müller
|
return this.includes;
|
276 |
|
|
}
|
277 |
ee91bcd9
|
ben.clark
|
|
278 |
c9866164
|
ben.clark
|
protected void setIncludes(Set<T> includes) {
|
279 |
|
|
this.includes = includes;
|
280 |
|
|
}
|
281 |
|
|
|
282 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
283 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#addIncludes(T)
|
284 |
|
|
*/
|
285 |
b9adfb4e
|
ben.clark
|
public void addIncludes(T includes) {
|
286 |
7ef24b51
|
ben.clark
|
includes.setPartOf(this);
|
287 |
9479da48
|
Andreas Müller
|
this.includes.add(includes);
|
288 |
|
|
}
|
289 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
290 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#removeIncludes(T)
|
291 |
|
|
*/
|
292 |
b9adfb4e
|
ben.clark
|
public void removeIncludes(T includes) {
|
293 |
7ef24b51
|
ben.clark
|
if(this.includes.contains(includes)) {
|
294 |
|
|
includes.setPartOf(null);
|
295 |
|
|
this.includes.remove(includes);
|
296 |
|
|
}
|
297 |
9479da48
|
Andreas Müller
|
}
|
298 |
|
|
|
299 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
300 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getMedia()
|
301 |
|
|
*/
|
302 |
9479da48
|
Andreas Müller
|
public Set<Media> getMedia(){
|
303 |
|
|
return this.media;
|
304 |
|
|
}
|
305 |
ee91bcd9
|
ben.clark
|
|
306 |
0d656d7a
|
Andreas Müller
|
/* (non-Javadoc)
|
307 |
|
|
* @see eu.etaxonomy.cdm.model.common.IDefinedTerm#addMedia(eu.etaxonomy.cdm.model.media.Media)
|
308 |
|
|
*/
|
309 |
9479da48
|
Andreas Müller
|
public void addMedia(Media media) {
|
310 |
|
|
this.media.add(media);
|
311 |
|
|
}
|
312 |
|
|
public void removeMedia(Media media) {
|
313 |
|
|
this.media.remove(media);
|
314 |
|
|
}
|
315 |
|
|
|
316 |
a24c7b5d
|
Andreas Müller
|
/**
|
317 |
|
|
* @return
|
318 |
0d656d7a
|
Andreas Müller
|
*/
|
319 |
f6765014
|
ben.clark
|
public TermVocabulary<T> getVocabulary() {
|
320 |
9479da48
|
Andreas Müller
|
return this.vocabulary;
|
321 |
|
|
}
|
322 |
a24c7b5d
|
Andreas Müller
|
|
323 |
ed9d3d4f
|
Andreas Müller
|
//for bedirectional use only, use vocabulary.addTerm instead
|
324 |
a24c7b5d
|
Andreas Müller
|
/**
|
325 |
|
|
* @param newVocabulary
|
326 |
0d656d7a
|
Andreas Müller
|
*/
|
327 |
a24c7b5d
|
Andreas Müller
|
protected void setVocabulary(TermVocabulary<T> newVocabulary) {
|
328 |
9479da48
|
Andreas Müller
|
this.vocabulary = newVocabulary;
|
329 |
f6765014
|
ben.clark
|
}
|
330 |
2e8b8e21
|
Katja Luther
|
|
331 |
|
|
//*********************** CLONE ********************************************************/
|
332 |
|
|
|
333 |
|
|
/**
|
334 |
|
|
* Clones <i>this</i> DefinedTermBase. This is a shortcut that enables to create
|
335 |
|
|
* a new instance that differs only slightly from <i>this</i> defined term base by
|
336 |
|
|
* modifying only some of the attributes.
|
337 |
|
|
*
|
338 |
|
|
* @see eu.etaxonomy.cdm.model.common.TermBase#clone()
|
339 |
|
|
* @see java.lang.Object#clone()
|
340 |
|
|
*/
|
341 |
|
|
@Override
|
342 |
|
|
public Object clone() {
|
343 |
|
|
DefinedTermBase result;
|
344 |
|
|
try {
|
345 |
|
|
result = (DefinedTermBase) super.clone();
|
346 |
|
|
}catch (CloneNotSupportedException e) {
|
347 |
|
|
logger.warn("Object does not implement cloneable");
|
348 |
|
|
e.printStackTrace();
|
349 |
|
|
return null;
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
result.generalizationOf = new HashSet<DefinedTermBase>();
|
353 |
|
|
for (DefinedTermBase generalizationOf : this.generalizationOf){
|
354 |
|
|
result.generalizationOf.add((DefinedTermBase) generalizationOf.clone());
|
355 |
|
|
}
|
356 |
|
|
|
357 |
|
|
result.includes = new HashSet<DefinedTermBase>();
|
358 |
|
|
|
359 |
|
|
for (DefinedTermBase include: this.includes){
|
360 |
|
|
result.includes.add((DefinedTermBase) include.clone());
|
361 |
|
|
}
|
362 |
|
|
|
363 |
1f105b30
|
Katja Luther
|
result.media = new HashSet<Media>();
|
364 |
|
|
|
365 |
|
|
for (Media media: this.media){
|
366 |
|
|
result.addMedia(media);
|
367 |
|
|
}
|
368 |
|
|
|
369 |
|
|
|
370 |
|
|
|
371 |
2e8b8e21
|
Katja Luther
|
|
372 |
|
|
return result;
|
373 |
|
|
|
374 |
|
|
}
|
375 |
9479da48
|
Andreas Müller
|
}
|