cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/AnnotatableEntity.java @ d257613d
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 org.apache.log4j.Logger; |
13 |
import org.hibernate.annotations.Cascade; |
14 |
import org.hibernate.annotations.CascadeType; |
15 |
|
16 |
import java.util.*; |
17 |
|
18 |
import javax.persistence.*; |
19 |
|
20 |
/**
|
21 |
* Abstract superclass implementing human annotations and machine markers to be assigned to CDM objects.
|
22 |
* @author m.doering
|
23 |
* @version 1.0
|
24 |
* @created 08-Nov-2007 13:06:10
|
25 |
*/
|
26 |
@MappedSuperclass
|
27 |
public abstract class AnnotatableEntity<T extends AnnotatableEntity> extends VersionableEntity<T> { |
28 |
static Logger logger = Logger.getLogger(AnnotatableEntity.class); |
29 |
|
30 |
protected Set<Marker> markers = new HashSet<Marker>(); |
31 |
protected Set<Annotation> annotations = new HashSet<Annotation>(); |
32 |
|
33 |
protected AnnotatableEntity() { |
34 |
super(); |
35 |
}
|
36 |
|
37 |
//*************** MARKER **********************************************
|
38 |
|
39 |
|
40 |
@OneToMany(fetch=FetchType.LAZY) |
41 |
@Cascade({CascadeType.SAVE_UPDATE}) |
42 |
public Set<Marker> getMarkers(){ |
43 |
return this.markers; |
44 |
}
|
45 |
public void addMarker(Marker marker){ |
46 |
if (marker != null){ |
47 |
marker.setMarkedObj(this); |
48 |
markers.add(marker); |
49 |
}
|
50 |
}
|
51 |
public void removeMarker(Marker marker){ |
52 |
marker.setMarkedObj(null); |
53 |
}
|
54 |
protected void setMarkers(Set<Marker> markers) { |
55 |
this.markers = markers; |
56 |
}
|
57 |
|
58 |
//*************** ANNOTATIONS **********************************************
|
59 |
|
60 |
@OneToMany(fetch=FetchType.LAZY) //(mappedBy="AnnotatedObj") |
61 |
@Cascade({CascadeType.SAVE_UPDATE}) |
62 |
public Set<Annotation> getAnnotations(){ |
63 |
return this.annotations; |
64 |
}
|
65 |
public void addAnnotation(Annotation annotation){ |
66 |
if (annotation != null){ |
67 |
annotation.setAnnotatedObj(this); |
68 |
annotations.add(annotation); |
69 |
}
|
70 |
}
|
71 |
public void removeAnnotation(Annotation annotation){ |
72 |
annotation.setAnnotatedObj(null); |
73 |
}
|
74 |
protected void setAnnotations(Set<Annotation> annotations) { |
75 |
this.annotations = annotations; |
76 |
}
|
77 |
|
78 |
}
|