Revision 6b3b78d4
Added by Andreas Müller almost 4 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/uzbekistan/UzbekistanTaxonImport.java | ||
---|---|---|
105 | 105 |
} |
106 | 106 |
|
107 | 107 |
private void makeTaxon(SimpleExcelTaxonImportState<CONFIG> state, String line, Map<String, String> record) { |
108 |
state.getTransactionStatus().flush(); |
|
108 | 109 |
|
109 | 110 |
Reference sec = getSecReference(state); |
111 |
state.getTransactionStatus().flush(); |
|
110 | 112 |
|
111 | 113 |
String fullTitle = getValue(record, FULL_TITLE); |
112 | 114 |
String fullName = getValue(record, FULL_NAME); |
... | ... | |
117 | 119 |
|
118 | 120 |
//TODO validation, deduplication, source, ... |
119 | 121 |
|
120 |
//taxon |
|
121 |
TaxonBase<?> taxonBase = makeTaxonBase(state, line, record, taxonName, sec); |
|
122 |
|
|
123 | 122 |
//name status |
124 | 123 |
makeNameStatus(line, record, taxonName); |
125 | 124 |
|
126 |
//common name |
|
127 |
makeCommonName(line, record, taxonBase); |
|
128 |
|
|
129 | 125 |
taxonName = TaxonName.castAndDeproxy(taxonName); |
130 | 126 |
//TODO |
131 | 127 |
checkParsed(TaxonName.castAndDeproxy(taxonName), fullTitle, fullName, line); |
... | ... | |
133 | 129 |
replaceNameAuthorsAndReferences(state, taxonName); |
134 | 130 |
taxonName.addSource(makeOriginalSource(state)); |
135 | 131 |
|
132 |
//taxon |
|
133 |
TaxonBase<?> taxonBase = makeTaxonBase(state, line, record, taxonName, sec); |
|
134 |
//common name |
|
135 |
makeCommonName(line, record, taxonBase); |
|
136 |
|
|
136 | 137 |
getNameService().saveOrUpdate(taxonName); |
137 | 138 |
if (taxonBase != null){ |
138 | 139 |
getTaxonService().saveOrUpdate(taxonBase); |
139 | 140 |
} |
141 |
state.getTransactionStatus().flush(); |
|
140 | 142 |
|
141 | 143 |
return; |
142 | 144 |
} |
... | ... | |
302 | 304 |
UUID acceptedUuid = getUuid(record, ACCEPTED_TAXON_UUID, false, line); |
303 | 305 |
if (acceptedUuid != null){ |
304 | 306 |
TaxonBase<?> acceptedBase = getTaxonService().find(acceptedUuid); |
305 |
if(!acceptedBase.isInstanceOf(Taxon.class)){ |
|
307 |
if(acceptedBase == null){ |
|
308 |
logger.warn(line + "Taxon for existing uuid could not be found. This should not happen"); |
|
309 |
return; |
|
310 |
}else if(!acceptedBase.isInstanceOf(Taxon.class)){ |
|
306 | 311 |
logger.warn(line + "Accepted taxon is not accepted: " + acceptedUuid); |
307 | 312 |
}else if (taxonBase == null || (!taxonBase.isInstanceOf(Synonym.class))){ |
308 | 313 |
logger.warn(line + "Synonym has accepted uuid but has not status accepted"); |
... | ... | |
410 | 415 |
|
411 | 416 |
private TaxonNode getClassification(SimpleExcelTaxonImportState<CONFIG> state) { |
412 | 417 |
if (rootNode == null){ |
418 |
logger.warn("Load root node"); |
|
419 |
rootNode = getTaxonNodeService().find(UUID.fromString("3ee689d2-17c2-4f02-9905-7092a45aa1b9")); |
|
420 |
} |
|
421 |
if (rootNode == null){ |
|
422 |
logger.warn("Create root node"); |
|
413 | 423 |
Reference sec = getSecReference(state); |
414 | 424 |
String classificationName = state.getConfig().getClassificationName(); |
415 | 425 |
Language language = Language.DEFAULT(); |
... | ... | |
425 | 435 |
|
426 | 436 |
private Reference getSecReference(SimpleExcelTaxonImportState<CONFIG> state) { |
427 | 437 |
if (this.secReference == null){ |
438 |
logger.warn("Load sec ref"); |
|
428 | 439 |
this.secReference = getPersistentReference(state.getConfig().getSecReference()); |
440 |
if (this.secReference == null){ |
|
441 |
logger.warn("Sec ref is null"); |
|
442 |
} |
|
429 | 443 |
} |
430 | 444 |
return this.secReference; |
431 | 445 |
} |
432 | 446 |
|
433 |
protected Reference getSourceCitation(SimpleExcelTaxonImportState<CONFIG> state) {
|
|
447 |
private Reference getSourceCitation(SimpleExcelTaxonImportState<CONFIG> state) {
|
|
434 | 448 |
if (this.sourceReference == null){ |
435 | 449 |
this.sourceReference = getPersistentReference(state.getConfig().getSourceReference()); |
450 |
this.sourceReference.setInReference(getSecReference(state)); //special for Uzbekistan |
|
436 | 451 |
} |
437 | 452 |
return this.sourceReference; |
438 | 453 |
} |
439 | 454 |
|
440 | 455 |
private Reference getPersistentReference(Reference reference) { |
441 | 456 |
Reference result = getReferenceService().find(reference.getUuid()); |
457 |
logger.warn("Loaded persistent reference: "+ reference.getUuid()); |
|
442 | 458 |
if (result == null){ |
459 |
logger.warn("Persistent reference is null: " + reference.getUuid()); |
|
443 | 460 |
result = reference; |
461 |
getReferenceService().saveOrUpdate(result); |
|
444 | 462 |
} |
445 | 463 |
return result; |
446 | 464 |
} |
... | ... | |
450 | 468 |
} |
451 | 469 |
|
452 | 470 |
private ImportDeduplicationHelper<SimpleExcelTaxonImportState<CONFIG>> dedupHelper; |
453 |
private ImportDeduplicationHelper<SimpleExcelTaxonImportState<CONFIG>> dedupHelper() { |
|
471 |
@SuppressWarnings({ "rawtypes", "unchecked" }) |
|
472 |
private ImportDeduplicationHelper<SimpleExcelTaxonImportState<CONFIG>> dedupHelper() { |
|
454 | 473 |
if (dedupHelper == null) { |
455 | 474 |
dedupHelper = (ImportDeduplicationHelper)ImportDeduplicationHelper.NewInstance(this); |
456 | 475 |
} |
... | ... | |
460 | 479 |
@Override |
461 | 480 |
protected IdentifiableSource makeOriginalSource(SimpleExcelTaxonImportState<CONFIG> state) { |
462 | 481 |
String noStr = getValue(state.getOriginalRecord(), "taxonUuid"); |
463 |
return IdentifiableSource.NewDataImportInstance(noStr, "taxonUuid", state.getConfig().getSourceReference());
|
|
482 |
return IdentifiableSource.NewDataImportInstance(noStr, "taxonUuid", getSourceCitation(state));
|
|
464 | 483 |
} |
465 | 484 |
|
466 | 485 |
} |
Also available in: Unified diff
fix #8996 latest changes to FoU import