Performed project cleanup.
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / strategy / cache / reference / BookSectionDefaultCacheStrategy.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 package eu.etaxonomy.cdm.strategy.cache.reference;
10
11 import java.util.UUID;
12
13 import org.apache.log4j.Logger;
14
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;
19
20 public class BookSectionDefaultCacheStrategy <T extends BookSection> extends NomRefDefaultCacheStrategyBase<T> implements INomenclaturalReferenceCacheStrategy<T> {
21 private static final Logger logger = Logger.getLogger(BookSectionDefaultCacheStrategy.class);
22
23 private String afterBookAuthor = " - ";
24 private String inBook = "in ";
25 private String blank = " ";
26
27 final static UUID uuid = UUID.fromString("f9c53f20-addd-4d2f-9697-ef1fe727deba");
28
29 /* (non-Javadoc)
30 * @see eu.etaxonomy.cdm.strategy.StrategyBase#getUuid()
31 */
32 @Override
33 protected UUID getUuid() {
34 return uuid;
35 }
36
37
38 /**
39 * Factory method
40 * @return
41 */
42 public static BookSectionDefaultCacheStrategy NewInstance(){
43 return new BookSectionDefaultCacheStrategy();
44 }
45
46 /**
47 * Constructor
48 */
49 private BookSectionDefaultCacheStrategy(){
50 super();
51 }
52
53
54
55 /* (non-Javadoc)
56 * @see eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy#getTokenizedNomenclaturalTitel(eu.etaxonomy.cdm.model.reference.INomenclaturalReference)
57 */
58 @Override
59 public String getTokenizedNomenclaturalTitel(T bookSection) {
60 if (bookSection.getInBook() == null){
61 return null;
62 }
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;
67 return result;
68 }
69
70 /* (non-Javadoc)
71 * @see eu.etaxonomy.cdm.strategy.cache.reference.INomenclaturalReferenceCacheStrategy#getTitleCache(eu.etaxonomy.cdm.model.reference.INomenclaturalReference)
72 */
73 @Override
74 public String getTitleCache(T bookSection) {
75 if (bookSection.getInBook() == null){
76 return null;
77 }
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;
86 }
87
88 return result;
89 }
90
91
92 /* (non-Javadoc)
93 * @see eu.etaxonomy.cdm.strategy.cache.reference.NomRefDefaultCacheStrategyBase#getNomRefTitleWithoutYearAndAuthor(eu.etaxonomy.cdm.model.reference.ReferenceBase)
94 */
95 @Override
96 protected String getNomRefTitleWithoutYearAndAuthor(T reference) {
97 // not needed in BookSection
98 logger.warn("Questionable procedure call. Procedure not implemented because not needed. ");
99 return null;
100 }
101
102
103 }