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
.*;
24 * @created 08-Nov-2007 13:06:10
27 public class Annotation
extends LanguageStringBase
{
28 private static final Logger logger
= Logger
.getLogger(Annotation
.class);
37 public static Annotation
NewInstance(String text
, Language lang
){
38 return new Annotation(text
, lang
);
42 * Factory method. Using default language.
46 public static Annotation
NewDefaultLanguageInstance(String text
){
47 return new Annotation(text
, Language
.DEFAULT());
59 protected Annotation(String text
, Language language
) {
60 super(text
, language
);
66 private Person commentator
;
67 private AnnotatableEntity annotatedObj
;
68 // for external annotations/comments the URL of these can be set.
69 // should be useful to implement trackback, pingback or linkback:
70 // http://en.wikipedia.org/wiki/Linkback
71 private URL linkbackUrl
;
74 public AnnotatableEntity
getAnnotatedObj() {
77 protected void setAnnotatedObj(AnnotatableEntity newAnnotatedObj
) {
78 this.annotatedObj
= newAnnotatedObj
;
82 @Cascade({CascadeType
.SAVE_UPDATE
})
83 public Person
getCommentator(){
84 return this.commentator
;
86 public void setCommentator(Person commentator
){
87 this.commentator
= commentator
;
91 public URL
getLinkbackUrl() {
94 public void setLinkbackUrl(URL linkbackUrl
) {
95 this.linkbackUrl
= linkbackUrl
;
99 * private get/set methods for Hibernate that allows us to save the URL as strings
102 private String
getLinkbackUrlStr() {
103 if (linkbackUrl
== null){
106 return linkbackUrl
.toString();
108 private void setLinkbackUrlStr(String linkbackUrlString
) {
109 if (linkbackUrlString
== null){
110 this.linkbackUrl
= null;
113 this.linkbackUrl
= new URL(linkbackUrlString
);
114 } catch (MalformedURLException e
) { //can't be thrown as otherwise Hibernate throws PropertyAccessExceptioin
115 logger
.warn("Runtime error occurred in setLinkbackUrlStr");