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 eu
.etaxonomy
.cdm
.model
.agent
.Person
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.hibernate
.annotations
.Cascade
;
15 import org
.hibernate
.annotations
.CascadeType
;
17 import java
.net
.MalformedURLException
;
19 import javax
.persistence
.*;
20 import javax
.xml
.bind
.annotation
.XmlAccessType
;
21 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
22 import javax
.xml
.bind
.annotation
.XmlElement
;
23 import javax
.xml
.bind
.annotation
.XmlType
;
28 * @created 08-Nov-2007 13:06:10
30 @XmlAccessorType(XmlAccessType
.FIELD
)
31 @XmlType(name
= "Annotation", propOrder
= {
36 public class Annotation
extends LanguageStringBase
{
37 private static final Logger logger
= Logger
.getLogger(Annotation
.class);
46 public static Annotation
NewInstance(String text
, Language lang
){
47 return new Annotation(text
, lang
);
51 * Factory method. Using default language.
55 public static Annotation
NewDefaultLanguageInstance(String text
){
56 return new Annotation(text
, Language
.DEFAULT());
68 protected Annotation(String text
, Language language
) {
69 super(text
, language
);
74 @XmlElement(name
= "Commentator")
76 //@XmlSchemaType(name = "IDREF")
77 private Person commentator
;
79 @XmlElement(name
= "AnnotatedObject")
81 //@XmlSchemaType(name = "IDREF")
82 private AnnotatableEntity annotatedObj
;
84 // for external annotations/comments the URL of these can be set.
85 // should be useful to implement trackback, pingback or linkback:
86 // http://en.wikipedia.org/wiki/Linkback
87 @XmlElement(name
= "LinkbackURL")
88 private URL linkbackUrl
;
91 public AnnotatableEntity
getAnnotatedObj() {
94 protected void setAnnotatedObj(AnnotatableEntity newAnnotatedObj
) {
95 this.annotatedObj
= newAnnotatedObj
;
99 @Cascade({CascadeType
.SAVE_UPDATE
})
100 public Person
getCommentator(){
101 return this.commentator
;
103 public void setCommentator(Person commentator
){
104 this.commentator
= commentator
;
108 public URL
getLinkbackUrl() {
111 public void setLinkbackUrl(URL linkbackUrl
) {
112 this.linkbackUrl
= linkbackUrl
;
116 * private get/set methods for Hibernate that allows us to save the URL as strings
119 private String
getLinkbackUrlStr() {
120 if (linkbackUrl
== null){
123 return linkbackUrl
.toString();
125 private void setLinkbackUrlStr(String linkbackUrlString
) {
126 if (linkbackUrlString
== null){
127 this.linkbackUrl
= null;
130 this.linkbackUrl
= new URL(linkbackUrlString
);
131 } catch (MalformedURLException e
) { //can't be thrown as otherwise Hibernate throws PropertyAccessExceptioin
132 logger
.warn("Runtime error occurred in setLinkbackUrlStr");