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
.reference
.Article
;
17 import eu
.etaxonomy
.cdm
.model
.reference
.Book
;
18 import eu
.etaxonomy
.cdm
.model
.reference
.INomenclaturalReference
;
19 import eu
.etaxonomy
.cdm
.strategy
.StrategyBase
;
21 public class ArticleDefaultCacheStrategy
<T
extends Article
> extends NomRefDefaultCacheStrategyBase
<T
> implements INomenclaturalReferenceCacheStrategy
<T
> {
22 private static final Logger logger
= Logger
.getLogger(ArticleDefaultCacheStrategy
.class);
24 private String prefixSeries
= "ser.";
25 private String prefixVolume
= "vol.";
26 private String prefixReferenceJounal
= "in";
27 private String blank
= " ";
28 private String comma
= ",";
29 private String dot
=".";
31 final static UUID uuid
= UUID
.fromString("0d45343a-0c8a-4a64-97ca-e94974b65c96");
34 * @see eu.etaxonomy.cdm.strategy.StrategyBase#getUuid()
37 protected UUID
getUuid() {
46 public static ArticleDefaultCacheStrategy
NewInstance(){
47 return new ArticleDefaultCacheStrategy();
53 private ArticleDefaultCacheStrategy(){
57 protected String
getNomRefTitleWithoutYearAndAuthor(T article
){
61 if (article
.getInJournal() == null){
65 String titelAbbrev
= CdmUtils
.Nz(article
.getInJournal().getTitle());
66 String series
= CdmUtils
.Nz(article
.getSeries());
67 String volume
= CdmUtils
.Nz(article
.getVolume());
69 boolean lastCharIsDouble
;
72 String character
=".";
73 len
= titelAbbrev
.length();
74 if (len
> 0){lastChar
= titelAbbrev
.substring(len
-1, len
);}
75 //lastCharIsDouble = f_core_CompareStrings(RIGHT(@TitelAbbrev,1),character);
76 lastCharIsDouble
= titelAbbrev
.equals(character
);
78 // if(lastCharIsDouble && edition.length() == 0 && series.length() == 0 && volume.length() == 0 && refYear.length() > 0 ){
79 // titelAbbrev = titelAbbrev.substring(1, len-1); // SUBSTRING(@TitelAbbrev,1,@LEN-1)
83 boolean needsComma
= false;
85 String nomRefCache
= "";
88 nomRefCache
= prefixReferenceJounal
+ blank
;
91 if (!"".equals(titelAbbrev
)){
92 nomRefCache
= nomRefCache
+ titelAbbrev
+ blank
;
96 String seriesPart
= "";
97 if (!"".equals(series
)){
99 if (isNumeric(series
)){
100 seriesPart
= prefixSeries
+ blank
+ seriesPart
;
103 seriesPart
= comma
+ seriesPart
;
107 nomRefCache
+= seriesPart
;
111 String volumePart
= "";
112 if (!"".equals(volume
)){
115 volumePart
= comma
+ blank
+ volumePart
;
117 //needsComma = false;
119 nomRefCache
+= volumePart
;
122 while (nomRefCache
.endsWith(".")){
123 nomRefCache
= nomRefCache
.substring(0, nomRefCache
.length()-1);
129 private boolean isNumeric(String string
){
134 Double
.valueOf(string
);
136 } catch (NumberFormatException e
) {