Project

General

Profile

« Previous | Next » 

Revision b53cbc41

Added by Andreas Müller about 8 years ago

Add post-separator to better handle tagged text

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/NonViralName.java
1379 1379
        }
1380 1380
    }
1381 1381

  
1382

  
1383
    /**
1384
     * Defines the last part of the name.
1385
     * This is for infraspecific taxa, the infraspecific epithet,
1386
     * for species the specific epithet, for infageneric taxa the infrageneric epithet
1387
     * else the genusOrUninomial.
1388
     * However, the result does not depend on the rank (which may be not correctly set
1389
     * in case of dirty data) but returns the first name part which is not blank
1390
     * considering the above order.
1391
     * @return the first not blank name part in reverse order
1392
     */
1393
    public String getLastNamePart() {
1394
        String result =
1395
                StringUtils.isNotBlank(this.getInfraSpecificEpithet())?
1396
                    this.getInfraSpecificEpithet() :
1397
                StringUtils.isNotBlank(this.getSpecificEpithet()) ?
1398
                    this.getSpecificEpithet():
1399
                StringUtils.isNotBlank(this.getInfraGenericEpithet()) ?
1400
                    this.getInfraGenericEpithet():
1401
                this.getGenusOrUninomial();
1402
        return result;
1403
    }
1404

  
1382 1405
//*********************** CLONE ********************************************************/
1383 1406

  
1384 1407
    /**
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/TagEnum.java
70 70
	 */
71 71
	separator,
72 72
	/**
73
     *  A separator that needs to be added to the previous text if and only if
74
     *  the previous tag is used (not filtered) and if it is not the last tag
75
     *  in the list.
76
     *  A post-separator should include all needed whitespaces. So adding of whitespace
77
     *  is not needed if a post-separator is given.
78
     */
79
    postSeparator,
80
	/**
73 81
	 *  The hybrid sign.
74 82
	 */
75 83
	hybridSign,
......
103 111
		return this == nomStatus;
104 112
	}
105 113
	public boolean isSeparator(){
106
		return this == separator;
114
		return this == separator || this == postSeparator;
107 115
	}
108 116
	public boolean isHybridSign(){
109 117
		return this == hybridSign;
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/name/INameCacheStrategy.java
12 12

  
13 13
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
14 14
import eu.etaxonomy.cdm.strategy.cache.HTMLTagRules;
15
import eu.etaxonomy.cdm.strategy.cache.TagEnum;
15 16
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
16 17
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
17 18

  
......
59 60
     * Get {@link TaggedText} for the nomenclatural status part
60 61
     * @param taxonName
61 62
     * @param includeSeparatorBefore if a separator should be added before
62
     * @param includeSeparatorAfter if a separator should be added after
63
     * @param includePostSeparator if a {@link TagEnum#postSeparator post-separator}
64
     *  should be added after
63 65
     * @return
64 66
     */
65 67
    public List<TaggedText> getNomStatusTags(T taxonName, boolean includeSeparatorBefore,
66
            boolean includeSeparatorAfter);
68
            boolean includePostSeparator);
67 69

  
68 70
    /**
69 71
     * Returns the full title cache as a string. The full title cache contains
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/name/NonViralNameDefaultCacheStrategy.java
391 391
            }
392 392
            nomStatusTags.add(new TaggedText(TagEnum.nomStatus, nomStatusStr));
393 393
            if (includeSeparatorAfter){
394
                nomStatusTags.add(new TaggedText(TagEnum.separator, ","));
394
                nomStatusTags.add(new TaggedText(TagEnum.postSeparator, ","));
395 395
            }
396 396
        }
397 397
        return nomStatusTags;
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/taxon/TaxonBaseDefaultCacheStrategy.java
67 67
                tags.addAll(nameTags);
68 68

  
69 69
                String secSeparator =  " sec. ";
70
                if (nameTags.get(nameTags.size() - 1).getType().equals(TagEnum.nomStatus)){
71
                    secSeparator = "," + secSeparator;
72
                }
70
                //not used: we currently use a post-separator in the name tags
71
//                if (nameTags.get(nameTags.size() - 1).getType().equals(TagEnum.nomStatus)){
72
//                    secSeparator = "," + secSeparator;
73
//                }
73 74

  
74 75
                //ref.
75 76
                List<TaggedText> secTags = getSecundumTags(taxonBase);

Also available in: Unified diff