Project

General

Profile

« Previous | Next » 

Revision 7319c528

Added by Patrick Plitzner about 8 years ago

Refactor name-author mapping

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java
20 20
import org.springframework.stereotype.Component;
21 21

  
22 22
import eu.etaxonomy.cdm.common.CdmUtils;
23
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
23 24
import eu.etaxonomy.cdm.io.common.DbImportBase;
24 25
import eu.etaxonomy.cdm.io.common.IPartitionedIO;
25 26
import eu.etaxonomy.cdm.io.common.ImportHelper;
26 27
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
27 28
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
28
import eu.etaxonomy.cdm.model.agent.AgentBase;
29
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
29 30
import eu.etaxonomy.cdm.model.common.CdmBase;
30 31
import eu.etaxonomy.cdm.model.name.BotanicalName;
31 32
import eu.etaxonomy.cdm.model.name.Rank;
......
47 48

  
48 49
    private static final String pluralString = "names";
49 50

  
50
    private static final String TAXON_NAMESPACE = "name";
51
    private static final String AUTHOR_KOMB_NAMESPACE = "author_komb";
52
    private static final String AUTHOR_BASI_NAMESPACE = "author_basi";
51
    private static final String NAME_NAMESPACE = "name";
53 52

  
54 53
    public RedListGefaesspflanzenImportNames() {
55 54
        super(tableName, pluralString);
......
80 79
    @Override
81 80
    public boolean doPartition(ResultSetPartitioner partitioner, RedListGefaesspflanzenImportState state) {
82 81
        ResultSet rs = partitioner.getResultSet();
83
        Set<TaxonNameBase> taxaToSave = new HashSet<TaxonNameBase>();
82
        Set<TaxonNameBase> namesToSave = new HashSet<TaxonNameBase>();
84 83
        try {
85 84
            while (rs.next()){
86
                makeSingleName(state, rs, taxaToSave);
85
                makeSingleName(state, rs, namesToSave);
87 86

  
88 87
            }
89 88
        } catch (SQLException e) {
90 89
            e.printStackTrace();
91 90
        }
92 91

  
93
        getNameService().saveOrUpdate(taxaToSave);
92
        getNameService().saveOrUpdate(namesToSave);
94 93
        return true;
95 94
    }
96 95

  
......
104 103
        String ep3String = rs.getString("EPI3");
105 104
        String nomZusatzString = rs.getString("NOM_ZUSATZ");
106 105
        String zusatzString = rs.getString("ZUSATZ");
106
        String authorKombString = rs.getString("AUTOR_KOMB");
107
        String authorBasiString = rs.getString("AUTOR_BASI");
107 108

  
108 109
        if(CdmUtils.isBlank(taxNameString) && CdmUtils.isBlank(ep1String)){
109 110
            logger.error("NAMNR: "+id+" No name found!");
......
120 121
        }
121 122

  
122 123
        //add author
123
        AgentBase authorKomb = getAgentService().load(state.getAuthorKombMap().get(id));
124
//        name.setCombinationAuthorship(authorKomb);
124
        TeamOrPersonBase authorKomb = HibernateProxyHelper.deproxy(getAgentService().load(state.getAuthorMap().get(authorKombString)), TeamOrPersonBase.class);
125
        name.setCombinationAuthorship(authorKomb);
125 126

  
126 127
        //id
127
        ImportHelper.setOriginalSource(name, state.getTransactionalSourceReference(), id, TAXON_NAMESPACE);
128
        ImportHelper.setOriginalSource(name, state.getTransactionalSourceReference(), id, NAME_NAMESPACE);
129

  
130
        namesToSave.add(name);
128 131
    }
129 132

  
130 133
    private Rank makeRank(RedListGefaesspflanzenImportState state, String rankStr) {

Also available in: Unified diff