Project

General

Profile

« Previous | Next » 

Revision c385a1b7

Added by Andreas Müller almost 6 years ago

latest changes to BgbmInstancesUpdater, E+M Import, GermanSL Import, etct

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/germanSL/GermanSLTaxonRelationImport.java
15 15
import org.apache.log4j.Logger;
16 16
import org.springframework.stereotype.Component;
17 17

  
18
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport;
19 18
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState;
20
import eu.etaxonomy.cdm.model.common.CdmBase;
21 19
import eu.etaxonomy.cdm.model.reference.Reference;
22 20
import eu.etaxonomy.cdm.model.taxon.Classification;
23 21
import eu.etaxonomy.cdm.model.taxon.Synonym;
......
31 29
 *
32 30
 */
33 31
@Component
34
public class GermanSLTaxonRelationImport<CONFIG extends GermanSLImportConfigurator>
35
            extends SimpleExcelTaxonImport<CONFIG> {
32
public class GermanSLTaxonRelationImport extends GermanSLImporBase {
36 33

  
37 34
    private static final long serialVersionUID = 3381597141845204995L;
38 35

  
......
50 47
    private int count = 0;
51 48

  
52 49
    @Override
53
    protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) {
50
    protected void firstPass(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
54 51
        count++;
55 52
        Map<String, String> record = state.getOriginalRecord();
56 53
        String line = state.getCurrentLine() + ": ";
......
59 56
        String acceptedStr = getValue(record, GermanSLTaxonImport.VALID_NR);
60 57
        String idStr = getValue(record, GermanSLTaxonImport.SPECIES_NR);
61 58
        String statusStr = getValue(record, GermanSLTaxonImport.SYNONYM);
59
        NameResult nameResult = GermanSLTaxonImport.makeName (line, record, state);
62 60

  
63 61
        Classification classification = getClassification(state);
64 62
        TaxonBase<?> taxonBase = GermanSLTaxonImport.taxonIdMap.get(idStr);
65 63
        Taxon parent;
66
        if (isAccepted(statusStr)){
64
        if (isAccepted(statusStr, nameResult)){
67 65
            TaxonBase<?> parentTmp = GermanSLTaxonImport.taxonIdMap.get(parentStr);
68 66
            if (parentTmp == null){
69 67
                logger.warn(line + "Parent is missing: "+ parentStr);
......
100 98
    }
101 99

  
102 100

  
103
    private boolean isAccepted(String statusStr){
104
        if ("FALSE()".equals(statusStr) || "0".equals(statusStr) || "false".equalsIgnoreCase(statusStr)){
105
            return true;
106
        } else if ("TRUE()".equals(statusStr) || "1".equals(statusStr)|| "true".equalsIgnoreCase(statusStr)){
107
            return false;
108
        }else{
109
            logger.warn("Unhandled taxon status: " + statusStr);
110
            return false;
111
        }
112
    }
113

  
114

  
115
    /**
116
     * @param next
117
     * @return
118
     */
119
    private Taxon getAccepted(TaxonBase<?> taxonBase) {
120
        if (taxonBase.isInstanceOf(Taxon.class)){
121
            return CdmBase.deproxy(taxonBase, Taxon.class);
122
        }else{
123
            Synonym syn = CdmBase.deproxy(taxonBase, Synonym.class);
124
            return syn.getAcceptedTaxon();
125
        }
126
    }
127

  
128

  
129 101
    boolean needsFinalSave = true;
130 102
    /**
131 103
     * {@inheritDoc}
132 104
     */
133 105
    @Override
134
    protected void secondPass(SimpleExcelTaxonImportState<CONFIG> state) {
106
    protected void secondPass(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
135 107
        if (needsFinalSave){
136 108
            getTaxonService().saveOrUpdate(taxaToSave);
137 109
            needsFinalSave = false;
......
142 114
    /**
143 115
     * @return
144 116
     */
145
    private Classification getClassification(SimpleExcelTaxonImportState<CONFIG> state) {
117
    private Classification getClassification(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
146 118
        if (classification == null){
147 119
            GermanSLImportConfigurator config = state.getConfig();
148 120
            classification = Classification.NewInstance(config.getClassificationName());
......
154 126
    }
155 127

  
156 128
    @Override
157
    protected boolean isIgnore(SimpleExcelTaxonImportState<CONFIG> state) {
129
    protected boolean isIgnore(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
158 130
        return ! state.getConfig().isDoTaxa();
159 131
    }
160 132
}

Also available in: Unified diff