1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.model.occurrence;
|
11
|
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.agent.Institution;
|
14
|
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
import org.hibernate.annotations.Cascade;
|
18
|
import org.hibernate.annotations.CascadeType;
|
19
|
import org.hibernate.annotations.Index;
|
20
|
import org.hibernate.annotations.Table;
|
21
|
|
22
|
import javax.persistence.*;
|
23
|
import javax.xml.bind.annotation.XmlAccessType;
|
24
|
import javax.xml.bind.annotation.XmlAccessorType;
|
25
|
import javax.xml.bind.annotation.XmlElement;
|
26
|
import javax.xml.bind.annotation.XmlIDREF;
|
27
|
import javax.xml.bind.annotation.XmlRootElement;
|
28
|
import javax.xml.bind.annotation.XmlSchemaType;
|
29
|
import javax.xml.bind.annotation.XmlType;
|
30
|
|
31
|
/**
|
32
|
* @author m.doering
|
33
|
* @version 1.0
|
34
|
* @created 08-Nov-2007 13:06:16
|
35
|
*/
|
36
|
@XmlAccessorType(XmlAccessType.FIELD)
|
37
|
@XmlType(name = "Collection", propOrder = {
|
38
|
"name",
|
39
|
"code",
|
40
|
"codeStandard",
|
41
|
"townOrLocation",
|
42
|
"institute",
|
43
|
"superCollection"
|
44
|
})
|
45
|
@XmlRootElement(name = "Collection")
|
46
|
@Entity
|
47
|
@Table(appliesTo="Collection", indexes = { @Index(name = "collectionTitleCacheIndex", columnNames = { "titleCache" }) })
|
48
|
public class Collection extends IdentifiableMediaEntity implements Cloneable{
|
49
|
private static final Logger logger = Logger.getLogger(Collection.class);
|
50
|
|
51
|
@XmlElement(name = "Code")
|
52
|
private String code;
|
53
|
|
54
|
@XmlElement(name = "CodeStandard")
|
55
|
private String codeStandard;
|
56
|
|
57
|
@XmlElement(name = "Name")
|
58
|
private String name;
|
59
|
|
60
|
@XmlElement(name = "TownOrLocation")
|
61
|
private String townOrLocation;
|
62
|
|
63
|
@XmlElement(name = "Institution")
|
64
|
@XmlIDREF
|
65
|
@XmlSchemaType(name = "IDREF")
|
66
|
private Institution institute;
|
67
|
|
68
|
@XmlElement(name = "SuperCollection")
|
69
|
@XmlIDREF
|
70
|
@XmlSchemaType(name = "IDREF")
|
71
|
private Collection superCollection;
|
72
|
|
73
|
|
74
|
/**
|
75
|
* Factory method
|
76
|
* @return
|
77
|
*/
|
78
|
public static Collection NewInstance(){
|
79
|
return new Collection();
|
80
|
}
|
81
|
|
82
|
/**
|
83
|
* Constructor
|
84
|
*/
|
85
|
protected Collection() {
|
86
|
super();
|
87
|
}
|
88
|
|
89
|
|
90
|
@ManyToOne
|
91
|
@Cascade({CascadeType.SAVE_UPDATE})
|
92
|
public Institution getInstitute(){
|
93
|
return this.institute;
|
94
|
}
|
95
|
|
96
|
/**
|
97
|
*
|
98
|
* @param institute institute
|
99
|
*/
|
100
|
public void setInstitute(Institution institute){
|
101
|
this.institute = institute;
|
102
|
}
|
103
|
|
104
|
public String getCode(){
|
105
|
return this.code;
|
106
|
}
|
107
|
|
108
|
/**
|
109
|
*
|
110
|
* @param code code
|
111
|
*/
|
112
|
public void setCode(String code){
|
113
|
this.code = code;
|
114
|
}
|
115
|
|
116
|
public String getCodeStandard(){
|
117
|
return this.codeStandard;
|
118
|
}
|
119
|
|
120
|
/**
|
121
|
*
|
122
|
* @param codeStandard codeStandard
|
123
|
*/
|
124
|
public void setCodeStandard(String codeStandard){
|
125
|
this.codeStandard = codeStandard;
|
126
|
}
|
127
|
|
128
|
public String getName(){
|
129
|
return this.name;
|
130
|
}
|
131
|
|
132
|
/**
|
133
|
*
|
134
|
* @param name name
|
135
|
*/
|
136
|
public void setName(String name){
|
137
|
this.name = name;
|
138
|
}
|
139
|
|
140
|
public String getTownOrLocation(){
|
141
|
return this.townOrLocation;
|
142
|
}
|
143
|
|
144
|
/**
|
145
|
*
|
146
|
* @param townOrLocation townOrLocation
|
147
|
*/
|
148
|
public void setTownOrLocation(String townOrLocation){
|
149
|
this.townOrLocation = townOrLocation;
|
150
|
}
|
151
|
|
152
|
@Override
|
153
|
public String generateTitle(){
|
154
|
return "";
|
155
|
}
|
156
|
|
157
|
@ManyToOne
|
158
|
@Cascade({CascadeType.SAVE_UPDATE})
|
159
|
public Collection getSuperCollection() {
|
160
|
return superCollection;
|
161
|
}
|
162
|
|
163
|
public void setSuperCollection(Collection superCollection) {
|
164
|
this.superCollection = superCollection;
|
165
|
}
|
166
|
|
167
|
|
168
|
//*********** CLONE **********************************/
|
169
|
|
170
|
/**
|
171
|
* Clones <i>this</i> collection. This is a shortcut that enables to
|
172
|
* create a new instance that differs only slightly from <i>this</i> collection
|
173
|
* by modifying only some of the attributes.<BR>
|
174
|
* This method overrides the clone method from {@link IdentifiableMediaEntity IdentifiableMediaEntity}.
|
175
|
*
|
176
|
* @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
|
177
|
* @see java.lang.Object#clone()
|
178
|
*/
|
179
|
@Override
|
180
|
public Collection clone(){
|
181
|
try{
|
182
|
Collection result = (Collection)super.clone();
|
183
|
//superCollection
|
184
|
result.setSuperCollection(this.superCollection);
|
185
|
//institute
|
186
|
result.setInstitute(this.institute);
|
187
|
//no changes to: code, codeStandard, name, townOrLocation
|
188
|
return result;
|
189
|
} catch (CloneNotSupportedException e) {
|
190
|
logger.warn("Object does not implement cloneable");
|
191
|
e.printStackTrace();
|
192
|
return null;
|
193
|
}
|
194
|
}
|
195
|
|
196
|
|
197
|
|
198
|
}
|