2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.common
;
12 import javax
.persistence
.Column
;
13 import javax
.persistence
.Entity
;
14 import javax
.persistence
.FetchType
;
15 import javax
.persistence
.JoinColumn
;
16 import javax
.persistence
.ManyToOne
;
17 import javax
.persistence
.Transient
;
18 import javax
.validation
.constraints
.NotNull
;
19 import javax
.xml
.bind
.annotation
.XmlAccessType
;
20 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
21 import javax
.xml
.bind
.annotation
.XmlElement
;
22 import javax
.xml
.bind
.annotation
.XmlIDREF
;
23 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
24 import javax
.xml
.bind
.annotation
.XmlType
;
26 import org
.apache
.log4j
.Logger
;
27 import org
.hibernate
.annotations
.Any
;
28 import org
.hibernate
.annotations
.Cascade
;
29 import org
.hibernate
.annotations
.CascadeType
;
30 import org
.hibernate
.envers
.Audited
;
31 import org
.hibernate
.envers
.NotAudited
;
34 * This class aims to make available some "flags" for identifiable entities in a
35 * flexible way. Application developers (and even users) can define their own
36 * "flags" as a MarkerType.
39 * @created 08-Nov-2007 13:06:33
42 @XmlAccessorType(XmlAccessType
.FIELD
)
43 @XmlType(name
= "Marker")
46 public class Marker
extends VersionableEntity
implements Cloneable
{
47 private static final long serialVersionUID
= -7474489691871404610L;
48 @SuppressWarnings("unused")
49 private static final Logger logger
= Logger
.getLogger(Marker
.class);
51 @XmlElement(name
= "Flag")
54 @XmlElement(name
= "MarkerType")
56 @XmlSchemaType(name
= "IDREF")
57 @ManyToOne(fetch
= FetchType
.LAZY
)
59 private MarkerType markerType
;
61 @XmlElement(name
= "MarkedObject")
63 @XmlSchemaType(name
= "IDREF")
64 @Any(metaDef
= "CdmBase",
66 metaColumn
= @Column(name
="markedObj_type"),
68 @JoinColumn(name
= "markedObj_id")
70 private AnnotatableEntity markedObj
;
76 public static Marker
NewInstance(){
82 * @param markerType The type of the marker
83 * @param flag The value of the marker
86 public static Marker
NewInstance(MarkerType markerType
, boolean flag
){
87 return new Marker(markerType
, flag
);
90 public static Marker
NewInstance(AnnotatableEntity annotatedObject
, boolean flag
, MarkerType markerType
){
91 Marker marker
= new Marker();
93 marker
.setMarkerType(markerType
);
94 annotatedObject
.addMarker(marker
);
108 protected Marker(MarkerType markerType
, boolean flag
){
109 this.markerType
= markerType
;
116 public AnnotatableEntity
getMarkedObj() {
119 public void setMarkedObj(AnnotatableEntity newMarkedObject
) {
120 this.markedObj
= newMarkedObject
;
126 public MarkerType
getMarkerType(){
127 return this.markerType
;
129 public void setMarkerType(MarkerType type
){
130 this.markerType
= type
;
137 public boolean getFlag(){
140 public void setFlag(boolean flag
){
149 public boolean getValue(){
154 //****************** CLONE ************************************************/
158 * @see java.lang.Object#clone()
161 public Object
clone() throws CloneNotSupportedException
{
162 Marker result
= (Marker
)super.clone();
163 result
.setFlag(this.flag
);
164 result
.setMarkerType(this.markerType
);
169 * Clones this marker and sets the clones marked object to 'markedObject'
170 * @see java.lang.Object#clone()
172 public Marker
clone(AnnotatableEntity markedObject
) throws CloneNotSupportedException
{
173 Marker result
= (Marker
)clone();
174 result
.setMarkedObj(markedObject
);