Project

General

Profile

Download (23.6 KB) Statistics
| Branch: | Revision:
1
/**
2
 * Copyright (C) 2007 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

    
10
package eu.etaxonomy.cdm.io.redlist.gefaesspflanzen;
11

    
12
import java.sql.ResultSet;
13
import java.sql.SQLException;
14
import java.util.HashMap;
15
import java.util.HashSet;
16
import java.util.Map;
17
import java.util.Set;
18

    
19
import org.apache.log4j.Logger;
20
import org.springframework.stereotype.Component;
21

    
22
import eu.etaxonomy.cdm.common.CdmUtils;
23
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
24
import eu.etaxonomy.cdm.io.common.DbImportBase;
25
import eu.etaxonomy.cdm.io.common.IPartitionedIO;
26
import eu.etaxonomy.cdm.io.common.ImportHelper;
27
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
28
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
29
import eu.etaxonomy.cdm.model.agent.AgentBase;
30
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
31
import eu.etaxonomy.cdm.model.common.CdmBase;
32
import eu.etaxonomy.cdm.model.name.BotanicalName;
33
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
34
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
35
import eu.etaxonomy.cdm.model.name.NonViralName;
36
import eu.etaxonomy.cdm.model.name.Rank;
37
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
38
import eu.etaxonomy.cdm.model.taxon.Synonym;
39
import eu.etaxonomy.cdm.model.taxon.Taxon;
40
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
41
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
42
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
43
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
44

    
45
/**
46
 *
47
 * @author pplitzner
48
 * @date Mar 1, 2016
49
 *
50
 */
