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