(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / Marker.java
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 javax.persistence.*;
17
18 /**
19 * This class aims to make available some "flags" for identifiable entities in a
20 * flexible way. Application developers (and even users) can define their own
21 * "flags" as a MarkerType.
22 * @author m.doering
23 * @version 1.0
24 * @created 08-Nov-2007 13:06:33
25 */
26 @Entity
27 public class Marker extends VersionableEntity {
28 private static final Logger logger = Logger.getLogger(Marker.class);
29
30 private boolean flag;
31 private MarkerType markerType;
32 private AnnotatableEntity markedObj;
33
34 /**
35 * Factory method
36 * @param markerType The type of the marker
37 * @param flag The value of the marker
38 * @return
39 */
40 public static Marker NewInstance(MarkerType markerType, boolean flag){
41 return new Marker(markerType, flag);
42 }
43
44 /**
45 * Constructor
46 * @param flage
47 */
48 protected Marker(MarkerType markerType, boolean flag){
49 this.markerType = markerType;
50 this.flag = flag;
51
52 }
53
54 /**
55 * @return
56 */
57 @Transient
58 public AnnotatableEntity getMarkedObj() {
59 return markedObj;
60 }
61 protected void setMarkedObj(AnnotatableEntity newMarkedObject) {
62 this.markedObj = newMarkedObject;
63 }
64
65 /**
66 * @return
67 */
68 @ManyToOne
69 @Cascade({CascadeType.SAVE_UPDATE})
70 public MarkerType getMarkerType(){
71 return this.markerType;
72 }
73 public void setMarkerType(MarkerType type){
74 this.markerType = type;
75 }
76
77 /**
78 * The flag value.
79 * @return
80 */
81 public boolean getFlag(){
82 return this.flag;
83 }
84 public void setFlag(boolean flag){
85 this.flag = flag;
86 }
87
88 }