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.greece;
|
10
|
|
11
|
import java.util.HashMap;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
|
15
|
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport;
|
16
|
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
|
17
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
18
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
19
|
import eu.etaxonomy.cdm.model.name.Rank;
|
20
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
21
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
22
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
23
|
|
24
|
/**
|
25
|
* @author a.mueller
|
26
|
* @date 14.12.2016
|
27
|
*/
|
28
|
|
29
|
public abstract class FloraHellenicaImportBase<CONFIG extends FloraHellenicaImportConfigurator>
|
30
|
extends SimpleExcelTaxonImport<CONFIG>{
|
31
|
|
32
|
private static final long serialVersionUID = 2593130403213346396L;
|
33
|
private static final Logger logger = Logger.getLogger(FloraHellenicaImportBase.class);
|
34
|
|
35
|
|
36
|
/**
|
37
|
* @param taxon
|
38
|
* @return
|
39
|
*/
|
40
|
protected TaxonDescription getTaxonDescription(Taxon taxon) {
|
41
|
if (!taxon.getDescriptions().isEmpty()){
|
42
|
return taxon.getDescriptions().iterator().next();
|
43
|
}else{
|
44
|
TaxonDescription desc = TaxonDescription.NewInstance(taxon);
|
45
|
desc.setDefault(true);
|
46
|
return desc;
|
47
|
}
|
48
|
}
|
49
|
|
50
|
|
51
|
/**
|
52
|
* @param state
|
53
|
* @return
|
54
|
*/
|
55
|
protected Reference getSourceCitation(SimpleExcelTaxonImportState<CONFIG> state) {
|
56
|
return state.getConfig().getSourceReference();
|
57
|
}
|
58
|
|
59
|
|
60
|
protected Reference getSecReference(SimpleExcelTaxonImportState<CONFIG> state) {
|
61
|
// TODO Auto-generated method stub
|
62
|
return null;
|
63
|
}
|
64
|
|
65
|
|
66
|
/**
|
67
|
* @param record
|
68
|
* @param state
|
69
|
* @return
|
70
|
*/
|
71
|
protected Taxon getAcceptedTaxon(HashMap<String, String> record,
|
72
|
SimpleExcelTaxonImportState<CONFIG> state, String key) {
|
73
|
String accStr = getValue(record, key);
|
74
|
if (accStr == null){
|
75
|
return null;
|
76
|
}
|
77
|
accStr = accStr.trim();
|
78
|
|
79
|
Taxon accTaxon = state.getTaxon(accStr);
|
80
|
if (accTaxon == null){
|
81
|
String message = state.getCurrentLine()+ ": Accepted taxon could not be found: " + accStr;
|
82
|
logger.warn(message);
|
83
|
return null;
|
84
|
}else{
|
85
|
accTaxon = (Taxon)getTaxonService().find(accTaxon.getUuid());
|
86
|
}
|
87
|
return accTaxon;
|
88
|
}
|
89
|
|
90
|
|
91
|
|
92
|
protected BotanicalName makeFamilyName(SimpleExcelTaxonImportState<CONFIG> state, String famStr) {
|
93
|
BotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.FAMILY());
|
94
|
name.setGenusOrUninomial(famStr);
|
95
|
name.addSource(makeOriginalSource(state));
|
96
|
return name;
|
97
|
}
|
98
|
|
99
|
}
|