(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
13 import org.apache.log4j.Logger;
14 import org.hibernate.annotations.Cascade;
15 import org.hibernate.annotations.CascadeType;
16
17 import java.util.*;
18 import javax.persistence.*;
19
20 /**
21 * This class aims to make available some "flags" for identifiable entities in a
22 * flexible way. Application developers (and even users) can define their own
23 * "flags" as a MarkerType.
24 * @author m.doering
25 * @version 1.0
26 * @created 08-Nov-2007 13:06:33
27 */
28 @Entity
29 public class Marker extends VersionableEntity {
30 static Logger logger = Logger.getLogger(Marker.class);
31 private boolean flag;
32 private MarkerType type;
33 private AnnotatableEntity markedObj;
34
35 @Transient
36 public AnnotatableEntity getMarkedObj() {
37 return markedObj;
38 }
39 protected void setMarkedObj(AnnotatableEntity newMarkedObject) {
40 // Hibernate bidirectional cascade hack:
41 // http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
42 if(this.markedObj == newMarkedObject) return;
43 if (markedObj != null) {
44 markedObj.markers.remove(this);
45 }
46 if (newMarkedObject!= null) {
47 newMarkedObject.markers.add(this);
48 }
49 this.markedObj = newMarkedObject;
50 }
51
52 @ManyToOne
53 @Cascade({CascadeType.SAVE_UPDATE})
54 public MarkerType getType(){
55 return this.type;
56 }
57 public void setType(MarkerType type){
58 this.type = type;
59 }
60
61 public boolean getFlag(){
62 return this.flag;
63 }
64 public void setFlag(boolean flag){
65 this.flag = flag;
66 }
67
68 }