1
|
/**
|
2
|
* Copyright (C) 2023 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.caryo;
|
10
|
|
11
|
import java.util.HashMap;
|
12
|
import java.util.HashSet;
|
13
|
import java.util.Map;
|
14
|
import java.util.Set;
|
15
|
|
16
|
import eu.etaxonomy.cdm.common.DoubleResult;
|
17
|
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport;
|
18
|
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
|
19
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
20
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
21
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
22
|
|
23
|
/**
|
24
|
* @author a.mueller
|
25
|
* @date 02.02.2023
|
26
|
*/
|
27
|
public abstract class CaryoSileneaeImportBase extends SimpleExcelTaxonImport<CaryoSileneaeImportConfigurator> {
|
28
|
|
29
|
private static final long serialVersionUID = -299606747509423614L;
|
30
|
|
31
|
private Reference secRef = null;
|
32
|
|
33
|
protected static Map<Integer,TaxonName> nameMap = new HashMap<>();
|
34
|
|
35
|
private static Map<Integer,Taxon> taxonMap = new HashMap<>();
|
36
|
|
37
|
protected static Map<Integer,TaxonName> origNameMap = new HashMap<>();
|
38
|
protected static Map<Integer,TaxonName> orphanedNameMap = new HashMap<>();
|
39
|
protected static Set<TaxonName> origSpellingNames = new HashSet<>();
|
40
|
|
41
|
protected static Map<Integer, Integer> accIdMap = new HashMap<>();
|
42
|
|
43
|
protected static Map<Integer,DoubleResult<String,String>> origPublicationMap = new HashMap<>();
|
44
|
|
45
|
|
46
|
|
47
|
protected Taxon getTaxon(Integer taxonLinkId) {
|
48
|
return taxonMap.get(taxonLinkId);
|
49
|
}
|
50
|
|
51
|
protected TaxonName getName(Integer nameLinkId) {
|
52
|
return nameMap.get(nameLinkId);
|
53
|
}
|
54
|
|
55
|
protected void putToNameMap(Integer id, TaxonName name) {
|
56
|
nameMap.put(id, name);
|
57
|
origNameMap.put(id, name);
|
58
|
orphanedNameMap.put(id, name);
|
59
|
}
|
60
|
protected void putToTaxonMap(Integer id, Taxon taxon) {
|
61
|
taxonMap.put(id, taxon);
|
62
|
}
|
63
|
|
64
|
protected Reference getSecRef(SimpleExcelTaxonImportState<CaryoSileneaeImportConfigurator> state) {
|
65
|
if (secRef == null){
|
66
|
secRef = getReferenceService().find(state.getConfig().getSecUuid());
|
67
|
}
|
68
|
return secRef;
|
69
|
}
|
70
|
|
71
|
protected void newTransaction(SimpleExcelTaxonImportState<CaryoSileneaeImportConfigurator> state) {
|
72
|
commitTransaction(state.getTransactionStatus());
|
73
|
secRef = null;
|
74
|
state.getDeduplicationHelper().reset();
|
75
|
state.setSourceReference(null);
|
76
|
System.gc();
|
77
|
state.setTransactionStatus(startTransaction());
|
78
|
}
|
79
|
|
80
|
protected Integer getInt(String value) {
|
81
|
return isBlank(value) ? null : Integer.valueOf(value);
|
82
|
}
|
83
|
}
|