1
|
/**
|
2
|
* Copyright (C) 2017 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.List;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.springframework.stereotype.Component;
|
15
|
|
16
|
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport;
|
17
|
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
|
18
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
19
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
20
|
import eu.etaxonomy.cdm.strategy.exceptions.StringNotParsableException;
|
21
|
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
|
22
|
|
23
|
/**
|
24
|
* @author a.mueller
|
25
|
* @since 08.12.2017
|
26
|
*/
|
27
|
@Component
|
28
|
public class GreeceGenusAuthorImport
|
29
|
extends SimpleExcelTaxonImport<GreeceGenusAuthorImportConfigurator>{
|
30
|
|
31
|
private static final long serialVersionUID = 1173327042682886814L;
|
32
|
private static final Logger logger = Logger.getLogger(GreeceGenusAuthorImport.class);
|
33
|
|
34
|
private NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
|
35
|
|
36
|
@Override
|
37
|
protected void firstPass(SimpleExcelTaxonImportState<GreeceGenusAuthorImportConfigurator> state) {
|
38
|
String genus = state.getOriginalRecord().get("Genus");
|
39
|
String author = state.getOriginalRecord().get("Author");
|
40
|
List<TaxonName> existingNames = getNameService().findNamesByNameCache(genus, MatchMode.EXACT, null);
|
41
|
if (existingNames.size() != 1){
|
42
|
logger.warn("Name '"+genus+"' has not exactly one record, but " + existingNames.size());
|
43
|
}else{
|
44
|
TaxonName name = existingNames.iterator().next();
|
45
|
// TaxonName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS()) ;
|
46
|
// name.setGenusOrUninomial("Genus");
|
47
|
try {
|
48
|
parser.parseAuthors(name, author);
|
49
|
state.getDeduplicationHelper().replaceAuthorNamesAndNomRef(name);
|
50
|
name.addImportSource(null, null, state.getConfig().getSourceReference(), String.valueOf(state.getCurrentLine()));
|
51
|
} catch (StringNotParsableException e) {
|
52
|
e.printStackTrace();
|
53
|
}
|
54
|
}
|
55
|
}
|
56
|
}
|