2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.cuba
;
13 import java
.util
.UUID
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.springframework
.stereotype
.Component
;
17 import org
.springframework
.transaction
.TransactionStatus
;
19 import eu
.etaxonomy
.cdm
.common
.DOI
;
20 import eu
.etaxonomy
.cdm
.io
.common
.CdmImportBase
;
21 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.IInputTransformer
;
22 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.UndefinedTransformerMethodException
;
23 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
24 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
25 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
26 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
27 import eu
.etaxonomy
.cdm
.model
.description
.PresenceAbsenceTerm
;
28 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
29 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaLevel
;
30 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaType
;
31 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
32 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
33 import eu
.etaxonomy
.cdm
.strategy
.parser
.TimePeriodParser
;
42 public class CubaVocabularyImport
extends CdmImportBase
<CubaImportConfigurator
, CubaImportState
> {
43 private static final long serialVersionUID
= -747486709409732371L;
45 private static final Logger logger
= Logger
.getLogger(CubaVocabularyImport
.class);
51 protected void doInvoke(CubaImportState state
) {
54 makePresenceAbsenceTerms(state
);
55 makeAlternativeFloras(state
);
56 } catch (UndefinedTransformerMethodException e
) {
64 private void makeAlternativeFloras(CubaImportState state
) {
67 Reference
<?
> refFRC
= ReferenceFactory
.newBook();
68 refFRC
.setUuid(CubaTransformer
.uuidRefFRC
);
69 refFRC
.setTitle("Flora de la República de Cuba");
70 getReferenceService().save(refFRC
);
73 Reference
<?
> refAS
= ReferenceFactory
.newArticle();
74 refAS
.setUuid(CubaTransformer
.uuidRefAS
);
75 refAS
.setTitle("Catalogue of seed plants of the West Indies");
76 Person acevedo
= Person
.NewInstance();
77 acevedo
.setFirstname("Pedro");
78 acevedo
.setLastname("Acevedo-Rodríguez");
79 Person strong
= Person
.NewInstance();
80 strong
.setFirstname("Mark T.");
81 strong
.setLastname("Strong");
82 Team asTeam
= Team
.NewInstance();
83 asTeam
.addTeamMember(acevedo
);
84 asTeam
.addTeamMember(strong
);
85 refAS
.setAuthorship(asTeam
);
86 refAS
.setDatePublished(TimePeriodParser
.parseString("2012-01-01"));
87 refAS
.setVolume("98");
88 refAS
.setPages("i-xxv, 1-1192");
89 refAS
.setIssn("0081-024X");
90 refAS
.setDoi(DOI
.fromString("10.5479/si.0081024X.98.1"));
91 refAS
.setUri(URI
.create("http://hdl.handle.net/10088/17551"));
92 String abstracct
= "The catalogue enumerates all taxa of Gymnosperms, Dicotyledons, and Monocotyledons occurring in the West Indies archipelago excluding the islands off the coast of Venezuela (Netherlands Antilles, Venezuelan Antilles, Tobago, and Trinidad). For each accepted taxon, nomenclature (including synonyms described from the West Indies and their references to publication), distribution in the West Indies (including endemic, native, or exotic status), common names, and a numerical listing of literature records are given. Type specimen citations are provided for accepted names and synonyms of Cyperaceae, Sapindaceae, and some selected genera in several families including the Apocynaceae (Plumeria), Aquifoliaceae (Ilex), and Santalaceae (Dendrophthora). More than 30,000 names were treated comprising 208 families, 2,033 genera, and 12,279 taxa, which includes exotic and commonly cultivated plants. The total number of indigenous taxa was approximately 10,470 of which 71% (7,446 taxa) are endemic to the archipelago or part of it. Fifteen new names, 37 combinations, and 7 lectotypifications are validated. A searchable website of this catalogue, maintained and continuously updated at the Smithsonian Institution, is available at http://botany.si.edu/antilles/WestIndies/.";
93 refAS
.setReferenceAbstract(abstracct
);
94 Reference
<?
> refASIn
= ReferenceFactory
.newJournal();
95 refAS
.setInReference(refASIn
);
96 getReferenceService().save(refAS
);
99 Reference
<?
> refFC
= ReferenceFactory
.newBook();
100 refFC
.setUuid(CubaTransformer
.uuidRefFC
);
101 refFC
.setTitle("Flora de Cuba");
102 Person leon
= Person
.NewTitledInstance("León");
103 Person alain
= Person
.NewTitledInstance("Alain");
104 Team fcTeam
= Team
.NewInstance();
105 fcTeam
.addTeamMember(leon
);
106 fcTeam
.addTeamMember(alain
);
107 refAS
.setAuthorship(fcTeam
);
108 getReferenceService().save(refFC
);
114 * @throws UndefinedTransformerMethodException
116 private void makePresenceAbsenceTerms(CubaImportState state
) throws UndefinedTransformerMethodException
{
117 TransactionStatus tx
= startTransaction();
119 IInputTransformer transformer
= state
.getTransformer();
122 UUID cubaStatusVocabularyUuid
= UUID
.fromString("e74bba61-551b-4f59-af83-a1a770e4b0ae");
123 String label
= "Flora of Cuba Distribution Status";
124 String abbrev
= null;
125 boolean isOrdered
= true;
126 PresenceAbsenceTerm anyTerm
= PresenceAbsenceTerm
.PRESENT(); //just any
127 TermVocabulary
<PresenceAbsenceTerm
> cubaStatusVocabualary
= getVocabulary(TermType
.PresenceAbsenceTerm
, cubaStatusVocabularyUuid
, label
, label
, abbrev
, null, isOrdered
, anyTerm
);
129 final boolean PRESENT
= false;
132 UUID doubtfullyEndemicUuid
= transformer
.getPresenceTermUuid("?E");
133 this.getPresenceTerm(state
, doubtfullyEndemicUuid
, "endemic, doubtfully present", "endemic, doubtfully present", "?E", false);
136 // UUID indigenousUuid = transformer.getPresenceTermUuid("+");
137 // this.getPresenceTerm(state, indigenousUuid, "indigenous", "Indigenous", "+", false);
138 // UUID indigenousDoubtfulUuid = transformer.getPresenceTermUuid("?");
139 // this.getPresenceTerm(state, indigenousDoubtfulUuid, "indigenous, doubtfully present", "indigenous, doubtfully present", "?", false);
141 UUID nonNativeDoubtfulNaturalizedUuid
= transformer
.getPresenceTermUuid("P");
142 this.getPresenceTerm(state
, nonNativeDoubtfulNaturalizedUuid
, "non-native and doubtfully naturalised", "non-native and doubtfully naturalised", "P", false);
143 UUID rareCasualUuid
= transformer
.getPresenceTermUuid("(A)");
144 this.getPresenceTerm(state
, rareCasualUuid
, "rare casual", "rare casual", "(A)", false);
146 //occasionally cultivated
147 label
= "occasionally cultivated";
149 UUID occasionallyCultivatedUuid
= transformer
.getPresenceTermUuid(abbrev
);
150 getPresenceTerm(state
, occasionallyCultivatedUuid
, label
, label
, abbrev
, PRESENT
, cubaStatusVocabualary
);
153 UUID indigenousDoubtfullyPresentUuid
= transformer
.getPresenceTermUuid("D");
154 this.getPresenceTerm(state
, indigenousDoubtfullyPresentUuid
, "indigenous?", "Indigenous?", "D", false);
155 UUID doubtfullyIndigenousDoubtfullyPresentUuid
= transformer
.getPresenceTermUuid("??");
156 this.getPresenceTerm(state
, doubtfullyIndigenousDoubtfullyPresentUuid
, "?indigenous?", "doubfully indigenous, (and) doubtfully present", "??", false);
158 UUID doubtfullyNaturalisedUuid
= transformer
.getPresenceTermUuid("?N");
159 this.getPresenceTerm(state
, doubtfullyNaturalisedUuid
, "?non-native and doubtfully naturalised", "non-native and doubtfully naturalised, doubtfully present", "?N", false);
160 UUID doubtfullyNonNativeUuid
= transformer
.getPresenceTermUuid("?P");
161 this.getPresenceTerm(state
, doubtfullyNonNativeUuid
, "?adventive (casual) alien ", "adventive (casual) alien, doubtfully present", "?P", false);
164 boolean isAbsent
= true;
165 UUID endemicErrorUuid
= transformer
.getPresenceTermUuid("-E");
166 this.getPresenceTerm(state
, endemicErrorUuid
, "endemic, reported in error", "endemic, reported in error", "-E", isAbsent
);
167 UUID naturalizedErrorUuid
= transformer
.getPresenceTermUuid("-N");
168 this.getPresenceTerm(state
, naturalizedErrorUuid
, "naturalised, reported in error", "naturalised, reported in error", "-N", isAbsent
);
169 UUID nonNativeErrorUuid
= transformer
.getPresenceTermUuid("-P");
170 this.getPresenceTerm(state
, nonNativeErrorUuid
, "non-native and doubtfully naturalised, reported in error", "non-native and doubtfully naturalised, reported in error", "-P", isAbsent
);
171 UUID casualErrorUuid
= transformer
.getPresenceTermUuid("-A");
172 this.getPresenceTerm(state
, casualErrorUuid
, "adventive alien , reported in error", "adventive alien , reported in error", "-A", isAbsent
);
174 commitTransaction(tx
);
177 private boolean makeAreas(CubaImportState state
) throws UndefinedTransformerMethodException
{
178 TransactionStatus tx
= startTransaction();
180 IInputTransformer transformer
= state
.getTransformer();
183 UUID cubaAreasVocabularyUuid
= UUID
.fromString("c81e3c7b-3c01-47d1-87cf-388de4b1908c");
184 String label
= "Cuba Areas";
185 String abbrev
= null;
186 boolean isOrdered
= true;
187 NamedArea anyArea
= NamedArea
.ARCTICOCEAN(); //just any
188 TermVocabulary
<NamedArea
> cubaAreasVocabualary
= getVocabulary(TermType
.NamedArea
, cubaAreasVocabularyUuid
, label
, label
, abbrev
, null, isOrdered
, anyArea
);
190 TermMatchMode matchMode
= null;
192 NamedAreaType areaType
= null; //TODO
193 NamedAreaLevel level
= null; //TODO
196 level
= NamedAreaLevel
.COUNTRY();
199 UUID cubaUuid
= transformer
.getNamedAreaUuid(abbrev
);
200 NamedArea cuba
= getNamedArea(state
, cubaUuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
201 cuba
.setIdInVocabulary(abbrev
);
207 label
= "Western Cuba";
209 UUID cubaWestUuid
= transformer
.getNamedAreaUuid(abbrev
);
210 NamedArea westernCuba
= getNamedArea(state
, cubaWestUuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
211 cuba
.addIncludes(westernCuba
);
212 westernCuba
.setIdInVocabulary(abbrev
);
215 label
= "Central Cuba";
217 UUID cubaCentralUuid
= transformer
.getNamedAreaUuid(abbrev
);
218 NamedArea centralCuba
= getNamedArea(state
, cubaCentralUuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
219 cuba
.addIncludes(centralCuba
);
220 centralCuba
.setIdInVocabulary(abbrev
);
225 UUID cubaEastUuid
= transformer
.getNamedAreaUuid(abbrev
);
226 NamedArea eastCuba
= getNamedArea(state
, cubaEastUuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
227 cuba
.addIncludes(eastCuba
);
228 eastCuba
.setIdInVocabulary(abbrev
);
231 level
= NamedAreaLevel
.PROVINCE();
234 label
= "Pinar del Río";
236 UUID uuid
= transformer
.getNamedAreaUuid(abbrev
);
237 NamedArea area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
238 westernCuba
.addIncludes(area
);
239 area
.setIdInVocabulary(abbrev
);
242 // label = "Habana"; //including Ciudad de la Habana, Mayabeque, Artemisa
244 // uuid = transformer.getNamedAreaUuid(abbrev);
245 // NamedArea habana = getNamedArea(state, uuid, label, label, abbrev, areaType, level, cubaAreasVocabualary, matchMode);
246 // westernCuba.addIncludes(habana);
247 // area.setIdInVocabulary(abbrev);
252 uuid
= transformer
.getNamedAreaUuid(abbrev
);
253 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
254 westernCuba
.addIncludes(area
);
255 area
.setIdInVocabulary(abbrev
);
257 //Ciudad de la Habana
258 label
= "Ciudad de la Habana";
260 uuid
= transformer
.getNamedAreaUuid(abbrev
);
261 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
262 westernCuba
.addIncludes(area
);
263 area
.setIdInVocabulary(abbrev
);
265 //Ciudad de la Habana
268 uuid
= transformer
.getNamedAreaUuid(abbrev
);
269 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
270 westernCuba
.addIncludes(area
);
271 area
.setIdInVocabulary(abbrev
);
277 uuid
= transformer
.getNamedAreaUuid(abbrev
);
278 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
279 westernCuba
.addIncludes(area
);
280 area
.setIdInVocabulary(abbrev
);
282 //Isla de la Juventud IJ
283 label
= "Isla de la Juventud";
285 uuid
= transformer
.getNamedAreaUuid(abbrev
);
286 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
287 westernCuba
.addIncludes(area
);
288 area
.setIdInVocabulary(abbrev
);
290 //Provinces - Central
292 label
= "Villa Clara";
294 uuid
= transformer
.getNamedAreaUuid(abbrev
);
295 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
296 centralCuba
.addIncludes(area
);
297 area
.setIdInVocabulary(abbrev
);
300 label
= "Cienfuegos";
302 uuid
= transformer
.getNamedAreaUuid(abbrev
);
303 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
304 centralCuba
.addIncludes(area
);
305 area
.setIdInVocabulary(abbrev
);
308 label
= "Sancti Spiritus";
310 uuid
= transformer
.getNamedAreaUuid(abbrev
);
311 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
312 centralCuba
.addIncludes(area
);
313 area
.setIdInVocabulary(abbrev
);
316 label
= "Ciego de Ávila";
318 uuid
= transformer
.getNamedAreaUuid(abbrev
);
319 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
320 centralCuba
.addIncludes(area
);
321 area
.setIdInVocabulary(abbrev
);
326 uuid
= transformer
.getNamedAreaUuid(abbrev
);
327 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
328 centralCuba
.addIncludes(area
);
329 area
.setIdInVocabulary(abbrev
);
334 uuid
= transformer
.getNamedAreaUuid(abbrev
);
335 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
336 centralCuba
.addIncludes(area
);
337 area
.setIdInVocabulary(abbrev
);
343 uuid
= transformer
.getNamedAreaUuid(abbrev
);
344 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
345 eastCuba
.addIncludes(area
);
346 area
.setIdInVocabulary(abbrev
);
351 uuid
= transformer
.getNamedAreaUuid(abbrev
);
352 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
353 eastCuba
.addIncludes(area
);
354 area
.setIdInVocabulary(abbrev
);
356 //Santiago de Cuba SC
357 label
= "Santiago de Cuba";
359 uuid
= transformer
.getNamedAreaUuid(abbrev
);
360 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
361 eastCuba
.addIncludes(area
);
362 area
.setIdInVocabulary(abbrev
);
365 label
= "Guantánamo";
367 uuid
= transformer
.getNamedAreaUuid(abbrev
);
368 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
369 eastCuba
.addIncludes(area
);
370 area
.setIdInVocabulary(abbrev
);
372 //other Greater Antilles (Cuba, Española, Jamaica, Puerto Rico)
374 //Española Esp (=Haiti + Dominican Republic)
377 uuid
= transformer
.getNamedAreaUuid(abbrev
);
378 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
379 area
.setIdInVocabulary(abbrev
);
382 level
= NamedAreaLevel
.COUNTRY();
385 uuid
= transformer
.getNamedAreaUuid(abbrev
);
386 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
387 area
.setIdInVocabulary(abbrev
);
390 level
= NamedAreaLevel
.COUNTRY();
391 label
= "Puerto Rico";
393 uuid
= transformer
.getNamedAreaUuid(abbrev
);
394 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
395 area
.setIdInVocabulary(abbrev
);
397 //Lesser Antilles Men
399 label
= "Lesser Antilles";
401 uuid
= transformer
.getNamedAreaUuid(abbrev
);
402 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
403 area
.setIdInVocabulary(abbrev
);
408 uuid
= transformer
.getNamedAreaUuid(abbrev
);
409 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
410 area
.setIdInVocabulary(abbrev
);
413 label
= "Cayman Islands"; //[Trinidad, Tobago, Curaçao, Margarita, ABC Isl. => S. America];
415 uuid
= transformer
.getNamedAreaUuid(abbrev
);
416 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
417 area
.setIdInVocabulary(abbrev
);
421 label
= "N America"; //(incl. Mexico)
423 uuid
= transformer
.getNamedAreaUuid(abbrev
);
424 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
425 area
.setIdInVocabulary(abbrev
);
428 label
= "Central America";
430 uuid
= transformer
.getNamedAreaUuid(abbrev
);
431 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
432 area
.setIdInVocabulary(abbrev
);
437 uuid
= transformer
.getNamedAreaUuid(abbrev
);
438 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
439 area
.setIdInVocabulary(abbrev
);
442 label
= "Old World ";
444 uuid
= transformer
.getNamedAreaUuid(abbrev
);
445 area
= getNamedArea(state
, uuid
, label
, label
, abbrev
, areaType
, level
, cubaAreasVocabualary
, matchMode
);
446 area
.setIdInVocabulary(abbrev
);
448 commitTransaction(tx
);
454 protected boolean isIgnore(CubaImportState state
) {
455 return ! state
.getConfig().isDoVocabularies();
460 protected boolean doCheck(CubaImportState state
) {
461 logger
.warn("DoCheck not yet implemented for CubaVocabularyImport");