Project

General

Profile

« Previous | Next » 

Revision 800f157b

Added by Patrick Plitzner over 8 years ago

speed up classification import

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportAuthor.java
74 74

  
75 75
    private void makeAuthors(RedListGefaesspflanzenImportState state, String columnName) {
76 76

  
77
        //--- combination authors ---
78 77
        String query = "select distinct "+columnName+" from V_TAXATLAS_D20_EXPORT t"
79 78
                + " WHERE TRIM(t."+columnName+") <>''";
80 79

  
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java
12 12
import java.sql.ResultSet;
13 13
import java.sql.SQLException;
14 14
import java.util.HashMap;
15
import java.util.HashSet;
15 16
import java.util.Map;
17
import java.util.Set;
16 18

  
17 19
import org.apache.log4j.Logger;
18 20
import org.springframework.stereotype.Component;
......
23 25
import eu.etaxonomy.cdm.model.common.CdmBase;
24 26
import eu.etaxonomy.cdm.model.taxon.Classification;
25 27
import eu.etaxonomy.cdm.model.taxon.Synonym;
28
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
26 29
import eu.etaxonomy.cdm.model.taxon.Taxon;
27 30
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
28 31

  
......
89 92

  
90 93
    private void makeSingleTaxonNode(RedListGefaesspflanzenImportState state, ResultSet rs, Classification classification)
91 94
            throws SQLException {
92
        long id = rs.getLong("NAMNR");
93
        long parentId = rs.getLong("LOWER");
95
        String id = String.valueOf(rs.getLong("NAMNR"));
96
        String parentId = String.valueOf(rs.getLong("LOWER"));
94 97
        String gueltString = rs.getString("GUELT");
95 98

  
96
        TaxonBase taxonBase = getTaxonService().load(state.getTaxonMap().get(id));
97
        Taxon parent = (Taxon) getTaxonService().load(state.getTaxonMap().get(parentId));
99
        TaxonBase taxonBase = state.getRelatedObject(Namespace.TAXON_NAMESPACE, id, TaxonBase.class);
100
        Taxon parent = (Taxon) state.getRelatedObject(Namespace.TAXON_NAMESPACE, parentId, TaxonBase.class);
98 101

  
99 102
        if(taxonBase.isInstanceOf(Taxon.class)){
100 103
            classification.addParentChild(parent, (Taxon)taxonBase, null, null);
101 104
        }
102 105
        else if(taxonBase.isInstanceOf(Synonym.class)){
103 106
            if(gueltString.equals("b")){
104
                //TODO
107
                parent.addHomotypicSynonym((Synonym) taxonBase, null, null);
108
                parent.getName().addBasionym(taxonBase.getName());
105 109
            }
106 110
            else{
107 111
                //TODO: how to correctly add a synonym?
108
                parent.addHomotypicSynonym((Synonym) taxonBase, null, null);
112
                parent.addSynonym((Synonym) taxonBase, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), null, null);
113
//                parent.addSynonym((Synonym) taxonBase, SynonymRelationshipType.SYNONYM_OF(), null, null);
109 114
            }
110 115
        }
111 116
    }
......
114 119
    public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs,
115 120
            RedListGefaesspflanzenImportState state) {
116 121
        Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>();
122

  
123
        Set<String> idSet = new HashSet<String>();
124
        try {
125
            while (rs.next()){
126
                idSet.add(String.valueOf(rs.getLong("NAMNR")));
127
                idSet.add(String.valueOf(rs.getLong("LOWER")));
128
            }
129
        } catch (SQLException e) {
130
            e.printStackTrace();
131
        }
132
        Map<String, TaxonBase> taxonMap = (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, Namespace.TAXON_NAMESPACE);
133
        result.put(Namespace.TAXON_NAMESPACE, taxonMap);
117 134
        return result;
118 135
    }
119 136

  

Also available in: Unified diff