Project

General

Profile

« Previous | Next » 

Revision 9dc896c9

Added by Andreas Müller almost 7 years ago

fix #6368 rename table and class TaxonNameBase

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/name/NonViralNameDefaultCacheStrategy.java
31 31
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
32 32
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
33 33
import eu.etaxonomy.cdm.model.name.Rank;
34
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
34
import eu.etaxonomy.cdm.model.name.TaxonName;
35 35
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
36 36
import eu.etaxonomy.cdm.model.reference.Reference;
37
import eu.etaxonomy.cdm.strategy.cache.HTMLTagRules;
38 37
import eu.etaxonomy.cdm.strategy.cache.TagEnum;
39
import eu.etaxonomy.cdm.strategy.cache.TaggedCacheHelper;
40 38
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
41 39
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
42 40
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImplRegExBase;
......
54 52
public class NonViralNameDefaultCacheStrategy<T extends INonViralName>
55 53
        extends NameCacheStrategyBase<T>
56 54
        implements INonViralNameCacheStrategy<T> {
57
	private static final Logger logger = Logger.getLogger(NonViralNameDefaultCacheStrategy.class);
55

  
56
    private static final Logger logger = Logger.getLogger(NonViralNameDefaultCacheStrategy.class);
58 57
	private static final long serialVersionUID = -6577757501563212669L;
59 58

  
60 59
    final static UUID uuid = UUID.fromString("1cdda0d1-d5bc-480f-bf08-40a510a2f223");
......
171 170

  
172 171
//** *****************************************************************************************/
173 172

  
174
    @Override
175
    public String getTitleCache(T nonViralName) {
176
    	return getTitleCache(nonViralName, null);
177
    }
178

  
179
    @Override
180
	public String getTitleCache(T nonViralName, HTMLTagRules htmlTagRules) {
181
    	List<TaggedText> tags = getTaggedTitle(nonViralName);
182
		if (tags == null){
183
			return null;
184
		}else{
185
			String result = createString(tags, htmlTagRules);
186
		    return result;
187
		}
188
    }
189

  
190
	@Override
191
	public String getFullTitleCache(T nonViralName, HTMLTagRules htmlTagRules) {
192
		List<TaggedText> tags = getTaggedFullTitle(nonViralName);
193
	    if (tags == null){
194
	    	return null;
195
	    }else{
196
	    	String result = createString(tags, htmlTagRules);
197
	    	return result;
198
	    }
199
	}
200

  
201
    @Override
202
    public String getFullTitleCache(T nonViralName) {
203
    	return getFullTitleCache(nonViralName, null);
204
    }
205

  
206 173

  
207
    /**
208
     * Generates and returns the "name cache" (only scientific name without author teams and year).
209
     * @see eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy#getNameCache(eu.etaxonomy.cdm.model.name.TaxonNameBase)
210
     */
211
    @Override
212
    public String getNameCache(T nonViralName) {
213
        List<TaggedText> tags = getTaggedName(nonViralName);
214
        if (tags == null){
215
            return null;
216
        }else{
217
            String result = createString(tags);
218
            return result;
219
        }
220
    }
221 174

  
222 175

  
223 176
// ******************* Authorship ******************************/
224 177

  
225 178
    @Override
226
    public String getAuthorshipCache(T nonViralName) {
227
        if (nonViralName == null){
179
    public String getAuthorshipCache(T taxonName) {
180
        if (taxonName == null){
228 181
            return null;
229 182
        }
230 183
        //cache protected
231
        if (nonViralName.isProtectedAuthorshipCache() == true) {
232
            return nonViralName.getAuthorshipCache();
184
        if (taxonName.isProtectedAuthorshipCache() == true) {
185
            return taxonName.getAuthorshipCache();
233 186
        }
234
        return getNonCacheAuthorshipCache(nonViralName);
187
        return getNonCacheAuthorshipCache(taxonName);
235 188
    }
236 189

  
237 190
    /**
......
358 311
    @Override
359 312
    public List<TaggedText> getNomStatusTags(T nonViralName, boolean includeSeparatorBefore,
360 313
            boolean includeSeparatorAfter) {
314

  
361 315
        Set<NomenclaturalStatus> ncStati = nonViralName.getStatus();
362 316
        Iterator<NomenclaturalStatus> iterator = ncStati.iterator();
363
        List<TaggedText> nomStatusTags = new ArrayList<TaggedText>();
317
        List<TaggedText> nomStatusTags = new ArrayList<>();
364 318
        while (iterator.hasNext()) {
365 319
            NomenclaturalStatus ncStatus = iterator.next();
366 320
            // since the NewInstance method of nomencatural status allows null as parameter
......
856 810
			NameRelationshipType type = nameRel.getType();
857 811
    		if(type != null && type.equals(NameRelationshipType.ORIGINAL_SPELLING())){
858 812
    			String originalNameString;
859
    			TaxonNameBase<?,?> originalName = nameRel.getFromName();
813
    			TaxonName originalName = nameRel.getFromName();
860 814
    			if (!originalName.isNonViral()){
861 815
    				originalNameString = originalName.getTitleCache();
862 816
    			}else{
......
920 874

  
921 875

  
922 876
	@Override
923
    public String getLastEpithet(T taxonNameBase) {
924
        Rank rank = taxonNameBase.getRank();
877
    public String getLastEpithet(T taxonName) {
878
        Rank rank = taxonName.getRank();
925 879
        if(rank.isGenus() || rank.isSupraGeneric()) {
926
            return taxonNameBase.getGenusOrUninomial();
880
            return taxonName.getGenusOrUninomial();
927 881
        } else if(rank.isInfraGeneric()) {
928
            return taxonNameBase.getInfraGenericEpithet();
882
            return taxonName.getInfraGenericEpithet();
929 883
        } else if(rank.isSpecies()) {
930
            return taxonNameBase.getSpecificEpithet();
884
            return taxonName.getSpecificEpithet();
931 885
        } else {
932
            return taxonNameBase.getInfraSpecificEpithet();
886
            return taxonName.getInfraSpecificEpithet();
933 887
        }
934 888
    }
935 889

  
936 890

  
937 891
    /**
938
     * @param tags
939
     * @return
892
     * {@inheritDoc}
940 893
     */
941
    private String createString(List<TaggedText> tags) {
942
        return TaggedCacheHelper.createString(tags);
943
    }
894
    @Override
895
    protected List<TaggedText> doGetTaggedTitle(T nonViralName) {
896
        List<TaggedText> tags = new ArrayList<>();
897
        if (nonViralName.isHybridFormula()){
898
            //hybrid formula
899
            String hybridSeparator = NonViralNameParserImplRegExBase.hybridSign;
900
            boolean isFirst = true;
901
            List<HybridRelationship> rels = nonViralName.getOrderedChildRelationships();
902
            for (HybridRelationship rel: rels){
903
                if (! isFirst){
904
                    tags.add(new TaggedText(TagEnum.hybridSign, hybridSeparator));
905
                }
906
                isFirst = false;
907
                tags.addAll(getTaggedTitle((T)rel.getParentName()));
908
            }
909
            return tags;
910
        }else if (nonViralName.isAutonym()){
911
            //Autonym
912
            tags.addAll(handleTaggedAutonym(nonViralName));
913
        }else{ //not Autonym
914
    //      String nameCache = nonViralName.getNameCache();  //OLD: CdmUtils.Nz(getNameCache(nonViralName));
944 915

  
945
    /**
946
     * @param tags
947
     * @param htmlTagRules
948
     * @return
949
     */
950
    private String createString(List<TaggedText> tags, HTMLTagRules htmlTagRules) {
951
        return TaggedCacheHelper.createString(tags, htmlTagRules);
916
            List<TaggedText> nameTags = getTaggedName(nonViralName);
917
            tags.addAll(nameTags);
918
            String authorCache = getAuthorshipCache(nonViralName);
919
            if (StringUtils.isNotBlank(authorCache)){
920
                tags.add(new TaggedText(TagEnum.authors, authorCache));
921
            }
922
        }
923
        return tags;
952 924
    }
953 925

  
954

  
955

  
956 926
}

Also available in: Unified diff