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
;
18 public class ArticleDefaultCacheStrategy
<T
extends Article
> extends NomRefDefaultCacheStrategyBase
<T
> implements INomenclaturalReferenceCacheStrategy
<T
> {
19 private static final Logger logger
= Logger
.getLogger(ArticleDefaultCacheStrategy
.class);
21 private String prefixSeries
= "ser.";
22 private String prefixVolume
= "vol.";
23 private String prefixReferenceJounal
= "in";
24 private String blank
= " ";
25 private String comma
= ",";
26 private String dot
=".";
28 final static UUID uuid
= UUID
.fromString("0d45343a-0c8a-4a64-97ca-e94974b65c96");
31 * @see eu.etaxonomy.cdm.strategy.StrategyBase#getUuid()
34 protected UUID
getUuid() {
43 public static ArticleDefaultCacheStrategy
NewInstance(){
44 return new ArticleDefaultCacheStrategy();
50 private ArticleDefaultCacheStrategy(){
54 protected String
getNomRefTitleWithoutYearAndAuthor(T article
){
58 if (article
.getInJournal() == null){
62 String titelAbbrev
= CdmUtils
.Nz(article
.getInJournal().getTitle()).trim();
63 String series
= CdmUtils
.Nz(article
.getSeries()).trim();
64 String volume
= CdmUtils
.Nz(article
.getVolume()).trim();
66 boolean lastCharIsDouble
;
69 String character
=".";
70 len
= titelAbbrev
.length();
71 if (len
> 0){lastChar
= titelAbbrev
.substring(len
-1, len
);}
72 //lastCharIsDouble = f_core_CompareStrings(RIGHT(@TitelAbbrev,1),character);
73 lastCharIsDouble
= titelAbbrev
.equals(character
);
75 // if(lastCharIsDouble && edition.length() == 0 && series.length() == 0 && volume.length() == 0 && refYear.length() > 0 ){
76 // titelAbbrev = titelAbbrev.substring(1, len-1); // SUBSTRING(@TitelAbbrev,1,@LEN-1)
80 boolean needsComma
= false;
82 String nomRefCache
= "";
85 nomRefCache
= prefixReferenceJounal
+ blank
;
88 if (!"".equals(titelAbbrev
)){
89 nomRefCache
= nomRefCache
+ titelAbbrev
+ blank
;
93 String seriesPart
= "";
94 if (!"".equals(series
)){
96 if (isNumeric(series
)){
97 seriesPart
= prefixSeries
+ blank
+ seriesPart
;
100 seriesPart
= comma
+ seriesPart
;
104 nomRefCache
+= seriesPart
;
108 String volumePart
= "";
109 if (!"".equals(volume
)){
112 volumePart
= comma
+ blank
+ volumePart
;
114 //needsComma = false;
116 nomRefCache
+= volumePart
;
119 while (nomRefCache
.endsWith(".")){
120 nomRefCache
= nomRefCache
.substring(0, nomRefCache
.length()-1);
123 return nomRefCache
.trim();
126 private boolean isNumeric(String string
){
131 Double
.valueOf(string
);
133 } catch (NumberFormatException e
) {