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.
9 package eu
.etaxonomy
.cdm
.strategy
.cache
.reference
;
11 import java
.util
.UUID
;
13 import org
.apache
.log4j
.Logger
;
15 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
16 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
17 import eu
.etaxonomy
.cdm
.model
.reference
.BookSection
;
18 import eu
.etaxonomy
.cdm
.model
.reference
.INomenclaturalReference
;
20 public class BookSectionDefaultCacheStrategy
<T
extends BookSection
> extends NomRefDefaultCacheStrategyBase
<T
> implements INomenclaturalReferenceCacheStrategy
<T
> {
21 private static final Logger logger
= Logger
.getLogger(BookSectionDefaultCacheStrategy
.class);
23 private String afterBookAuthor
= " - ";
24 private String inBook
= "in ";
25 private String blank
= " ";
27 final static UUID uuid
= UUID
.fromString("f9c53f20-addd-4d2f-9697-ef1fe727deba");
30 * @see eu.etaxonomy.cdm.strategy.StrategyBase#getUuid()
33 protected UUID
getUuid() {
42 public static BookSectionDefaultCacheStrategy
NewInstance(){
43 return new BookSectionDefaultCacheStrategy();
49 private BookSectionDefaultCacheStrategy(){
56 * @see eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy#getTokenizedNomenclaturalTitel(eu.etaxonomy.cdm.model.reference.INomenclaturalReference)
59 public String
getTokenizedNomenclaturalTitel(T bookSection
) {
60 if (bookSection
.getInBook() == null){
63 String result
= bookSection
.getInBook().getNomenclaturalCitation(INomenclaturalReference
.MICRO_REFERENCE_TOKEN
);
64 //TODO beforeMicroReference should be the bookstrategy one's
65 result
= result
.replace(beforeMicroReference
+ INomenclaturalReference
.MICRO_REFERENCE_TOKEN
, INomenclaturalReference
.MICRO_REFERENCE_TOKEN
);
66 result
= "in " + result
;
71 * @see eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy#getTitleCache(eu.etaxonomy.cdm.model.reference.INomenclaturalReference)
74 public String
getTitleCache(T bookSection
) {
75 if (bookSection
.getInBook() == null){
78 String result
= bookSection
.getInBook().getTitleCache();
79 TeamOrPersonBase team
= bookSection
.getAuthorTeam();
80 String bookAuthor
= CdmUtils
.Nz(team
== null?
"" : team
.getTitleCache());
81 result
= bookAuthor
+ afterBookAuthor
+ result
;
82 result
= inBook
+ result
;
83 String title
= CdmUtils
.Nz(bookSection
.getTitle());
84 if (title
.length() > 0){
85 result
= title
+ blank
+ result
;
93 * @see eu.etaxonomy.cdm.strategy.cache.reference.NomRefDefaultCacheStrategyBase#getNomRefTitleWithoutYearAndAuthor(eu.etaxonomy.cdm.model.reference.ReferenceBase)
96 protected String
getNomRefTitleWithoutYearAndAuthor(T reference
) {
97 // not needed in BookSection
98 logger
.warn("Questionable procedure call. Procedure not implemented because not needed. ");