Revision c0c4c356
Added by Patrick Plitzner almost 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java | ||
---|---|---|
37 | 37 |
import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
38 | 38 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
39 | 39 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
40 |
import eu.etaxonomy.cdm.model.name.CultivarPlantName; |
|
40 | 41 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus; |
41 | 42 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
42 | 43 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
... | ... | |
338 | 339 |
RedListUtil.logMessage(id, "No name found!", logger); |
339 | 340 |
} |
340 | 341 |
|
342 |
NonViralName<?> name = null; |
|
341 | 343 |
Rank rank = makeRank(id, state, rangString, ep3String!=null); |
342 |
NonViralName<?> name = BotanicalName.NewInstance(rank); |
|
344 |
//cultivar |
|
345 |
if(rank!= null && rank.equals(Rank.CULTIVAR())){ |
|
346 |
CultivarPlantName cultivar = CultivarPlantName.NewInstance(rank); |
|
347 |
cultivar.setGenusOrUninomial(ep1String); |
|
348 |
cultivar.setSpecificEpithet(ep2String); |
|
349 |
cultivar.setCultivarName(ep3String); |
|
350 |
name = cultivar; |
|
351 |
} |
|
352 |
//botanical names |
|
353 |
else{ |
|
354 |
name = BotanicalName.NewInstance(rank); |
|
343 | 355 |
|
344 |
//ep1 should always be present |
|
345 |
if(CdmUtils.isBlank(ep1String)){ |
|
346 |
RedListUtil.logMessage(id, RedListUtil.EPI1+" is empty!", logger); |
|
347 |
} |
|
348 |
name.setGenusOrUninomial(ep1String); |
|
349 |
if(CdmUtils.isNotBlank(ep2String)){ |
|
350 |
if(rank!=null && rank.isInfraGenericButNotSpeciesGroup()){ |
|
351 |
name.setInfraGenericEpithet(ep2String); |
|
352 |
} |
|
353 |
else{ |
|
354 |
name.setSpecificEpithet(ep2String); |
|
356 |
//ep1 should always be present |
|
357 |
if(CdmUtils.isBlank(ep1String)){ |
|
358 |
RedListUtil.logMessage(id, RedListUtil.EPI1+" is empty!", logger); |
|
355 | 359 |
} |
356 |
} |
|
357 |
if(CdmUtils.isNotBlank(ep3String)){ |
|
358 |
name.setInfraSpecificEpithet(ep3String); |
|
359 |
} |
|
360 |
//nomenclatural status |
|
361 |
if(CdmUtils.isNotBlank(nomZusatzString)){ |
|
362 |
NomenclaturalStatusType statusType = makeNomenclaturalStatus(id, state, nomZusatzString); |
|
363 |
if(statusType!=null){ |
|
364 |
NomenclaturalStatus status = NomenclaturalStatus.NewInstance(statusType); |
|
365 |
//special case for invalid names where the DB entry contains |
|
366 |
//additional information in brackets e.g. "nom. inval. (sine basion.)" |
|
367 |
if(statusType.equals(NomenclaturalStatusType.INVALID())){ |
|
368 |
Pattern pattern = Pattern.compile("\\((.*?)\\)"); |
|
369 |
Matcher matcher = pattern.matcher(nomZusatzString); |
|
370 |
if (matcher.find()){ |
|
371 |
status.setRuleConsidered(matcher.group(1)); |
|
372 |
} |
|
360 |
name.setGenusOrUninomial(ep1String); |
|
361 |
if(CdmUtils.isNotBlank(ep2String)){ |
|
362 |
if(rank!=null && rank.isInfraGenericButNotSpeciesGroup()){ |
|
363 |
name.setInfraGenericEpithet(ep2String); |
|
364 |
} |
|
365 |
else{ |
|
366 |
name.setSpecificEpithet(ep2String); |
|
373 | 367 |
} |
374 |
name.addStatus(status); |
|
375 | 368 |
} |
376 | 369 |
} |
377 | 370 |
//hybrid |
... | ... | |
385 | 378 |
|
386 | 379 |
if(hybString.equals(RedListUtil.HYB_X)){ |
387 | 380 |
name.setBinomHybrid(true); |
388 |
} |
|
389 |
else if(hybString.equals(RedListUtil.HYB_G)){ |
|
390 |
name.setMonomHybrid(true); |
|
391 |
} |
|
392 |
else if(hybString.equals(RedListUtil.HYB_XF)){ |
|
393 |
name.setHybridFormula(true); |
|
394 |
if(ep1String.contains(RedListUtil.HYB_SIGN)){ |
|
395 |
RedListUtil.logMessage(id, "EPI1 has hybrid signs but with flag: "+RedListUtil.HYB_XF, logger); |
|
381 |
if(CdmUtils.isNotBlank(ep3String)){ |
|
382 |
name.setInfraSpecificEpithet(ep3String); |
|
396 | 383 |
} |
397 |
else if(ep2String.contains(RedListUtil.HYB_SIGN)){ |
|
398 |
String[] split = ep2String.split(RedListUtil.HYB_SIGN); |
|
399 |
if(split.length!=2){ |
|
400 |
RedListUtil.logMessage(id, "Multiple hybrid signs found in "+ep2String, logger); |
|
401 |
} |
|
402 |
String hybridFormula1 = ep1String+" "+split[0].trim(); |
|
403 |
String hybridFormula2 = ep1String+" "+split[1].trim(); |
|
404 |
if(CdmUtils.isNotBlank(ep3String)){ |
|
405 |
hybridFormula1 += " "+ep3String; |
|
406 |
hybridFormula2 += " "+ep3String; |
|
384 |
//nomenclatural status |
|
385 |
if(CdmUtils.isNotBlank(nomZusatzString)){ |
|
386 |
NomenclaturalStatusType statusType = makeNomenclaturalStatus(id, state, nomZusatzString); |
|
387 |
if(statusType!=null){ |
|
388 |
NomenclaturalStatus status = NomenclaturalStatus.NewInstance(statusType); |
|
389 |
//special case for invalid names where the DB entry contains |
|
390 |
//additional information in brackets e.g. "nom. inval. (sine basion.)" |
|
391 |
if(statusType.equals(NomenclaturalStatusType.INVALID())){ |
|
392 |
Pattern pattern = Pattern.compile("\\((.*?)\\)"); |
|
393 |
Matcher matcher = pattern.matcher(nomZusatzString); |
|
394 |
if (matcher.find()){ |
|
395 |
status.setRuleConsidered(matcher.group(1)); |
|
396 |
} |
|
397 |
} |
|
398 |
name.addStatus(status); |
|
407 | 399 |
} |
408 |
String fullFormula = hybridFormula1+" "+RedListUtil.HYB_SIGN+" "+hybridFormula2; |
|
409 |
name = NonViralNameParserImpl.NewInstance().parseFullName(fullFormula); |
|
410 | 400 |
} |
411 |
else if(ep3String.contains(RedListUtil.HYB_SIGN)){ |
|
412 |
String[] split = ep3String.split(RedListUtil.HYB_SIGN); |
|
413 |
if(split.length!=2){ |
|
414 |
RedListUtil.logMessage(id, "Multiple hybrid signs found in "+ep3String, logger); |
|
401 |
//hybrid |
|
402 |
if(CdmUtils.isNotBlank(hybString)){ |
|
403 |
if(hybString.equals(RedListUtil.HYB_X)){ |
|
404 |
name.setBinomHybrid(true); |
|
405 |
} |
|
406 |
else if(hybString.equals(RedListUtil.HYB_G)){ |
|
407 |
name.setMonomHybrid(true); |
|
408 |
} |
|
409 |
else if(hybString.equals(RedListUtil.HYB_XF)){ |
|
410 |
name.setHybridFormula(true); |
|
411 |
if(ep1String.contains(RedListUtil.HYB_SIGN)){ |
|
412 |
RedListUtil.logMessage(id, "EPI1 has hybrid signs but with flag: "+RedListUtil.HYB_XF, logger); |
|
413 |
} |
|
414 |
else if(ep2String.contains(RedListUtil.HYB_SIGN)){ |
|
415 |
String[] split = ep2String.split(RedListUtil.HYB_SIGN); |
|
416 |
if(split.length!=2){ |
|
417 |
RedListUtil.logMessage(id, "Multiple hybrid signs found in "+ep2String, logger); |
|
418 |
} |
|
419 |
String hybridFormula1 = ep1String+" "+split[0].trim(); |
|
420 |
String hybridFormula2 = ep1String+" "+split[1].trim(); |
|
421 |
if(CdmUtils.isNotBlank(ep3String)){ |
|
422 |
hybridFormula1 += " "+ep3String; |
|
423 |
hybridFormula2 += " "+ep3String; |
|
424 |
} |
|
425 |
String fullFormula = hybridFormula1+" "+RedListUtil.HYB_SIGN+" "+hybridFormula2; |
|
426 |
name = NonViralNameParserImpl.NewInstance().parseFullName(fullFormula); |
|
427 |
} |
|
428 |
else if(ep3String.contains(RedListUtil.HYB_SIGN)){ |
|
429 |
String[] split = ep3String.split(RedListUtil.HYB_SIGN); |
|
430 |
if(split.length!=2){ |
|
431 |
RedListUtil.logMessage(id, "Multiple hybrid signs found in "+ep3String, logger); |
|
432 |
} |
|
433 |
String hybridFormula1 = ep1String+" "+ep2String+" "+split[0]; |
|
434 |
String hybridFormula2 = ep1String+" "+ep2String+" "+split[1]; |
|
435 |
String fullFormula = hybridFormula1+" "+RedListUtil.HYB_SIGN+" "+hybridFormula2; |
|
436 |
name = NonViralNameParserImpl.NewInstance().parseFullName(fullFormula); |
|
437 |
} |
|
438 |
} |
|
439 |
else if(hybString.equals(RedListUtil.HYB_N)){ |
|
440 |
name = NonViralNameParserImpl.NewInstance().parseFullName(ep1String+" "+ep2String+" nothosubsp. "+ep3String); |
|
441 |
} |
|
442 |
else if(hybString.equals(RedListUtil.HYB_GF)){ |
|
443 |
if(ep1String.contains(RedListUtil.HYB_SIGN)){ |
|
444 |
name = NonViralNameParserImpl.NewInstance().parseFullName(ep1String); |
|
445 |
} |
|
446 |
else{ |
|
447 |
RedListUtil.logMessage(id, "HYB is "+hybString+" but "+RedListUtil.HYB+" does not contain "+RedListUtil.HYB_SIGN, logger); |
|
448 |
} |
|
449 |
} |
|
450 |
else if(hybString.equals(RedListUtil.HYB_XS)){ |
|
451 |
//nothing to do |
|
452 |
} |
|
453 |
else{ |
|
454 |
logger.error("HYB value "+hybString+" not yet handled"); |
|
415 | 455 |
} |
416 |
String hybridFormula1 = ep1String+" "+ep2String+" "+split[0]; |
|
417 |
String hybridFormula2 = ep1String+" "+ep2String+" "+split[1]; |
|
418 |
String fullFormula = hybridFormula1+" "+RedListUtil.HYB_SIGN+" "+hybridFormula2; |
|
419 |
name = NonViralNameParserImpl.NewInstance().parseFullName(fullFormula); |
|
420 |
} |
|
421 |
} |
|
422 |
else if(hybString.equals(RedListUtil.HYB_N)){ |
|
423 |
name = NonViralNameParserImpl.NewInstance().parseFullName(ep1String+" "+ep2String+" nothosubsp. "+ep3String); |
|
424 |
} |
|
425 |
else if(hybString.equals(RedListUtil.HYB_GF)){ |
|
426 |
if(ep1String.contains(RedListUtil.HYB_SIGN)){ |
|
427 |
name = NonViralNameParserImpl.NewInstance().parseFullName(ep1String); |
|
428 | 456 |
} |
429 | 457 |
else{ |
430 |
RedListUtil.logMessage(id, "HYB is "+hybString+" but "+RedListUtil.HYB+" does not contain "+RedListUtil.HYB_SIGN, logger);
|
|
458 |
logger.error("HYB value "+hybString+" not yet handled");
|
|
431 | 459 |
} |
432 | 460 |
} |
433 |
else if(hybString.equals(RedListUtil.HYB_XS)){ |
|
434 |
//nothing to do |
|
435 |
} |
|
436 |
else{ |
|
437 |
logger.error("HYB value "+hybString+" not yet handled"); |
|
438 |
} |
|
439 | 461 |
} |
440 | 462 |
//add source |
441 | 463 |
ImportHelper.setOriginalSource(name, state.getTransactionalSourceReference(), id, RedListUtil.NAME_NAMESPACE); |
Also available in: Unified diff
#5448 Import cultivar as CultivarPlantName