51

    
52
@Component
53
@SuppressWarnings("serial")
54
public class RedListGefaesspflanzenImportNames extends DbImportBase<RedListGefaesspflanzenImportState, RedListGefaesspflanzenImportConfigurator> {
55

    
56
    private static final Logger logger = Logger.getLogger(RedListGefaesspflanzenImportNames.class);
57

    
58
    private static final String tableName = "Rote Liste Gefäßpflanzen";
59

    
60
    private static final String pluralString = "names";
61

    
62
    public RedListGefaesspflanzenImportNames() {
63
        super(tableName, pluralString);
64
    }
65

    
66
    @Override
67
    protected String getIdQuery(RedListGefaesspflanzenImportState state) {
68
        return "SELECT NAMNR "
69
                + "FROM V_TAXATLAS_D20_EXPORT t "
70
                + " ORDER BY NAMNR";
71
    }
72

    
73
    @Override
74
    protected String getRecordQuery(RedListGefaesspflanzenImportConfigurator config) {
75
        String result = " SELECT * "
76
                + " FROM V_TAXATLAS_D20_EXPORT t "
77
                + " WHERE t.NAMNR IN (@IDSET)";
78
        result = result.replace("@IDSET", IPartitionedIO.ID_LIST_TOKEN);
79
        return result;
80
    }
81

    
82
    @Override
83
    protected void doInvoke(RedListGefaesspflanzenImportState state) {
84
        super.doInvoke(state);
85
    }
86

    
87

    
88
    @Override
89
    public boolean doPartition(ResultSetPartitioner partitioner, RedListGefaesspflanzenImportState state) {
90
        ResultSet rs = partitioner.getResultSet();
91
        Set<TaxonNameBase> namesToSave = new HashSet<TaxonNameBase>();
92
        Set<TaxonBase> taxaToSave = new HashSet<TaxonBase>();
93
        try {
94
            while (rs.next()){
95
                makeSingleNameAndTaxon(state, rs, namesToSave, taxaToSave);
96

    
97
            }
98
        } catch (SQLException e) {
99
            e.printStackTrace();
100
        }
101

    
102
        getNameService().saveOrUpdate(namesToSave);
103
        getTaxonService().saveOrUpdate(taxaToSave);
104
        return true;
105
    }
106

    
107
    private void makeSingleNameAndTaxon(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonNameBase> namesToSave, Set<TaxonBase> taxaToSave)
108
            throws SQLException {
109
        //cell values
110
        long id = rs.getLong(RedListUtil.NAMNR);
111
        String taxNameString = rs.getString(RedListUtil.TAXNAME);
112
        String gueltString = rs.getString(RedListUtil.GUELT);
113
        String rangString = rs.getString(RedListUtil.RANG);
114
        String ep1String = rs.getString(RedListUtil.EPI1);
115
        String ep2String = rs.getString(RedListUtil.EPI2);
116
        String ep3String = rs.getString(RedListUtil.EPI3);
117
        String nomZusatzString = rs.getString(RedListUtil.NOM_ZUSATZ);
118
        String taxZusatzString = rs.getString(RedListUtil.TAX_ZUSATZ);
119
        String zusatzString = rs.getString(RedListUtil.ZUSATZ);
120
        String nonString = rs.getString(RedListUtil.NON);
121
        String sensuString = rs.getString(RedListUtil.SENSU);
122
        String authorKombString = rs.getString(RedListUtil.AUTOR_KOMB);
123
        String authorBasiString = rs.getString(RedListUtil.AUTOR_BASI);
124
        String hybString = rs.getString(RedListUtil.HYB);
125
        String clTaxonString = rs.getString(RedListUtil.CL_TAXON);
126
        String relationE = rs.getString(RedListUtil.E);
127
        String relationW = rs.getString(RedListUtil.W);
128
        String relationK = rs.getString(RedListUtil.K);
129
        String relationAW = rs.getString(RedListUtil.AW);
130
        String relationAO = rs.getString(RedListUtil.AO);
131
        String relationR = rs.getString(RedListUtil.R);
132
        String relationO = rs.getString(RedListUtil.O);
133
        String relationS = rs.getString(RedListUtil.S);
134

    
135
        //---NAME---
136
        NonViralName name = importName(state, id, taxNameString, rangString, ep1String, ep2String, ep3String,
137
                nomZusatzString, hybString, namesToSave);
138

    
139

    
140
        //--- AUTHORS ---
141
        importAuthors(state, rs, id, nomZusatzString, taxZusatzString, zusatzString, authorKombString,
142
                authorBasiString, name);
143

    
144
        //---TAXON---
145
        TaxonBase taxonBase = importTaxon(id, taxNameString, gueltString, authorBasiString, hybString, name);
146
        if(taxonBase==null){
147
            RedListUtil.logMessage(id, "Taxon for name "+name+" could not be created.", logger);
148
            return;
149
        }
150

    
151
        //---CONCEPT RELATIONSHIPS---
152
        /*check if taxon/synonym also exists in other classification
153
         * 1. create new taxon with the same name (in that classification)
154
         * 2. create concept relationship between both
155
         */
156
        //checklist
157
        if(CdmUtils.isNotBlank(clTaxonString) && !clTaxonString.trim().equals("-")){
158
            cloneTaxon(taxonBase, name, TaxonRelationshipType.CONGRUENT_TO(), taxaToSave, id, RedListUtil.TAXON_CHECKLISTE_NAMESPACE, false, true, state);
159
        }
160
        //E, W, K, AW, AO, R, O, S
161
        addConceptRelation(relationE, RedListUtil.CLASSIFICATION_NAMESPACE_E, taxonBase, name, taxaToSave, id, state);
162
        addConceptRelation(relationW, RedListUtil.CLASSIFICATION_NAMESPACE_W, taxonBase, name, taxaToSave, id, state);
163
        addConceptRelation(relationK, RedListUtil.CLASSIFICATION_NAMESPACE_K, taxonBase, name, taxaToSave, id, state);
164
        addConceptRelation(relationAW, RedListUtil.CLASSIFICATION_NAMESPACE_AW, taxonBase, name, taxaToSave, id, state);
165
        addConceptRelation(relationAO, RedListUtil.CLASSIFICATION_NAMESPACE_AO, taxonBase, name, taxaToSave, id, state);
166
        addConceptRelation(relationR, RedListUtil.CLASSIFICATION_NAMESPACE_R, taxonBase, name, taxaToSave, id, state);
167
        addConceptRelation(relationO, RedListUtil.CLASSIFICATION_NAMESPACE_O, taxonBase, name, taxaToSave, id, state);
168
        addConceptRelation(relationS, RedListUtil.CLASSIFICATION_NAMESPACE_S, taxonBase, name, taxaToSave, id, state);
169

    
170
        //NOTE: the source has to be added after cloning or otherwise the clone would also get the source
171
        ImportHelper.setOriginalSource(taxonBase, state.getTransactionalSourceReference(), id, RedListUtil.TAXON_GESAMTLISTE_NAMESPACE);
172
        taxaToSave.add(taxonBase);
173
    }
174

    
175
    private void addConceptRelation(String relationString, String classificationNamespace, TaxonBase taxonBase, TaxonNameBase name, Set<TaxonBase> taxaToSave, long id, RedListGefaesspflanzenImportState state){
176
        if(CdmUtils.isNotBlank(relationString) && !relationString.equals(".")){
177
            String substring = relationString.substring(relationString.length()-1, relationString.length());
178
            TaxonRelationshipType taxonRelationshipTypeByKey = new RedListGefaesspflanzenTransformer().getTaxonRelationshipTypeByKey(substring);
179
            if(taxonRelationshipTypeByKey==null){
180
                RedListUtil.logMessage(id, "Could not interpret relationship "+relationString+" for taxon "+taxonBase.generateTitle(), logger);
181
            }
182
            //there is no type "included in" so we have to reverse the direction
183
            if(substring.equals("<")){
184
                cloneTaxon(taxonBase, name, taxonRelationshipTypeByKey, taxaToSave, id, classificationNamespace, true, false, state);
185
            }
186
            else{
187
                cloneTaxon(taxonBase, name, taxonRelationshipTypeByKey, taxaToSave, id, classificationNamespace, false, false, state);
188
            }
189
        }
190
    }
191

    
192
    /**
193
     * <b>NOTE:</b> the {@link TaxonRelationshipType} passed as parameter is
194
     * directed <b>from the clone</b> to the taxon.<br>
195
     * This can be changed with parameter <i>reverseRelation</i>
196
     */
197
    private void cloneTaxon(TaxonBase taxonBase, TaxonNameBase name, TaxonRelationshipType relationFromCloneToTaxon, Set<TaxonBase> taxaToSave, long id, String sourceNameSpace, boolean reverseRelation, boolean doubtful, RedListGefaesspflanzenImportState state){
198
        TaxonBase clone = (TaxonBase) taxonBase.clone();
199
        clone.setName(name);
200
        if(taxonBase.isInstanceOf(Taxon.class)){
201
            TaxonRelationship taxonRelation;
202
            if(reverseRelation){
203
                taxonRelation = ((Taxon) taxonBase).addTaxonRelation((Taxon) clone, relationFromCloneToTaxon, null, null);
204
            }
205
            else {
206
                taxonRelation = ((Taxon) clone).addTaxonRelation((Taxon) taxonBase, relationFromCloneToTaxon, null, null);
207
            }
208
            taxonRelation.setDoubtful(doubtful);
209
        }
210
        ImportHelper.setOriginalSource(clone, state.getTransactionalSourceReference(), id, sourceNameSpace);
211
        taxaToSave.add(clone);
212
    }
213

    
214
    private TaxonBase importTaxon(long id, String taxNameString, String gueltString, String authorBasiString,
215
            String hybString, NonViralName name) {
216
        TaxonBase taxonBase = null;
217
        if(authorBasiString.trim().contains(RedListUtil.AUCT)){
218
            taxonBase = Taxon.NewInstance(name, null);
219
            taxonBase.setAppendedPhrase(RedListUtil.AUCT);
220
        }
221
        else if(gueltString.equals(RedListUtil.GUELT_ACCEPTED_TAXON)){
222
            taxonBase = Taxon.NewInstance(name, null);
223
        }
224
        else if(gueltString.equals(RedListUtil.GUELT_SYNONYM) || gueltString.equals(RedListUtil.GUELT_BASIONYM)){
225
            taxonBase = Synonym.NewInstance(name, null);
226
        }
227
        else{
228
            return null;
229
        }
230

    
231
        //check taxon name consistency
232
        checkTaxonNameConsistency(id, taxNameString, hybString, taxonBase);
233
        return taxonBase;
234
    }
235

    
236
    private void importAuthors(RedListGefaesspflanzenImportState state, ResultSet rs, long id, String nomZusatzString,
237
            String taxZusatzString, String zusatzString, String authorKombString, String authorBasiString,
238
            NonViralName name) throws SQLException {
239
        //combination author
240
        if(authorKombString.contains(RedListUtil.EX)){
241
            //TODO: what happens with multiple ex authors??
242
            String[] kombSplit = authorKombString.split(RedListUtil.EX);
243
            if(kombSplit.length!=2){
244
                RedListUtil.logMessage(id, "Multiple ex combination authors found", logger);
245
            }
246
            for (int i = 0; i < kombSplit.length; i++) {
247
                if(i==0){
248
                    //first author is ex author
249
                    TeamOrPersonBase authorKomb = (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, kombSplit[i]);
250
                    name.setExCombinationAuthorship(authorKomb);
251
                }
252
                else{
253
                    TeamOrPersonBase authorKomb = (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, kombSplit[i]);
254
                    name.setCombinationAuthorship(authorKomb);
255
                }
256
            }
257
        }
258
        else if(authorKombString.trim().contains(RedListUtil.AUCT)){
259
            RedListUtil.logMessage(id, "AUCT information in "+RedListUtil.AUTOR_KOMB+" column", logger);
260
        }
261
        else if(CdmUtils.isNotBlank(authorKombString)){
262
            TeamOrPersonBase authorKomb = (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, authorKombString);
263
            name.setCombinationAuthorship(authorKomb);
264
        }
265
        //basionym author
266
        if(authorBasiString.contains(RedListUtil.EX)){
267
            String[] basiSplit = authorBasiString.split(RedListUtil.EX);
268
            for (int i = 0; i < basiSplit.length; i++) {
269
                if(basiSplit.length!=2){
270
                    RedListUtil.logMessage(id, "Multiple ex basionymn authors found", logger);
271
                }
272
                if(i==0){
273
                    TeamOrPersonBase authorBasi= (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, basiSplit[i]);
274
                    if(CdmUtils.isBlank(authorKombString)){
275
                        name.setExCombinationAuthorship(authorBasi);
276
                    }
277
                    else{
278
                        name.setExBasionymAuthorship(authorBasi);
279
                    }
280
                }
281
                else{
282
                    TeamOrPersonBase authorBasi= (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, basiSplit[i]);
283
                    if(CdmUtils.isBlank(authorKombString)){
284
                        name.setCombinationAuthorship(authorBasi);
285
                    }
286
                    else{
287
                        name.setBasionymAuthorship(authorBasi);
288
                    }
289
                }
290
            }
291
        }
292
        else if(CdmUtils.isNotBlank(authorBasiString)){
293
            //this seems to be a convention in the source database: When there is only a single author then only the "AUTOR_BASI" column is used
294
            TeamOrPersonBase authorBasi= (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, authorBasiString);
295
            if(CdmUtils.isBlank(authorKombString)){
296
                name.setCombinationAuthorship(authorBasi);
297
            }
298
            else{
299
                name.setBasionymAuthorship(authorBasi);
300
            }
301
        }
302

    
303
        //check authorship consistency
304
        String authorString = rs.getString(RedListUtil.AUTOR);
305
        String authorshipCache = name.getAuthorshipCache();
306
        checkAuthorShipConsistency(id, nomZusatzString, taxZusatzString, zusatzString, authorString, authorshipCache);
307
    }
308

    
309
    private NonViralName importName(RedListGefaesspflanzenImportState state, long id, String taxNameString,
310
            String rangString, String ep1String, String ep2String, String ep3String, String nomZusatzString,
311
            String hybString, Set<TaxonNameBase> namesToSave) {
312
        if(CdmUtils.isBlank(taxNameString) && CdmUtils.isBlank(ep1String)){
313
            RedListUtil.logMessage(id, "No name found!", logger);
314
        }
315

    
316
        Rank rank = makeRank(id, state, rangString);
317
        NonViralName name = BotanicalName.NewInstance(rank);
318

    
319
        //ep1 should always be present
320
        if(CdmUtils.isBlank(ep1String)){
321
            RedListUtil.logMessage(id, RedListUtil.EPI1+" is empty!", logger);
322
        }
323
        name.setGenusOrUninomial(ep1String);
324
        if(CdmUtils.isNotBlank(ep2String)){
325
            name.setSpecificEpithet(ep2String);
326
        }
327
        if(CdmUtils.isNotBlank(ep3String)){
328
            name.setInfraSpecificEpithet(ep3String);
329
        }
330
        //nomenclatural status
331
        if(CdmUtils.isNotBlank(nomZusatzString)){
332
            NomenclaturalStatusType status = makeNomenclaturalStatus(id, state, nomZusatzString);
333
            if(status!=null){
334
                name.addStatus(NomenclaturalStatus.NewInstance(status));
335
            }
336
        }
337
        //hybrid
338
        if(CdmUtils.isNotBlank(hybString)){
339
            if(hybString.equals(RedListUtil.HYB_X)){
340
                name.setBinomHybrid(true);
341
            }
342
            else if(hybString.equals(RedListUtil.HYB_XF)){
343
                name.setHybridFormula(true);
344
                if(ep1String.contains(RedListUtil.HYB_SIGN)){
345
                    RedListUtil.logMessage(id, "EPI1 has hybrid signs but with flag: "+RedListUtil.HYB_XF, logger);
346
                }
347
                else if(ep2String.contains(RedListUtil.HYB_SIGN)){
348
                    String[] split = ep2String.split(RedListUtil.HYB_SIGN);
349
                    if(split.length!=2){
350
                        RedListUtil.logMessage(id, "Multiple hybrid signs found in "+ep2String, logger);
351
                    }
352
                    String hybridFormula1 = ep1String+" "+split[0].trim();
353
                    String hybridFormula2 = ep1String+" "+split[1].trim();
354
                    if(CdmUtils.isNotBlank(ep3String)){
355
                        hybridFormula1 += " "+ep3String;
356
                        hybridFormula2 += " "+ep3String;
357
                    }
358
                    String fullFormula = hybridFormula1+" "+RedListUtil.HYB_SIGN+" "+hybridFormula2;
359
                    name = NonViralNameParserImpl.NewInstance().parseFullName(fullFormula);
360
                }
361
                else if(ep3String.contains(RedListUtil.HYB_SIGN)){
362
                    String[] split = ep3String.split(RedListUtil.HYB_SIGN);
363
                    if(split.length!=2){
364
                        RedListUtil.logMessage(id, "Multiple hybrid signs found in "+ep3String, logger);
365
                    }
366
                    String hybridFormula1 = ep1String+" "+ep2String+" "+split[0];
367
                    String hybridFormula2 = ep1String+" "+ep2String+" "+split[1];
368
                    String fullFormula = hybridFormula1+" "+RedListUtil.HYB_SIGN+" "+hybridFormula2;
369
                    name = NonViralNameParserImpl.NewInstance().parseFullName(fullFormula);
370
                }
371
            }
372
        }
373
        //add source
374
        ImportHelper.setOriginalSource(name, state.getTransactionalSourceReference(), id, RedListUtil.NAME_NAMESPACE);
375

    
376
        namesToSave.add(name);
377
        return name;
378
    }
379

    
380
    private void checkAuthorShipConsistency(long id, String nomZusatzString, String taxZusatzString,
381
            String zusatzString, String authorString, String authorshipCache) {
382
        if(CdmUtils.isNotBlank(zusatzString)){
383
            authorString = authorString.replace(", "+zusatzString, "");
384
        }
385
        if(CdmUtils.isNotBlank(nomZusatzString)){
386
            authorString = authorString.replace(", "+nomZusatzString, "");
387
        }
388
        if(CdmUtils.isNotBlank(taxZusatzString)){
389
            authorString = authorString.replace(", "+taxZusatzString, "");
390
        }
391
        if(authorString.equals(RedListUtil.AUCT)){
392
            authorString = "";
393
        }
394
        if(!authorString.equals(authorshipCache)){
395
            RedListUtil.logMessage(id, "Authorship inconsistent! name.authorhshipCache <-> Column "+RedListUtil.AUTOR+": "+authorshipCache+" <-> "+authorString, logger);
396
        }
397
    }
398

    
399
    private void checkTaxonNameConsistency(long id, String taxNameString, String hybString, TaxonBase taxonBase) {
400
        if(hybString.equals(RedListUtil.HYB_XF)){
401
            if(HibernateProxyHelper.deproxy(taxonBase.getName(),NonViralName.class).getHybridChildRelations().isEmpty()){
402
                RedListUtil.logMessage(id, "Hybrid name but no hybrid child relations", logger);
403
                return;
404
            }
405
            return;
406
        }
407

    
408

    
409
        String nameCache = HibernateProxyHelper.deproxy(taxonBase.getName(), NonViralName.class).getNameCache().trim();
410

    
411
        if(taxNameString.endsWith("agg.")){
412
            taxNameString = taxNameString.replace("agg.", "aggr.");
413
        }
414
        if(hybString.equals(RedListUtil.HYB_X)){
415
            taxNameString = taxNameString.replace("× ", "×");//hybrid sign has no space after it in titleCache for binomial hybrids
416
        }
417
//        if(taxNameString.endsWith(Rank.SPECIESGROUP().toString())){
418
        if(taxNameString.endsWith("species group")){
419
            taxNameString.replaceAll(Rank.SPECIESGROUP().toString(), "- Gruppe");
420
            if(!taxNameString.trim().equals(nameCache)){
421
                taxNameString.replaceAll(Rank.SPECIESGROUP().toString(), "- group");
422
            }
423
        }
424
        if(!taxNameString.trim().equals(nameCache)){
425
            RedListUtil.logMessage(id, "Taxon name inconsistent! taxon.titleCache <-> Column "+RedListUtil.TAXNAME+": "+nameCache+" <-> "+taxNameString, logger);
426
        }
427
    }
428

    
429
    private Rank makeRank(long id, RedListGefaesspflanzenImportState state, String rankStr) {
430
        Rank rank = null;
431
        try {
432
            rank = state.getTransformer().getRankByKey(rankStr);
433
        } catch (UndefinedTransformerMethodException e) {
434
            e.printStackTrace();
435
        }
436
        if(rank==null){
437
            RedListUtil.logMessage(id, rankStr+" could not be associated to a known rank.", logger);
438
        }
439
        return rank;
440
    }
441

    
442
    private NomenclaturalStatusType makeNomenclaturalStatus(long id, RedListGefaesspflanzenImportState state, String nomZusatzString) {
443
        NomenclaturalStatusType status = null;
444
        try {
445
            status = state.getTransformer().getNomenclaturalStatusByKey(nomZusatzString);
446
        } catch (UndefinedTransformerMethodException e) {
447
            e.printStackTrace();
448
        }
449
        if(status==null){
450
            RedListUtil.logMessage(id, nomZusatzString+" could not be associated to a known nomenclatural status.", logger);
451
        }
452
        return status;
453
    }
454

    
455

    
456

    
457
    @Override
458
    public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs,
459
            RedListGefaesspflanzenImportState state) {
460
        Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>();
461
        Map<String, AgentBase<?>> authorMap = new HashMap<String, AgentBase<?>>();
462

    
463
        try {
464
            while (rs.next()){
465
                String authorKombString = rs.getString(RedListUtil.AUTOR_KOMB);
466

    
467
                if(authorKombString.contains(RedListUtil.EX)){
468
                    String[] kombSplit = authorKombString.split(RedListUtil.EX);
469
                    for (int i = 0; i < kombSplit.length; i++) {
470
                        if(!authorMap.containsKey(kombSplit[i])){
471
                            authorMap.put(kombSplit[i], getAgentService().load(state.getAuthorMap().get(kombSplit[i])));
472
                        }
473
                    }
474
                }
475
                else if(CdmUtils.isNotBlank(authorKombString) && !authorMap.containsKey(authorKombString)){
476
                    authorMap.put(authorKombString, getAgentService().load(state.getAuthorMap().get(authorKombString)));
477
                }
478

    
479
                String authorBasiString = rs.getString(RedListUtil.AUTOR_BASI);
480
                //basionym author
481
                if(authorBasiString.contains(RedListUtil.EX)){
482
                    String[] basiSplit = authorBasiString.split(RedListUtil.EX);
483
                    for (int i = 0; i < basiSplit.length; i++) {
484
                        if(!authorMap.containsKey(basiSplit[i])){
485
                            authorMap.put(basiSplit[i], getAgentService().load(state.getAuthorMap().get(basiSplit[i])));
486
                        }
487
                    }
488
                }
489
                else if(CdmUtils.isNotBlank(authorBasiString) && !authorMap.containsKey(authorBasiString)){
490
                    authorMap.put(authorBasiString, getAgentService().load(state.getAuthorMap().get(authorBasiString)));
491
                }
492
            }
493
        } catch (SQLException e) {
494
            e.printStackTrace();
495
        }
496
        result.put(RedListUtil.AUTHOR_NAMESPACE, authorMap);
497

    
498
        return result;
499
    }
500

    
501
    @Override
502
    protected boolean doCheck(RedListGefaesspflanzenImportState state) {
503
        return false;
504
    }
505

    
506
    @Override
507
    protected boolean isIgnore(RedListGefaesspflanzenImportState state) {
508
        return false;
509
    }
510

    
511
}
(4-4/7)