1
|
/**
|
2
|
* Copyright (C) 2016 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
|
package eu.etaxonomy.cdm.io.uzbekistan;
|
10
|
|
11
|
import java.util.Arrays;
|
12
|
import java.util.List;
|
13
|
import java.util.Map;
|
14
|
import java.util.Set;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import org.apache.log4j.Logger;
|
18
|
import org.springframework.stereotype.Component;
|
19
|
|
20
|
import eu.etaxonomy.cdm.io.common.utils.ImportDeduplicationHelper;
|
21
|
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport;
|
22
|
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
|
23
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
24
|
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
|
25
|
import eu.etaxonomy.cdm.model.common.Language;
|
26
|
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
|
27
|
import eu.etaxonomy.cdm.model.name.INonViralName;
|
28
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
|
29
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
30
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
|
31
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
32
|
import eu.etaxonomy.cdm.model.name.Rank;
|
33
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
34
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
35
|
import eu.etaxonomy.cdm.model.reference.ReferenceType;
|
36
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
37
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
38
|
import eu.etaxonomy.cdm.model.taxon.SynonymType;
|
39
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
40
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
41
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
42
|
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
|
43
|
|
44
|
/**
|
45
|
* Uzbekistan taxon import.
|
46
|
*
|
47
|
* @author a.mueller
|
48
|
* @since 05.05.2020
|
49
|
*/
|
50
|
@Component
|
51
|
public class UzbekistanTaxonImport<CONFIG extends UzbekistanTaxonImportConfigurator>
|
52
|
extends SimpleExcelTaxonImport<CONFIG>{
|
53
|
|
54
|
private static final long serialVersionUID = 7793140600785382094L;
|
55
|
private static final Logger logger = Logger.getLogger(UzbekistanTaxonImport.class);
|
56
|
|
57
|
private static final String COMMON_NAME = "common name";
|
58
|
private static final String PARENT_TAXON_UUID = "parentTaxonUuid";
|
59
|
private static final String ACCEPTED_TAXON_UUID = "acceptedTaxonUuid";
|
60
|
private static final String NAME_TYPE_UUID = "nameTypeUuid";
|
61
|
private static final String REPLACED_SYNONYM_UUID = "replacedSynonymUuid";
|
62
|
private static final String BASIONYM_UUID = "basionymUuid";
|
63
|
private static final String TAXON_UUID = "taxonUuid";
|
64
|
private static final String NAME_STATUS = "nameStatus";
|
65
|
private static final String STATUS = "status";
|
66
|
private static final String RANK = "rank";
|
67
|
private static final String FULL_NAME = "fullName";
|
68
|
private static final String FULL_TITLE = "fullTitle";
|
69
|
private static final String REFERENCE_TYPE = "referenceType";
|
70
|
|
71
|
private static UUID rootUuid = UUID.fromString("3ee689d2-17c2-4f02-9905-7092a45aa1b9");
|
72
|
|
73
|
private static List<String> expectedKeys= Arrays.asList(new String[]{
|
74
|
TAXON_UUID,FULL_TITLE,FULL_NAME,"pureName",
|
75
|
RANK,STATUS,REFERENCE_TYPE,PARENT_TAXON_UUID,"parenTaxonName",
|
76
|
ACCEPTED_TAXON_UUID,"acceptedTaxonName","homotypicGroupUuid",BASIONYM_UUID,
|
77
|
REPLACED_SYNONYM_UUID,NAME_STATUS,NAME_TYPE_UUID,COMMON_NAME
|
78
|
});
|
79
|
|
80
|
private Reference sourceReference;
|
81
|
private Reference secReference;
|
82
|
|
83
|
private NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
|
84
|
|
85
|
// @Override
|
86
|
// protected String getWorksheetName(CONFIG config) {
|
87
|
// return "valid taxa names";
|
88
|
// }
|
89
|
|
90
|
@Override
|
91
|
protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) {
|
92
|
|
93
|
String line = getLine(state, 50);
|
94
|
System.out.println(line);
|
95
|
Map<String, String> record = state.getOriginalRecord();
|
96
|
|
97
|
Set<String> keys = record.keySet();
|
98
|
for (String key: keys) {
|
99
|
if (! expectedKeys.contains(key)){
|
100
|
logger.warn(line + "Unexpected Key: " + key);
|
101
|
}
|
102
|
}
|
103
|
|
104
|
makeTaxon(state, line, record);
|
105
|
}
|
106
|
|
107
|
private void makeTaxon(SimpleExcelTaxonImportState<CONFIG> state, String line, Map<String, String> record) {
|
108
|
state.getTransactionStatus().flush();
|
109
|
|
110
|
Reference sec = getSecReference(state);
|
111
|
state.getTransactionStatus().flush();
|
112
|
|
113
|
String fullTitle = getValue(record, FULL_TITLE);
|
114
|
String fullName = getValue(record, FULL_NAME);
|
115
|
Rank rank = makeRank(line, record);
|
116
|
|
117
|
//name
|
118
|
TaxonName taxonName = parser.parseReferencedName(fullTitle, NomenclaturalCode.ICNAFP, rank);
|
119
|
|
120
|
//TODO validation, deduplication, source, ...
|
121
|
|
122
|
//name status
|
123
|
makeNameStatus(line, record, taxonName);
|
124
|
|
125
|
taxonName = TaxonName.castAndDeproxy(taxonName);
|
126
|
//TODO
|
127
|
checkParsed(TaxonName.castAndDeproxy(taxonName), fullTitle, fullName, line);
|
128
|
checkReference(record, line, taxonName, fullTitle);
|
129
|
replaceNameAuthorsAndReferences(state, taxonName);
|
130
|
taxonName.addSource(makeOriginalSource(state));
|
131
|
|
132
|
//taxon
|
133
|
TaxonBase<?> taxonBase = makeTaxonBase(state, line, record, taxonName, sec);
|
134
|
//common name
|
135
|
makeCommonName(line, record, taxonBase);
|
136
|
|
137
|
getNameService().saveOrUpdate(taxonName);
|
138
|
if (taxonBase != null){
|
139
|
getTaxonService().saveOrUpdate(taxonBase);
|
140
|
}
|
141
|
state.getTransactionStatus().flush();
|
142
|
|
143
|
return;
|
144
|
}
|
145
|
|
146
|
private void checkReference(Map<String, String> record, String line,
|
147
|
TaxonName taxonName, String fullTitle) {
|
148
|
String refTypeStr = getValue(record, REFERENCE_TYPE);
|
149
|
String statusStr = getValue(record, STATUS);
|
150
|
Reference ref = taxonName.getNomenclaturalReference();
|
151
|
if(ref == null){
|
152
|
if (isNotBlank(refTypeStr)){
|
153
|
logger.warn(line + "RefType given but no nom. ref. parsed: " + fullTitle);
|
154
|
}
|
155
|
if(isNotBlank(statusStr)){
|
156
|
logger.warn(line+"Taxon status exist but name has no nom. ref.: " + fullTitle);
|
157
|
}
|
158
|
}else{
|
159
|
if ("A".equals(refTypeStr)){
|
160
|
if (!ref.getType().equals(ReferenceType.Article)){
|
161
|
logger.warn(line+"RefType should be article but was not: " + ref.getType().getMessage() + ";" + fullTitle);
|
162
|
}
|
163
|
}else if ("B".equals(refTypeStr)){
|
164
|
if (!ref.getType().equals(ReferenceType.Book)){
|
165
|
logger.warn(line+"RefType should be book but was not: " + ref.getType().getMessage() + ";" + fullTitle);
|
166
|
}
|
167
|
}else if ("BS".equals(refTypeStr)){
|
168
|
if (!ref.getType().equals(ReferenceType.BookSection)){
|
169
|
logger.warn(line+"RefType should be book section but was not: " + ref.getType().getMessage() + ";" + fullTitle) ;
|
170
|
}
|
171
|
}else{
|
172
|
logger.warn(line+"Name has nom. ref. but ref type could not be recognized/was empty: " + refTypeStr + ";" + fullTitle);
|
173
|
}
|
174
|
}
|
175
|
}
|
176
|
|
177
|
private void makeCommonName(String line,
|
178
|
Map<String, String> record,
|
179
|
TaxonBase<?> taxonBase) {
|
180
|
String commonNameStr = getValue(record, COMMON_NAME);
|
181
|
if(isBlank(commonNameStr)){
|
182
|
return;
|
183
|
}else if(taxonBase == null){
|
184
|
logger.warn(line + "No taxon exists for common name: " + commonNameStr);
|
185
|
}else if(! (taxonBase instanceof Taxon)){
|
186
|
logger.warn(line + "Taxon is not accepted for common name: " + commonNameStr);
|
187
|
}else{
|
188
|
Taxon taxon = (Taxon)taxonBase;
|
189
|
CommonTaxonName commonName = CommonTaxonName.NewInstance(commonNameStr, Language.RUSSIAN());
|
190
|
getTaxonDescription(taxon, false, true).addElement(commonName);
|
191
|
}
|
192
|
}
|
193
|
|
194
|
private void makeNameStatus(String line, Map<String, String> record,
|
195
|
TaxonName taxonName) {
|
196
|
String nameStatus = getValue(record, NAME_STATUS);
|
197
|
NomenclaturalStatusType status;
|
198
|
if (isBlank(nameStatus)){
|
199
|
status = null;
|
200
|
}else if ("nom. cons.".equals(nameStatus)){
|
201
|
status = NomenclaturalStatusType.CONSERVED();
|
202
|
}else if ("nom. inval.".equals(nameStatus)){
|
203
|
status = NomenclaturalStatusType.INVALID();
|
204
|
}else if ("nom. illeg.".equals(nameStatus)){
|
205
|
status = NomenclaturalStatusType.ILLEGITIMATE();
|
206
|
}else if ("nom. rej.".equals(nameStatus)){
|
207
|
status = NomenclaturalStatusType.REJECTED();
|
208
|
}else{
|
209
|
logger.warn(line + "Nom. status not recognized: " + nameStatus);
|
210
|
status = null;
|
211
|
}
|
212
|
if (status != null){
|
213
|
taxonName.addStatus(NomenclaturalStatus.NewInstance(status));
|
214
|
}
|
215
|
}
|
216
|
|
217
|
|
218
|
private TaxonBase<?> makeTaxonBase(SimpleExcelTaxonImportState<CONFIG> state, String line,
|
219
|
Map<String, String> record, TaxonName taxonName, Reference sec) {
|
220
|
TaxonBase<?> taxonBase;
|
221
|
String statusStr = getValue(record, STATUS);
|
222
|
String taxonUuidStr = getValue(record, TAXON_UUID);
|
223
|
UUID taxonUuid = UUID.fromString(taxonUuidStr);
|
224
|
if ("A".equals(statusStr)){
|
225
|
taxonBase = Taxon.NewInstance(taxonName, sec);
|
226
|
}else if ("S".equals(statusStr)){
|
227
|
taxonBase = Synonym.NewInstance(taxonName, sec);
|
228
|
}else if (statusStr == null){
|
229
|
taxonName.setUuid(taxonUuid);
|
230
|
return null;
|
231
|
}else{
|
232
|
logger.warn(line + "Status not handled: " + statusStr);
|
233
|
return null;
|
234
|
}
|
235
|
taxonBase.setUuid(taxonUuid);
|
236
|
taxonBase.addSource(makeOriginalSource(state));
|
237
|
return taxonBase;
|
238
|
}
|
239
|
|
240
|
private Rank makeRank(String line, Map<String, String> record) {
|
241
|
String rankStr = getValue(record, RANK);
|
242
|
if (rankStr.equals("family")){
|
243
|
return Rank.FAMILY();
|
244
|
}else if(rankStr.equals("genus")){
|
245
|
return Rank.GENUS();
|
246
|
}else if(rankStr.equals("species")){
|
247
|
return Rank.SPECIES();
|
248
|
}else if(rankStr.equals("section")){
|
249
|
return Rank.SECTION_BOTANY();
|
250
|
}else if(rankStr.equals("subsection")){
|
251
|
return Rank.SUBSECTION_BOTANY();
|
252
|
}else if(rankStr.equals("series")){
|
253
|
return Rank.SERIES();
|
254
|
}else if(rankStr.equals("subgenus")){
|
255
|
return Rank.SUBGENUS();
|
256
|
}else if(rankStr.equals("subspecies")){
|
257
|
return Rank.SUBSPECIES();
|
258
|
}else if(rankStr.equals("variety")){
|
259
|
return Rank.VARIETY();
|
260
|
}else if(rankStr.equals("unranked infrageneric")){
|
261
|
return Rank.UNRANKED_INFRAGENERIC();
|
262
|
}else{
|
263
|
logger.warn(line + "Unknown rank: " + rankStr);
|
264
|
}
|
265
|
return null;
|
266
|
}
|
267
|
|
268
|
@Override
|
269
|
protected void secondPass(SimpleExcelTaxonImportState<CONFIG> state) {
|
270
|
String line = state.getCurrentLine() + ": ";
|
271
|
System.out.println(line);
|
272
|
Map<String, String> record = state.getOriginalRecord();
|
273
|
|
274
|
String statusStr = getValue(record, STATUS);
|
275
|
String rankStr = getValue(record, RANK);
|
276
|
|
277
|
UUID taxonUuid = getUuid(record, TAXON_UUID, true, line);
|
278
|
TaxonBase<?> taxonBase = getTaxonService().find(taxonUuid);
|
279
|
TaxonName taxonName;
|
280
|
if (taxonBase == null){
|
281
|
taxonName = getNameService().find(taxonUuid);
|
282
|
}else{
|
283
|
taxonName = taxonBase.getName();
|
284
|
}
|
285
|
|
286
|
UUID parentUuid = getUuid(record, PARENT_TAXON_UUID, false, line);
|
287
|
if (parentUuid != null){
|
288
|
TaxonBase<?> parentBase = getTaxonService().find(parentUuid);
|
289
|
if(!parentBase.isInstanceOf(Taxon.class)){
|
290
|
logger.warn(line + "Parent taxon is not accepted: " + parentUuid);
|
291
|
}else if (taxonBase == null || (!taxonBase.isInstanceOf(Taxon.class))){
|
292
|
logger.warn(line + "Taxon has parent uuid but has not status accepted");
|
293
|
}else{
|
294
|
Taxon child = CdmBase.deproxy(taxonBase, Taxon.class);
|
295
|
Taxon parentTaxon = CdmBase.deproxy(parentBase, Taxon.class);
|
296
|
Classification classification = getClassification(state).getClassification();
|
297
|
TaxonNode node = classification.addParentChild(parentTaxon, child, null, null);
|
298
|
getTaxonNodeService().saveOrUpdate(node);
|
299
|
}
|
300
|
}else if("A".equals(statusStr) && !"family".equals(rankStr)){
|
301
|
logger.warn(line + "No parent given for accepted non-family taxon");
|
302
|
}
|
303
|
|
304
|
UUID acceptedUuid = getUuid(record, ACCEPTED_TAXON_UUID, false, line);
|
305
|
if (acceptedUuid != null){
|
306
|
TaxonBase<?> acceptedBase = getTaxonService().find(acceptedUuid);
|
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)){
|
311
|
logger.warn(line + "Accepted taxon is not accepted: " + acceptedUuid);
|
312
|
}else if (taxonBase == null || (!taxonBase.isInstanceOf(Synonym.class))){
|
313
|
logger.warn(line + "Synonym has accepted uuid but has not status accepted");
|
314
|
}else{
|
315
|
Synonym syn = CdmBase.deproxy(taxonBase, Synonym.class);
|
316
|
Taxon acc = CdmBase.deproxy(acceptedBase, Taxon.class);
|
317
|
//TODO synType
|
318
|
acc.addSynonym(syn, SynonymType.HETEROTYPIC_SYNONYM_OF());
|
319
|
}
|
320
|
}else if("S".equals(statusStr)){
|
321
|
logger.warn(line + "No accepted taxon given for synonym");
|
322
|
}
|
323
|
|
324
|
UUID basionymUuid = getUuid(record, BASIONYM_UUID, false, line);
|
325
|
if (basionymUuid != null){
|
326
|
TaxonBase<?> basionymTaxon = getTaxonService().find(basionymUuid);
|
327
|
if(basionymTaxon == null){
|
328
|
logger.warn(line + "Basionym does not exist as taxon but only as name: " + basionymUuid);
|
329
|
}else{
|
330
|
TaxonName basionymName = basionymTaxon.getName();
|
331
|
taxonName.addBasionym(basionymName);
|
332
|
taxonName.mergeHomotypicGroups(basionymName); //just in case this is not automatically done
|
333
|
adjustSynonymType(taxonBase, basionymTaxon, line);
|
334
|
}
|
335
|
}
|
336
|
|
337
|
UUID replacedSynonymUuid = getUuid(record, REPLACED_SYNONYM_UUID, false, line);
|
338
|
if (replacedSynonymUuid != null){
|
339
|
TaxonBase<?> replacedTaxon = getTaxonService().find(replacedSynonymUuid);
|
340
|
if(replacedTaxon == null){
|
341
|
logger.warn(line + "Replaced synonym does not exist as taxon but only as name: " + replacedSynonymUuid);
|
342
|
}else{
|
343
|
TaxonName replacedName = replacedTaxon.getName();
|
344
|
taxonName.addBasionym(replacedName);
|
345
|
taxonName.mergeHomotypicGroups(replacedName); //just in case this is not automatically done
|
346
|
adjustSynonymType(taxonBase, replacedTaxon, line);
|
347
|
}
|
348
|
}
|
349
|
|
350
|
UUID nameTypeUuid = getUuid(record, NAME_TYPE_UUID, false, line);
|
351
|
if (nameTypeUuid != null){
|
352
|
TaxonBase<?> typeTaxon = getTaxonService().find(nameTypeUuid);
|
353
|
TaxonName typeName;
|
354
|
if (typeTaxon == null){
|
355
|
typeName = getNameService().find(nameTypeUuid);
|
356
|
}else{
|
357
|
typeName = typeTaxon.getName();
|
358
|
}
|
359
|
//TODO
|
360
|
NameTypeDesignationStatus status = null; //NameTypeDesignationStatus.
|
361
|
taxonName.addNameTypeDesignation(typeName, null, null, null, status, false);
|
362
|
}
|
363
|
}
|
364
|
|
365
|
private void adjustSynonymType(TaxonBase<?> taxonBase, TaxonBase<?> homotypicTaxon, String line) {
|
366
|
adjustSynonymTypeOrdered(taxonBase, homotypicTaxon, line);
|
367
|
adjustSynonymTypeOrdered(homotypicTaxon, taxonBase, line);
|
368
|
}
|
369
|
|
370
|
private void adjustSynonymTypeOrdered(TaxonBase<?> firstTaxon, TaxonBase<?> secondTaxon, String line) {
|
371
|
if (firstTaxon == null){
|
372
|
logger.warn(line + "first taxon is null for adjust synonym type");
|
373
|
}else if (secondTaxon == null){
|
374
|
logger.warn(line + "second taxon is null for adjust synonym type");
|
375
|
}else if (secondTaxon.isInstanceOf(Synonym.class)){
|
376
|
Synonym syn = CdmBase.deproxy(secondTaxon, Synonym.class);
|
377
|
if (firstTaxon.equals(syn.getAcceptedTaxon())){
|
378
|
syn.setType(SynonymType.HOMOTYPIC_SYNONYM_OF());
|
379
|
}
|
380
|
}
|
381
|
}
|
382
|
|
383
|
protected UUID getUuid(Map<String, String> record, String columnName, boolean required, String line) {
|
384
|
String uuidStr = getValue(record, columnName);
|
385
|
if (isNotBlank(uuidStr)){
|
386
|
UUID uuid;
|
387
|
try {
|
388
|
uuid = UUID.fromString(uuidStr);
|
389
|
return uuid;
|
390
|
} catch (Exception e) {
|
391
|
logger.warn(line + "UUID could not be parsed: " + uuidStr);
|
392
|
return null;
|
393
|
}
|
394
|
}else{
|
395
|
if (required){
|
396
|
logger.warn(line + "UUID required but does not exist");
|
397
|
}
|
398
|
return null;
|
399
|
}
|
400
|
}
|
401
|
|
402
|
private void checkParsed(TaxonName name, String fullName, String nameStr, String line) {
|
403
|
if (name.isProtectedTitleCache() || name.isProtectedFullTitleCache() || name.isProtectedNameCache()) {
|
404
|
logger.warn(line + "Name could not be parsed: " + fullName);
|
405
|
}
|
406
|
if (name.getNomenclaturalReference() != null && name.getNomenclaturalReference().isProtectedTitleCache()){
|
407
|
logger.warn(line + "Nom ref could not be parsed: " + fullName);
|
408
|
}
|
409
|
if (!name.getTitleCache().equals(nameStr)){
|
410
|
logger.warn(line + "Name part not parsed correctly: " + name.getTitleCache() + "<-> expected: " + nameStr);
|
411
|
}
|
412
|
}
|
413
|
|
414
|
private TaxonNode rootNode;
|
415
|
|
416
|
private TaxonNode getClassification(SimpleExcelTaxonImportState<CONFIG> state) {
|
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");
|
423
|
Reference sec = getSecReference(state);
|
424
|
String classificationName = state.getConfig().getClassificationName();
|
425
|
Language language = Language.DEFAULT();
|
426
|
Classification classification = Classification.NewInstance(classificationName, sec, language);
|
427
|
classification.setUuid(state.getConfig().getClassificationUuid());
|
428
|
classification.getRootNode().setUuid(rootUuid);
|
429
|
getClassificationService().save(classification);
|
430
|
|
431
|
rootNode = classification.getRootNode();
|
432
|
}
|
433
|
return rootNode;
|
434
|
}
|
435
|
|
436
|
private Reference getSecReference(SimpleExcelTaxonImportState<CONFIG> state) {
|
437
|
if (this.secReference == null){
|
438
|
logger.warn("Load sec ref");
|
439
|
this.secReference = getPersistentReference(state.getConfig().getSecReference());
|
440
|
if (this.secReference == null){
|
441
|
logger.warn("Sec ref is null");
|
442
|
}
|
443
|
}
|
444
|
return this.secReference;
|
445
|
}
|
446
|
|
447
|
private Reference getSourceCitation(SimpleExcelTaxonImportState<CONFIG> state) {
|
448
|
if (this.sourceReference == null){
|
449
|
this.sourceReference = getPersistentReference(state.getConfig().getSourceReference());
|
450
|
this.sourceReference.setInReference(getSecReference(state)); //special for Uzbekistan
|
451
|
}
|
452
|
return this.sourceReference;
|
453
|
}
|
454
|
|
455
|
private Reference getPersistentReference(Reference reference) {
|
456
|
Reference result = getReferenceService().find(reference.getUuid());
|
457
|
logger.warn("Loaded persistent reference: "+ reference.getUuid());
|
458
|
if (result == null){
|
459
|
logger.warn("Persistent reference is null: " + reference.getUuid());
|
460
|
result = reference;
|
461
|
getReferenceService().saveOrUpdate(result);
|
462
|
}
|
463
|
return result;
|
464
|
}
|
465
|
|
466
|
private void replaceNameAuthorsAndReferences(SimpleExcelTaxonImportState<CONFIG> state, INonViralName name) {
|
467
|
dedupHelper().replaceAuthorNamesAndNomRef(state, name);
|
468
|
}
|
469
|
|
470
|
private ImportDeduplicationHelper<SimpleExcelTaxonImportState<CONFIG>> dedupHelper;
|
471
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
472
|
private ImportDeduplicationHelper<SimpleExcelTaxonImportState<CONFIG>> dedupHelper() {
|
473
|
if (dedupHelper == null) {
|
474
|
dedupHelper = (ImportDeduplicationHelper)ImportDeduplicationHelper.NewInstance(this);
|
475
|
}
|
476
|
return dedupHelper;
|
477
|
}
|
478
|
|
479
|
@Override
|
480
|
protected IdentifiableSource makeOriginalSource(SimpleExcelTaxonImportState<CONFIG> state) {
|
481
|
String noStr = getValue(state.getOriginalRecord(), "taxonUuid");
|
482
|
return IdentifiableSource.NewDataImportInstance(noStr, "taxonUuid", getSourceCitation(state));
|
483
|
}
|
484
|
|
485
|
}
|