import org.hibernate.annotations.CascadeType;
import javax.persistence.*;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
/**
* This class aims to make available some "flags" for identifiable entities in a
* @version 1.0
* @created 08-Nov-2007 13:06:33
*/
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "Marker")
@Entity
-public class Marker extends VersionableEntity {
+public class Marker extends VersionableEntity implements Cloneable{
private static final Logger logger = Logger.getLogger(Marker.class);
+ @XmlElement(name = "Flag")
private boolean flag;
+
+ @XmlElement(name = "MarkerType")
private MarkerType markerType;
+
+ @XmlElement(name = "MarkedObject")
private AnnotatableEntity markedObj;
+ /**
+ * Factory method
+ * @return
+ */
+ public static Marker NewInstance(){
+ return new Marker();
+ }
+
/**
* Factory method
* @param markerType The type of the marker
return new Marker(markerType, flag);
}
+ /**
+ * Default Constructor
+ */
+ private Marker() {
+ }
+
/**
* Constructor
- * @param flage
+ * @param flag
*/
protected Marker(MarkerType markerType, boolean flag){
this.markerType = markerType;
this.flag = flag;
-
}
/**
return markedObj;
}
protected void setMarkedObj(AnnotatableEntity newMarkedObject) {
- // Hibernate bidirectional cascade hack:
- // http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
- if(this.markedObj == newMarkedObject) return;
- if (markedObj != null) {
- markedObj.markers.remove(this);
- }
- if (newMarkedObject!= null) {
- newMarkedObject.markers.add(this);
- }
this.markedObj = newMarkedObject;
}
public void setFlag(boolean flag){
this.flag = flag;
}
+
+
+//****************** CLONE ************************************************/
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException{
+ Marker result = (Marker)super.clone();
+ //no changes to: type, flag
+ return result;
+ }
+
+ /**
+ * Clones this marker and sets the clones marked object to 'markedObject'
+ * @see java.lang.Object#clone()
+ */
+ public Marker clone(AnnotatableEntity markedObject) throws CloneNotSupportedException{
+ Marker result = (Marker)clone();
+ result.setMarkedObj(markedObject);
+ return result;
+ }
}
\ No newline at end of file