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
.envers
.Audited
;
29 import org
.hibernate
.envers
.NotAudited
;
32 * This class aims to make available some "flags" for identifiable entities in a
33 * flexible way. Application developers (and even users) can define their own
34 * "flags" as a MarkerType.
37 * @created 08-Nov-2007 13:06:33
40 @XmlAccessorType(XmlAccessType
.FIELD
)
41 @XmlType(name
= "Marker")
44 public class Marker
extends VersionableEntity
implements Cloneable
{
45 private static final long serialVersionUID
= -7474489691871404610L;
46 @SuppressWarnings("unused")
47 private static final Logger logger
= Logger
.getLogger(Marker
.class);
49 @XmlElement(name
= "Flag")
52 @XmlElement(name
= "MarkerType")
54 @XmlSchemaType(name
= "IDREF")
55 @ManyToOne(fetch
= FetchType
.LAZY
)
57 private MarkerType markerType
;
59 @XmlElement(name
= "MarkedObject")
61 @XmlSchemaType(name
= "IDREF")
62 @Any(metaDef
= "CdmBase",
64 metaColumn
= @Column(name
="markedObj_type"),
66 @JoinColumn(name
= "markedObj_id")
68 private AnnotatableEntity markedObj
;
74 public static Marker
NewInstance(){
80 * @param markerType The type of the marker
81 * @param flag The value of the marker
84 public static Marker
NewInstance(MarkerType markerType
, boolean flag
){
85 return new Marker(markerType
, flag
);
88 public static Marker
NewInstance(AnnotatableEntity annotatedObject
, boolean flag
, MarkerType markerType
){
89 Marker marker
= new Marker();
91 marker
.setMarkerType(markerType
);
92 annotatedObject
.addMarker(marker
);
106 protected Marker(MarkerType markerType
, boolean flag
){
107 this.markerType
= markerType
;
114 public AnnotatableEntity
getMarkedObj() {
117 public void setMarkedObj(AnnotatableEntity newMarkedObject
) {
118 this.markedObj
= newMarkedObject
;
124 public MarkerType
getMarkerType(){
125 return this.markerType
;
127 public void setMarkerType(MarkerType type
){
128 this.markerType
= type
;
135 public boolean getFlag(){
138 public void setFlag(boolean flag
){
147 public boolean getValue(){
152 //****************** CLONE ************************************************/
156 * @see java.lang.Object#clone()
159 public Object
clone() throws CloneNotSupportedException
{
160 Marker result
= (Marker
)super.clone();
161 result
.setFlag(this.flag
);
162 result
.setMarkerType(this.markerType
);
167 * Clones this marker and sets the clones marked object to 'markedObject'
168 * @see java.lang.Object#clone()
170 public Marker
clone(AnnotatableEntity markedObject
) throws CloneNotSupportedException
{
171 Marker result
= (Marker
)clone();
172 result
.setMarkedObj(markedObject
);