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
.Entity
;
13 import javax
.persistence
.FetchType
;
14 import javax
.persistence
.ManyToOne
;
15 import javax
.persistence
.Transient
;
16 import javax
.validation
.constraints
.NotNull
;
17 import javax
.xml
.bind
.annotation
.XmlAccessType
;
18 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
19 import javax
.xml
.bind
.annotation
.XmlElement
;
20 import javax
.xml
.bind
.annotation
.XmlIDREF
;
21 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
22 import javax
.xml
.bind
.annotation
.XmlType
;
24 import org
.apache
.log4j
.Logger
;
25 import org
.hibernate
.envers
.Audited
;
27 import eu
.etaxonomy
.cdm
.validation
.Level2
;
30 * This class aims to make available some "flags" for identifiable entities in a
31 * flexible way. Application developers (and even users) can define their own
32 * "flags" as a MarkerType.
34 * @since 08-Nov-2007 13:06:33
37 @XmlAccessorType(XmlAccessType
.FIELD
)
38 @XmlType(name
= "Marker")
41 public class Marker
extends VersionableEntity
implements Cloneable
{
42 private static final long serialVersionUID
= -7474489691871404610L;
43 @SuppressWarnings("unused")
44 private static final Logger logger
= Logger
.getLogger(Marker
.class);
46 @XmlElement(name
= "Flag")
49 @XmlElement(name
= "MarkerType")
51 @XmlSchemaType(name
= "IDREF")
52 @ManyToOne(fetch
= FetchType
.LAZY
)
53 @NotNull(groups
=Level2
.class) //removed from Level1 for now, see #4588
54 private MarkerType markerType
;
56 // *********************** FACTORY *****************************/
62 public static Marker
NewInstance(){
68 * @param markerType The type of the marker
69 * @param flag The value of the marker
72 public static Marker
NewInstance(MarkerType markerType
, boolean flag
){
73 return new Marker(markerType
, flag
);
76 public static Marker
NewInstance(AnnotatableEntity markedObject
, boolean flag
, MarkerType markerType
){
77 Marker marker
= new Marker();
79 marker
.setMarkerType(markerType
);
80 markedObject
.addMarker(marker
);
84 //************************** CONSTRUCTOR **********************************/
96 protected Marker(MarkerType markerType
, boolean flag
){
97 this.markerType
= markerType
;
101 // ****************************** GETTER / SETTER ***************************/
106 public MarkerType
getMarkerType(){
107 return this.markerType
;
109 public void setMarkerType(MarkerType type
){
110 this.markerType
= type
;
117 public boolean getFlag(){
120 public void setFlag(boolean flag
){
129 public boolean getValue(){
134 //****************** CLONE ************************************************/
137 public Object
clone() throws CloneNotSupportedException
{
138 Marker result
= (Marker
)super.clone();
139 result
.setFlag(this.flag
);
140 result
.setMarkerType(this.markerType
);