Project

General

Profile

« Previous | Next » 

Revision 2300c416

Added by Andreas Müller almost 3 years ago

cleanup

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/reference/TitleWithoutYearAndAuthorHelper.java
100 100
        //titelAbbrev
101 101
        if (isNotBlank(journalTitel)){
102 102
            result = result + journalTitel;
103
            needsComma = makeNeedsCommaArticle(needsComma, result, volume, series);
103
            needsComma = computeNeedsCommaArticle(result, volume, series);
104 104
            if (! needsComma){
105 105
                result = result + blank;
106 106
            }
......
122 122
        return result.trim();
123 123
    }
124 124

  
125

  
126 125
    private static String getTitleWithoutYearAndAuthorBook(Reference ref, boolean isAbbrev){
127 126
        if (ref == null){
128 127
            return null;
......
135 134
        String volume = CdmUtils.Nz(ref.getVolume()).trim();
136 135
        String refYear = "";  //TODO nomenclaturalReference.getYear();
137 136

  
138

  
139 137
        String nomRefCache = "";
140 138
        Integer len;
141 139
        String lastChar = "";
......
147 145
        //lastCharIsDouble = f_core_CompareStrings(RIGHT(@TitelAbbrev,1),character);
148 146
        boolean lastCharIsDouble = title.equals(character);
149 147

  
150
        if(lastCharIsDouble  && edition.length() == 0 && refSeriesPart.length() == 0 && volume.length() == 0 && refYear.length() > 0 ){
148
        if(lastCharIsDouble && edition.length() == 0 && refSeriesPart.length() == 0 && volume.length() == 0 && refYear.length() > 0 ){
151 149
            title =  title.substring(1, len-1); //  SUBSTRING(@TitelAbbrev,1,@LEN-1)
152 150
        }
153 151

  
......
182 180
        }
183 181
        nomRefCache += seriesPart;
184 182

  
185

  
186 183
        //volume Part
187 184
        String volumePart = "";
188 185
        if (isNotBlank(volume)){
......
366 363

  
367 364
//**************************** HELPER ********************************/
368 365

  
369
    private static boolean makeNeedsCommaArticle(boolean needsComma, String nomRefCache, String volume, String series) {
370
        if (needsComma){
366
    public static boolean computeNeedsCommaArticle(String nomRefCache, String volume, String series) {
367

  
368
        nomRefCache = nomRefCache.toLowerCase();
369
        int serIndex = nomRefCache.indexOf(" ser. ");
370
        int sectIndex = nomRefCache.indexOf(" sect. ");
371
        int abtIndex = nomRefCache.indexOf(" abt. ");
372
        int index = Math.max(Math.max(serIndex, sectIndex), abtIndex);
373
        int commaIndex = nomRefCache.indexOf(",", index);
374
        if (index > -1 && commaIndex == -1 && isNotBlank(volume)){
375
            return true;
376
        }else if (isNotBlank(series)){
371 377
            return true;
372 378
        }else{
373
            nomRefCache = nomRefCache.toLowerCase();
374
            int serIndex = nomRefCache.indexOf(" ser. ");
375
            int sectIndex = nomRefCache.indexOf(" sect. ");
376
            int abtIndex = nomRefCache.indexOf(" abt. ");
377
            int index = Math.max(Math.max(serIndex, sectIndex), abtIndex);
378
            int commaIndex = nomRefCache.indexOf(",", index);
379
            if (index > -1 && commaIndex == -1 && isNotBlank(volume)){
380
                return true;
381
            }else if (isNotBlank(series)){
382
                return true;
383
            }else{
384
                return false;
385
            }
379
            return false;
386 380
        }
387 381
    }
388 382

  
......
402 396
        }
403 397
        nomRefCache += seriesPart;
404 398

  
405

  
406 399
        //volume Part
407 400
        String volumePart = "";
408 401
        if (!"".equals(volume)){

Also available in: Unified diff