1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns;
|
11
|
|
12
|
import java.sql.ResultSet;
|
13
|
import java.sql.SQLException;
|
14
|
import java.util.ArrayList;
|
15
|
import java.util.HashMap;
|
16
|
import java.util.HashSet;
|
17
|
import java.util.List;
|
18
|
import java.util.Map;
|
19
|
import java.util.Set;
|
20
|
import java.util.UUID;
|
21
|
import java.util.regex.Matcher;
|
22
|
import java.util.regex.Pattern;
|
23
|
|
24
|
import org.apache.commons.lang.StringUtils;
|
25
|
import org.apache.log4j.Logger;
|
26
|
import org.springframework.stereotype.Component;
|
27
|
|
28
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
29
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
|
30
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
31
|
import eu.etaxonomy.cdm.io.common.IOValidator;
|
32
|
import eu.etaxonomy.cdm.io.common.mapping.DbImportAnnotationMapper;
|
33
|
import eu.etaxonomy.cdm.io.common.mapping.DbImportExtensionMapper;
|
34
|
import eu.etaxonomy.cdm.io.common.mapping.DbImportMapping;
|
35
|
import eu.etaxonomy.cdm.io.common.mapping.DbImportMethodMapper;
|
36
|
import eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapper;
|
37
|
import eu.etaxonomy.cdm.io.common.mapping.DbNotYetImplementedMapper;
|
38
|
import eu.etaxonomy.cdm.io.common.mapping.IMappingImport;
|
39
|
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
|
40
|
import eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns.validation.CentralAfricaFernsTaxonImportValidator;
|
41
|
import eu.etaxonomy.cdm.model.agent.Team;
|
42
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
43
|
import eu.etaxonomy.cdm.model.common.AnnotationType;
|
44
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
45
|
import eu.etaxonomy.cdm.model.common.ExtensionType;
|
46
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
47
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
48
|
import eu.etaxonomy.cdm.model.name.IBotanicalName;
|
49
|
import eu.etaxonomy.cdm.model.name.INonViralName;
|
50
|
import eu.etaxonomy.cdm.model.name.ITaxonNameBase;
|
51
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
|
52
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
|
53
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
54
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
|
55
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
56
|
import eu.etaxonomy.cdm.model.name.Rank;
|
57
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
58
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
|
59
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
60
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
61
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
62
|
import eu.etaxonomy.cdm.model.occurrence.Collection;
|
63
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
64
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
65
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
66
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
67
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
68
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
69
|
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
|
70
|
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
|
71
|
|
72
|
|
73
|
/**
|
74
|
* @author a.mueller
|
75
|
* @created 20.02.2010
|
76
|
*/
|
77
|
@Component
|
78
|
public class CentralAfricaFernsTaxonImport extends CentralAfricaFernsImportBase<TaxonBase> implements IMappingImport<TaxonBase, CentralAfricaFernsImportState>{
|
79
|
private static final Logger logger = Logger.getLogger(CentralAfricaFernsTaxonImport.class);
|
80
|
|
81
|
public static final UUID TNS_EXT_UUID = UUID.fromString("41cb0450-ac84-4d73-905e-9c7773c23b05");
|
82
|
|
83
|
|
84
|
private DbImportMapping<?,?> mapping;
|
85
|
|
86
|
//second path is not used anymore, there is now an ErmsTaxonRelationImport class instead
|
87
|
// private boolean isSecondPath = false;
|
88
|
|
89
|
private static final String pluralString = "taxa";
|
90
|
private static final String dbTableName = "[African pteridophytes]";
|
91
|
private static final Class<?> cdmTargetClass = TaxonBase.class;
|
92
|
|
93
|
public CentralAfricaFernsTaxonImport(){
|
94
|
super(pluralString, dbTableName, cdmTargetClass);
|
95
|
}
|
96
|
|
97
|
|
98
|
@Override
|
99
|
protected String getIdQuery() {
|
100
|
String strQuery = " SELECT [Taxon number] FROM " + dbTableName ;
|
101
|
return strQuery;
|
102
|
}
|
103
|
|
104
|
@Override
|
105
|
protected DbImportMapping<?,?> getMapping() {
|
106
|
if (mapping == null){
|
107
|
mapping = new DbImportMapping();
|
108
|
|
109
|
mapping.addMapper(DbImportObjectCreationMapper.NewInstance(this, "Taxon number", TAXON_NAMESPACE)); //id + tu_status
|
110
|
|
111
|
mapping.addMapper(DbImportMethodMapper.NewInstance(this, "mapTypes", ResultSet.class, CentralAfricaFernsImportState.class));
|
112
|
mapping.addMapper(DbImportAnnotationMapper.NewInstance("Notes", AnnotationType.EDITORIAL()));
|
113
|
|
114
|
mapping.addMapper(DbImportMethodMapper.NewInstance(this, "mapReferences", ResultSet.class, CentralAfricaFernsImportState.class));
|
115
|
mapping.addMapper(DbImportMethodMapper.NewInstance(this, "mapNomRemarks", ResultSet.class, CentralAfricaFernsImportState.class));
|
116
|
|
117
|
mapping.addMapper(DbImportExtensionMapper.NewInstance("Illustrations - non-original", CentralAfricaFernsTransformer.uuidIllustrationsNonOriginal, "Illustrations - non-original", "Illustrations - non-original", null));
|
118
|
|
119
|
// mapping.addMapper(DbImportTextDataCreationMapper.NewInstance("Illustrations - non-original", objectToCreateNamespace, dbTaxonFkAttribute, this.TAXON_NAMESPACE, "Illustrations - non-original", Language.ENGLISH(), Feature, null);
|
120
|
// mapping.addMapper(DbImportTextDataCreationMapper.NewInstance(dbIdAttribute, objectToCreateNamespace, dbTaxonFkAttribute, taxonNamespace, dbTextAttribute, Language.ENGLISH(), Feature.ECOLOGY(), null));
|
121
|
|
122
|
//not yet implemented or ignore
|
123
|
mapping.addMapper(DbNotYetImplementedMapper.NewInstance("Types XXX", "Method Mapper does not work yet. Needs implementation for all 5 types. FIXMEs in implementation"));
|
124
|
|
125
|
mapping.addMapper(DbNotYetImplementedMapper.NewInstance("Basionym of", "Needs better understanding"));
|
126
|
mapping.addMapper(DbNotYetImplementedMapper.NewInstance("Synonym of", "Needs better understanding. Strange values like "));
|
127
|
|
128
|
|
129
|
mapping.addMapper(DbNotYetImplementedMapper.NewInstance("Chromosome number" , "Wrong data. Seems to be 'reference full'"));
|
130
|
|
131
|
mapping.addMapper(DbNotYetImplementedMapper.NewInstance("Book Publisher & Place" , "How to access the reference via String mapper?"));
|
132
|
|
133
|
mapping.addMapper(DbNotYetImplementedMapper.NewInstance("Reprint no" , "What's this?"));
|
134
|
mapping.addMapper(DbNotYetImplementedMapper.NewInstance("Date verified" , "Needed?"));
|
135
|
|
136
|
|
137
|
//
|
138
|
// UUID credibilityUuid = ErmsTransformer.uuidCredibility;
|
139
|
// mapping.addMapper(DbImportExtensionMapper.NewInstance("tu_credibility", credibilityUuid, "credibility", "credibility", "credibility")); //Werte: null, unknown, marked for deletion
|
140
|
//
|
141
|
//ignore
|
142
|
// mapping.addMapper(DbIgnoreMapper.NewInstance("cache_citation", "citation cache not needed in PESI"));
|
143
|
|
144
|
//not yet implemented or ignore
|
145
|
// mapping.addMapper(DbNotYetImplementedMapper.NewInstance("tu_hidden", "Needs DbImportMarkerMapper implemented"));
|
146
|
|
147
|
}
|
148
|
return mapping;
|
149
|
}
|
150
|
|
151
|
/* (non-Javadoc)
|
152
|
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getRecordQuery(eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator)
|
153
|
*/
|
154
|
@Override
|
155
|
protected String getRecordQuery(CentralAfricaFernsImportConfigurator config) {
|
156
|
String strSelect = " SELECT * ";
|
157
|
String strFrom = " FROM [African pteridophytes] as ap";
|
158
|
String strWhere = " WHERE ( ap.[taxon number] IN (" + ID_LIST_TOKEN + ") )";
|
159
|
String strOrderBy = " ORDER BY [Taxon number]";
|
160
|
String strRecordQuery = strSelect + strFrom + strWhere + strOrderBy;
|
161
|
return strRecordQuery;
|
162
|
}
|
163
|
|
164
|
|
165
|
@Override
|
166
|
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, CentralAfricaFernsImportState state) {
|
167
|
// String nameSpace;
|
168
|
// Class<?> cdmClass;
|
169
|
// Set<String> idSet;
|
170
|
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
171
|
|
172
|
try{
|
173
|
Set<String> nameIdSet = new HashSet<String>();
|
174
|
Set<String> referenceIdSet = new HashSet<String>();
|
175
|
while (rs.next()){
|
176
|
// handleForeignKey(rs, nameIdSet, "PTNameFk");
|
177
|
// handleForeignKey(rs, referenceIdSet, "PTRefFk");
|
178
|
}
|
179
|
|
180
|
//reference map
|
181
|
// nameSpace = "Reference";
|
182
|
// cdmClass = Reference.class;
|
183
|
// Map<String, Person> referenceMap = (Map<String, Person>)getCommonService().getSourcedObjectsByIdInSource(Person.class, teamIdSet, nameSpace);
|
184
|
// result.put(Reference.class, referenceMap);
|
185
|
|
186
|
} catch (SQLException e) {
|
187
|
throw new RuntimeException(e);
|
188
|
}
|
189
|
return result;
|
190
|
}
|
191
|
|
192
|
private TaxonBase mapTypes(ResultSet rs, CentralAfricaFernsImportState state) throws SQLException{
|
193
|
TaxonBase<?> taxonBase = state.getRelatedObject(state.CURRENT_OBJECT_NAMESPACE, state.CURRENT_OBJECT_ID, TaxonBase.class);
|
194
|
TaxonNameBase name = taxonBase.getName();
|
195
|
for (int i = 1; i <= 5; i++){
|
196
|
String[] typeInfo = new String[3];
|
197
|
typeInfo = getTypeInfo(rs, i);
|
198
|
if (StringUtils.isBlank(typeInfo[0]) && StringUtils.isBlank(typeInfo[1]) && StringUtils.isBlank(typeInfo[2])){
|
199
|
continue;
|
200
|
}
|
201
|
makeSingleType(state, name, typeInfo[0], typeInfo[1], typeInfo[2]);
|
202
|
}
|
203
|
return taxonBase;
|
204
|
}
|
205
|
|
206
|
|
207
|
private String[] getTypeInfo(ResultSet rs, int i) throws SQLException {
|
208
|
String[] typeInfo = new String[3];
|
209
|
String number;
|
210
|
if (i == 1){
|
211
|
number = "";
|
212
|
}else{
|
213
|
number = String.valueOf(i);
|
214
|
}
|
215
|
typeInfo[0] = rs.getString("Type" + number);
|
216
|
typeInfo[1] = rs.getString("Type collector and number" + number);
|
217
|
typeInfo[2] = rs.getString("Type location" + number);
|
218
|
|
219
|
return typeInfo;
|
220
|
}
|
221
|
|
222
|
|
223
|
|
224
|
private void makeSingleType(CentralAfricaFernsImportState state, TaxonNameBase name, String typeString, String typeCollectorString, String typeLocationString) {
|
225
|
if (name.getRank().isHigher(Rank.SPECIES())){
|
226
|
//TODO move to TaxonRelationImport
|
227
|
handleNameType(state, name, typeString, typeCollectorString, typeLocationString);
|
228
|
}else{
|
229
|
handleSpecimenType(state, name, typeString, typeCollectorString, typeLocationString);
|
230
|
}
|
231
|
}
|
232
|
|
233
|
|
234
|
|
235
|
private void handleSpecimenType(CentralAfricaFernsImportState state, TaxonNameBase name, String typeString, String typeCollectorString, String typeLocationString) {
|
236
|
List<SpecimenTypeDesignation> designations = new ArrayList<SpecimenTypeDesignation>();
|
237
|
typeLocationString = CdmUtils.Nz(typeLocationString);
|
238
|
if (typeLocationString.equalsIgnoreCase("not located")){
|
239
|
|
240
|
}else{
|
241
|
String[] splits = typeLocationString.split(";");
|
242
|
for (String split : splits){
|
243
|
List<SpecimenTypeDesignation> splitDesignations = handleTypeLocationPart(state, typeString, typeCollectorString, split);
|
244
|
designations.addAll(splitDesignations);
|
245
|
}
|
246
|
}
|
247
|
if (designations.size() == 0){
|
248
|
logger.error(state.getTaxonNumber() + " - No designations defined. TypeString: " + CdmUtils.Nz(typeString) + ", CollectorString: " + typeCollectorString);
|
249
|
}
|
250
|
//type and collector
|
251
|
DerivedUnitFacade lastFacade = null;
|
252
|
for (SpecimenTypeDesignation designation: designations){
|
253
|
name.addTypeDesignation(designation, false);
|
254
|
if (typeString != null && (typeString.contains("Not designated.")|| typeString.contains("No type designated."))){
|
255
|
designation.setNotDesignated(true);
|
256
|
}
|
257
|
|
258
|
DerivedUnit specimen = designation.getTypeSpecimen();
|
259
|
|
260
|
if (lastFacade != null){
|
261
|
lastFacade.addDuplicate(specimen);
|
262
|
}else{
|
263
|
|
264
|
try {
|
265
|
lastFacade = DerivedUnitFacade.NewInstance(specimen);
|
266
|
} catch (DerivedUnitFacadeNotSupportedException e) {
|
267
|
throw new RuntimeException(e);
|
268
|
}
|
269
|
|
270
|
//TODO not so nice
|
271
|
lastFacade.setLocality(typeString);
|
272
|
makeTypeCollectorInfo(lastFacade, typeCollectorString);
|
273
|
|
274
|
}
|
275
|
}
|
276
|
|
277
|
}
|
278
|
|
279
|
|
280
|
|
281
|
private List<SpecimenTypeDesignation> handleTypeLocationPart(CentralAfricaFernsImportState state,
|
282
|
String typeString, String typeCollectorString, String typeLocationPart) {
|
283
|
List<SpecimenTypeDesignation> result = new ArrayList<SpecimenTypeDesignation>();
|
284
|
String[] splits = typeLocationPart.split(",");
|
285
|
//see also SpecimenTypeParser
|
286
|
String typeTypePattern = "(holo.|lecto.|iso.|isolecto.|syn.|isosyn.|neo.|isoneo.)";
|
287
|
String collectionPattern = "^[A-Z]+(\\-[A-Z]+)?";
|
288
|
String numberPattern = "([0-9]+([\\-\\s\\.\\/][0-9]+)?)?";
|
289
|
String addInfoPattern = "[!\\+\\?]?";
|
290
|
String typeCollectionPattern = collectionPattern + "\\s?" + numberPattern + addInfoPattern;
|
291
|
SpecimenTypeDesignation lastDesignation = null;
|
292
|
|
293
|
for (String split: splits){
|
294
|
split = split.trim();
|
295
|
if (StringUtils.isBlank(split)){
|
296
|
continue;
|
297
|
}else if(split.trim().startsWith("designated by")){
|
298
|
split = handleDesignatedBy(lastDesignation, split);
|
299
|
}else if (split.trim().matches(typeTypePattern)){
|
300
|
makeSpecimentTypeStatus(lastDesignation, split);
|
301
|
}else if(split.matches(typeCollectionPattern)){
|
302
|
|
303
|
lastDesignation = makeSpecimenTypeCollection(lastDesignation, split, collectionPattern, numberPattern, addInfoPattern);
|
304
|
}else if(split.equalsIgnoreCase("not located")){
|
305
|
lastDesignation = makeCachedSpecimenDesignation(split);
|
306
|
}else{
|
307
|
logger.error(state.getTaxonNumber() + " - Unknown type location part: " + split);
|
308
|
if (lastDesignation == null){
|
309
|
lastDesignation = makeCachedSpecimenDesignation(split);
|
310
|
}
|
311
|
}
|
312
|
if (lastDesignation != null && ! result.contains(lastDesignation)){
|
313
|
result.add(lastDesignation);
|
314
|
}else if (lastDesignation == null){
|
315
|
logger.warn("Last Designation is null");
|
316
|
}
|
317
|
}
|
318
|
|
319
|
return result;
|
320
|
}
|
321
|
|
322
|
|
323
|
|
324
|
/**
|
325
|
* @param split
|
326
|
* @return
|
327
|
*/
|
328
|
private SpecimenTypeDesignation makeCachedSpecimenDesignation(String split) {
|
329
|
SpecimenTypeDesignation lastDesignation;
|
330
|
lastDesignation = SpecimenTypeDesignation.NewInstance();
|
331
|
DerivedUnit specimen = DerivedUnit.NewPreservedSpecimenInstance();
|
332
|
specimen.setTitleCache(split, true);
|
333
|
lastDesignation.setTypeSpecimen(specimen);
|
334
|
return lastDesignation;
|
335
|
}
|
336
|
|
337
|
|
338
|
|
339
|
private SpecimenTypeDesignation makeSpecimenTypeCollection(SpecimenTypeDesignation designation, String collectionString, String strCollectionPattern, String strNumberPattern, String strAddInfoPattern) {
|
340
|
SpecimenTypeDesignation result = SpecimenTypeDesignation.NewInstance();
|
341
|
DerivedUnit specimen = DerivedUnit.NewPreservedSpecimenInstance();
|
342
|
result.setTypeSpecimen(specimen);
|
343
|
|
344
|
//collection
|
345
|
Pattern collectionPattern = Pattern.compile(strCollectionPattern);
|
346
|
Matcher matcher = collectionPattern.matcher(collectionString);
|
347
|
if (! matcher.find()){
|
348
|
throw new RuntimeException("collectionString doesn't match: " + collectionString);
|
349
|
}
|
350
|
String strCollection = matcher.group();
|
351
|
Collection collection = getCollection(strCollection);
|
352
|
specimen.setCollection(collection);
|
353
|
collectionString = collectionString.substring(strCollection.length()).trim();
|
354
|
|
355
|
|
356
|
//collection number
|
357
|
Pattern numberPattern = Pattern.compile(strNumberPattern);
|
358
|
matcher = numberPattern.matcher(collectionString);
|
359
|
if (matcher.find()){
|
360
|
String strNumber = matcher.group();
|
361
|
collectionString = collectionString.substring(strNumber.length()).trim();
|
362
|
if (StringUtils.isNotBlank(strNumber)){
|
363
|
specimen.setCatalogNumber(strNumber);
|
364
|
}
|
365
|
}else{
|
366
|
//throw new RuntimeException("numberString doesn't match: " + collectionString);
|
367
|
}
|
368
|
|
369
|
//additional info
|
370
|
Pattern addInfoPattern = Pattern.compile(strAddInfoPattern);
|
371
|
matcher = addInfoPattern.matcher(collectionString);
|
372
|
if (matcher.find()){
|
373
|
String strAddInfo = matcher.group();
|
374
|
collectionString = collectionString.substring(strAddInfo.length()).trim();
|
375
|
if (StringUtils.isBlank(strAddInfo)){
|
376
|
//do nothing
|
377
|
}else if (strAddInfo.equals("!")){
|
378
|
//TODO add seen by author
|
379
|
}else if (strAddInfo.equals("?")){
|
380
|
//TODO add doubtful
|
381
|
}else if (strAddInfo.equals("+")){
|
382
|
//TODO add +
|
383
|
}
|
384
|
}else{
|
385
|
//throw new RuntimeException("addInfoString doesn't match: " + collectionString);
|
386
|
}
|
387
|
if (StringUtils.isNotBlank(collectionString)){
|
388
|
logger.error("Collection string is not empty: " + collectionString );
|
389
|
}
|
390
|
return result;
|
391
|
}
|
392
|
|
393
|
|
394
|
|
395
|
private Collection getCollection(String strCollection) {
|
396
|
//TODO use BCI and deduplication
|
397
|
Collection result = Collection.NewInstance();
|
398
|
return result;
|
399
|
}
|
400
|
|
401
|
|
402
|
|
403
|
private void makeSpecimentTypeStatus(SpecimenTypeDesignation designation, String type) {
|
404
|
SpecimenTypeDesignationStatus status;
|
405
|
if (type.equalsIgnoreCase("iso.")){
|
406
|
status = SpecimenTypeDesignationStatus.ISOTYPE();
|
407
|
}else if (type.equalsIgnoreCase("isolecto.")){
|
408
|
status = SpecimenTypeDesignationStatus.ISOLECTOTYPE();
|
409
|
}else if (type.equalsIgnoreCase("syn.")){
|
410
|
status = SpecimenTypeDesignationStatus.SYNTYPE();
|
411
|
}else if (type.equalsIgnoreCase("holo.")){
|
412
|
status = SpecimenTypeDesignationStatus.HOLOTYPE();
|
413
|
}else if (type.equalsIgnoreCase("lecto.")){
|
414
|
status = SpecimenTypeDesignationStatus.LECTOTYPE();
|
415
|
}else if (type.equalsIgnoreCase("isosyn.")){
|
416
|
status = SpecimenTypeDesignationStatus.ISOSYNTYPE();
|
417
|
}else if (type.equalsIgnoreCase("neo.")){
|
418
|
status = SpecimenTypeDesignationStatus.NEOTYPE();
|
419
|
}else if (type.equalsIgnoreCase("isoneo.")){
|
420
|
status = SpecimenTypeDesignationStatus.ISONEOTYPE();
|
421
|
}else{
|
422
|
logger.error("Type Status not supported: " + type);
|
423
|
throw new RuntimeException("Type Status not supported: " + type);
|
424
|
}
|
425
|
if (designation == null){
|
426
|
logger.error("Designation is null");
|
427
|
}else{
|
428
|
designation.setTypeStatus(status);
|
429
|
}
|
430
|
}
|
431
|
|
432
|
|
433
|
|
434
|
private void handleNameType(CentralAfricaFernsImportState state, TaxonNameBase name, String typeString, String typeCollectorString, String typeLocation) {
|
435
|
String originalString = typeString; //just for testing
|
436
|
if (StringUtils.isNotBlank(typeCollectorString)){
|
437
|
logger.error(state.getTaxonNumber() + " - Type collector string for name type is not empty: " + typeCollectorString);
|
438
|
}
|
439
|
if (StringUtils.isNotBlank(typeLocation)){
|
440
|
logger.error(state.getTaxonNumber() + " - Type location string for name type is not empty: " + typeLocation);
|
441
|
}
|
442
|
NameTypeDesignation nameTypeDesignation = NameTypeDesignation.NewInstance();
|
443
|
NameTypeDesignationStatus status = null;
|
444
|
if (StringUtils.isBlank(typeString)){
|
445
|
logger.warn(state.getTaxonNumber() + " - TypeString is empty");
|
446
|
}
|
447
|
if (typeString.startsWith("None designated.")){
|
448
|
nameTypeDesignation.setNotDesignated(true);
|
449
|
typeString = typeString.replaceFirst("None designated\\.", "").trim();
|
450
|
}
|
451
|
if (typeString.contains("Lectotype: ")|| typeString.contains(", lecto." )){
|
452
|
status = NameTypeDesignationStatus.LECTOTYPE();
|
453
|
typeString = typeString.replace("Lectotype: ", "");
|
454
|
typeString = typeString.replace(", lecto.", "");
|
455
|
typeString = handleDesignatedBy(nameTypeDesignation, typeString);
|
456
|
}else{
|
457
|
typeString = handleDesignatedBy(nameTypeDesignation, typeString);
|
458
|
}
|
459
|
|
460
|
// String strSecondNamePattern = "([^\\(]*|\\(.*\\))+;.+"; //never ending story
|
461
|
String strSecondNamePattern = ".+;.+";
|
462
|
String firstName;
|
463
|
String secondName = null;
|
464
|
if (typeString.matches(strSecondNamePattern)){
|
465
|
String[] split = typeString.split(";");
|
466
|
firstName = split[0].trim();
|
467
|
secondName = split[1].trim();
|
468
|
if (split.length > 2){
|
469
|
logger.warn(state.getTaxonNumber() + " - There are more than 2 name types: " + typeString);
|
470
|
}
|
471
|
}else{
|
472
|
firstName = typeString;
|
473
|
}
|
474
|
if (StringUtils.isNotBlank(firstName)){
|
475
|
IBotanicalName[] nameTypeNames = getNameTypeName(firstName);
|
476
|
IBotanicalName nameTypeName = nameTypeNames[0];
|
477
|
IBotanicalName nameTypeAcceptedName = nameTypeNames[1];
|
478
|
nameTypeDesignation.setTypeName(TaxonNameBase.castAndDeproxy(nameTypeName));
|
479
|
if (nameTypeName.isProtectedTitleCache()){
|
480
|
logger.error(state.getTaxonNumber() + " - Name type could not be parsed: " + nameTypeName.getTitleCache());
|
481
|
}
|
482
|
if (! nameTypeName.getRank().equals(Rank.SPECIES())){
|
483
|
logger.warn(state.getTaxonNumber() + " - Name type is not of rank species: " + nameTypeName.getTitleCache());
|
484
|
}
|
485
|
}
|
486
|
if (StringUtils.isNotBlank(secondName)){
|
487
|
ITaxonNameBase secondNameType = handleSecondNameTypeName(secondName);
|
488
|
if (secondNameType.isProtectedTitleCache()){
|
489
|
logger.error(state.getTaxonNumber() + " - Second name type could not be parsed: " + secondNameType.getTitleCache());
|
490
|
}
|
491
|
if (! secondNameType.getRank().equals(Rank.SPECIES())){
|
492
|
logger.error(state.getTaxonNumber() + " - Second name type is not of rank species: " + secondNameType.getTitleCache());
|
493
|
}
|
494
|
|
495
|
}
|
496
|
nameTypeDesignation.setTypeStatus(status);
|
497
|
name.addTypeDesignation(nameTypeDesignation, false);
|
498
|
|
499
|
}
|
500
|
|
501
|
|
502
|
|
503
|
private ITaxonNameBase handleSecondNameTypeName(String strName) {
|
504
|
//TODO needs feedbacke from Thomas
|
505
|
logger.info("Not yet implemented");
|
506
|
if (strName.endsWith(",")){
|
507
|
strName = strName.substring(0, strName.length() -1);
|
508
|
}
|
509
|
IBotanicalName result = (BotanicalName)NonViralNameParserImpl.NewInstance().parseFullName(strName, NomenclaturalCode.ICNAFP, Rank.SPECIES());
|
510
|
return result;
|
511
|
}
|
512
|
|
513
|
|
514
|
|
515
|
private IBotanicalName[] getNameTypeName(String strName) {
|
516
|
//TODO implement get existing names
|
517
|
logger.info("Not yet fully implemented");
|
518
|
|
519
|
IBotanicalName[] result = new BotanicalName[2];
|
520
|
if (strName.endsWith(",")){
|
521
|
strName = strName.substring(0, strName.length() -1);
|
522
|
}
|
523
|
String acceptedName;
|
524
|
String acceptedNamePattern = "\\(.*\\)\\.?$";
|
525
|
if (strName.matches(".*" + acceptedNamePattern)){
|
526
|
int accStart = strName.lastIndexOf("(");
|
527
|
String notAcceptedName = strName.substring(0, accStart -1 );
|
528
|
acceptedName = strName.substring(accStart + 1, strName.length() - 1);
|
529
|
if (acceptedName.endsWith(")")){
|
530
|
acceptedName = acceptedName.substring(0, acceptedName.length()-1);
|
531
|
}
|
532
|
acceptedName = acceptedName.replaceFirst("=", "").trim();
|
533
|
result[1] = (BotanicalName)NonViralNameParserImpl.NewInstance().parseFullName(acceptedName, NomenclaturalCode.ICNAFP, null);
|
534
|
strName = notAcceptedName;
|
535
|
}
|
536
|
|
537
|
result[0] = (BotanicalName)NonViralNameParserImpl.NewInstance().parseFullName(strName, NomenclaturalCode.ICNAFP, Rank.SPECIES());
|
538
|
return result;
|
539
|
}
|
540
|
|
541
|
|
542
|
|
543
|
private String handleDesignatedBy(TypeDesignationBase<?> typeDesignation, String typeString) {
|
544
|
String[] splitDesignated = typeString.split(", designated by ");
|
545
|
if (splitDesignated.length > 1){
|
546
|
Reference designationCitation = getDesignationCitation(typeDesignation, splitDesignated[1]);
|
547
|
typeDesignation.setCitation(designationCitation);
|
548
|
if (splitDesignated.length > 2){
|
549
|
throw new IllegalStateException("More than one designation is not expected");
|
550
|
}
|
551
|
}
|
552
|
return splitDesignated[0].trim();
|
553
|
}
|
554
|
|
555
|
|
556
|
|
557
|
private Reference getDesignationCitation(TypeDesignationBase<?> typeDesignation, String citationString) {
|
558
|
// TODO try to find an existing Reference
|
559
|
Reference result = ReferenceFactory.newGeneric();
|
560
|
String strBracketPattern = "\\((10 Oct. )?\\d{4}:\\s?(\\d{1,3}(--\\d{1,3})?|[XLVI]{1,7}|\\.{1,8})\\)\\.?";
|
561
|
|
562
|
String strStandardPattern = ".*" + strBracketPattern;
|
563
|
// strStandardPattern = ".*";
|
564
|
if (Pattern.matches(strStandardPattern, citationString)){
|
565
|
parseStandardPattern(typeDesignation, result, citationString, strBracketPattern);
|
566
|
}else{
|
567
|
logger.error("Can't parse designation citation: " + citationString);
|
568
|
result.setTitleCache(citationString);
|
569
|
}
|
570
|
return result;
|
571
|
}
|
572
|
|
573
|
|
574
|
|
575
|
private void parseStandardPattern(TypeDesignationBase typeDesignation, Reference result, String citationString, String bracketPattern) {
|
576
|
String authorPart = citationString.split(bracketPattern)[0];
|
577
|
String bracket = citationString.substring(authorPart.length()+1, citationString.length()-1).trim();
|
578
|
authorPart = authorPart.trim();
|
579
|
if (bracket.endsWith(")")){
|
580
|
bracket = bracket.substring(0, bracket.length()-1);
|
581
|
}
|
582
|
Team team = Team.NewTitledInstance(authorPart, authorPart);
|
583
|
result.setAuthorship(team);
|
584
|
String[] bracketSplit = bracket.split(":");
|
585
|
TimePeriod datePublished = TimePeriodParser.parseString(bracketSplit[0].trim());
|
586
|
result.setDatePublished(datePublished);
|
587
|
String citationMicroReference = bracketSplit[1].trim();
|
588
|
citationMicroReference = citationMicroReference.replace("--", "-");
|
589
|
typeDesignation.setCitationMicroReference(citationMicroReference);
|
590
|
}
|
591
|
|
592
|
|
593
|
|
594
|
private void makeTypeCollectorInfo(DerivedUnitFacade specimen, String collectorAndNumberString) {
|
595
|
if (StringUtils.isBlank(collectorAndNumberString)){
|
596
|
return;
|
597
|
}
|
598
|
String reNumber = "(s\\.n\\.|\\d.*)";
|
599
|
Pattern reNumberPattern = Pattern.compile(reNumber);
|
600
|
Matcher matcher = reNumberPattern.matcher(collectorAndNumberString);
|
601
|
|
602
|
if ( matcher.find()){
|
603
|
int numberStart = matcher.start();
|
604
|
String number = collectorAndNumberString.substring(numberStart).trim();
|
605
|
if (numberStart > 0){
|
606
|
numberStart = numberStart -1;
|
607
|
}
|
608
|
String collectorString = collectorAndNumberString.substring(0, numberStart).trim();
|
609
|
specimen.setFieldNumber(number);
|
610
|
TeamOrPersonBase team = getTeam(collectorString);
|
611
|
specimen.setCollector(team);
|
612
|
|
613
|
}else{
|
614
|
logger.warn("collector string did not match number pattern: " + collectorAndNumberString);
|
615
|
|
616
|
}
|
617
|
}
|
618
|
|
619
|
|
620
|
private TeamOrPersonBase getTeam(String teamString) {
|
621
|
//TODO check existing team
|
622
|
TeamOrPersonBase result = Team.NewTitledInstance(teamString, teamString);
|
623
|
return result;
|
624
|
}
|
625
|
|
626
|
|
627
|
|
628
|
/**
|
629
|
* for internal use only, used by MethodMapper
|
630
|
*/
|
631
|
private TaxonBase mapReferences(ResultSet rs, CentralAfricaFernsImportState state) throws SQLException{
|
632
|
String taxonNumber = state.getTaxonNumber();
|
633
|
String referenceFullString = rs.getString("Reference full");
|
634
|
String referenceAbbreviatedString = rs.getString("Reference - abbreviated");
|
635
|
String volume = rs.getString("Book / Journal volume");
|
636
|
String pages = rs.getString("Book / Journal pages");
|
637
|
String illustrations = rs.getString("Illustration/s");
|
638
|
|
639
|
String fascicle = rs.getString("Book / Journal fascicle");
|
640
|
String part = rs.getString("Book / Journal part");
|
641
|
String paperTitle = rs.getString("Book / Paper title");
|
642
|
|
643
|
String datePublishedString = rs.getString("Date published");
|
644
|
String referenceString = referenceFullString;
|
645
|
if (StringUtils.isBlank(referenceString)){
|
646
|
referenceString = referenceAbbreviatedString;
|
647
|
}
|
648
|
|
649
|
TaxonBase<?> taxonBase = state.getRelatedObject(state.CURRENT_OBJECT_NAMESPACE, state.CURRENT_OBJECT_ID, TaxonBase.class);
|
650
|
if (StringUtils.isNotBlank(referenceString) || StringUtils.isNotBlank(volume) ||
|
651
|
StringUtils.isNotBlank(pages) || StringUtils.isNotBlank(illustrations) ||
|
652
|
StringUtils.isNotBlank(datePublishedString) || StringUtils.isNotBlank(paperTitle)){
|
653
|
INonViralName name = taxonBase.getName();
|
654
|
Reference reference = ReferenceFactory.newGeneric();
|
655
|
reference.setAuthorship(name.getCombinationAuthorship());
|
656
|
reference.setTitle(referenceString);
|
657
|
reference.setVolume(volume);
|
658
|
reference.setEdition(part);
|
659
|
Reference inreference = null;
|
660
|
//TODO parser
|
661
|
TimePeriod datePublished = TimePeriodParser.parseString(datePublishedString);
|
662
|
reference.setDatePublished(datePublished);
|
663
|
if (StringUtils.isNotBlank(paperTitle)){
|
664
|
Reference innerReference = ReferenceFactory.newGeneric();
|
665
|
innerReference.setDatePublished(datePublished);
|
666
|
name.setNomenclaturalReference(innerReference);
|
667
|
innerReference.setInReference(reference);
|
668
|
reference = innerReference;
|
669
|
}else{
|
670
|
name.setNomenclaturalReference(reference);
|
671
|
}
|
672
|
|
673
|
//details
|
674
|
String details = CdmUtils.concat(", ", pages, illustrations);
|
675
|
details = StringUtils.isBlank(details) ? null : details.trim();
|
676
|
name.setNomenclaturalMicroReference(details);
|
677
|
try {
|
678
|
UUID uuidFascicle = state.getTransformer().getExtensionTypeUuid("fascicle");
|
679
|
ExtensionType extensionType = getExtensionType(state, uuidFascicle, "Fascicle", "Fascicle", null);
|
680
|
reference.addExtension(fascicle, extensionType);
|
681
|
} catch (UndefinedTransformerMethodException e) {
|
682
|
e.printStackTrace();
|
683
|
}
|
684
|
|
685
|
}else{
|
686
|
logger.warn(taxonNumber + " - Taxon has no reference");
|
687
|
}
|
688
|
return taxonBase;
|
689
|
}
|
690
|
|
691
|
/**
|
692
|
* for internal use only, used by MethodMapper
|
693
|
* @throws Exception
|
694
|
*/
|
695
|
private TaxonBase mapNomRemarks(ResultSet rs, CentralAfricaFernsImportState state) throws Exception{
|
696
|
try {
|
697
|
String taxonNumber = state.getTaxonNumber();
|
698
|
String nomRemarksString = rs.getString("Nom remarks");
|
699
|
String taxonStatus = rs.getString("Current/Synonym");
|
700
|
|
701
|
TaxonBase<?> taxonBase = state.getRelatedObject(state.CURRENT_OBJECT_NAMESPACE, state.CURRENT_OBJECT_ID, TaxonBase.class);
|
702
|
if (StringUtils.isNotBlank(nomRemarksString)){
|
703
|
INonViralName name = taxonBase.getName();
|
704
|
parseNomRemark(state, name, nomRemarksString.trim(),taxonStatus, taxonNumber);
|
705
|
}
|
706
|
return taxonBase;
|
707
|
} catch (Exception e) {
|
708
|
throw e;
|
709
|
}
|
710
|
}
|
711
|
|
712
|
|
713
|
private void parseNomRemark(CentralAfricaFernsImportState state, INonViralName name, String nomRemarksString, String taxonStatus, String taxonNumber) {
|
714
|
|
715
|
if (nomRemarksString.equalsIgnoreCase("comb. illeg.")){
|
716
|
name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.COMBINATION_ILLEGITIMATE()));
|
717
|
return;
|
718
|
// }else if (nomRemarksString.startsWith("comb. inval.")){
|
719
|
// //TODO
|
720
|
// nomRemarksString = nomRemarksString.replace("comb. inval.", "");
|
721
|
// }else if (nomRemarksString.equals("comb. nov.")){
|
722
|
// name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.COMBINATION_NOVUM);
|
723
|
}else if (nomRemarksString.equals("nom. ambig.")){
|
724
|
name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.AMBIGUOUS()));
|
725
|
return;
|
726
|
}else if (nomRemarksString.matches("nom\\. cons(erv)?\\.")){
|
727
|
name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONSERVED()));
|
728
|
return;
|
729
|
}else if (nomRemarksString.matches("nom\\. illeg(it)?\\.")){
|
730
|
name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ILLEGITIMATE()));
|
731
|
return;
|
732
|
}else if (nomRemarksString.matches("nom\\. inval(id)?\\.")){
|
733
|
name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.INVALID()));
|
734
|
return;
|
735
|
}else if (nomRemarksString.matches("nom\\. nov\\.")){
|
736
|
name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.NOVUM()));
|
737
|
return;
|
738
|
}else if (nomRemarksString.matches("nom\\. nud\\.")){
|
739
|
name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.NUDUM()));
|
740
|
return;
|
741
|
}else if (nomRemarksString.matches("nom\\. superfl\\.")){
|
742
|
name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.SUPERFLUOUS()));
|
743
|
return;
|
744
|
}else if (nomRemarksString.matches("p(\\.|ro\\s)?p(\\.|arte)")){
|
745
|
//pro parte is handled in taxon relationship import
|
746
|
if (! taxonStatus.equals("s")){
|
747
|
logger.warn(" - " + taxonNumber + " Pro parte synonym is not of type synonym");
|
748
|
}
|
749
|
return;
|
750
|
}else if (nomRemarksString.matches("as '.*'")){
|
751
|
String nameAsString = nomRemarksString.substring(4, nomRemarksString.length()-1);
|
752
|
//TODO discuss make it a name relationship
|
753
|
UUID uuidPublishedAs = CentralAfricaFernsTransformer.uuidNamePublishedAs;
|
754
|
ExtensionType extensionType = getExtensionType(state, uuidPublishedAs, "Name published as", "Name published as", "as");
|
755
|
name.addExtension(nameAsString, extensionType);
|
756
|
return;
|
757
|
}
|
758
|
|
759
|
|
760
|
if (StringUtils.isNotBlank(nomRemarksString)){
|
761
|
ExtensionType extensionType = getExtensionType(state, CentralAfricaFernsTransformer.uuidNomenclaturalRemarks, "Nomenclatural remarks", "Nomenclatural remarks", null);
|
762
|
name.addExtension(nomRemarksString, extensionType);
|
763
|
}
|
764
|
|
765
|
|
766
|
|
767
|
|
768
|
}
|
769
|
|
770
|
|
771
|
|
772
|
/* (non-Javadoc)
|
773
|
* @see eu.etaxonomy.cdm.io.common.mapping.IMappingImport#createObject(java.sql.ResultSet)
|
774
|
*/
|
775
|
@Override
|
776
|
public TaxonBase createObject(ResultSet rs, CentralAfricaFernsImportState state) throws SQLException {
|
777
|
IBotanicalName taxonName = TaxonNameFactory.NewBotanicalInstance(null);
|
778
|
Reference sec = state.getConfig().getSourceReference();
|
779
|
|
780
|
String taxonNumber = rs.getString("Taxon number");
|
781
|
state.setTaxonNumber(taxonNumber);
|
782
|
|
783
|
String orderName = rs.getString("Order name");
|
784
|
String subOrderName = rs.getString("Suborder name");
|
785
|
String familyName = rs.getString("Family name");
|
786
|
String subFamilyName = rs.getString("Subfamily name");
|
787
|
String tribusName = rs.getString("Tribus name");
|
788
|
String subTribusName = rs.getString("Subtribus name");
|
789
|
String sectionName = rs.getString("Section name");
|
790
|
String genusName = rs.getString("Genus name");
|
791
|
String subGenusName = rs.getString("Subgenus name");
|
792
|
String seriesName = rs.getString("Series name");
|
793
|
String specificEpihet = rs.getString("Specific epihet");
|
794
|
String subspeciesName = rs.getString("Subspecies name");
|
795
|
String varietyName = rs.getString("Variety name");
|
796
|
String subFormaName = rs.getString("Subforma");
|
797
|
String subVariety = rs.getString("Subvariery");
|
798
|
String formaName = rs.getString("Forma name");
|
799
|
String subsectionName = rs.getString("Subsection name");
|
800
|
|
801
|
String status = rs.getString("Current/Synonym");
|
802
|
|
803
|
TaxonBase taxon = makeTaxon(taxonName, sec, taxonNumber, status);
|
804
|
|
805
|
// Integer parent3Rank = rs.getInt("parent3rank");
|
806
|
|
807
|
//rank and epithets
|
808
|
Rank lowestRank = setLowestUninomial(taxonName, orderName, subOrderName, familyName, subFamilyName, tribusName, subTribusName,genusName);
|
809
|
lowestRank = setLowestInfraGeneric(taxonName, lowestRank, subGenusName, sectionName, subsectionName, seriesName);
|
810
|
if (StringUtils.isNotBlank(specificEpihet)){
|
811
|
taxonName.setSpecificEpithet(specificEpihet);
|
812
|
lowestRank = Rank.SPECIES();
|
813
|
}
|
814
|
lowestRank = setLowestInfraSpecific(taxonName, lowestRank, subspeciesName, varietyName, subVariety, formaName,subFormaName);
|
815
|
|
816
|
taxonName.setRank(lowestRank);
|
817
|
state.setCurrentRank(taxonName.getRank());
|
818
|
setAuthor(taxonName, rs, taxonNumber, false);
|
819
|
|
820
|
//add original source for taxon name (taxon original source is added in mapper
|
821
|
// Reference citation = state.getConfig().getSourceReference();
|
822
|
// addOriginalSource(taxonName, taxonNumber, TAXON_NAMESPACE, citation);
|
823
|
return taxon;
|
824
|
|
825
|
}
|
826
|
|
827
|
|
828
|
|
829
|
/**
|
830
|
* Creates the taxon object depending on name, sec and status
|
831
|
* @param taxonName
|
832
|
* @param sec
|
833
|
* @param taxonNumber
|
834
|
* @param status
|
835
|
* @return
|
836
|
*/
|
837
|
private TaxonBase makeTaxon(IBotanicalName taxonName, Reference sec, String taxonNumber, String status) {
|
838
|
TaxonBase taxon;
|
839
|
if ("c".equalsIgnoreCase(status)|| "incertus".equalsIgnoreCase(status) ){
|
840
|
taxon = Taxon.NewInstance(taxonName, sec);
|
841
|
if ("incertus".equalsIgnoreCase(status)){
|
842
|
taxon.setDoubtful(true);
|
843
|
}
|
844
|
}else if ("s".equalsIgnoreCase(status)){
|
845
|
taxon = Synonym.NewInstance(taxonName, sec);
|
846
|
}else{
|
847
|
logger.warn(taxonNumber + ": Status not given for taxon " );
|
848
|
taxon = Taxon.NewUnknownStatusInstance(TaxonNameBase.castAndDeproxy(taxonName), sec);
|
849
|
}
|
850
|
return taxon;
|
851
|
}
|
852
|
|
853
|
|
854
|
private Rank setLowestInfraSpecific(IBotanicalName taxonName, Rank lowestRank, String subspeciesName, String varietyName,
|
855
|
String subVariety, String formaName, String subFormaName) {
|
856
|
if (StringUtils.isNotBlank(subFormaName)){
|
857
|
taxonName.setInfraSpecificEpithet(subFormaName);
|
858
|
return Rank.SUBFORM();
|
859
|
}else if (StringUtils.isNotBlank(formaName)){
|
860
|
taxonName.setInfraSpecificEpithet(formaName);
|
861
|
return Rank.FORM();
|
862
|
}else if (StringUtils.isNotBlank(subVariety)){
|
863
|
taxonName.setInfraSpecificEpithet(subVariety);
|
864
|
return Rank.SUBVARIETY();
|
865
|
}else if (StringUtils.isNotBlank(varietyName)){
|
866
|
taxonName.setInfraSpecificEpithet(varietyName);
|
867
|
return Rank.VARIETY();
|
868
|
}else if (StringUtils.isNotBlank(subspeciesName)){
|
869
|
taxonName.setInfraSpecificEpithet(subspeciesName);
|
870
|
return Rank.SUBSPECIES();
|
871
|
}else{
|
872
|
return lowestRank;
|
873
|
}
|
874
|
}
|
875
|
|
876
|
|
877
|
|
878
|
private Rank setLowestInfraGeneric(IBotanicalName taxonName, Rank lowestRank, String subGenusName, String sectionName, String subSectionName, String seriesName) {
|
879
|
if (StringUtils.isNotBlank(seriesName)){
|
880
|
taxonName.setInfraGenericEpithet(seriesName);
|
881
|
return Rank.SERIES();
|
882
|
}else if (StringUtils.isNotBlank(subSectionName)){
|
883
|
taxonName.setInfraGenericEpithet(subSectionName);
|
884
|
return Rank.SUBSECTION_BOTANY();
|
885
|
}else if (StringUtils.isNotBlank(sectionName)){
|
886
|
taxonName.setInfraGenericEpithet(sectionName);
|
887
|
return Rank.SECTION_BOTANY();
|
888
|
}else if (StringUtils.isNotBlank(subGenusName)){
|
889
|
taxonName.setInfraGenericEpithet(subGenusName);
|
890
|
return Rank.SUBGENUS();
|
891
|
}else{
|
892
|
return lowestRank;
|
893
|
}
|
894
|
}
|
895
|
|
896
|
|
897
|
|
898
|
private Rank setLowestUninomial(IBotanicalName taxonName, String orderName, String subOrderName, String familyName, String subFamilyName,
|
899
|
String tribusName, String subTribusName, String genusName) {
|
900
|
|
901
|
if (StringUtils.isNotBlank(genusName)){
|
902
|
taxonName.setGenusOrUninomial(genusName);
|
903
|
return Rank.GENUS();
|
904
|
}else if (StringUtils.isNotBlank(subTribusName)){
|
905
|
taxonName.setGenusOrUninomial(subTribusName);
|
906
|
return Rank.SUBTRIBE();
|
907
|
}else if (StringUtils.isNotBlank(tribusName)){
|
908
|
taxonName.setGenusOrUninomial(tribusName);
|
909
|
return Rank.TRIBE();
|
910
|
}else if (StringUtils.isNotBlank(subFamilyName)){
|
911
|
taxonName.setGenusOrUninomial(subFamilyName);
|
912
|
return Rank.SUBFAMILY();
|
913
|
}else if (StringUtils.isNotBlank(familyName)){
|
914
|
taxonName.setGenusOrUninomial(familyName);
|
915
|
return Rank.FAMILY();
|
916
|
}else if (StringUtils.isNotBlank(subOrderName)){
|
917
|
taxonName.setGenusOrUninomial(subOrderName);
|
918
|
return Rank.SUBORDER();
|
919
|
}else if (StringUtils.isNotBlank(orderName)){
|
920
|
taxonName.setGenusOrUninomial(orderName);
|
921
|
return Rank.ORDER();
|
922
|
}else{
|
923
|
return null;
|
924
|
}
|
925
|
}
|
926
|
|
927
|
|
928
|
/* (non-Javadoc)
|
929
|
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase)
|
930
|
*/
|
931
|
@Override
|
932
|
protected boolean doCheck(CentralAfricaFernsImportState state){
|
933
|
IOValidator<CentralAfricaFernsImportState> validator = new CentralAfricaFernsTaxonImportValidator();
|
934
|
return validator.validate(state);
|
935
|
}
|
936
|
|
937
|
|
938
|
/* (non-Javadoc)
|
939
|
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IoStateBase)
|
940
|
*/
|
941
|
@Override
|
942
|
protected boolean isIgnore(CentralAfricaFernsImportState state){
|
943
|
return ! state.getConfig().isDoTaxa();
|
944
|
}
|
945
|
|
946
|
|
947
|
|
948
|
}
|