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
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.hibernate
.annotations
.Cascade
;
15 import org
.hibernate
.annotations
.CascadeType
;
18 import java
.util
.HashSet
;
21 import javax
.persistence
.*;
26 * @created 08-Nov-2007 13:06:27
29 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
30 public abstract class IdentifiableEntity
<T
extends IdentifiableEntity
> extends AnnotatableEntity
<T
> implements IOriginalSource
{
31 static Logger logger
= Logger
.getLogger(IdentifiableEntity
.class);
34 private String titleCache
;
35 //if true titleCache will not be automatically generated/updated
36 private boolean protectedTitleCache
;
37 private Set
<Rights
> rights
= new HashSet();
38 private Set
<Extension
> extensions
= new HashSet();
39 private Set
<OriginalSource
> sources
= new HashSet();
41 public IdentifiableEntity() {
46 public String
getLsid(){
49 public void setLsid(String lsid
){
53 public abstract String
generateTitle();
55 public String
getTitleCache(){
56 if (protectedTitleCache
){
57 return this.titleCache
;
59 // is title dirty, i.e. equal NULL?
60 if (titleCache
== null){
61 this.titleCache
= generateTitle();
65 public void setTitleCache(String titleCache
){
66 this.titleCache
= titleCache
;
67 this.setProtectedTitleCache(true);
71 @Cascade({CascadeType
.SAVE_UPDATE
})
72 public Set
<Rights
> getRights(){
76 protected void setRights(Set
<Rights
> rights
) {
79 public void addRights(Rights right
){
80 this.rights
.add(right
);
82 public void removeRights(Rights right
){
83 this.rights
.remove(right
);
86 @OneToMany//(mappedBy="extendedObj")
87 @Cascade({CascadeType
.SAVE_UPDATE
})
88 public Set
<Extension
> getExtensions(){
89 return this.extensions
;
91 protected void setExtensions(Set
<Extension
> extensions
) {
92 this.extensions
= extensions
;
94 public void addExtension(Extension extension
){
95 this.extensions
.add(extension
);
97 public void removeExtension(Extension extension
){
98 this.extensions
.remove(extension
);
102 public boolean isProtectedTitleCache() {
103 return protectedTitleCache
;
106 public void setProtectedTitleCache(boolean protectedTitleCache
) {
107 this.protectedTitleCache
= protectedTitleCache
;
111 @OneToMany //(mappedBy="sourcedObj")
112 @Cascade({CascadeType
.SAVE_UPDATE
})
113 public Set
<OriginalSource
> getSources() {
117 protected void setSources(Set
<OriginalSource
> sources
) {
118 this.sources
= sources
;
121 public void addSource(OriginalSource source
) {
122 this.sources
.add(source
);
125 public void removeSource(OriginalSource source
) {
126 this.sources
.remove(source
);