Revision 7a76c575
Added by Andreas Müller about 1 year ago
app-import/src/main/java/eu/etaxonomy/cdm/io/caryo/KewExcelTaxonImport.java | ||
---|---|---|
135 | 135 |
Reference sec = getSecReference(state, record); |
136 | 136 |
|
137 | 137 |
//name |
138 |
TaxonName existingName = getExistingName(state, line); |
|
139 |
if (existingName != null){ |
|
140 |
verifyName(state, existingName, record, line, false); |
|
138 |
boolean isNewName = true; |
|
139 |
TaxonName name = getExistingName(state, line); |
|
140 |
if (name != null){ |
|
141 |
verifyName(state, name, record, line, false); |
|
142 |
isNewName = false; |
|
141 | 143 |
}else{ |
142 |
existingName = createName(state, line);
|
|
144 |
name = createName(state, line);
|
|
143 | 145 |
} |
144 | 146 |
|
145 | 147 |
//taxon |
146 |
TaxonBase<?> taxonBase = makeTaxonBase(state, line, record, existingName, sec);
|
|
148 |
TaxonBase<?> taxonBase = makeTaxonBase(state, line, record, name, sec, isNewName);
|
|
147 | 149 |
|
148 | 150 |
if (taxonBase != null){ |
149 | 151 |
getTaxonService().saveOrUpdate(taxonBase); |
... | ... | |
341 | 343 |
|
342 | 344 |
private String verifyField(String expectedValue, Map<String, String> record, String fieldName, String line, |
343 | 345 |
String noLogIf, String noLogIf2, boolean isNew) { |
346 |
|
|
344 | 347 |
String value = getValue(record, fieldName); |
345 | 348 |
if (!CdmUtils.nullSafeEqual(expectedValue, value)){ |
346 | 349 |
String diff = singleDiff(expectedValue, value); |
347 |
String label = isNew ? "New " : "Existing"; |
|
350 |
String label1 = isNew ? "Parsed " : "Existing"; |
|
351 |
String label2 = isNew ? "Atomized" : "Kew "; |
|
348 | 352 |
if (!diff.equals(noLogIf) && !diff.equals(noLogIf2) || diff.equals(NO_SIMPLE_DIFF)){ |
349 |
System.out.println(" " + line + fieldName + "\n "+label+": " + expectedValue + "\n Kew : " + value);
|
|
353 |
System.out.println(" " + line + fieldName + "\n "+label1+": " + expectedValue + "\n "+label2+": " + value);
|
|
350 | 354 |
} |
351 | 355 |
return diff; |
352 | 356 |
}else{ |
... | ... | |
384 | 388 |
putName(kewNameId, existingName.getUuid(), line); |
385 | 389 |
return CdmBase.deproxy(existingName); |
386 | 390 |
}else{ |
391 |
logger.warn(line + "Name with CDM-Name_UUID="+cdmNameUuid+" could not be found in database"); |
|
387 | 392 |
return null; |
388 | 393 |
} |
389 | 394 |
} |
... | ... | |
395 | 400 |
} |
396 | 401 |
} |
397 | 402 |
|
398 |
|
|
399 | 403 |
private void makeNameStatus(String line, Map<String, String> record, |
400 | 404 |
TaxonName taxonName) { |
401 | 405 |
String nameStatus = getValue(record, Kew_Nomencl_Status); |
... | ... | |
421 | 425 |
|
422 | 426 |
|
423 | 427 |
private TaxonBase<?> makeTaxonBase(SimpleExcelTaxonImportState<CONFIG> state, String line, |
424 |
Map<String, String> record, TaxonName taxonName, Reference sec) { |
|
428 |
Map<String, String> record, TaxonName taxonName, Reference sec, boolean isNewName) {
|
|
425 | 429 |
|
426 | 430 |
TaxonBase<?> taxonBase; |
427 | 431 |
boolean isUnplaced = false; |
428 | 432 |
String taxStatusStr = getValue(record, Kew_Taxonomic_Status); |
429 | 433 |
|
434 |
|
|
435 |
TaxonBase<?> existingTaxon = null; |
|
436 |
if (!isNewName && !taxonName.getTaxa().isEmpty()) { |
|
437 |
if (taxonName.getTaxa().size() > 1) { |
|
438 |
System.out.println(" " + line + "Existing name is used in more than 1 taxon/synonym: " + taxonName.getTitleCache()); |
|
439 |
} |
|
440 |
existingTaxon = CdmBase.deproxy(taxonName.getTaxa().iterator().next()); |
|
441 |
} |
|
442 |
|
|
430 | 443 |
if ("Accepted".equals(taxStatusStr)){ |
431 | 444 |
taxonBase = Taxon.NewInstance(taxonName, sec); |
432 | 445 |
}else if ("Synonym".equals(taxStatusStr)){ |
... | ... | |
439 | 452 |
logger.warn(line + "Status not handled: " + taxStatusStr); |
440 | 453 |
return null; |
441 | 454 |
} |
455 |
if (existingTaxon != null && existingTaxon.getClass().equals(taxonBase.getClass())) { |
|
456 |
taxonBase = existingTaxon; |
|
457 |
} |
|
458 |
|
|
459 |
|
|
442 | 460 |
taxonBase.addSource(makeOriginalSource(state)); |
443 | 461 |
taxonMap.put(getValue(record, Kew_Name_ID), taxonBase.getUuid()); |
444 | 462 |
if (taxonBase instanceof Taxon){ |
... | ... | |
516 | 534 |
UUID orphanedTaxonUuid = state.getConfig().getOrphanedPlaceholderTaxonUuid(); |
517 | 535 |
orphanedSynonymTaxon = CdmBase.deproxy(getTaxonService().find(orphanedTaxonUuid), Taxon.class); |
518 | 536 |
if (orphanedSynonymTaxon == null){ |
519 |
TaxonName placeholderName = TaxonNameFactory.NewBacterialInstance(Rank.SUBFAMILY());
|
|
537 |
TaxonName placeholderName = TaxonNameFactory.NewBotanicalInstance(Rank.SUBFAMILY());
|
|
520 | 538 |
placeholderName.setTitleCache("Orphaned_Synonyms_KEW", true); |
521 | 539 |
orphanedSynonymTaxon = Taxon.NewInstance(placeholderName, getSecReference(state, state.getOriginalRecord())); |
522 | 540 |
orphanedSynonymTaxon.setUuid(orphanedTaxonUuid); |
Also available in: Unified diff
fix #10224 final to KewImport for Nyctaginaceae import