| 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 java.net.URI; |
|---|
| 14 | import java.util.List; |
|---|
| 15 | |
|---|
| 16 | import javax.persistence.Column; |
|---|
| 17 | import javax.persistence.Embedded; |
|---|
| 18 | import javax.persistence.Entity; |
|---|
| 19 | import javax.persistence.FetchType; |
|---|
| 20 | import javax.persistence.Inheritance; |
|---|
| 21 | import javax.persistence.InheritanceType; |
|---|
| 22 | import javax.persistence.Lob; |
|---|
| 23 | import javax.persistence.ManyToOne; |
|---|
| 24 | import javax.persistence.Transient; |
|---|
| 25 | import javax.validation.constraints.Pattern; |
|---|
| 26 | import javax.xml.bind.annotation.XmlAccessType; |
|---|
| 27 | import javax.xml.bind.annotation.XmlAccessorType; |
|---|
| 28 | import javax.xml.bind.annotation.XmlAttribute; |
|---|
| 29 | import javax.xml.bind.annotation.XmlElement; |
|---|
| 30 | import javax.xml.bind.annotation.XmlIDREF; |
|---|
| 31 | import javax.xml.bind.annotation.XmlRootElement; |
|---|
| 32 | import javax.xml.bind.annotation.XmlSchemaType; |
|---|
| 33 | import javax.xml.bind.annotation.XmlType; |
|---|
| 34 | |
|---|
| 35 | import org.apache.commons.lang.StringUtils; |
|---|
| 36 | import org.apache.log4j.Logger; |
|---|
| 37 | import org.hibernate.annotations.Cascade; |
|---|
| 38 | import org.hibernate.annotations.CascadeType; |
|---|
| 39 | import org.hibernate.annotations.Table; |
|---|
| 40 | import org.hibernate.annotations.Type; |
|---|
| 41 | import org.hibernate.envers.Audited; |
|---|
| 42 | import org.hibernate.search.annotations.Field; |
|---|
| 43 | import org.hibernate.search.annotations.Index; |
|---|
| 44 | import org.hibernate.search.annotations.IndexedEmbedded; |
|---|
| 45 | import org.hibernate.validator.constraints.Length; |
|---|
| 46 | |
|---|
| 47 | import eu.etaxonomy.cdm.model.agent.Institution; |
|---|
| 48 | import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|---|
| 49 | import eu.etaxonomy.cdm.model.common.TimePeriod; |
|---|
| 50 | import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity; |
|---|
| 51 | import eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy; |
|---|
| 52 | import eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy; |
|---|
| 53 | import eu.etaxonomy.cdm.strategy.cache.reference.BookSectionDefaultCacheStrategy; |
|---|
| 54 | import eu.etaxonomy.cdm.strategy.cache.reference.GenericDefaultCacheStrategy; |
|---|
| 55 | import eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy; |
|---|
| 56 | import eu.etaxonomy.cdm.strategy.cache.reference.IReferenceBaseCacheStrategy; |
|---|
| 57 | import eu.etaxonomy.cdm.strategy.cache.reference.JournalDefaultCacheStrategy; |
|---|
| 58 | import eu.etaxonomy.cdm.strategy.cache.reference.ReferenceBaseDefaultCacheStrategy; |
|---|
| 59 | import eu.etaxonomy.cdm.strategy.match.Match; |
|---|
| 60 | import eu.etaxonomy.cdm.strategy.match.MatchMode; |
|---|
| 61 | import eu.etaxonomy.cdm.strategy.merge.Merge; |
|---|
| 62 | import eu.etaxonomy.cdm.strategy.merge.MergeMode; |
|---|
| 63 | import eu.etaxonomy.cdm.strategy.parser.ParserProblem; |
|---|
| 64 | import eu.etaxonomy.cdm.validation.Level2; |
|---|
| 65 | import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty; |
|---|
| 66 | import eu.etaxonomy.cdm.validation.annotation.InReference; |
|---|
| 67 | import eu.etaxonomy.cdm.validation.annotation.ReferenceCheck; |
|---|
| 68 | |
|---|
| 69 | /** |
|---|
| 70 | * The upmost (abstract) class for references (information sources). |
|---|
| 71 | * <P> |
|---|
| 72 | * This class corresponds to: <ul> |
|---|
| 73 | * <li> PublicationCitation according to the TDWG ontology |
|---|
| 74 | * <li> Publication according to the TCS |
|---|
| 75 | * <li> Reference according to the ABCD schema |
|---|
| 76 | * </ul> |
|---|
| 77 | * |
|---|
| 78 | * @author m.doering |
|---|
| 79 | * @version 1.0 |
|---|
| 80 | * @created 08-Nov-2007 13:06:47 |
|---|
| 81 | */ |
|---|
| 82 | @XmlAccessorType(XmlAccessType.FIELD) |
|---|
| 83 | @XmlType(name = "Reference", propOrder = { |
|---|
| 84 | "type", |
|---|
| 85 | "uri", |
|---|
| 86 | "nomenclaturallyRelevant", |
|---|
| 87 | "authorTeam", |
|---|
| 88 | "referenceAbstract", |
|---|
| 89 | "title", |
|---|
| 90 | "editor", |
|---|
| 91 | "volume", |
|---|
| 92 | "pages", |
|---|
| 93 | "series", |
|---|
| 94 | "edition", |
|---|
| 95 | "isbn", |
|---|
| 96 | "issn", |
|---|
| 97 | "seriesPart", |
|---|
| 98 | "datePublished", |
|---|
| 99 | "publisher", |
|---|
| 100 | "placePublished", |
|---|
| 101 | "institution", |
|---|
| 102 | "school", |
|---|
| 103 | "organization", |
|---|
| 104 | "inReference" |
|---|
| 105 | // ,"fullReference", |
|---|
| 106 | // "abbreviatedReference" |
|---|
| 107 | }) |
|---|
| 108 | @XmlRootElement(name = "Reference") |
|---|
| 109 | @Entity |
|---|
| 110 | @Inheritance(strategy=InheritanceType.SINGLE_TABLE) |
|---|
| 111 | @Audited |
|---|
| 112 | @javax.persistence.Table(name="Reference") |
|---|
| 113 | @Table(appliesTo="Reference", indexes = { @org.hibernate.annotations.Index(name = "ReferenceTitleCacheIndex", columnNames = { "titleCache" }) }) |
|---|
| 114 | @InReference(groups = Level2.class) |
|---|
| 115 | @ReferenceCheck(groups = Level2.class) |
|---|
| 116 | //public abstract class Reference<S extends IReferenceBaseCacheStrategy> extends IdentifiableMediaEntity<S> implements IParsable, IMergable, IMatchable, IArticle, IBook, IJournal, IBookSection,ICdDvd,IGeneric,IInProceedings, IProceedings, IPrintSeries, IReport, IThesis,IWebPage { |
|---|
| 117 | public class Reference<S extends IReferenceBaseCacheStrategy> extends IdentifiableMediaEntity<S> implements INomenclaturalReference, IArticle, IBook, IPatent, IDatabase, IJournal, IBookSection,ICdDvd,IGeneric,IInProceedings, IProceedings, IPrintSeries, IReport, IThesis,IWebPage, IPersonalCommunication, IReference, Cloneable { |
|---|
| 118 | private static final long serialVersionUID = -2034764545042691295L; |
|---|
| 119 | private static final Logger logger = Logger.getLogger(Reference.class); |
|---|
| 120 | |
|---|
| 121 | @XmlAttribute(name ="type") |
|---|
| 122 | @Column(name="refType") |
|---|
| 123 | protected ReferenceType type; |
|---|
| 124 | |
|---|
| 125 | //Title of the reference |
|---|
| 126 | @XmlElement(name ="Title" ) |
|---|
| 127 | @Column(length=4096, name="title") |
|---|
| 128 | @Lob |
|---|
| 129 | @Field(index=Index.TOKENIZED) |
|---|
| 130 | @Match(MatchMode.EQUAL_REQUIRED) |
|---|
| 131 | @NullOrNotEmpty |
|---|
| 132 | @Length(max = 4096) |
|---|
| 133 | private String title; |
|---|
| 134 | |
|---|
| 135 | //********************************************************/ |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | @XmlElement(name = "Editor") |
|---|
| 139 | @Field(index=Index.TOKENIZED) |
|---|
| 140 | @NullOrNotEmpty |
|---|
| 141 | @Length(max = 255) |
|---|
| 142 | protected String editor; |
|---|
| 143 | |
|---|
| 144 | @XmlElement(name = "Series") |
|---|
| 145 | @Field(index=Index.TOKENIZED) |
|---|
| 146 | @NullOrNotEmpty |
|---|
| 147 | @Length(max = 255) |
|---|
| 148 | protected String series; |
|---|
| 149 | |
|---|
| 150 | @XmlElement(name = "Volume") |
|---|
| 151 | @Field(index=Index.TOKENIZED) |
|---|
| 152 | @NullOrNotEmpty |
|---|
| 153 | @Length(max = 255) |
|---|
| 154 | protected String volume; |
|---|
| 155 | |
|---|
| 156 | @XmlElement(name = "Pages") |
|---|
| 157 | @Field(index=Index.TOKENIZED) |
|---|
| 158 | @NullOrNotEmpty |
|---|
| 159 | @Length(max = 255) |
|---|
| 160 | protected String pages; |
|---|
| 161 | |
|---|
| 162 | @XmlElement(name = "Edition") |
|---|
| 163 | @Field(index=Index.TOKENIZED) |
|---|
| 164 | @NullOrNotEmpty |
|---|
| 165 | @Length(max = 255) |
|---|
| 166 | protected String edition; |
|---|
| 167 | |
|---|
| 168 | @XmlElement(name = "ISBN") |
|---|
| 169 | @Field(index=Index.TOKENIZED) |
|---|
| 170 | @NullOrNotEmpty |
|---|
| 171 | @Length(max = 255) |
|---|
| 172 | @Pattern(regexp = "(?=.{13}$)\\d{1,5}([- ])\\d{1,7}\\1\\d{1,6}\\1(\\d|X)$", groups = Level2.class, message = "{eu.etaxonomy.cdm.model.reference.Reference.isbn.message}") |
|---|
| 173 | protected String isbn; |
|---|
| 174 | |
|---|
| 175 | @XmlElement(name = "ISSN") |
|---|
| 176 | @Field(index=Index.TOKENIZED) |
|---|
| 177 | @NullOrNotEmpty |
|---|
| 178 | @Length(max = 255) |
|---|
| 179 | @Pattern(regexp = "(?=.{9}$)\\d{4}([- ])\\d{4} (\\d|X)$", groups = Level2.class, message = "{eu.etaxonomy.cdm.model.reference.Reference.issn.message}") |
|---|
| 180 | protected String issn; |
|---|
| 181 | |
|---|
| 182 | @XmlElement(name = "SeriesPart") |
|---|
| 183 | @Field(index=Index.TOKENIZED) |
|---|
| 184 | @NullOrNotEmpty |
|---|
| 185 | @Length(max = 255) |
|---|
| 186 | protected String seriesPart; |
|---|
| 187 | |
|---|
| 188 | @XmlElement(name = "Organization") |
|---|
| 189 | @Field(index=Index.TOKENIZED) |
|---|
| 190 | @NullOrNotEmpty |
|---|
| 191 | @Length(max = 255) |
|---|
| 192 | protected String organization; |
|---|
| 193 | |
|---|
| 194 | @XmlElement(name = "Publisher") |
|---|
| 195 | @Field(index=Index.TOKENIZED) |
|---|
| 196 | @NullOrNotEmpty |
|---|
| 197 | @Length(max = 255) |
|---|
| 198 | protected String publisher; |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | @XmlElement(name = "PlacePublished") |
|---|
| 202 | @Field(index=Index.TOKENIZED) |
|---|
| 203 | @NullOrNotEmpty |
|---|
| 204 | @Length(max = 255) |
|---|
| 205 | protected String placePublished; |
|---|
| 206 | |
|---|
| 207 | @XmlElement(name = "Institution") |
|---|
| 208 | @XmlIDREF |
|---|
| 209 | @XmlSchemaType(name = "IDREF") |
|---|
| 210 | @ManyToOne(fetch = FetchType.LAZY) |
|---|
| 211 | @IndexedEmbedded |
|---|
| 212 | @Cascade(CascadeType.SAVE_UPDATE) |
|---|
| 213 | protected Institution institution; |
|---|
| 214 | |
|---|
| 215 | @XmlElement(name = "School") |
|---|
| 216 | @XmlIDREF |
|---|
| 217 | @XmlSchemaType(name = "IDREF") |
|---|
| 218 | @ManyToOne(fetch = FetchType.LAZY) |
|---|
| 219 | @IndexedEmbedded |
|---|
| 220 | @Cascade(CascadeType.SAVE_UPDATE) |
|---|
| 221 | protected Institution school; |
|---|
| 222 | |
|---|
| 223 | @XmlElement(name = "InReference") |
|---|
| 224 | @XmlIDREF |
|---|
| 225 | @XmlSchemaType(name = "IDREF") |
|---|
| 226 | @ManyToOne(fetch = FetchType.LAZY) |
|---|
| 227 | // @IndexedEmbedded |
|---|
| 228 | @Cascade(CascadeType.SAVE_UPDATE) |
|---|
| 229 | // @InReference(groups=Level2.class) |
|---|
| 230 | protected Reference inReference; |
|---|
| 231 | |
|---|
| 232 | // @XmlElement(name = "FullReference") |
|---|
| 233 | // @XmlIDREF |
|---|
| 234 | // @XmlSchemaType(name = "IDREF") |
|---|
| 235 | // @ManyToOne(fetch = FetchType.LAZY) |
|---|
| 236 | //// @IndexedEmbedded |
|---|
| 237 | // @Cascade(CascadeType.SAVE_UPDATE) |
|---|
| 238 | // protected Reference fullReference; |
|---|
| 239 | // |
|---|
| 240 | // @XmlElement(name = "AbbreviatedReference") |
|---|
| 241 | // @XmlIDREF |
|---|
| 242 | // @XmlSchemaType(name = "IDREF") |
|---|
| 243 | // @ManyToOne(fetch = FetchType.LAZY) |
|---|
| 244 | //// @IndexedEmbedded |
|---|
| 245 | // @Cascade(CascadeType.SAVE_UPDATE) |
|---|
| 246 | // protected Reference abbreviatedReference; |
|---|
| 247 | |
|---|
| 248 | |
|---|
| 249 | //********************************************************/ |
|---|
| 250 | |
|---|
| 251 | //The date range assigned to the reference. ISO Date range like. Flexible, year can be left out, etc |
|---|
| 252 | @XmlElement(name ="DatePublished" ) |
|---|
| 253 | @Embedded |
|---|
| 254 | @IndexedEmbedded |
|---|
| 255 | private TimePeriod datePublished = TimePeriod.NewInstance(); |
|---|
| 256 | |
|---|
| 257 | @XmlElement(name ="Abstract" ) |
|---|
| 258 | @Column(length=65536, name="referenceAbstract") |
|---|
| 259 | @Lob |
|---|
| 260 | @Field(index=Index.TOKENIZED) |
|---|
| 261 | @NullOrNotEmpty |
|---|
| 262 | @Length(max = 65536) |
|---|
| 263 | private String referenceAbstract; //abstract is a reserved term in Java |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | //URIs like DOIs, LSIDs or Handles for this reference |
|---|
| 267 | @XmlElement(name = "URI") |
|---|
| 268 | @Field(index=org.hibernate.search.annotations.Index.UN_TOKENIZED) |
|---|
| 269 | @Type(type="uriUserType") |
|---|
| 270 | private URI uri; |
|---|
| 271 | |
|---|
| 272 | //flag to subselect only references that could be useful for nomenclatural citations. If a reference is used as a |
|---|
| 273 | //nomenclatural reference in a name this flag should be automatically set |
|---|
| 274 | @XmlElement(name = "IsNomenclaturallyRelevant") |
|---|
| 275 | @Merge(MergeMode.OR) |
|---|
| 276 | private boolean nomenclaturallyRelevant; |
|---|
| 277 | |
|---|
| 278 | @XmlElement(name = "AuthorTeam") |
|---|
| 279 | @XmlIDREF |
|---|
| 280 | @XmlSchemaType(name = "IDREF") |
|---|
| 281 | @ManyToOne(fetch = FetchType.LAZY) |
|---|
| 282 | @IndexedEmbedded |
|---|
| 283 | @Cascade(CascadeType.SAVE_UPDATE) |
|---|
| 284 | private TeamOrPersonBase authorTeam; |
|---|
| 285 | |
|---|
| 286 | // @XmlElement(name = "ReferenceIdentity") |
|---|
| 287 | // @XmlIDREF |
|---|
| 288 | // @XmlSchemaType(name = "IDREF") |
|---|
| 289 | // @ManyToOne(fetch = FetchType.LAZY) |
|---|
| 290 | // //@IndexedEmbedded |
|---|
| 291 | // @Cascade(CascadeType.SAVE_UPDATE) |
|---|
| 292 | // @Transient |
|---|
| 293 | // private ReferenceIdentity referenceIdentity; |
|---|
| 294 | |
|---|
| 295 | @XmlAttribute |
|---|
| 296 | @Match(MatchMode.IGNORE) |
|---|
| 297 | private int parsingProblem = 0; |
|---|
| 298 | |
|---|
| 299 | @XmlAttribute |
|---|
| 300 | @Match(MatchMode.IGNORE) |
|---|
| 301 | private int problemStarts = -1; |
|---|
| 302 | |
|---|
| 303 | @XmlAttribute |
|---|
| 304 | @Match(MatchMode.IGNORE) |
|---|
| 305 | private int problemEnds = -1; |
|---|
| 306 | |
|---|
| 307 | @Transient |
|---|
| 308 | @XmlAttribute |
|---|
| 309 | @Match(MatchMode.IGNORE) |
|---|
| 310 | private boolean cacheStrategyRectified = false; |
|---|
| 311 | |
|---|
| 312 | protected Reference(){ |
|---|
| 313 | super(); |
|---|
| 314 | this.type = ReferenceType.Generic; |
|---|
| 315 | this.cacheStrategy =(S)this.type.getCacheStrategy(); |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | protected Reference(ReferenceType type) { |
|---|
| 319 | this.type = type; |
|---|
| 320 | this.cacheStrategy =(S) type.getCacheStrategy(); |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | |
|---|
| 324 | //*************************** GETTER / SETTER ******************************************/ |
|---|
| 325 | public String getEditor() { |
|---|
| 326 | return editor; |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | public void setEditor(String editor) { |
|---|
| 330 | this.editor = editor; |
|---|
| 331 | } |
|---|
| 332 | |
|---|
| 333 | public String getSeries() { |
|---|
| 334 | return series; |
|---|
| 335 | } |
|---|
| 336 | |
|---|
| 337 | public void setSeries(String series) { |
|---|
| 338 | this.series = series; |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | public String getVolume() { |
|---|
| 342 | return volume; |
|---|
| 343 | } |
|---|
| 344 | |
|---|
| 345 | public void setVolume(String volume) { |
|---|
| 346 | this.volume = volume; |
|---|
| 347 | } |
|---|
| 348 | |
|---|
| 349 | public String getPages() { |
|---|
| 350 | return pages; |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | public void setPages(String pages) { |
|---|
| 354 | this.pages = pages; |
|---|
| 355 | } |
|---|
| 356 | |
|---|
| 357 | public String getEdition() { |
|---|
| 358 | return edition; |
|---|
| 359 | } |
|---|
| 360 | |
|---|
| 361 | public void setEdition(String edition) { |
|---|
| 362 | this.edition = edition; |
|---|
| 363 | } |
|---|
| 364 | |
|---|
| 365 | public String getIsbn() { |
|---|
| 366 | return isbn; |
|---|
| 367 | } |
|---|
| 368 | |
|---|
| 369 | public void setIsbn(String isbn) { |
|---|
| 370 | this.isbn = isbn; |
|---|
| 371 | } |
|---|
| 372 | |
|---|
| 373 | public String getIssn() { |
|---|
| 374 | return issn; |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | public void setIssn(String issn) { |
|---|
| 378 | this.issn = issn; |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | public String getSeriesPart() { |
|---|
| 382 | return seriesPart; |
|---|
| 383 | } |
|---|
| 384 | |
|---|
| 385 | public void setSeriesPart(String seriesPart) { |
|---|
| 386 | this.seriesPart = seriesPart; |
|---|
| 387 | } |
|---|
| 388 | |
|---|
| 389 | public String getOrganization() { |
|---|
| 390 | return organization; |
|---|
| 391 | } |
|---|
| 392 | |
|---|
| 393 | public void setOrganization(String organization) { |
|---|
| 394 | this.organization = organization; |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | public String getPublisher() { |
|---|
| 398 | return publisher; |
|---|
| 399 | } |
|---|
| 400 | |
|---|
| 401 | public void setPublisher(String publisher) { |
|---|
| 402 | this.publisher = publisher; |
|---|
| 403 | } |
|---|
| 404 | |
|---|
| 405 | public void setPublisher(String publisher, String placePublished){ |
|---|
| 406 | this.publisher = publisher; |
|---|
| 407 | this.placePublished = placePublished; |
|---|
| 408 | } |
|---|
| 409 | |
|---|
| 410 | public String getPlacePublished() { |
|---|
| 411 | return placePublished; |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | public void setPlacePublished(String placePublished) { |
|---|
| 415 | this.placePublished = placePublished; |
|---|
| 416 | } |
|---|
| 417 | |
|---|
| 418 | public Institution getInstitution() { |
|---|
| 419 | return institution; |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | public void setInstitution(Institution institution) { |
|---|
| 423 | this.institution = institution; |
|---|
| 424 | } |
|---|
| 425 | |
|---|
| 426 | public Institution getSchool() { |
|---|
| 427 | return school; |
|---|
| 428 | } |
|---|
| 429 | |
|---|
| 430 | public void setSchool(Institution school) { |
|---|
| 431 | this.school = school; |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | public Reference getInReference() { |
|---|
| 435 | return inReference; |
|---|
| 436 | } |
|---|
| 437 | |
|---|
| 438 | public void setInReference(Reference inReference) { |
|---|
| 439 | this.inReference = inReference; |
|---|
| 440 | } |
|---|
| 441 | |
|---|
| 442 | public void setType(ReferenceType type) { |
|---|
| 443 | this.setCacheStrategy((S) type.getCacheStrategy()); |
|---|
| 444 | this.type = type; |
|---|
| 445 | } |
|---|
| 446 | |
|---|
| 447 | /** |
|---|
| 448 | * @return the type |
|---|
| 449 | */ |
|---|
| 450 | public ReferenceType getType() { |
|---|
| 451 | return type; |
|---|
| 452 | } |
|---|
| 453 | |
|---|
| 454 | /** |
|---|
| 455 | * Whether this reference is of the given type |
|---|
| 456 | * |
|---|
| 457 | * @param type |
|---|
| 458 | * @return |
|---|
| 459 | */ |
|---|
| 460 | public boolean isOfType(ReferenceType type){ |
|---|
| 461 | return type == getType(); |
|---|
| 462 | } |
|---|
| 463 | |
|---|
| 464 | /** |
|---|
| 465 | * Returns a string representing the title of <i>this</i> reference. If a |
|---|
| 466 | * reference has different titles (for instance abbreviated and not |
|---|
| 467 | * abbreviated) then for each title a new instance must be created. |
|---|
| 468 | * |
|---|
| 469 | * @return the title string of <i>this</i> reference |
|---|
| 470 | * @see #getCitation() |
|---|
| 471 | */ |
|---|
| 472 | public String getTitle(){ |
|---|
| 473 | return this.title; |
|---|
| 474 | } |
|---|
| 475 | /** |
|---|
| 476 | * @see #getTitle() |
|---|
| 477 | */ |
|---|
| 478 | public void setTitle(String title){ |
|---|
| 479 | this.title = title; |
|---|
| 480 | } |
|---|
| 481 | |
|---|
| 482 | /** |
|---|
| 483 | * Returns the date (mostly only the year) of publication / creation of |
|---|
| 484 | * <i>this</i> reference. |
|---|
| 485 | */ |
|---|
| 486 | public TimePeriod getDatePublished(){ |
|---|
| 487 | return this.datePublished; |
|---|
| 488 | } |
|---|
| 489 | /** |
|---|
| 490 | * @see #getDatePublished() |
|---|
| 491 | */ |
|---|
| 492 | public void setDatePublished(TimePeriod datePublished){ |
|---|
| 493 | this.datePublished = datePublished; |
|---|
| 494 | } |
|---|
| 495 | |
|---|
| 496 | public boolean hasDatePublished(){ |
|---|
| 497 | boolean result = ! ( (this.datePublished == null) || StringUtils.isBlank(datePublished.toString())); |
|---|
| 498 | return result; |
|---|
| 499 | } |
|---|
| 500 | |
|---|
| 501 | /** |
|---|
| 502 | * Returns the {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author (team)} who created the |
|---|
| 503 | * content of <i>this</i> reference. |
|---|
| 504 | * |
|---|
| 505 | * @return the author (team) of <i>this</i> reference |
|---|
| 506 | * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase |
|---|
| 507 | */ |
|---|
| 508 | public TeamOrPersonBase getAuthorTeam(){ |
|---|
| 509 | return this.authorTeam; |
|---|
| 510 | } |
|---|
| 511 | |
|---|
| 512 | /** |
|---|
| 513 | * @see #getAuthorTeam() |
|---|
| 514 | */ |
|---|
| 515 | public void setAuthorTeam(TeamOrPersonBase authorTeam){ |
|---|
| 516 | this.authorTeam = authorTeam; |
|---|
| 517 | } |
|---|
| 518 | |
|---|
| 519 | /** |
|---|
| 520 | * Returns the Uniform Resource Identifier (URI) corresponding to <i>this</i> |
|---|
| 521 | * reference. An URI is a string of characters used to identify a resource |
|---|
| 522 | * on the Internet. |
|---|
| 523 | * |
|---|
| 524 | * @return the URI of <i>this</i> reference |
|---|
| 525 | */ |
|---|
| 526 | public URI getUri(){ |
|---|
| 527 | return this.uri; |
|---|
| 528 | } |
|---|
| 529 | /** |
|---|
| 530 | * @see #getUri() |
|---|
| 531 | */ |
|---|
| 532 | public void setUri(URI uri){ |
|---|
| 533 | this.uri = uri; |
|---|
| 534 | } |
|---|
| 535 | |
|---|
| 536 | /** |
|---|
| 537 | * @return the referenceAbstract |
|---|
| 538 | */ |
|---|
| 539 | public String getReferenceAbstract() { |
|---|
| 540 | return referenceAbstract; |
|---|
| 541 | } |
|---|
| 542 | |
|---|
| 543 | /** |
|---|
| 544 | * @param referenceAbstract the referenceAbstract to set |
|---|
| 545 | */ |
|---|
| 546 | public void setReferenceAbstract(String referenceAbstract) { |
|---|
| 547 | this.referenceAbstract = referenceAbstract; |
|---|
| 548 | } |
|---|
| 549 | |
|---|
| 550 | |
|---|
| 551 | |
|---|
| 552 | |
|---|
| 553 | /** |
|---|
| 554 | * Returns "true" if the isNomenclaturallyRelevant flag is set. This |
|---|
| 555 | * indicates that a {@link TaxonNameBase taxon name} has been originally |
|---|
| 556 | * published in <i>this</i> reference following the rules of a |
|---|
| 557 | * {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode nomenclature code} and is therefore used for |
|---|
| 558 | * nomenclatural citations. This flag will be set as soon as <i>this</i> |
|---|
| 559 | * reference is used as a nomenclatural reference for any taxon name.<BR> |
|---|
| 560 | * FIXME what happens if the only taxon name referencing this reference is not |
|---|
| 561 | * any longer using this reference as a nomenclatural reference. How does the |
|---|
| 562 | * reference get informed about the fact that it is not nomenclaturally relevant |
|---|
| 563 | * anymore? |
|---|
| 564 | */ |
|---|
| 565 | public boolean isNomenclaturallyRelevant(){ |
|---|
| 566 | return this.nomenclaturallyRelevant; |
|---|
| 567 | } |
|---|
| 568 | |
|---|
| 569 | /** |
|---|
| 570 | * @see #isNomenclaturallyRelevant() |
|---|
| 571 | */ |
|---|
| 572 | public void setNomenclaturallyRelevant(boolean nomenclaturallyRelevant){ |
|---|
| 573 | this.nomenclaturallyRelevant = nomenclaturallyRelevant; |
|---|
| 574 | } |
|---|
| 575 | |
|---|
| 576 | |
|---|
| 577 | // /** |
|---|
| 578 | // * Returns the full reference that belongs to this abbreviated reference. If this |
|---|
| 579 | // * reference is not abbreviated the full reference should be <code>null</code>.<BR> |
|---|
| 580 | // * A full reference should be added to a reference |
|---|
| 581 | // * which represents the abbreviated form of a reference. The full reference can be used |
|---|
| 582 | // * by publication tools to link to the unabbreviated and therefore more complete version |
|---|
| 583 | // * of the reference. |
|---|
| 584 | // * |
|---|
| 585 | // * @see #getAbbreviatedReference() |
|---|
| 586 | // * @return the full reference |
|---|
| 587 | // */ |
|---|
| 588 | // public Reference getFullReference() { |
|---|
| 589 | // return fullReference; |
|---|
| 590 | // } |
|---|
| 591 | // |
|---|
| 592 | // /** |
|---|
| 593 | // * @see #getFullReference() |
|---|
| 594 | // * @param fullReference |
|---|
| 595 | // */ |
|---|
| 596 | // public void setFullReference(Reference fullReference) { |
|---|
| 597 | // this.fullReference = fullReference; |
|---|
| 598 | // } |
|---|
| 599 | // |
|---|
| 600 | // /** |
|---|
| 601 | // * Returns the abbreviated reference that belongs to this full reference. If this |
|---|
| 602 | // * reference is not a full reference the abbeviated referece must be <code>null</code>.<BR> |
|---|
| 603 | // * An abbreviated reference should be added to a reference which represents the long (full) |
|---|
| 604 | // * form of a reference. |
|---|
| 605 | // * In future this may become a set or handled differently as there are multiple |
|---|
| 606 | // * |
|---|
| 607 | // * @see #getFullReference() |
|---|
| 608 | // * @return the full reference |
|---|
| 609 | // */ |
|---|
| 610 | // public Reference getAbbreviatedReference() { |
|---|
| 611 | // return abbreviatedReference; |
|---|
| 612 | // } |
|---|
| 613 | // |
|---|
| 614 | // /** |
|---|
| 615 | // * @see #getAbbreviatedReference() |
|---|
| 616 | // * @param abbreviatedReference |
|---|
| 617 | // * |
|---|
| 618 | // */ |
|---|
| 619 | // public void setAbbreviatedReference(Reference abbreviatedReference) { |
|---|
| 620 | // this.abbreviatedReference = abbreviatedReference; |
|---|
| 621 | // } |
|---|
| 622 | |
|---|
| 623 | //**************************************************** / |
|---|
| 624 | |
|---|
| 625 | // /** |
|---|
| 626 | // * Returns the string representing the name of the editor of <i>this</i> |
|---|
| 627 | // * generic reference. An editor is mostly a person (team) who assumed the |
|---|
| 628 | // * responsibility for the content of the publication as a whole without |
|---|
| 629 | // * being the author of this content.<BR> |
|---|
| 630 | // * If there is an editor then the generic reference must be some |
|---|
| 631 | // * kind of {@link PrintedUnitBase physical printed unit}. |
|---|
| 632 | // * |
|---|
| 633 | // * @return the string identifying the editor of <i>this</i> |
|---|
| 634 | // * generic reference |
|---|
| 635 | // * @see #getPublisher() |
|---|
| 636 | // */ |
|---|
| 637 | // protected String getEditor(){ |
|---|
| 638 | // return this.editor; |
|---|
| 639 | // } |
|---|
| 640 | // |
|---|
| 641 | // /** |
|---|
| 642 | // * @see #getEditor() |
|---|
| 643 | // */ |
|---|
| 644 | // protected void setEditor(String editor){ |
|---|
| 645 | // this.editor = editor; |
|---|
| 646 | // } |
|---|
| 647 | // |
|---|
| 648 | // /** |
|---|
| 649 | // * Returns the string representing the series (for instance for books or |
|---|
| 650 | // * within journals) - and series part - in which <i>this</i> generic reference |
|---|
| 651 | // * was published.<BR> |
|---|
| 652 | // * If there is a series then the generic reference must be some |
|---|
| 653 | // * kind of {@link PrintedUnitBase physical printed unit} or an {@link Article article}. |
|---|
| 654 | // * |
|---|
| 655 | // * @return the string identifying the series for <i>this</i> |
|---|
| 656 | // * generic reference |
|---|
| 657 | // */ |
|---|
| 658 | // protected String getSeries(){ |
|---|
| 659 | // return this.series; |
|---|
| 660 | // } |
|---|
| 661 | // |
|---|
| 662 | // /** |
|---|
| 663 | // * @see #getSeries() |
|---|
| 664 | // */ |
|---|
| 665 | // protected void setSeries(String series){ |
|---|
| 666 | // this.series = series; |
|---|
| 667 | // } |
|---|
| 668 | // |
|---|
| 669 | // /** |
|---|
| 670 | // * Returns the string representing the volume (for instance for books or |
|---|
| 671 | // * within journals) in which <i>this</i> generic reference was published.<BR> |
|---|
| 672 | // * If there is a volume then the generic reference must be some |
|---|
| 673 | // * kind of {@link PrintedUnitBase physical printed unit} or an {@link Article article}. |
|---|
| 674 | // * |
|---|
| 675 | // * @return the string identifying the volume for <i>this</i> |
|---|
| 676 | // * generic reference |
|---|
| 677 | // */ |
|---|
| 678 | // protected String getVolume(){ |
|---|
| 679 | // return this.volume; |
|---|
| 680 | // } |
|---|
| 681 | // |
|---|
| 682 | // /** |
|---|
| 683 | // * @see #getVolume() |
|---|
| 684 | // */ |
|---|
| 685 | // protected void setVolume(String volume){ |
|---|
| 686 | // this.volume = volume; |
|---|
| 687 | // } |
|---|
| 688 | // |
|---|
| 689 | // /** |
|---|
| 690 | // * Returns the string representing the page(s) where the content of |
|---|
| 691 | // * <i>this</i> generic reference is located.<BR> |
|---|
| 692 | // * If there is a pages information then the generic reference must be some |
|---|
| 693 | // * kind of {@link PrintedUnitBase physical printed unit} or an {@link Article article}. |
|---|
| 694 | // * |
|---|
| 695 | // * @return the string containing the pages corresponding to <i>this</i> |
|---|
| 696 | // * generic reference |
|---|
| 697 | // */ |
|---|
| 698 | // protected String getPages(){ |
|---|
| 699 | // return this.pages; |
|---|
| 700 | // } |
|---|
| 701 | // |
|---|
| 702 | // /** |
|---|
| 703 | // * @see #getPages() |
|---|
| 704 | // */ |
|---|
| 705 | // protected void setPages(String pages){ |
|---|
| 706 | // this.pages = pages; |
|---|
| 707 | // } |
|---|
| 708 | |
|---|
| 709 | |
|---|
| 710 | /** |
|---|
| 711 | * Returns a formatted string containing the entire reference citation, |
|---|
| 712 | * including authors, corresponding to <i>this</i> reference. |
|---|
| 713 | * |
|---|
| 714 | * @see #generateTitle() |
|---|
| 715 | */ |
|---|
| 716 | // TODO implement |
|---|
| 717 | @Transient |
|---|
| 718 | public String getCitation(){ |
|---|
| 719 | rectifyCacheStrategy(); |
|---|
| 720 | if (cacheStrategy == null){ |
|---|
| 721 | logger.warn("No CacheStrategy defined for "+ this.getClass() + ": " + this.getUuid()); |
|---|
| 722 | return null; |
|---|
| 723 | }else{ |
|---|
| 724 | return cacheStrategy.getTitleCache(this); |
|---|
| 725 | } |
|---|
| 726 | } |
|---|
| 727 | |
|---|
| 728 | /* (non-Javadoc) |
|---|
| 729 | * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle() |
|---|
| 730 | */ |
|---|
| 731 | public String generateTitle() { |
|---|
| 732 | rectifyCacheStrategy(); |
|---|
| 733 | return super.generateTitle(); |
|---|
| 734 | } |
|---|
| 735 | |
|---|
| 736 | /** |
|---|
| 737 | * Returns a string representation for the year of publication / creation |
|---|
| 738 | * of <i>this</i> reference. If the {@link #getDatePublished() datePublished} |
|---|
| 739 | * of this reference contains more date information then (starting) year |
|---|
| 740 | * only the year is returned. |
|---|
| 741 | * than attribute. |
|---|
| 742 | */ |
|---|
| 743 | @Transient |
|---|
| 744 | public String getYear(){ |
|---|
| 745 | TimePeriod datePublished = this.getDatePublished(); |
|---|
| 746 | if (datePublished != null ){ |
|---|
| 747 | String result = getDatePublished().getYear(); |
|---|
| 748 | return result; |
|---|
| 749 | }else{ |
|---|
| 750 | return null; |
|---|
| 751 | } |
|---|
| 752 | } |
|---|
| 753 | |
|---|
| 754 | /** |
|---|
| 755 | * Convenience method that returns a string representation for the publication date / creation |
|---|
| 756 | * of <i>this</i> reference. The string is obtained by |
|---|
| 757 | * {@link #getDatePublished()#toString() the string representation |
|---|
| 758 | * of the date published}. |
|---|
| 759 | */ |
|---|
| 760 | @Transient |
|---|
| 761 | public String getDatePublishedString(){ |
|---|
| 762 | TimePeriod datePublished = this.getDatePublished(); |
|---|
| 763 | if (datePublished != null ){ |
|---|
| 764 | return getDatePublished().toString(); |
|---|
| 765 | }else{ |
|---|
| 766 | return null; |
|---|
| 767 | } |
|---|
| 768 | } |
|---|
| 769 | |
|---|
| 770 | |
|---|
| 771 | |
|---|
| 772 | /* (non-Javadoc) |
|---|
| 773 | * @see eu.etaxonomy.cdm.model.common.IParsable#getHasProblem() |
|---|
| 774 | */ |
|---|
| 775 | public int getParsingProblem(){ |
|---|
| 776 | return this.parsingProblem; |
|---|
| 777 | } |
|---|
| 778 | |
|---|
| 779 | /* (non-Javadoc) |
|---|
| 780 | * @see eu.etaxonomy.cdm.model.common.IParsable#setHasProblem(boolean) |
|---|
| 781 | */ |
|---|
| 782 | public void setParsingProblem(int parsingProblem){ |
|---|
| 783 | this.parsingProblem = parsingProblem; |
|---|
| 784 | } |
|---|
| 785 | |
|---|
| 786 | /* (non-Javadoc) |
|---|
| 787 | * @see eu.etaxonomy.cdm.model.common.IParsable#hasProblem() |
|---|
| 788 | */ |
|---|
| 789 | public boolean hasProblem(){ |
|---|
| 790 | return parsingProblem != 0; |
|---|
| 791 | } |
|---|
| 792 | |
|---|
| 793 | /* (non-Javadoc) |
|---|
| 794 | * @see eu.etaxonomy.cdm.model.common.IParsable#hasProblem(eu.etaxonomy.cdm.strategy.parser.ParserProblem) |
|---|
| 795 | */ |
|---|
| 796 | public boolean hasProblem(ParserProblem problem) { |
|---|
| 797 | return getParsingProblems().contains(problem); |
|---|
| 798 | } |
|---|
| 799 | |
|---|
| 800 | |
|---|
| 801 | /* (non-Javadoc) |
|---|
| 802 | * @see eu.etaxonomy.cdm.model.common.IParsable#problemStarts() |
|---|
| 803 | */ |
|---|
| 804 | public int getProblemStarts(){ |
|---|
| 805 | return this.problemStarts; |
|---|
| 806 | } |
|---|
| 807 | |
|---|
| 808 | /* (non-Javadoc) |
|---|
| 809 | * @see eu.etaxonomy.cdm.model.common.IParsable#setProblemStarts(int) |
|---|
| 810 | */ |
|---|
| 811 | public void setProblemStarts(int start) { |
|---|
| 812 | this.problemStarts = start; |
|---|
| 813 | } |
|---|
| 814 | |
|---|
| 815 | /* (non-Javadoc) |
|---|
| 816 | * @see eu.etaxonomy.cdm.model.common.IParsable#problemEnds() |
|---|
| 817 | */ |
|---|
| 818 | public int getProblemEnds(){ |
|---|
| 819 | return this.problemEnds; |
|---|
| 820 | } |
|---|
| 821 | |
|---|
| 822 | /* (non-Javadoc) |
|---|
| 823 | * @see eu.etaxonomy.cdm.model.common.IParsable#setProblemEnds(int) |
|---|
| 824 | */ |
|---|
| 825 | public void setProblemEnds(int end) { |
|---|
| 826 | this.problemEnds = end; |
|---|
| 827 | } |
|---|
| 828 | |
|---|
| 829 | /* (non-Javadoc) |
|---|
| 830 | * @see eu.etaxonomy.cdm.model.common.IParsable#addProblem(eu.etaxonomy.cdm.strategy.parser.NameParserWarning) |
|---|
| 831 | */ |
|---|
| 832 | public void addParsingProblem(ParserProblem warning){ |
|---|
| 833 | parsingProblem = ParserProblem.addProblem(parsingProblem, warning); |
|---|
| 834 | } |
|---|
| 835 | |
|---|
| 836 | /* (non-Javadoc) |
|---|
| 837 | * @see eu.etaxonomy.cdm.model.common.IParsable#removeParsingProblem(eu.etaxonomy.cdm.strategy.parser.ParserProblem) |
|---|
| 838 | */ |
|---|
| 839 | public void removeParsingProblem(ParserProblem problem) { |
|---|
| 840 | parsingProblem = ParserProblem.removeProblem(parsingProblem, problem); |
|---|
| 841 | } |
|---|
| 842 | |
|---|
| 843 | /* (non-Javadoc) |
|---|
| 844 | * @see eu.etaxonomy.cdm.model.common.IParsable#getParsingProblems() |
|---|
| 845 | */ |
|---|
| 846 | @Transient |
|---|
| 847 | public List<ParserProblem> getParsingProblems() { |
|---|
| 848 | return ParserProblem.warningList(this.parsingProblem); |
|---|
| 849 | } |
|---|
| 850 | |
|---|
| 851 | |
|---|
| 852 | @Transient |
|---|
| 853 | public String getNomenclaturalCitation(String microReference) { |
|---|
| 854 | rectifyCacheStrategy(); |
|---|
| 855 | String typeName = this.getType()== null ? "(no type defined)" : this.getType().getMessage(); |
|---|
| 856 | if (cacheStrategy == null){ |
|---|
| 857 | logger.warn("No CacheStrategy defined for "+ typeName + ": " + this.getUuid()); |
|---|
| 858 | return null; |
|---|
| 859 | }else{ |
|---|
| 860 | if (cacheStrategy instanceof INomenclaturalReferenceCacheStrategy){ |
|---|
| 861 | return ((INomenclaturalReferenceCacheStrategy)cacheStrategy).getNomenclaturalCitation(this,microReference); |
|---|
| 862 | }else { |
|---|
| 863 | logger.warn("No INomenclaturalReferenceCacheStrategy defined for "+ typeName + ": " + this.getUuid()); |
|---|
| 864 | return null; |
|---|
| 865 | } |
|---|
| 866 | } |
|---|
| 867 | } |
|---|
| 868 | |
|---|
| 869 | |
|---|
| 870 | /** |
|---|
| 871 | * Generates, according to the {@link eu.etaxonomy.cdm.strategy.strategy.cache.reference.IReferenceBaseCacheStrategy cache strategy} |
|---|
| 872 | * assigned to <i>this</i> reference, a string that identifies <i>this</i> |
|---|
| 873 | * reference and returns it. This string may be stored in the inherited |
|---|
| 874 | * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.<BR> |
|---|
| 875 | * This method overrides the generic and inherited generateTitle method |
|---|
| 876 | * from {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity IdentifiableEntity}. |
|---|
| 877 | * |
|---|
| 878 | * @return the string identifying <i>this</i> reference |
|---|
| 879 | * @see #getCitation() |
|---|
| 880 | * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() |
|---|
| 881 | * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle() |
|---|
| 882 | * @see eu.etaxonomy.cdm.strategy.strategy.cache.common.IIdentifiableEntityCacheStrategy#getTitleCache() |
|---|
| 883 | */ |
|---|
| 884 | // @Override |
|---|
| 885 | // public String generateTitle(){ |
|---|
| 886 | // if (cacheStrategy == null){ |
|---|
| 887 | // logger.warn("No CacheStrategy defined for Reference: " + this.getUuid()); |
|---|
| 888 | // return null; |
|---|
| 889 | // }else{ |
|---|
| 890 | // return cacheStrategy.getTitleCache(this); |
|---|
| 891 | // } |
|---|
| 892 | // } |
|---|
| 893 | |
|---|
| 894 | |
|---|
| 895 | |
|---|
| 896 | // /** |
|---|
| 897 | // * Returns the reference identity object |
|---|
| 898 | // * @return the referenceIdentity |
|---|
| 899 | // */ |
|---|
| 900 | // public ReferenceIdentity getReferenceIdentity() { |
|---|
| 901 | // return referenceIdentity; |
|---|
| 902 | // } |
|---|
| 903 | // |
|---|
| 904 | // /** |
|---|
| 905 | // * For bidirectional use only |
|---|
| 906 | // * @param referenceIdentity the referenceIdentity to set |
|---|
| 907 | // */ |
|---|
| 908 | // protected void setReferenceIdentity(ReferenceIdentity referenceIdentity) { |
|---|
| 909 | // this.referenceIdentity = referenceIdentity; |
|---|
| 910 | // } |
|---|
| 911 | // |
|---|
| 912 | // /** |
|---|
| 913 | // * Returns the set of all identical references. Same as getReferenceIdentity().getReferences() |
|---|
| 914 | // * @return |
|---|
| 915 | // */ |
|---|
| 916 | // public Set<Reference> identicalReferences(){ |
|---|
| 917 | // return referenceIdentity.getReferences(); |
|---|
| 918 | // } |
|---|
| 919 | |
|---|
| 920 | |
|---|
| 921 | //********** Casting methods ***********************************/ |
|---|
| 922 | |
|---|
| 923 | public IArticle castReferenceToArticle(){ |
|---|
| 924 | setType(ReferenceType.Article); |
|---|
| 925 | return (IArticle) this; |
|---|
| 926 | } |
|---|
| 927 | |
|---|
| 928 | public IBook castReferenceToBook(){ |
|---|
| 929 | setType(ReferenceType.Book); |
|---|
| 930 | return (IBook) this; |
|---|
| 931 | } |
|---|
| 932 | |
|---|
| 933 | public IBookSection castReferenceToBookSection(){ |
|---|
| 934 | setType(ReferenceType.BookSection); |
|---|
| 935 | return (IBookSection) this; |
|---|
| 936 | } |
|---|
| 937 | |
|---|
| 938 | public ICdDvd castReferenceToCdDvd(){ |
|---|
| 939 | setType(ReferenceType.CdDvd); |
|---|
| 940 | return (ICdDvd) this; |
|---|
| 941 | } |
|---|
| 942 | |
|---|
| 943 | public IDatabase castReferenceToDatabase(){ |
|---|
| 944 | setType(ReferenceType.Database); |
|---|
| 945 | return (IDatabase) this; |
|---|
| 946 | } |
|---|
| 947 | |
|---|
| 948 | public IGeneric castReferenceToGeneric(){ |
|---|
| 949 | setType(ReferenceType.Generic); |
|---|
| 950 | return (IGeneric) this; |
|---|
| 951 | } |
|---|
| 952 | |
|---|
| 953 | public IInProceedings castReferenceToInProceedings(){ |
|---|
| 954 | setType(ReferenceType.InProceedings); |
|---|
| 955 | return (IInProceedings) this; |
|---|
| 956 | } |
|---|
| 957 | |
|---|
| 958 | public IJournal castReferenceToJournal(){ |
|---|
| 959 | setType(ReferenceType.Journal); |
|---|
| 960 | return (IJournal) this; |
|---|
| 961 | } |
|---|
| 962 | |
|---|
| 963 | public IMap castReferenceToMap(){ |
|---|
| 964 | setType(ReferenceType.Map); |
|---|
| 965 | return (IMap) this; |
|---|
| 966 | } |
|---|
| 967 | |
|---|
| 968 | public IPatent castReferenceToPatent(){ |
|---|
| 969 | setType(ReferenceType.Patent); |
|---|
| 970 | return (IPatent) this; |
|---|
| 971 | } |
|---|
| 972 | |
|---|
| 973 | public IPersonalCommunication castReferenceToPersonalCommunication(){ |
|---|
| 974 | setType(ReferenceType.PersonalCommunication); |
|---|
| 975 | return (IPersonalCommunication) this; |
|---|
| 976 | } |
|---|
| 977 | |
|---|
| 978 | public IPrintSeries castReferenceToPrintSeries(){ |
|---|
| 979 | setType(ReferenceType.PrintSeries); |
|---|
| 980 | return (IPrintSeries) this; |
|---|
| 981 | } |
|---|
| 982 | |
|---|
| 983 | public IWebPage castReferenceToWebPage(){ |
|---|
| 984 | setType(ReferenceType.WebPage); |
|---|
| 985 | return (IWebPage) this; |
|---|
| 986 | } |
|---|
| 987 | |
|---|
| 988 | public IProceedings castReferenceToProceedings(){ |
|---|
| 989 | setType(ReferenceType.Proceedings); |
|---|
| 990 | return (IProceedings) this; |
|---|
| 991 | } |
|---|
| 992 | |
|---|
| 993 | public IReport castReferenceToReport(){ |
|---|
| 994 | setType(ReferenceType.Report); |
|---|
| 995 | return (IReport) this; |
|---|
| 996 | } |
|---|
| 997 | |
|---|
| 998 | public IThesis castReferenceToThesis(){ |
|---|
| 999 | setType(ReferenceType.Thesis); |
|---|
| 1000 | return (IThesis) this; |
|---|
| 1001 | } |
|---|
| 1002 | |
|---|
| 1003 | |
|---|
| 1004 | @Transient // prevent from being serialized by webservice |
|---|
| 1005 | public IJournal getInJournal() { |
|---|
| 1006 | IJournal journal = this.inReference; |
|---|
| 1007 | return journal; |
|---|
| 1008 | } |
|---|
| 1009 | |
|---|
| 1010 | public void setInJournal(IJournal journal) { |
|---|
| 1011 | this.inReference = (Reference<JournalDefaultCacheStrategy<Reference>>) journal; |
|---|
| 1012 | |
|---|
| 1013 | } |
|---|
| 1014 | |
|---|
| 1015 | @Transient // prevent from being serialized by webservice |
|---|
| 1016 | public IPrintSeries getInSeries() { |
|---|
| 1017 | IPrintSeries printSeries = this.inReference; |
|---|
| 1018 | return printSeries; |
|---|
| 1019 | } |
|---|
| 1020 | |
|---|
| 1021 | public void setInSeries(IPrintSeries inSeries) { |
|---|
| 1022 | this.inReference = (Reference<IReferenceBaseCacheStrategy<Reference>>) inSeries; |
|---|
| 1023 | } |
|---|
| 1024 | |
|---|
| 1025 | @Transient // prevent from being serialized by webservice |
|---|
| 1026 | public IBook getInBook() { |
|---|
| 1027 | IBook book = this.inReference; |
|---|
| 1028 | return book; |
|---|
| 1029 | } |
|---|
| 1030 | |
|---|
| 1031 | //********************** In-References ***************************************** |
|---|
| 1032 | |
|---|
| 1033 | public void setInBook(IBook book) { |
|---|
| 1034 | this.inReference = (Reference<BookDefaultCacheStrategy<Reference>>) book; |
|---|
| 1035 | } |
|---|
| 1036 | |
|---|
| 1037 | @Transient // prevent from being serialized by webservice |
|---|
| 1038 | public IProceedings getInProceedings() { |
|---|
| 1039 | IProceedings proceedings = this.inReference; |
|---|
| 1040 | return proceedings; |
|---|
| 1041 | } |
|---|
| 1042 | |
|---|
| 1043 | public void setInProceedings(IProceedings proceeding) { |
|---|
| 1044 | this.inReference = (Reference<BookDefaultCacheStrategy<Reference>>) proceeding; |
|---|
| 1045 | } |
|---|
| 1046 | |
|---|
| 1047 | //*************************** CACHE STRATEGIES ******************************/ |
|---|
| 1048 | |
|---|
| 1049 | /** |
|---|
| 1050 | * The type property of this class is mapped on the field level to the data base column, so |
|---|
| 1051 | * Hibernate will consequently use the {@link org.hibernate.property.DirectPropertyAccessor} |
|---|
| 1052 | * to set the property. This PropertyAccessor directly sets the field instead of using the according setter so |
|---|
| 1053 | * the CacheStrategy is not correctly set after the initialization of the bean. Thus we need to |
|---|
| 1054 | * validate the CacheStrategy before it is to be used. |
|---|
| 1055 | */ |
|---|
| 1056 | private void rectifyCacheStrategy() { |
|---|
| 1057 | if(!cacheStrategyRectified ){ |
|---|
| 1058 | setType(getType()); |
|---|
| 1059 | cacheStrategyRectified = true; |
|---|
| 1060 | } |
|---|
| 1061 | } |
|---|
| 1062 | |
|---|
| 1063 | |
|---|
| 1064 | //public void setCacheStrategy(S cacheStrategy){ |
|---|
| 1065 | // this.cacheStrategy = cacheStrategy; |
|---|
| 1066 | //} |
|---|
| 1067 | |
|---|
| 1068 | public void setCacheStrategy(IReferenceBaseCacheStrategy iReferenceBaseCacheStrategy) { |
|---|
| 1069 | this.cacheStrategy = (S) iReferenceBaseCacheStrategy; |
|---|
| 1070 | |
|---|
| 1071 | } |
|---|
| 1072 | |
|---|
| 1073 | public void setCacheStrategy(ArticleDefaultCacheStrategy cacheStrategy) { |
|---|
| 1074 | this.cacheStrategy = (S) cacheStrategy; |
|---|
| 1075 | } |
|---|
| 1076 | |
|---|
| 1077 | public void setCacheStrategy(BookDefaultCacheStrategy cacheStrategy) { |
|---|
| 1078 | this.cacheStrategy = (S) cacheStrategy; |
|---|
| 1079 | } |
|---|
| 1080 | |
|---|
| 1081 | public void setCacheStrategy(JournalDefaultCacheStrategy cacheStrategy) { |
|---|
| 1082 | this.cacheStrategy = (S) cacheStrategy; |
|---|
| 1083 | } |
|---|
| 1084 | |
|---|
| 1085 | public void setCacheStrategy(BookSectionDefaultCacheStrategy cacheStrategy) { |
|---|
| 1086 | this.cacheStrategy = (S) cacheStrategy; |
|---|
| 1087 | } |
|---|
| 1088 | |
|---|
| 1089 | public void setCacheStrategy(GenericDefaultCacheStrategy cacheStrategy) { |
|---|
| 1090 | this.cacheStrategy = (S) cacheStrategy; |
|---|
| 1091 | } |
|---|
| 1092 | |
|---|
| 1093 | public void setCacheStrategy(ReferenceBaseDefaultCacheStrategy cacheStrategy) { |
|---|
| 1094 | this.cacheStrategy = (S)cacheStrategy; |
|---|
| 1095 | |
|---|
| 1096 | } |
|---|
| 1097 | |
|---|
| 1098 | |
|---|
| 1099 | //*********************** CLONE ********************************************************/ |
|---|
| 1100 | |
|---|
| 1101 | /** |
|---|
| 1102 | * Clones <i>this</i> reference. This is a shortcut that enables to create |
|---|
| 1103 | * a new instance that differs only slightly from <i>this</i> reference by |
|---|
| 1104 | * modifying only some of the attributes. |
|---|
| 1105 | * |
|---|
| 1106 | * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone() |
|---|
| 1107 | * @see java.lang.Object#clone() |
|---|
| 1108 | */ |
|---|
| 1109 | @Override |
|---|
| 1110 | public Object clone() { |
|---|
| 1111 | try { |
|---|
| 1112 | Reference result = (Reference)super.clone(); |
|---|
| 1113 | result.setDatePublished(datePublished != null? (TimePeriod)datePublished.clone(): null); |
|---|
| 1114 | //no changes to: title, authorTeam, hasProblem, nomenclaturallyRelevant, uri |
|---|
| 1115 | return result; |
|---|
| 1116 | } catch (CloneNotSupportedException e) { |
|---|
| 1117 | logger.warn("Object does not implement cloneable"); |
|---|
| 1118 | e.printStackTrace(); |
|---|
| 1119 | return null; |
|---|
| 1120 | } |
|---|
| 1121 | } |
|---|
| 1122 | |
|---|
| 1123 | } |
|---|