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
.occurrence
;
13 import javax
.persistence
.Entity
;
14 import javax
.persistence
.FetchType
;
15 import javax
.persistence
.ManyToOne
;
16 import javax
.xml
.bind
.annotation
.XmlAccessType
;
17 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
18 import javax
.xml
.bind
.annotation
.XmlElement
;
19 import javax
.xml
.bind
.annotation
.XmlIDREF
;
20 import javax
.xml
.bind
.annotation
.XmlRootElement
;
21 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
22 import javax
.xml
.bind
.annotation
.XmlType
;
24 import org
.apache
.log4j
.Logger
;
25 import org
.hibernate
.annotations
.Cascade
;
26 import org
.hibernate
.annotations
.CascadeType
;
27 import org
.hibernate
.annotations
.Index
;
28 import org
.hibernate
.annotations
.Table
;
29 import org
.hibernate
.envers
.Audited
;
30 import org
.hibernate
.search
.annotations
.Field
;
31 import org
.hibernate
.search
.annotations
.Indexed
;
32 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
33 import org
.springframework
.beans
.factory
.annotation
.Configurable
;
35 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
36 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
37 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IIdentifiableEntityCacheStrategy
;
38 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IdentifiableEntityDefaultCacheStrategy
;
43 * @created 08-Nov-2007 13:06:16
45 @XmlAccessorType(XmlAccessType
.FIELD
)
46 @XmlType(name
= "Collection", propOrder
= {
54 @XmlRootElement(name
= "Collection")
59 @Table(appliesTo
="Collection", indexes
= { @Index(name
= "collectionTitleCacheIndex", columnNames
= { "titleCache" }) })
60 public class Collection
extends IdentifiableMediaEntity
<IIdentifiableEntityCacheStrategy
<Collection
>> implements Cloneable
{
64 private static final long serialVersionUID
= -7833674897174732255L;
66 private static final Logger logger
= Logger
.getLogger(Collection
.class);
68 @XmlElement(name
= "Code")
69 @Field(index
=org
.hibernate
.search
.annotations
.Index
.UN_TOKENIZED
)
72 @XmlElement(name
= "CodeStandard")
73 @Field(index
=org
.hibernate
.search
.annotations
.Index
.UN_TOKENIZED
)
74 private String codeStandard
;
76 @XmlElement(name
= "Name")
77 @Field(index
=org
.hibernate
.search
.annotations
.Index
.TOKENIZED
)
80 @XmlElement(name
= "TownOrLocation")
81 @Field(index
=org
.hibernate
.search
.annotations
.Index
.TOKENIZED
)
82 private String townOrLocation
;
84 @XmlElement(name
= "Institution")
86 @XmlSchemaType(name
= "IDREF")
87 @ManyToOne(fetch
= FetchType
.LAZY
)
88 @Cascade(CascadeType
.SAVE_UPDATE
)
90 private Institution institute
;
92 @XmlElement(name
= "SuperCollection")
94 @XmlSchemaType(name
= "IDREF")
95 @ManyToOne(fetch
= FetchType
.LAZY
)
96 @Cascade(CascadeType
.SAVE_UPDATE
)
97 private Collection superCollection
;
104 public static Collection
NewInstance(){
105 return new Collection();
111 protected Collection() {
113 this.cacheStrategy
= new IdentifiableEntityDefaultCacheStrategy
<Collection
>();
116 public Institution
getInstitute(){
117 return this.institute
;
122 * @param institute institute
124 public void setInstitute(Institution institute
){
125 this.institute
= institute
;
128 public String
getCode(){
136 public void setCode(String code
){
140 public String
getCodeStandard(){
141 return this.codeStandard
;
146 * @param codeStandard codeStandard
148 public void setCodeStandard(String codeStandard
){
149 this.codeStandard
= codeStandard
;
152 public String
getName(){
160 public void setName(String name
){
164 public String
getTownOrLocation(){
165 return this.townOrLocation
;
170 * @param townOrLocation townOrLocation
172 public void setTownOrLocation(String townOrLocation
){
173 this.townOrLocation
= townOrLocation
;
177 // public String generateTitle(){
181 public Collection
getSuperCollection() {
182 return superCollection
;
185 public void setSuperCollection(Collection superCollection
) {
186 this.superCollection
= superCollection
;
190 //*********** CLONE **********************************/
193 * Clones <i>this</i> collection. This is a shortcut that enables to
194 * create a new instance that differs only slightly from <i>this</i> collection
195 * by modifying only some of the attributes.<BR>
196 * This method overrides the clone method from {@link IdentifiableMediaEntity IdentifiableMediaEntity}.
198 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
199 * @see java.lang.Object#clone()
202 public Collection
clone(){
204 Collection result
= (Collection
)super.clone();
206 result
.setSuperCollection(this.superCollection
);
208 result
.setInstitute(this.institute
);
209 //no changes to: code, codeStandard, name, townOrLocation
211 } catch (CloneNotSupportedException e
) {
212 logger
.warn("Object does not implement cloneable");