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.
10 package eu
.etaxonomy
.cdm
.strategy
.cache
.reference
;
12 import java
.util
.UUID
;
14 import org
.apache
.commons
.lang
.StringUtils
;
15 import org
.apache
.log4j
.Logger
;
17 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
18 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
19 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
20 import eu
.etaxonomy
.cdm
.strategy
.StrategyBase
;
26 public class JournalDefaultCacheStrategy
extends StrategyBase
implements IReferenceBaseCacheStrategy
{
27 private static final long serialVersionUID
= 8495999505123620960L;
30 @SuppressWarnings("unused")
31 private static final Logger logger
= Logger
.getLogger(JournalDefaultCacheStrategy
.class);
34 protected String beforeYear
= ". ";
35 protected String afterYear
= "";
36 protected String afterAuthor
= ", ";
38 // private String blank = " ";
39 // private String comma = ",";
40 // private String dot =".";
42 final static UUID uuid
= UUID
.fromString("c84846cd-c862-462e-81b8-53cf4100ed32");
45 * @see eu.etaxonomy.cdm.strategy.StrategyBase#getUuid()
48 protected UUID
getUuid() {
57 public static JournalDefaultCacheStrategy
NewInstance(){
58 return new JournalDefaultCacheStrategy();
64 private JournalDefaultCacheStrategy(){
70 public String
getTitleCache(Reference journal
) {
71 return getTitleCache(journal
, false);
78 public String
getAbbrevTitleCache(Reference journal
) {
79 return getTitleCache(journal
, true);
83 private String
getTitleCache(Reference journal
, boolean isAbbrev
){
88 String title
= CdmUtils
.getPreferredNonEmptyString(journal
.getTitle(), journal
.getAbbrevTitle(), isAbbrev
, true);
90 String result
= title
;
93 // while (result.endsWith(".")){
94 // result = result.substring(0, result.length()-1);
97 // result = addYear(result, journal);
100 TeamOrPersonBase
<?
> team
= journal
.getAuthorship();
102 String author
= CdmUtils
.getPreferredNonEmptyString(team
.getTitleCache(), team
.getNomenclaturalTitle(), isAbbrev
, true);
103 if (StringUtils
.isNotBlank(author
)){
104 result
= author
+ afterAuthor
+ result
;
111 public String
getCitation(Reference referenceBase
) {
112 StringBuilder stringBuilder
= new StringBuilder();
114 TeamOrPersonBase
<?
> team
= referenceBase
.getAuthorship();
115 if (team
!= null && ! (team
.getTitleCache() == null) && ! team
.getTitleCache().trim().equals("")){
116 //String author = CdmUtils.Nz(team == null? "" : team.getTitleCache());
117 stringBuilder
.append(team
.getTitleCache() + afterAuthor
);
120 String year
= CdmUtils
.Nz(referenceBase
.getYear());
121 if (!"".equals(year
)){
122 stringBuilder
.append(beforeYear
+ year
);
125 return stringBuilder
.toString();