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.reference;
|
11
|
|
12
|
|
13
|
import javax.persistence.Entity;
|
14
|
import javax.persistence.Transient;
|
15
|
import javax.xml.bind.annotation.XmlAccessType;
|
16
|
import javax.xml.bind.annotation.XmlAccessorType;
|
17
|
import javax.xml.bind.annotation.XmlElement;
|
18
|
import javax.xml.bind.annotation.XmlRootElement;
|
19
|
import javax.xml.bind.annotation.XmlTransient;
|
20
|
import javax.xml.bind.annotation.XmlType;
|
21
|
|
22
|
import org.apache.log4j.Logger;
|
23
|
import org.hibernate.envers.Audited;
|
24
|
import org.springframework.beans.factory.annotation.Configurable;
|
25
|
|
26
|
import eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy;
|
27
|
import eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy;
|
28
|
|
29
|
/**
|
30
|
* This class represents books. A book is a {@link PrintedUnitBase printed unit} usually
|
31
|
* published by a publishing company.
|
32
|
* <P>
|
33
|
* This class corresponds, according to the TDWG ontology, to the publication type
|
34
|
* terms (from PublicationTypeTerm): <ul>
|
35
|
* <li> "Book"
|
36
|
* <li> "EditedBook"
|
37
|
* </ul>
|
38
|
*
|
39
|
* @author m.doering
|
40
|
* @version 1.0
|
41
|
* @created 08-Nov-2007 13:06:13
|
42
|
*/
|
43
|
@XmlAccessorType(XmlAccessType.FIELD)
|
44
|
@XmlType(name = "Book", propOrder = {
|
45
|
"edition",
|
46
|
"isbn"
|
47
|
})
|
48
|
@XmlRootElement(name = "Book")
|
49
|
@Entity
|
50
|
@Audited
|
51
|
@Configurable
|
52
|
public class Book extends PrintedUnitBase<INomenclaturalReferenceCacheStrategy<Book>> implements INomenclaturalReference, Cloneable {
|
53
|
@SuppressWarnings("unused")
|
54
|
private static final Logger logger = Logger.getLogger(Book.class);
|
55
|
|
56
|
@XmlElement(name = "Edition")
|
57
|
private String edition;
|
58
|
|
59
|
@XmlElement(name = "ISBN")
|
60
|
private String isbn;
|
61
|
|
62
|
// @XmlTransient
|
63
|
// @Transient
|
64
|
// private NomenclaturalReferenceHelper nomRefBase = NomenclaturalReferenceHelper.NewInstance(this);
|
65
|
|
66
|
/**
|
67
|
* Class constructor: creates a new empty book instance
|
68
|
* only containing the {@link eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy default cache strategy}.
|
69
|
*
|
70
|
* @see eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy
|
71
|
*/
|
72
|
protected Book(){
|
73
|
super();
|
74
|
this.cacheStrategy = BookDefaultCacheStrategy.NewInstance();
|
75
|
}
|
76
|
|
77
|
/**
|
78
|
* Creates a new empty book instance
|
79
|
* only containing the {@link eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy default cache strategy}.
|
80
|
*
|
81
|
* @see #Book()
|
82
|
* @see eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy
|
83
|
*/
|
84
|
public static Book NewInstance(){
|
85
|
return new Book();
|
86
|
}
|
87
|
|
88
|
|
89
|
/**
|
90
|
* Returns the string representing the edition of <i>this</i> book. A book which
|
91
|
* is published once more after having been editorially revised or updated
|
92
|
* corresponds to another superior edition as the book the content of which
|
93
|
* had to be revised or updated (previous edition). Different book editions
|
94
|
* have almost the same content but may differ in layout. Editions are
|
95
|
* therefore essential for accurate citations.
|
96
|
*
|
97
|
* @return the string identifying the edition
|
98
|
*/
|
99
|
public String getEdition(){
|
100
|
return this.edition;
|
101
|
}
|
102
|
/**
|
103
|
* @see #getEdition()
|
104
|
*/
|
105
|
public void setEdition(String edition){
|
106
|
this.edition = edition;
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* Returns the string representing the ISBN (International Standard Book
|
111
|
* Number, a unique numerical commercial book identifier, based upon the
|
112
|
* 9-digit Standard Book Numbering code) of <i>this</i> book.
|
113
|
*
|
114
|
* @return the string representing the ISBN
|
115
|
*/
|
116
|
public String getIsbn(){
|
117
|
return this.isbn;
|
118
|
}
|
119
|
/**
|
120
|
* @see #getIsbn()
|
121
|
*/
|
122
|
public void setIsbn(String isbn){
|
123
|
this.isbn = isbn;
|
124
|
}
|
125
|
|
126
|
|
127
|
/**
|
128
|
* Returns a formatted string containing the entire reference citation,
|
129
|
* including authors, title, edition, volume, series, corresponding to
|
130
|
* <i>this</i> book.<BR>
|
131
|
* This method overrides the generic and inherited getCitation method
|
132
|
* from {@link StrictReferenceBase StrictReferenceBase}.
|
133
|
*
|
134
|
* @see #getNomenclaturalCitation(String)
|
135
|
* @see StrictReferenceBase#getCitation()
|
136
|
*/
|
137
|
// @Transient
|
138
|
// @Override
|
139
|
// public String getCitation(){
|
140
|
// return nomRefBase.getCitation();
|
141
|
// }
|
142
|
|
143
|
/**
|
144
|
* Returns a formatted string containing the entire citation used for
|
145
|
* nomenclatural purposes based on <i>this</i> book - including
|
146
|
* (abbreviated) title but not authors - and on the given
|
147
|
* details.
|
148
|
*
|
149
|
* @param microReference the string with the details (generally pages)
|
150
|
* within <i>this</i> book
|
151
|
* @return the formatted string representing the
|
152
|
* nomenclatural citation
|
153
|
* @see #getCitation()
|
154
|
*/
|
155
|
@Transient
|
156
|
public String getNomenclaturalCitation(String microReference) {
|
157
|
if (cacheStrategy == null){
|
158
|
logger.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid());
|
159
|
return null;
|
160
|
}else{
|
161
|
return cacheStrategy.getNomenclaturalCitation(this,microReference);
|
162
|
}
|
163
|
}
|
164
|
|
165
|
|
166
|
/**
|
167
|
* Generates, according to the {@link eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy default cache strategy}
|
168
|
* assigned to <i>this</i> book, a string that identifies <i>this</i>
|
169
|
* book and returns it. This string may be stored in the inherited
|
170
|
* {@link common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR>
|
171
|
* This method overrides the generic and inherited generateTitle method
|
172
|
* from {@link ReferenceBase ReferenceBase}.
|
173
|
*
|
174
|
* @return the string identifying <i>this</i> book
|
175
|
* @see #getCitation()
|
176
|
* @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
|
177
|
* @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
|
178
|
*/
|
179
|
// @Override
|
180
|
// public String generateTitle(){
|
181
|
// return nomRefBase.generateTitle();
|
182
|
// }
|
183
|
|
184
|
|
185
|
//*********** CLONE **********************************/
|
186
|
|
187
|
/**
|
188
|
* Clones <i>this</i> book. This is a shortcut that enables to
|
189
|
* create a new instance that differs only slightly from <i>this</i> book
|
190
|
* by modifying only some of the attributes.<BR>
|
191
|
* This method overrides the clone method from {@link StrictReferenceBase StrictReferenceBase}.
|
192
|
*
|
193
|
* @see StrictReferenceBase#clone()
|
194
|
* @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
|
195
|
* @see java.lang.Object#clone()
|
196
|
*/
|
197
|
@Override
|
198
|
public Book clone(){
|
199
|
Book result = (Book)super.clone();
|
200
|
result.cacheStrategy = BookDefaultCacheStrategy.NewInstance();
|
201
|
//no changes to: edition, isbn
|
202
|
return result;
|
203
|
}
|
204
|
|
205
|
|
206
|
}
|