1 |
aea90ab7
|
Andreas Müller
|
/**
|
2 |
|
|
* Copyright (C) 2017 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
6 |
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7 |
|
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8 |
|
|
*/
|
9 |
|
|
package eu.etaxonomy.cdm.io.greece;
|
10 |
|
|
|
11 |
|
|
import java.net.URI;
|
12 |
d6b2ef47
|
Andreas Müller
|
import java.text.ParseException;
|
13 |
aea90ab7
|
Andreas Müller
|
import java.util.UUID;
|
14 |
|
|
|
15 |
|
|
import org.apache.log4j.Logger;
|
16 |
|
|
import org.springframework.stereotype.Component;
|
17 |
|
|
import org.springframework.transaction.TransactionStatus;
|
18 |
|
|
|
19 |
|
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
20 |
|
|
import eu.etaxonomy.cdm.ext.geo.GeoServiceArea;
|
21 |
|
|
import eu.etaxonomy.cdm.ext.geo.GeoServiceAreaAnnotatedMapping;
|
22 |
|
|
import eu.etaxonomy.cdm.io.common.CdmImportBase;
|
23 |
|
|
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
|
24 |
|
|
import eu.etaxonomy.cdm.model.common.OrderedTermBase;
|
25 |
|
|
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
|
26 |
|
|
import eu.etaxonomy.cdm.model.common.TermType;
|
27 |
c6df7de0
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
28 |
aea90ab7
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.description.Feature;
|
29 |
|
|
import eu.etaxonomy.cdm.model.description.FeatureNode;
|
30 |
|
|
import eu.etaxonomy.cdm.model.description.FeatureTree;
|
31 |
|
|
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
|
32 |
|
|
import eu.etaxonomy.cdm.model.description.State;
|
33 |
|
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
34 |
|
|
import eu.etaxonomy.cdm.model.location.NamedAreaType;
|
35 |
|
|
|
36 |
|
|
/**
|
37 |
|
|
* @author a.mueller
|
38 |
53d7c437
|
Andreas Müller
|
* @since 13.05.2017
|
39 |
aea90ab7
|
Andreas Müller
|
*
|
40 |
|
|
*/
|
41 |
|
|
@Component
|
42 |
|
|
public class FloraHellenicaTermImport <CONFIG extends FloraHellenicaImportConfigurator>
|
43 |
|
|
extends CdmImportBase<CONFIG, SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator>>{
|
44 |
|
|
|
45 |
|
|
private static final long serialVersionUID = 1347759514044184010L;
|
46 |
|
|
|
47 |
|
|
@SuppressWarnings("unused")
|
48 |
|
|
private static final Logger logger = Logger.getLogger(FloraHellenicaTaxonImport.class);
|
49 |
|
|
|
50 |
|
|
private NamedArea greece;
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
/**
|
55 |
|
|
* {@inheritDoc}
|
56 |
|
|
*/
|
57 |
|
|
@Override
|
58 |
|
|
protected void doInvoke(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
59 |
|
|
|
60 |
|
|
TransactionStatus tx = this.startTransaction();
|
61 |
|
|
initAreaVocabulary(state);
|
62 |
|
|
initLifeformVocabulary(state);
|
63 |
|
|
initHabitatVocabulary(state);
|
64 |
|
|
initChorologicalVocabulary(state);
|
65 |
|
|
initStatusVocabulary(state);
|
66 |
|
|
makeFeatureTree(state);
|
67 |
d6b2ef47
|
Andreas Müller
|
makeMapColors(state);
|
68 |
aea90ab7
|
Andreas Müller
|
this.commitTransaction(tx);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
@SuppressWarnings("unchecked")
|
73 |
|
|
private void initAreaVocabulary(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
74 |
|
|
OrderedTermVocabulary<NamedArea> areasVoc = (OrderedTermVocabulary<NamedArea>)this.getVocabularyService().find(FloraHellenicaTransformer.uuidFloraHellenicaAreasVoc);
|
75 |
|
|
if (areasVoc == null){
|
76 |
|
|
createAreasVoc(state);
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
/**
|
81 |
|
|
* @param state
|
82 |
|
|
* @return
|
83 |
|
|
*/
|
84 |
|
|
@SuppressWarnings("unchecked")
|
85 |
|
|
private void createAreasVoc(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
86 |
|
|
//voc
|
87 |
|
|
URI termSourceUri = null;
|
88 |
|
|
String label = "Checklist of Greece Areas";
|
89 |
|
|
String description = "Areas as used in the Checklist of Greece";
|
90 |
|
|
OrderedTermVocabulary<NamedArea> areasVoc = OrderedTermVocabulary.NewInstance(TermType.NamedArea,
|
91 |
|
|
description, label, null, termSourceUri);
|
92 |
|
|
areasVoc.setUuid(FloraHellenicaTransformer.uuidFloraHellenicaAreasVoc);
|
93 |
|
|
// Representation rep = Representation.NewInstance("Estados Méxicanos", "Estados Méxicanos", null, Language.SPANISH_CASTILIAN());
|
94 |
|
|
// areasVoc.addRepresentation(rep);
|
95 |
|
|
|
96 |
|
|
//greece country
|
97 |
|
|
String countryLabel = "Greece";
|
98 |
|
|
greece = NamedArea.NewInstance(countryLabel, countryLabel, "GR");
|
99 |
|
|
greece.setUuid(FloraHellenicaTransformer.uuidAreaGreece);
|
100 |
|
|
greece.setIdInVocabulary("GR");
|
101 |
|
|
greece.setSymbol("GR");
|
102 |
|
|
areasVoc.addTerm(greece);
|
103 |
|
|
//FIXME
|
104 |
|
|
// addMapping(greece, xx "mex_adm0", "iso", "MEX");
|
105 |
|
|
|
106 |
|
|
addArea(state, areasVoc, "IoI", "Ionian Islands", 4, FloraHellenicaTransformer.uuidAreaIoI);
|
107 |
|
|
addArea(state, areasVoc, "NPi", "North Pindos", 13, FloraHellenicaTransformer.uuidAreaNPi);
|
108 |
|
|
addArea(state, areasVoc, "SPi", "South Pindos", 11, FloraHellenicaTransformer.uuidAreaSPi);
|
109 |
|
|
addArea(state, areasVoc, "Pe", "Peloponnisos", 1, FloraHellenicaTransformer.uuidAreaPe);
|
110 |
|
|
addArea(state, areasVoc, "StE", "Sterea Ellas", 12, FloraHellenicaTransformer.uuidAreaStE);
|
111 |
|
|
addArea(state, areasVoc, "EC", "East Central Greece", 5, FloraHellenicaTransformer.uuidAreaEC);
|
112 |
|
|
addArea(state, areasVoc, "NC", "North Central Greece", 2, FloraHellenicaTransformer.uuidAreaNC);
|
113 |
|
|
addArea(state, areasVoc, "NE", "North-East Greece", 10, FloraHellenicaTransformer.uuidAreaNE);
|
114 |
|
|
addArea(state, areasVoc, "NAe", "North Aegean islands", 7, FloraHellenicaTransformer.uuidAreaNAe);
|
115 |
|
|
addArea(state, areasVoc, "WAe", "West Aegean islands", 9, FloraHellenicaTransformer.uuidAreaWAe);
|
116 |
|
|
addArea(state, areasVoc, "Kik", "Kiklades", 8, FloraHellenicaTransformer.uuidAreaKik);
|
117 |
|
|
addArea(state, areasVoc, "KK", "Kriti and Karpathos", 6, FloraHellenicaTransformer.uuidAreaKK);
|
118 |
|
|
addArea(state, areasVoc, "EAe", "East Aegean islands", 3, FloraHellenicaTransformer.uuidAreaEAe);
|
119 |
|
|
|
120 |
|
|
this.getVocabularyService().save(areasVoc);
|
121 |
|
|
return;
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
private void addArea(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state,
|
126 |
|
|
OrderedTermVocabulary<NamedArea> areasVoc,
|
127 |
|
|
String abbrevLabel, String areaLabel,
|
128 |
|
|
Integer id, UUID uuid) {
|
129 |
|
|
addArea(state, areasVoc, abbrevLabel, areaLabel, uuid, String.valueOf(id)); //short cut if label and mapping label are equal
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
private void addArea(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state,
|
133 |
|
|
OrderedTermVocabulary<NamedArea> areasVoc,
|
134 |
|
|
String abbrevLabel, String areaLabel,
|
135 |
|
|
UUID uuid, String mappingLabel) {
|
136 |
|
|
addArea(state, areasVoc, abbrevLabel, areaLabel, uuid, mappingLabel, null); //short cut if label and mapping label are equal
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
/**
|
140 |
|
|
* @param state
|
141 |
|
|
* @param string
|
142 |
|
|
* @param uuidaguascalientes
|
143 |
|
|
*/
|
144 |
|
|
private void addArea(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state,
|
145 |
|
|
OrderedTermVocabulary<NamedArea> areasVoc,
|
146 |
|
|
String abbrevLabel, String areaLabel,
|
147 |
|
|
UUID uuid, String mappingLabel, Integer id1) {
|
148 |
|
|
NamedArea newArea = NamedArea.NewInstance(
|
149 |
|
|
areaLabel, areaLabel, abbrevLabel);
|
150 |
|
|
newArea.setIdInVocabulary(abbrevLabel);
|
151 |
|
|
newArea.setUuid(uuid);
|
152 |
|
|
newArea.setPartOf(greece);
|
153 |
|
|
newArea.setLevel(null);
|
154 |
|
|
newArea.setType(NamedAreaType.NATURAL_AREA());
|
155 |
|
|
areasVoc.addTerm(newArea);
|
156 |
|
|
if (mappingLabel != null){
|
157 |
|
|
addMapping(newArea, "phytogeographical_regions_of_greece", "id", mappingLabel);
|
158 |
|
|
}
|
159 |
|
|
}
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
private void addMapping(NamedArea area, String mapping_layer, String mapping_field, String abbrev) {
|
163 |
|
|
GeoServiceAreaAnnotatedMapping mapping = (GeoServiceAreaAnnotatedMapping)this.getBean("geoServiceAreaAnnotatedMapping");
|
164 |
|
|
GeoServiceArea geoServiceArea = new GeoServiceArea();
|
165 |
|
|
geoServiceArea.add(mapping_layer, mapping_field, abbrev);
|
166 |
|
|
mapping.set(area, geoServiceArea);
|
167 |
|
|
}
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
/**
|
171 |
|
|
* @param state
|
172 |
|
|
*/
|
173 |
|
|
private void initChorologicalVocabulary(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
174 |
|
|
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaChorologicalVoc;
|
175 |
|
|
OrderedTermVocabulary<State> chorologicalVoc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid);
|
176 |
|
|
if (chorologicalVoc == null){
|
177 |
|
|
createChorologicalVoc(state, uuid);
|
178 |
|
|
}
|
179 |
|
|
}
|
180 |
|
|
|
181 |
|
|
/**
|
182 |
|
|
* @param state
|
183 |
|
|
* @param uuid
|
184 |
|
|
*/
|
185 |
|
|
private void createChorologicalVoc(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state, UUID vocUuid) {
|
186 |
|
|
//voc
|
187 |
|
|
URI termSourceUri = null;
|
188 |
|
|
String label = "Checklist of Greece Chorological Categories";
|
189 |
|
|
String description = "Chorological Categories as used in the Checklist of Greece";
|
190 |
|
|
OrderedTermVocabulary<State> chorologicalVoc = OrderedTermVocabulary.NewInstance(TermType.State,
|
191 |
|
|
description, label, null, termSourceUri);
|
192 |
|
|
chorologicalVoc.setUuid(vocUuid);
|
193 |
|
|
|
194 |
|
|
addChorological(state, chorologicalVoc, "*", "Greek endemic", "Greek endemics (incl. single-island and single-mountain endemics)", FloraHellenicaTransformer.uuidChorologicalStar);
|
195 |
|
|
addChorological(state, chorologicalVoc, "Bk", "Balkan", "Taxa restricted to Balkan countries, occasionally extending to adjacent parts of SE Europe", FloraHellenicaTransformer.uuidChorologicalBk);
|
196 |
|
|
addChorological(state, chorologicalVoc, "BI", "Balkan-Italy", "Taxa restricted to Balkan countries and Italy (amphi-Adreatic)", FloraHellenicaTransformer.uuidChorologicalBI);
|
197 |
|
|
addChorological(state, chorologicalVoc, "BA", "Balkan-Anatolia", "Taxa restricted to Balkan countries and to Asia minor (Anatolia), occasionally extending to S Ukraine (Crimea), adjacent Caucasian countries (Georgia, Armenia) or N Iraq", FloraHellenicaTransformer.uuidChorologicalBA);
|
198 |
|
|
addChorological(state, chorologicalVoc, "BC", "Balkan-Central Europe", "Taxa distributed in the Balkans, Carpathians, Alps and adjacent areas (mainly in the mountains)", FloraHellenicaTransformer.uuidChorologicalBC);
|
199 |
|
|
addChorological(state, chorologicalVoc, "EM", "East Mediterranean", "Taxa restricted to the E Mediterranean, occasionally extending to S Italy or adjacent Caucasian countries", FloraHellenicaTransformer.uuidChorologicalEM);
|
200 |
|
|
addChorological(state, chorologicalVoc, "Me", "Mediterranean", "Taxa with a circum-Mediterranean distribution including Portugal, occasionally extending to the Caucasus area and N Iran", FloraHellenicaTransformer.uuidChorologicalMe);
|
201 |
|
|
addChorological(state, chorologicalVoc, "MA", "Mediterranean-Atlantic", "Taxa restricted to maritime W Europe and the Mediterranean", FloraHellenicaTransformer.uuidChorologicalMA);
|
202 |
|
|
addChorological(state, chorologicalVoc, "ME", "Mediterranean-European", "Taxa restricted to the Mediterranean and temperate Europe, occasionally extending to NW Africa and the Caucasus area", FloraHellenicaTransformer.uuidChorologicalME);
|
203 |
|
|
addChorological(state, chorologicalVoc, "MS", "Mediterranean-SW Asian", "Taxa distributed in one or more Mediterranean countries and extending to SW and C Asia", FloraHellenicaTransformer.uuidChorologicalMS);
|
204 |
|
|
addChorological(state, chorologicalVoc, "EA", "European-SW Asian", "Eruopean taxa (occasionally reachin N Africa) with a distribution extending to SW Asia, occasionally reaching C Asia", FloraHellenicaTransformer.uuidChorologicalEA);
|
205 |
|
|
addChorological(state, chorologicalVoc, "ES", "Euro-Siberian", "Taxa with main distribution in temperate Eurasia (occasionally reaching the Caucasus area)", FloraHellenicaTransformer.uuidChorologicalES);
|
206 |
|
|
addChorological(state, chorologicalVoc, "Eu", "European", "Taxa with a distribution all over Europe. In S European countries this category in fact represents the C European element", FloraHellenicaTransformer.uuidChorologicalEu);
|
207 |
|
|
addChorological(state, chorologicalVoc, "Pt", "Paleotemperate", "Taxa of extratropical Eurasia including the Himalaya and E Asia, not (or at most marginally) extending to North America", FloraHellenicaTransformer.uuidChorologicalPt);
|
208 |
|
|
addChorological(state, chorologicalVoc, "Ct", "Circumtemperate", "Taxa of both extratropical Eurasia and North America", FloraHellenicaTransformer.uuidChorologicalCt);
|
209 |
|
|
addChorological(state, chorologicalVoc, "IT", "Irano-Turanian", "Taxa with main distribution in arid SW and C Asia, extrazonally extending to the Mediterranean", FloraHellenicaTransformer.uuidChorologicalIT);
|
210 |
|
|
addChorological(state, chorologicalVoc, "SS", "Saharo-Sindian", "Taxa with main distribution in arid N Africa and SQ Asia, extrazonally extending to the Mediterranean", FloraHellenicaTransformer.uuidChorologicalSS);
|
211 |
|
|
addChorological(state, chorologicalVoc, "ST", "Subtropical-tropical", "Taxa widespread in the warmer regions of both hemispheres", FloraHellenicaTransformer.uuidChorologicalST);
|
212 |
|
|
addChorological(state, chorologicalVoc, "Bo", "(Circum-)Boreal", "Taxa with main distribution in N and high-montane Eurasia (occasionally extending to North America)", FloraHellenicaTransformer.uuidChorologicalBo);
|
213 |
|
|
addChorological(state, chorologicalVoc, "AA", "Arctic-Alpine", "Taxa with main distribution beyound the N and aove the high-montane timerlines o fEurasia (occasionally extending to North America)", FloraHellenicaTransformer.uuidChorologicalAA);
|
214 |
|
|
addChorological(state, chorologicalVoc, "Co", "Cosmopolitan", "Taxa distributed in all continents, i.e. beyond the N hemisphere. This category may be given in brackets after the known or supposed native distribution in cases of taxa that have been spread worldwide by humans", FloraHellenicaTransformer.uuidChorologicalCo);
|
215 |
|
|
|
216 |
066bfef4
|
Andreas Müller
|
addChorological(state, chorologicalVoc, "[SS]", "[Saharo-Sindian]", "Taxa with main distribution in arid N Africa and SQ Asia, extrazonally extending to the Mediterranean, not native in Greece", FloraHellenicaTransformer.uuidChorological_SS_);
|
217 |
|
|
addChorological(state, chorologicalVoc, "[?MS]", "[Mediterranean-SW Asian]", "Taxa distributed in one or more Mediterranean countries and extending to SW and C Asia, not native in Greece", FloraHellenicaTransformer.uuidChorological_dMS_);
|
218 |
|
|
addChorological(state, chorologicalVoc, "?EM", "? East Mediterranean", "Taxa restricted to the E Mediterranean, occasionally extending to S Italy or adjacent Caucasian countries", FloraHellenicaTransformer.uuidChorological_dEM);
|
219 |
|
|
|
220 |
|
|
|
221 |
aea90ab7
|
Andreas Müller
|
addChorological(state, chorologicalVoc, "[trop.]", "[tropical]", "", FloraHellenicaTransformer.uuidChorologicaltrop);
|
222 |
|
|
addChorological(state, chorologicalVoc, "[subtrop.]", "[subtropical]", "", FloraHellenicaTransformer.uuidChorologicalsubtrop);
|
223 |
|
|
addChorological(state, chorologicalVoc, "[paleotrop.]", "[paleotropical]", "", FloraHellenicaTransformer.uuidChorologicalpaleotrop);
|
224 |
|
|
addChorological(state, chorologicalVoc, "[neotrop.]", "[neotropical]", "", FloraHellenicaTransformer.uuidChorologicalneotrop);
|
225 |
|
|
addChorological(state, chorologicalVoc, "[pantrop.]", "[pantropical]", "", FloraHellenicaTransformer.uuidChorologicalpantrop);
|
226 |
|
|
addChorological(state, chorologicalVoc, "[N-Am.]", "[North American]", "", FloraHellenicaTransformer.uuidChorologicalN_Am);
|
227 |
|
|
addChorological(state, chorologicalVoc, "[S-Am.]", "[South American]", "", FloraHellenicaTransformer.uuidChorologicalS_Am);
|
228 |
|
|
addChorological(state, chorologicalVoc, "[E-As.]", "[East Asian]", "", FloraHellenicaTransformer.uuidChorologicalE_As);
|
229 |
|
|
addChorological(state, chorologicalVoc, "[SE-As.", "[South East Asian]", "", FloraHellenicaTransformer.uuidChorologicalSE_As);
|
230 |
|
|
addChorological(state, chorologicalVoc, "[S-Afr.]", "[South African]", "", FloraHellenicaTransformer.uuidChorologicalS_Afr);
|
231 |
|
|
addChorological(state, chorologicalVoc, "[Arab.]", "[Arabian]", "", FloraHellenicaTransformer.uuidChorologicalArab);
|
232 |
|
|
addChorological(state, chorologicalVoc, "[Arab. NE-Afr.]", "[Arabian and North East African]", "", FloraHellenicaTransformer.uuidChorologicalArab_NE_Afr);
|
233 |
|
|
addChorological(state, chorologicalVoc, "[Caucas.]", "[Caucasian]", "", FloraHellenicaTransformer.uuidChorologicalCaucas);
|
234 |
|
|
addChorological(state, chorologicalVoc, "[Pontic]", "[Pontic]", "", FloraHellenicaTransformer.uuidChorologicalPontic);
|
235 |
|
|
addChorological(state, chorologicalVoc, "[Europ.]", "[European]", "", FloraHellenicaTransformer.uuidChorologicalEurop);
|
236 |
|
|
addChorological(state, chorologicalVoc, "[Austr.]", "[Australian]", "", FloraHellenicaTransformer.uuidChorologicalAustral);
|
237 |
|
|
|
238 |
|
|
addChorological(state, chorologicalVoc, "[W-Med.]", "[West Mediterranean]", "", FloraHellenicaTransformer.uuidChorologicalW_Med);
|
239 |
|
|
addChorological(state, chorologicalVoc, "[C-Med.]", "[Central Mediterranean]", "", FloraHellenicaTransformer.uuidChorologicalC_Med);
|
240 |
|
|
addChorological(state, chorologicalVoc, "[W-Eur.]", "[West European]", "", FloraHellenicaTransformer.uuidChorologicalW_Eur);
|
241 |
|
|
addChorological(state, chorologicalVoc, "[S-Eur.]", "[South European]", "", FloraHellenicaTransformer.uuidChorologicalS_Eur);
|
242 |
|
|
addChorological(state, chorologicalVoc, "[C-Am.]", "[Central American]", "", FloraHellenicaTransformer.uuidChorologicalC_Am);
|
243 |
|
|
addChorological(state, chorologicalVoc, "[C-As.]", "[Central Asian]", "", FloraHellenicaTransformer.uuidChorologicalC_As);
|
244 |
|
|
addChorological(state, chorologicalVoc, "[SW-As.]", "[South West Asian]", "", FloraHellenicaTransformer.uuidChorologicalSW_As);
|
245 |
|
|
addChorological(state, chorologicalVoc, "[unknown]", "[unknown]", "", FloraHellenicaTransformer.uuidChorologicalUnknown);
|
246 |
|
|
addChorological(state, chorologicalVoc, "[N-Afr.]", "[North African]", "", FloraHellenicaTransformer.uuidChorologicalN_Afr);
|
247 |
|
|
addChorological(state, chorologicalVoc, "[Am.]", "[American]", "", FloraHellenicaTransformer.uuidChorologicalAm);
|
248 |
|
|
addChorological(state, chorologicalVoc, "[paleosubtrop.]", "[paleosubtropical]", "", FloraHellenicaTransformer.uuidChorologicalPaleosubtrop);
|
249 |
|
|
addChorological(state, chorologicalVoc, "[SW-Eur.]", "[South West European]", "", FloraHellenicaTransformer.uuidChorologicalSW_Eur);
|
250 |
|
|
|
251 |
|
|
addChorological(state, chorologicalVoc, "[S-As.]", "[South Asian]", "", FloraHellenicaTransformer.uuidChorologicalS_As);
|
252 |
|
|
addChorological(state, chorologicalVoc, "[NE-Afr.]", "[North East African]", "", FloraHellenicaTransformer.uuidChorologicalNE_Afr);
|
253 |
|
|
addChorological(state, chorologicalVoc, "[NW-Afr.]", "[North West African]", "", FloraHellenicaTransformer.uuidChorologicalNW_Afr);
|
254 |
|
|
addChorological(state, chorologicalVoc, "[trop. Afr.]", "[tropical African]", "", FloraHellenicaTransformer.uuidChorologicalTrop_Afr);
|
255 |
|
|
addChorological(state, chorologicalVoc, "[Afr.]", "[Arican]", "", FloraHellenicaTransformer.uuidChorologicalAfr);
|
256 |
|
|
addChorological(state, chorologicalVoc, "[As.]", "[Asian]", "", FloraHellenicaTransformer.uuidChorologicalAs);
|
257 |
|
|
addChorological(state, chorologicalVoc, "[W-As.]", "[West Asian]", "", FloraHellenicaTransformer.uuidChorologicalW_As);
|
258 |
|
|
addChorological(state, chorologicalVoc, "[C-Eur.]", "[Central European]", "", FloraHellenicaTransformer.uuidChorologicalC_Eur);
|
259 |
|
|
addChorological(state, chorologicalVoc, "[E-Afr.]", "[East African]", "", FloraHellenicaTransformer.uuidChorologicalE_Afr);
|
260 |
|
|
addChorological(state, chorologicalVoc, "[W-Austr.]", "[West Australian]", "", FloraHellenicaTransformer.uuidChorologicalW_Austr);
|
261 |
|
|
addChorological(state, chorologicalVoc, "[trop. As.]", "[tropical Asian]", "", FloraHellenicaTransformer.uuidChorologicaltrop_As);
|
262 |
|
|
|
263 |
|
|
addChorological(state, chorologicalVoc, "[Co]", "[Cosmopolitan]", "Taxa distributed in all continents, i.e. beyond the N hemisphere. This category may be given in brackets after the known or supposed native distribution in cases of taxa that have been spread worldwide by humans", FloraHellenicaTransformer.uuidChorological__Co_);
|
264 |
|
|
|
265 |
|
|
this.getVocabularyService().save(chorologicalVoc);
|
266 |
|
|
return;
|
267 |
|
|
|
268 |
|
|
}
|
269 |
|
|
|
270 |
|
|
/**
|
271 |
|
|
* @param state
|
272 |
|
|
* @param chorologicalVoc
|
273 |
|
|
* @param string
|
274 |
|
|
* @param string2
|
275 |
|
|
* @param string3
|
276 |
|
|
* @param uuidchorologicalstar
|
277 |
|
|
*/
|
278 |
|
|
private void addChorological(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state,
|
279 |
|
|
OrderedTermVocabulary<State> chorologicalVoc, String abbrevLabel, String label,
|
280 |
|
|
String desc, UUID uuidChorological) {
|
281 |
|
|
desc = isBlank(desc)? label : desc;
|
282 |
|
|
State chorologyTerm = addState(state, abbrevLabel, label, desc, uuidChorological, chorologicalVoc);
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
// ***************************** LIFEFORM ********************************/
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
@SuppressWarnings("unchecked")
|
289 |
|
|
private void initLifeformVocabulary(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
290 |
|
|
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaLifeformVoc;
|
291 |
|
|
OrderedTermVocabulary<State> lifeformVoc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid);
|
292 |
|
|
if (lifeformVoc == null){
|
293 |
|
|
createLifeformVoc(state, uuid);
|
294 |
|
|
}
|
295 |
|
|
}
|
296 |
|
|
|
297 |
|
|
/**
|
298 |
|
|
* @param state
|
299 |
|
|
* @param vocUuid
|
300 |
|
|
*/
|
301 |
|
|
private void createLifeformVoc(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state,
|
302 |
|
|
UUID vocUuid) {
|
303 |
|
|
//voc
|
304 |
|
|
URI termSourceUri = null;
|
305 |
|
|
String label = "Checklist of Greece Lifeforms";
|
306 |
|
|
String description = "Lifeforms as used in the Checklist of Greece";
|
307 |
|
|
OrderedTermVocabulary<State> lifeformVoc = OrderedTermVocabulary.NewInstance(TermType.State,
|
308 |
|
|
description, label, null, termSourceUri);
|
309 |
|
|
lifeformVoc.setUuid(vocUuid);
|
310 |
|
|
|
311 |
|
|
addLifeform(state, lifeformVoc, "A", "Aquatic", FloraHellenicaTransformer.uuidLifeformA);
|
312 |
|
|
addLifeform(state, lifeformVoc, "C", "Chamaephyte", FloraHellenicaTransformer.uuidLifeformC);
|
313 |
|
|
addLifeform(state, lifeformVoc, "G", "Geophyte (Cryptophyte)", FloraHellenicaTransformer.uuidLifeformG);
|
314 |
|
|
addLifeform(state, lifeformVoc, "H", "Hemicryptophyte", FloraHellenicaTransformer.uuidLifeformH);
|
315 |
|
|
addLifeform(state, lifeformVoc, "P", "Phanerophyte", FloraHellenicaTransformer.uuidLifeformP);
|
316 |
|
|
addLifeform(state, lifeformVoc, "T", "Therophyte", FloraHellenicaTransformer.uuidLifeformT);
|
317 |
|
|
this.getVocabularyService().save(lifeformVoc);
|
318 |
|
|
return;
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
/**
|
322 |
|
|
* @param state
|
323 |
|
|
* @param lifeformVoc
|
324 |
|
|
* @param string
|
325 |
|
|
* @param uuidlifeformt
|
326 |
|
|
*/
|
327 |
|
|
private void addLifeform(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state,
|
328 |
|
|
OrderedTermVocabulary<State> lifeformVoc, String abbrevLabel, String label, UUID uuidlifeform) {
|
329 |
2cab5074
|
Andreas Müller
|
addState(state, abbrevLabel, label, label, uuidlifeform, lifeformVoc);
|
330 |
aea90ab7
|
Andreas Müller
|
}
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
// ***************************** HABITAT ********************************/
|
334 |
|
|
|
335 |
|
|
private void initHabitatVocabulary(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
336 |
|
|
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaHabitatVoc;
|
337 |
|
|
OrderedTermVocabulary<State> habitatVoc = (OrderedTermVocabulary<State>)this.getVocabularyService().find(uuid);
|
338 |
|
|
if (habitatVoc == null){
|
339 |
|
|
createHabitatVoc(state, uuid);
|
340 |
|
|
}
|
341 |
|
|
}
|
342 |
|
|
|
343 |
|
|
/**
|
344 |
|
|
* @param state
|
345 |
|
|
*/
|
346 |
|
|
private void createHabitatVoc(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state, UUID vocUuid) {
|
347 |
|
|
//voc
|
348 |
|
|
URI termSourceUri = null;
|
349 |
|
|
String label = "Checklist of Greece Habitats";
|
350 |
|
|
String description = "Habitats as used in the Checklist of Greece";
|
351 |
|
|
OrderedTermVocabulary<State> habitatVoc = OrderedTermVocabulary.NewInstance(TermType.State,
|
352 |
|
|
description, label, null, termSourceUri);
|
353 |
|
|
habitatVoc.setUuid(vocUuid);
|
354 |
|
|
|
355 |
|
|
addHabitat(state, habitatVoc, "A", "Freshwater habitats", "Freshwater habitats (Aquatic habitats, springs and fens, reedbeds and damp tall herb vegetation, seasonally flooded depressions, damp and seepage meadows, streambanks, river and lake shores)", FloraHellenicaTransformer.uuidHabitatA);
|
356 |
|
|
addHabitat(state, habitatVoc, "C", "Cliffs, rocks, walls, ravines, boulders", "Cliffs, rocks, walls, ravines, boulders", FloraHellenicaTransformer.uuidHabitatC);
|
357 |
|
|
addHabitat(state, habitatVoc, "G", "Temperate and submediterranean Grasslands", "Temperate and submediterranean Grasslands (lowland to montane dry and mesic meadows and pastures, rock outcrops and stony ground, grassy non-ruderal verges and forest edges)", FloraHellenicaTransformer.uuidHabitatG);
|
358 |
|
|
addHabitat(state, habitatVoc, "H", "High mountain vegetation", "High mountain vegetation (subalpine and alpine grasslands, screes and rocks, scrub above the treeline)", FloraHellenicaTransformer.uuidHabitatH);
|
359 |
|
|
addHabitat(state, habitatVoc, "M", "Coastal habitats", "Coastal habitats (Marine waters and mudflats, salt marshes, sand dunes, littoral rocks, halo-nitrophilous scrub)", FloraHellenicaTransformer.uuidHabitatM);
|
360 |
|
|
addHabitat(state, habitatVoc, "P", "Xeric Mediterranean Phrygana and grasslands", "Xeric Mediterranean Phrygana and grasslands (Mediterranean dwarf shrub formations, annual-rich pastures and lowland screes)", FloraHellenicaTransformer.uuidHabitatP);
|
361 |
|
|
addHabitat(state, habitatVoc, "R", "Agricultural and Ruderal habitats", "Agricultural and Ruderal habitats (fields, gardens and plantations, roadsides and trampled sites, frequently disturbed and pioneer habitats)", FloraHellenicaTransformer.uuidHabitatR);
|
362 |
|
|
addHabitat(state, habitatVoc, "W", "Woodlands and scrub", "Woodlands and scrub (broadleaved and coniferous forest, riparian and mountain forest and scrub, hedges, shady woodland margins)", FloraHellenicaTransformer.uuidHabitatW);
|
363 |
|
|
|
364 |
|
|
this.getVocabularyService().save(habitatVoc);
|
365 |
|
|
return;
|
366 |
|
|
}
|
367 |
|
|
|
368 |
|
|
/**
|
369 |
|
|
* @param state
|
370 |
|
|
* @param habitatVoc
|
371 |
|
|
* @param string
|
372 |
|
|
* @param uuidlifeformt
|
373 |
|
|
*/
|
374 |
|
|
private void addHabitat(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state,
|
375 |
|
|
OrderedTermVocabulary<State> habitatVoc, String abbrev, String label, String desc, UUID uuidHabitat) {
|
376 |
|
|
addState(state, abbrev, label, desc, uuidHabitat, habitatVoc);
|
377 |
|
|
}
|
378 |
|
|
|
379 |
|
|
// ***************************** STATUS ********************************/
|
380 |
|
|
|
381 |
|
|
private void initStatusVocabulary(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
382 |
|
|
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaStatusVoc;
|
383 |
|
|
OrderedTermVocabulary<?> statusVoc = (OrderedTermVocabulary<?>)this.getVocabularyService().find(uuid);
|
384 |
|
|
if (statusVoc == null){
|
385 |
|
|
createStatusVoc(state, uuid);
|
386 |
|
|
}
|
387 |
|
|
}
|
388 |
|
|
|
389 |
|
|
/**
|
390 |
|
|
* @param state
|
391 |
|
|
*/
|
392 |
|
|
private void createStatusVoc(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state, UUID vocUuid) {
|
393 |
|
|
//voc
|
394 |
|
|
URI termSourceUri = null;
|
395 |
|
|
String label = "Checklist of Greece Status";
|
396 |
|
|
String description = "Status as used in the Checklist of Greece";
|
397 |
|
|
|
398 |
|
|
OrderedTermVocabulary<?> statusVoc;
|
399 |
|
|
if (state.getConfig().isStatusAsDistribution()){
|
400 |
|
|
statusVoc = OrderedTermVocabulary.NewInstance(TermType.PresenceAbsenceTerm,
|
401 |
|
|
description, label, null, termSourceUri);
|
402 |
|
|
}else{
|
403 |
|
|
statusVoc = OrderedTermVocabulary.NewInstance(TermType.State,
|
404 |
|
|
description, label, null, termSourceUri);
|
405 |
|
|
}
|
406 |
|
|
|
407 |
|
|
statusVoc.setUuid(vocUuid);
|
408 |
|
|
|
409 |
|
|
if (!state.getConfig().isStatusAsDistribution()){
|
410 |
|
|
addStatus(state, "N", "Native", "", FloraHellenicaTransformer.uuidStatusNative, statusVoc);
|
411 |
|
|
addStatus(state, "X", "Xenophyte", "", FloraHellenicaTransformer.uuidStatusXenophyte, statusVoc);
|
412 |
|
|
addStatus(state, "?X", "?Xenophyte", "", FloraHellenicaTransformer.uuidStatusXenophyteDoubtfully, statusVoc);
|
413 |
|
|
}
|
414 |
|
|
addStatus(state, "RR", "Range-restricted", "", FloraHellenicaTransformer.uuidStatusRangeRestricted, statusVoc);
|
415 |
|
|
addStatus(state, "?RR", "?Range-restricted", "", FloraHellenicaTransformer.uuidStatusRangeRestrictedDoubtfully, statusVoc);
|
416 |
|
|
|
417 |
|
|
|
418 |
|
|
|
419 |
|
|
this.getVocabularyService().save(statusVoc);
|
420 |
|
|
return;
|
421 |
|
|
}
|
422 |
|
|
|
423 |
|
|
// ************************** FEATURE TREE ************************************/
|
424 |
|
|
|
425 |
|
|
boolean hasFeatureTree = false;
|
426 |
|
|
|
427 |
|
|
/**
|
428 |
|
|
* @param state
|
429 |
|
|
*/
|
430 |
|
|
private void makeFeatureTree(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
431 |
|
|
if (hasFeatureTree ){
|
432 |
|
|
return;
|
433 |
|
|
}
|
434 |
|
|
if (getFeatureTreeService().find(state.getConfig().getUuidFeatureTree()) != null){
|
435 |
|
|
hasFeatureTree = true;
|
436 |
|
|
return;
|
437 |
|
|
}
|
438 |
|
|
FeatureTree result = FeatureTree.NewInstance(state.getConfig().getUuidFeatureTree());
|
439 |
|
|
result.setTitleCache(state.getConfig().getFeatureTreeTitle(), true);
|
440 |
|
|
FeatureNode root = result.getRoot();
|
441 |
|
|
FeatureNode newNode;
|
442 |
|
|
ITermService service = getTermService();
|
443 |
066bfef4
|
Andreas Müller
|
|
444 |
d45450b6
|
Andreas Müller
|
UUID uuid = FloraHellenicaTransformer.uuidFloraHellenicaTaxonInfoFeature;
|
445 |
|
|
Feature newFeature = getFeature(state, uuid, "Taxon info", "Taxon info", null, null);
|
446 |
066bfef4
|
Andreas Müller
|
newNode = FeatureNode.NewInstance(newFeature);
|
447 |
|
|
root.addChild(newNode);
|
448 |
|
|
|
449 |
|
|
newFeature = (Feature)service.find(Feature.DISTRIBUTION().getUuid());
|
450 |
aea90ab7
|
Andreas Müller
|
newNode = FeatureNode.NewInstance(newFeature);
|
451 |
|
|
root.addChild(newNode);
|
452 |
|
|
|
453 |
|
|
newFeature = (Feature)service.find(Feature.STATUS().getUuid());
|
454 |
|
|
newNode = FeatureNode.NewInstance(newFeature);
|
455 |
|
|
root.addChild(newNode);
|
456 |
c6df7de0
|
Andreas Müller
|
newFeature.setSupportsCategoricalData(true);
|
457 |
|
|
TermVocabulary<State> voc = this.getVocabularyService().find(FloraHellenicaTransformer.uuidFloraHellenicaStatusVoc);
|
458 |
|
|
newFeature.addSupportedCategoricalEnumeration(voc);
|
459 |
|
|
|
460 |
aea90ab7
|
Andreas Müller
|
|
461 |
d45450b6
|
Andreas Müller
|
uuid = FloraHellenicaTransformer.uuidFloraHellenicaChorologyFeature;
|
462 |
aea90ab7
|
Andreas Müller
|
newFeature = getFeature(state, uuid, "Chorology", "Chorology", null, null);
|
463 |
c6df7de0
|
Andreas Müller
|
newFeature.setSupportsCategoricalData(true);
|
464 |
|
|
voc = this.getVocabularyService().find(FloraHellenicaTransformer.uuidFloraHellenicaChorologicalVoc);
|
465 |
|
|
newFeature.addSupportedCategoricalEnumeration(voc);
|
466 |
aea90ab7
|
Andreas Müller
|
newNode = FeatureNode.NewInstance(newFeature);
|
467 |
|
|
root.addChild(newNode);
|
468 |
|
|
|
469 |
|
|
newFeature = (Feature)service.find(Feature.LIFEFORM().getUuid());
|
470 |
|
|
newNode = FeatureNode.NewInstance(newFeature);
|
471 |
|
|
root.addChild(newNode);
|
472 |
c6df7de0
|
Andreas Müller
|
newFeature.setSupportsCategoricalData(true);
|
473 |
|
|
voc = this.getVocabularyService().find(FloraHellenicaTransformer.uuidFloraHellenicaLifeformVoc);
|
474 |
|
|
newFeature.addSupportedCategoricalEnumeration(voc);
|
475 |
aea90ab7
|
Andreas Müller
|
|
476 |
|
|
newFeature = (Feature)service.find(Feature.HABITAT().getUuid());
|
477 |
|
|
newNode = FeatureNode.NewInstance(newFeature);
|
478 |
|
|
root.addChild(newNode);
|
479 |
c6df7de0
|
Andreas Müller
|
newFeature.setSupportsCategoricalData(true);
|
480 |
|
|
voc = this.getVocabularyService().find(FloraHellenicaTransformer.uuidFloraHellenicaHabitatVoc);
|
481 |
|
|
newFeature.addSupportedCategoricalEnumeration(voc);
|
482 |
aea90ab7
|
Andreas Müller
|
|
483 |
|
|
|
484 |
|
|
newFeature = (Feature)service.find(Feature.NOTES().getUuid());
|
485 |
|
|
newNode = FeatureNode.NewInstance(newFeature);
|
486 |
|
|
root.addChild(newNode);
|
487 |
|
|
|
488 |
|
|
getFeatureTreeService().saveOrUpdate(result);
|
489 |
|
|
hasFeatureTree = true;
|
490 |
|
|
|
491 |
|
|
}
|
492 |
|
|
|
493 |
|
|
|
494 |
|
|
private State addState(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state,
|
495 |
|
|
String abbrev, String stateLabel, String description, UUID uuid, OrderedTermVocabulary<State> voc) {
|
496 |
|
|
State newState = State.NewInstance(
|
497 |
|
|
description, stateLabel, abbrev);
|
498 |
|
|
newState.setUuid(uuid);
|
499 |
|
|
newState.setIdInVocabulary(abbrev);
|
500 |
|
|
voc.addTerm(newState);
|
501 |
|
|
return newState;
|
502 |
|
|
}
|
503 |
|
|
|
504 |
|
|
private OrderedTermBase addStatus(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state,
|
505 |
|
|
String abbrev, String stateLabel, String description, UUID uuid,
|
506 |
|
|
OrderedTermVocabulary voc) {
|
507 |
|
|
FloraHellenicaImportConfigurator config = state.getConfig();
|
508 |
|
|
OrderedTermBase<?> newStatus;
|
509 |
|
|
if (config.isStatusAsDistribution()){
|
510 |
|
|
newStatus = PresenceAbsenceTerm.NewPresenceInstance( description, stateLabel, abbrev);
|
511 |
|
|
}else{
|
512 |
|
|
newStatus = State.NewInstance(description, stateLabel, abbrev);
|
513 |
|
|
}
|
514 |
|
|
|
515 |
|
|
newStatus.setUuid(uuid);
|
516 |
|
|
newStatus.setIdInVocabulary(abbrev);
|
517 |
|
|
newStatus.setSymbol(abbrev);
|
518 |
|
|
voc.addTerm(newStatus);
|
519 |
|
|
return newStatus;
|
520 |
|
|
}
|
521 |
|
|
|
522 |
|
|
|
523 |
d6b2ef47
|
Andreas Müller
|
/**
|
524 |
|
|
* @param state
|
525 |
|
|
*/
|
526 |
|
|
private void makeMapColors(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
527 |
|
|
PresenceAbsenceTerm presentTerm = (PresenceAbsenceTerm)getTermService().find(PresenceAbsenceTerm.uuidPresent);
|
528 |
|
|
try {
|
529 |
|
|
presentTerm.setDefaultColor("ff0000");
|
530 |
|
|
getTermService().saveOrUpdate(presentTerm);
|
531 |
|
|
} catch (ParseException e) {
|
532 |
|
|
// TODO Auto-generated catch block
|
533 |
|
|
e.printStackTrace();
|
534 |
|
|
}
|
535 |
|
|
|
536 |
|
|
}
|
537 |
|
|
|
538 |
aea90ab7
|
Andreas Müller
|
|
539 |
|
|
/**
|
540 |
|
|
* {@inheritDoc}
|
541 |
|
|
*/
|
542 |
|
|
@Override
|
543 |
|
|
protected boolean doCheck(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
544 |
|
|
return false;
|
545 |
|
|
}
|
546 |
|
|
|
547 |
|
|
|
548 |
|
|
/**
|
549 |
|
|
* {@inheritDoc}
|
550 |
|
|
*/
|
551 |
|
|
@Override
|
552 |
|
|
protected boolean isIgnore(SimpleExcelTaxonImportState<FloraHellenicaImportConfigurator> state) {
|
553 |
|
|
return false;
|
554 |
|
|
}
|
555 |
|
|
}
|