Project

General

Profile

Download (2.46 KB) Statistics
| Branch: | Revision:
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.bogota;
10

    
11
import java.util.List;
12
import java.util.Map;
13
import java.util.Set;
14

    
15
import org.apache.log4j.Logger;
16

    
17
import eu.etaxonomy.cdm.io.excel.common.ExcelImportBase;
18
import eu.etaxonomy.cdm.io.excel.common.ExcelImportConfiguratorBase;
19
import eu.etaxonomy.cdm.io.excel.common.ExcelRowBase;
20
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
21
import eu.etaxonomy.cdm.strategy.parser.INonViralNameParser;
22
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
23

    
24
/**
25
 * Simple Excel import class that works without default state class
26
 * {@link SimpleExcelSpecimenImportState}
27
 * @author a.mueller
28
 * @since 16.06.2016
29
 */
30
public abstract class SimpleExcelSpecimenImport<CONFIG extends ExcelImportConfiguratorBase>
31
        extends ExcelImportBase<SimpleExcelSpecimenImportState<CONFIG>, CONFIG, ExcelRowBase>{
32

    
33
    private static final long serialVersionUID = -4345647703312616421L;
34

    
35
    private static final Logger logger = Logger.getLogger(SimpleExcelSpecimenImport.class);
36

    
37
    protected static INonViralNameParser<?> nameParser = NonViralNameParserImpl.NewInstance();
38

    
39

    
40
    @Override
41
    protected void analyzeRecord(Map<String, String> record, SimpleExcelSpecimenImportState<CONFIG> state) {
42
        //override only if needed
43
    }
44

    
45
    @Override
46
    protected void secondPass(SimpleExcelSpecimenImportState<CONFIG> state) {
47
        //override only if needed
48
    }
49

    
50
    @Override
51
    protected boolean isIgnore(SimpleExcelSpecimenImportState<CONFIG> state) {
52
        return false;
53
    }
54

    
55
//***************************** METHODS *********************************/
56

    
57

    
58
    /**
59
     * @param state
60
     * @return
61
     */
62
    protected IdentifiableSource makeOriginalSource(SimpleExcelSpecimenImportState<CONFIG> state) {
63
        return IdentifiableSource.NewDataImportInstance("line: " + state.getCurrentLine(), null, state.getConfig().getSourceReference());
64
    }
65

    
66

    
67
    /**
68
     * @param line
69
     * @param keys
70
     * @param expectedKeys
71
     */
72
    protected void checkAllKeysExist(String line, Set<String> keys, List<String> expectedKeys) {
73
        for (String key: keys) {
74
            if (! expectedKeys.contains(key)){
75
                logger.warn(line + "Unexpected Key: " + key);
76
            }
77
        }
78
    }
79

    
80

    
81
}
(5-5/6)