Project

General

Profile

Revision 81502ddd

ID81502ddd5cceb907898e7d34b33e97fc84dd46f7
Parent 82eb3374
Child 90ec321a

Added by Andreas Müller over 2 years ago

ref #6682 further fixes for taxon relationship service - better separators

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/format/taxon/TaxonRelationshipFormatter.java
41 41
    private static final String SYN_SEC = ", syn. sec. ";
42 42
    private static final String UNKNOWN_SEC = "???";
43 43
    private static final String NON_SEPARATOR = ", non ";
44
    private static final String QUOTE_START = "\"";   //TODO
44
    private static final String QUOTE_START = " \"";   //TODO
45 45
    private static final String QUOTE_END = "\"";   //TODO
46 46
    private static final String AUCT = "auct.";
47 47
    private static final String SENSU_SEPARATOR = " sensu ";
......
74 74
        String symbol = getSymbol(type, reverse, languages);
75 75
        tags.add(TaggedText.NewInstance(TagEnum.symbol, symbol));
76 76

  
77
        //whitespace
78
        tags.add(TaggedText.NewWhitespaceInstance());
79

  
80 77
        //name
81 78
        if (isMisapplied){
82 79
            //starting quote
......
89 86

  
90 87
            //end quote
91 88
            String endQuote = QUOTE_END;
92
            tags.add(TaggedText.NewSeparatorInstance(endQuote));
89
            tags.add(TaggedText.NewInstance(TagEnum.postSeparator, endQuote));
93 90
        }else{
91
            tags.add(TaggedText.NewWhitespaceInstance());
94 92
            //name title cache
95 93
            //TODO fullTitle?
96 94
            List<TaggedText> nameCacheTags = getNameTitleCacheTags(name);
......
213 211

  
214 212

  
215 213
    /**
216
     * @param sec
217
     * @param secMicroReference
218
     * @return
219
     */
220
    private List<TaggedText> getCitationTags(Reference ref, String secMicroReference) {
221
        List<TaggedText> result = new ArrayList<>();
222
        String secRef;
223

  
224
        if (ref != null){
225
            //copied from TaxonBaseDefaultCacheStrategy
226
            if (ref.isProtectedTitleCache() == false &&
227
                    ref.getCacheStrategy() != null &&
228
                    ref.getAuthorship() != null &&
229
                    isNotBlank(ref.getAuthorship().getTitleCache()) &&
230
                    isNotBlank(ref.getYear())){
231
                secRef = ref.getCacheStrategy().getCitation(ref);
232
            }else{
233
                secRef = ref.getTitleCache();
234
            }
235
            //TODO do we need a sensuReference type?
236
            TaggedText refTag = TaggedText.NewInstance(TagEnum.secReference, secRef);
237
            refTag.setEntityReference(new TypedEntityReference<>(ref.getClass(), ref.getUuid(), secRef));
238
            result.add(refTag);
239
        }
240
        if (isNotBlank(secMicroReference)){
241
            result.add(TaggedText.NewSeparatorInstance(DETAIL_SEPARATOR));
242
            TaggedText microTag = TaggedText.NewInstance(TagEnum.secMicroReference, secMicroReference);
243
            result.add(microTag);
244
        }
245
        return result;
246
    }
247

  
248

  
249
    /**
250 214
     * @param name
251 215
     * @return
252 216
     */
......
258 222
    private List<TaggedText> getNameTitleCacheTags(TaxonName name) {
259 223

  
260 224
        //TODO full title?
261
        List<TaggedText> result = name.getCacheStrategy().getTaggedTitle(name);
225
        List<TaggedText> result = name.getCacheStrategy().getTaggedFullTitle(name);
262 226
        return result;
263 227
    }
264 228

  
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/dto/TaxonRelationshipsDTOTest.java
129 129
        List<List<TaggedText>> misapplications = dto.getMisapplications();
130 130
        Assert.assertEquals(2, misapplications.size());  //1 deduplicated
131 131
        List<TaggedText> deduplicated = misapplications.get(0);
132
        Assert.assertEquals(14, deduplicated.size());
133
        Assert.assertSame(relToDuplicate.getTaggedText().get(7), deduplicated.get(9));
134
        Assert.assertEquals(12, misapplications.get(1).size());
132
        Assert.assertEquals(13, deduplicated.size());
133
        Assert.assertSame(relToDuplicate.getTaggedText().get(6), deduplicated.get(8));
134
        Assert.assertEquals(11, misapplications.get(1).size());
135 135

  
136 136
    }
137 137

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)