Project

General

Profile

« Previous | Next » 

Revision 6b45c577

Added by Katja Luther over 7 years ago

fix CubaCondensedStringComposer

View differences:

cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/geo/CondensedDistributionComposerBase.java
26 26

  
27 27
    protected static Map<UUID, String> statusSymbols;
28 28

  
29

  
30

  
31
    protected String areaPreTag = "<b>";
32

  
33
    protected String areaPostTag = "</b>";
34

  
35

  
36

  
29 37
    /**
30 38
     * @param status
31 39
     * @return
......
69 77
        return symbol;
70 78
    }
71 79

  
80

  
81
    public String getAreaPreTag() {
82
        return areaPreTag;
83
    }
84

  
85
    public void setAreaPreTag(String areaPreTag) {
86
        this.areaPreTag = areaPreTag;
87
    }
88

  
89
    public String getAreaPostTag() {
90
        return areaPostTag;
91
    }
92

  
93
    public void setAreaPostTag(String areaPostTag) {
94
        this.areaPostTag = areaPostTag;
95
    }
96

  
97

  
98

  
72 99
}
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/geo/FloraCubaCondensedDistributionComposer.java
21 21
import org.apache.log4j.Logger;
22 22

  
23 23
import eu.etaxonomy.cdm.api.service.dto.CondensedDistribution;
24
import eu.etaxonomy.cdm.common.UTF8;
24 25
import eu.etaxonomy.cdm.model.common.CdmBase;
25 26
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
26 27
import eu.etaxonomy.cdm.model.common.Language;
......
41 42

  
42 43
    private static Set<UUID> foreignStatusUuids;
43 44

  
45
    private UUID uuidInternalArea = UUID.fromString("d0144a6e-0e17-4a1d-bce5-d464a2aa7229");  //Cuba
46

  
47
    private String internalAreaSeparator = UTF8.EN_DASH.toString() + " ";
48

  
49

  
44 50
    // these status uuids are special for EuroPlusMed and might also be used
45 51
    private final static UUID REPORTED_IN_ERROR_UUID =  UUID.fromString("38604788-cf05-4607-b155-86db456f7680");
46 52

  
......
78 84
            areaList.add(0, (NamedArea)CdmBase.deproxy(dtb));
79 85
        }
80 86

  
87

  
88
        boolean isFirstAfterInternalArea = false;
81 89
        for (NamedArea area : areaList){
82 90

  
83 91
            if (area.getPartOf() != null){
84 92
                continue;  //subarea are handled later
85 93
            }
94

  
86 95
            StringBuilder areaStatusString = new StringBuilder();
96

  
97

  
98

  
87 99
            Distribution distribution = getDistribution(area, filteredDistributions);
88 100
            if (distribution == null){
89 101
                continue;
90 102
            }
91 103

  
104
            if (area.getUuid().equals(uuidInternalArea)){
105
                isFirstAfterInternalArea = true;
106
            }else if(isFirstAfterInternalArea && !area.getUuid().equals(uuidInternalArea)){
107
                areaStatusString.append(internalAreaSeparator);
108
                isFirstAfterInternalArea = false;
109
            }
110

  
92 111
            PresenceAbsenceTerm status = distribution.getStatus();
93 112

  
94 113
            String statusSymbol = statusSymbol(status);
......
103 122
//                areaStatusString.append(')');
104 123
            }
105 124

  
125

  
106 126
//            if(isForeignStatus(status)) {
107 127
//                condensedDistribution.addForeignDistributionItem(status, areaStatusString.toString(), areaLabel);
108 128
//            } else {
......
199 219
     * @return
200 220
     */
201 221
    private String makeAreaLabel(List<Language> langs, NamedArea area) {
202
        return area.getIdInVocabulary() != null ? area.getIdInVocabulary() :area.getPreferredRepresentation(langs).getAbbreviatedLabel();
222
        String result = area.getIdInVocabulary() != null ? area.getIdInVocabulary() :area.getPreferredRepresentation(langs).getAbbreviatedLabel();
223
        return areaPreTag + result + areaPostTag;
224
    }
225

  
226

  
227

  
228
    public String getInternalAreaSeparator() {
229
        return internalAreaSeparator;
230
    }
231

  
232
    public void setInternalAreaSeparator(String internalAreaSeparator) {
233
        this.internalAreaSeparator = internalAreaSeparator;
203 234
    }
204 235

  
205 236
    /**
......
257 288
        }
258 289
    }
259 290

  
291

  
292

  
260 293
}
cdmlib-ext/src/test/java/eu/etaxonomy/cdm/ext/geo/FloraCubaCondensedDistributionComposerTest.java
130 130
    @Test
131 131
    public void testCreateCondensedDistribution() {
132 132
        FloraCubaCondensedDistributionComposer composer = new FloraCubaCondensedDistributionComposer();
133
        composer.setAreaPreTag("");
134
        composer.setAreaPostTag("");
133 135

  
134 136
        Set<Distribution> filteredDistributions = new HashSet<Distribution>();
135 137
        filteredDistributions.add(Distribution.NewInstance(cuba, PresenceAbsenceTerm.NATURALISED()));
......
142 144
        CondensedDistribution condensedDistribution = composer.createCondensedDistribution(filteredDistributions, null);
143 145
        String condensedString = condensedDistribution.toString();
144 146

  
145
        Assert.assertEquals("Condensed string for Cuba differs", "nCu((c)CuE(nHo)) Bah ?VM ", condensedString);
147
        Assert.assertEquals("Condensed string for Cuba differs", "nCu((c)CuE(nHo)) "+composer.getInternalAreaSeparator() +"Bah ?VM ", condensedString);
146 148

  
147 149

  
148 150
        //TODO work in progress
......
162 164
        //Cuba
163 165
        label = "Cuba";
164 166
        abbrev = "Cu";
165
        UUID uuid = UUID.randomUUID();
167
        UUID uuid = UUID.fromString("d0144a6e-0e17-4a1d-bce5-d464a2aa7229");
166 168
        cuba = getNamedArea(uuid, label, abbrev, cubaAreasVocabualary);
167 169

  
168 170
        //Western Cuba

Also available in: Unified diff