Revision da9240c3
Added by Andreas Müller about 8 years ago
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/geo/CondensedDistributionComposerBase.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2016 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.cdm.ext.geo; |
|
11 |
|
|
12 |
import java.util.Map; |
|
13 |
import java.util.UUID; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.model.common.Language; |
|
16 |
import eu.etaxonomy.cdm.model.common.Representation; |
|
17 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
|
18 |
|
|
19 |
/** |
|
20 |
* Base class for Distribution Composers |
|
21 |
* @author a.mueller |
|
22 |
* @date 02.06.2016 |
|
23 |
* |
|
24 |
*/ |
|
25 |
public abstract class CondensedDistributionComposerBase implements ICondensedDistributionComposer{ |
|
26 |
|
|
27 |
protected static Map<UUID, String> statusSymbols; |
|
28 |
|
|
29 |
/** |
|
30 |
* @param status |
|
31 |
* @return |
|
32 |
*/ |
|
33 |
protected String statusSymbol(PresenceAbsenceTerm status) { |
|
34 |
if(status == null) { |
|
35 |
return ""; |
|
36 |
} |
|
37 |
String symbol = statusSymbols.get(status.getUuid()); |
|
38 |
if(symbol != null) { |
|
39 |
return symbol; |
|
40 |
}else if (status.getSymbol() != null){ |
|
41 |
return status.getSymbol(); |
|
42 |
}else if (status.getIdInVocabulary() != null){ |
|
43 |
return status.getIdInVocabulary(); |
|
44 |
}else { |
|
45 |
Representation r = status.getPreferredRepresentation((Language)null); |
|
46 |
if (r != null){ |
|
47 |
String abbrevLabel = r.getAbbreviatedLabel(); |
|
48 |
if (abbrevLabel != null){ |
|
49 |
return abbrevLabel; |
|
50 |
} |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
return "n.a."; |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* @param status |
|
59 |
* @return |
|
60 |
*/ |
|
61 |
private String statusSymbolEuroMedOld(PresenceAbsenceTerm status) { |
|
62 |
if(status == null) { |
|
63 |
return ""; |
|
64 |
} |
|
65 |
String symbol = statusSymbols.get(status.getUuid()); |
|
66 |
if(symbol == null) { |
|
67 |
symbol = ""; |
|
68 |
} |
|
69 |
return symbol; |
|
70 |
} |
|
71 |
|
|
72 |
} |
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/geo/EuroPlusMedCondensedDistributionComposer.java | ||
---|---|---|
33 | 33 |
* @date Jun 24, 2015 |
34 | 34 |
* |
35 | 35 |
*/ |
36 |
public class EuroPlusMedCondensedDistributionComposer implements ICondensedDistributionComposer {
|
|
36 |
public class EuroPlusMedCondensedDistributionComposer extends CondensedDistributionComposerBase {
|
|
37 | 37 |
|
38 | 38 |
@SuppressWarnings("unused") |
39 | 39 |
private static final Logger logger = Logger.getLogger(EuroPlusMedCondensedDistributionComposer.class); |
40 | 40 |
|
41 | 41 |
private final CondensedDistribution condensedDistribution; |
42 | 42 |
|
43 |
private static Map<UUID, String> statusSymbols; |
|
44 |
|
|
45 | 43 |
private static Set<UUID> foreignStatusUuids; |
46 | 44 |
|
47 | 45 |
// these status uuids are special for EuroPlusMed and might also be used |
... | ... | |
196 | 194 |
return condensedDistribution; |
197 | 195 |
} |
198 | 196 |
|
199 |
/** |
|
200 |
* @param status |
|
201 |
* @return |
|
202 |
*/ |
|
203 |
private String statusSymbol(PresenceAbsenceTerm status) { |
|
204 |
if(status == null) { |
|
205 |
return ""; |
|
206 |
} |
|
207 |
String symbol = statusSymbols.get(status.getUuid()); |
|
208 |
if(symbol == null) { |
|
209 |
symbol = ""; |
|
210 |
} |
|
211 |
return symbol; |
|
212 |
} |
|
213 | 197 |
|
214 | 198 |
private boolean isForeignStatus(PresenceAbsenceTerm status) { |
215 | 199 |
return foreignStatusUuids.contains(status.getUuid()); |
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/geo/FloraCubaCondensedDistributionComposer.java | ||
---|---|---|
14 | 14 |
import java.util.HashMap; |
15 | 15 |
import java.util.HashSet; |
16 | 16 |
import java.util.List; |
17 |
import java.util.Map; |
|
18 | 17 |
import java.util.Set; |
19 | 18 |
import java.util.UUID; |
20 | 19 |
|
... | ... | |
26 | 25 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
27 | 26 |
import eu.etaxonomy.cdm.model.common.Language; |
28 | 27 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
29 |
import eu.etaxonomy.cdm.model.common.Representation; |
|
30 | 28 |
import eu.etaxonomy.cdm.model.description.Distribution; |
31 | 29 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
32 | 30 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
... | ... | |
36 | 34 |
* @date Apr 05, 2016 |
37 | 35 |
* |
38 | 36 |
*/ |
39 |
public class FloraCubaCondensedDistributionComposer implements ICondensedDistributionComposer {
|
|
37 |
public class FloraCubaCondensedDistributionComposer extends CondensedDistributionComposerBase {
|
|
40 | 38 |
|
41 | 39 |
@SuppressWarnings("unused") |
42 | 40 |
private static final Logger logger = Logger.getLogger(FloraCubaCondensedDistributionComposer.class); |
43 | 41 |
|
44 |
private static Map<UUID, String> statusSymbols; |
|
45 |
|
|
46 | 42 |
private static Set<UUID> foreignStatusUuids; |
47 | 43 |
|
48 | 44 |
// these status uuids are special for EuroPlusMed and might also be used |
... | ... | |
66 | 62 |
@Override |
67 | 63 |
public CondensedDistribution createCondensedDistribution(Collection<Distribution> filteredDistributions, |
68 | 64 |
List<Language> langs) { |
65 |
|
|
69 | 66 |
CondensedDistribution condensedDistribution = new CondensedDistribution(); |
70 | 67 |
|
71 | 68 |
//empty |
... | ... | |
137 | 134 |
return null; |
138 | 135 |
} |
139 | 136 |
|
140 |
/** |
|
141 |
* @param status |
|
142 |
* @return |
|
143 |
*/ |
|
144 |
private String statusSymbol(PresenceAbsenceTerm status) { |
|
145 |
if(status == null) { |
|
146 |
return ""; |
|
147 |
} |
|
148 |
String symbol = statusSymbols.get(status.getUuid()); |
|
149 |
if(symbol != null) { |
|
150 |
return symbol; |
|
151 |
}else if (status.getSymbol() != null){ |
|
152 |
return status.getSymbol(); |
|
153 |
}else if (status.getIdInVocabulary() != null){ |
|
154 |
return status.getIdInVocabulary(); |
|
155 |
}else { |
|
156 |
Representation r = status.getPreferredRepresentation((Language)null); |
|
157 |
if (r != null){ |
|
158 |
String abbrevLabel = r.getAbbreviatedLabel(); |
|
159 |
if (abbrevLabel != null){ |
|
160 |
return abbrevLabel; |
|
161 |
} |
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
return "n.a."; |
|
166 |
} |
|
167 | 137 |
|
168 | 138 |
// private boolean isForeignStatus(PresenceAbsenceTerm status) { |
169 | 139 |
// return foreignStatusUuids.contains(status.getUuid()); |
Also available in: Unified diff
First step to combine Distribution Composers