Project

General

Profile

« Previous | Next » 

Revision b37b6a0f

Added by Patrick Plitzner about 8 years ago

Refactor duplicate code

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java
149 149
            for (int i = 0; i < kombSplit.length; i++) {
150 150
                if(i==0){
151 151
                    //first author is ex author
152
                    TeamOrPersonBase authorKomb = (TeamOrPersonBase) state.getRelatedObject(Namespace.AUTHOR_NAMESPACE, kombSplit[i]);
152
                    TeamOrPersonBase authorKomb = (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, kombSplit[i]);
153 153
                    name.setExCombinationAuthorship(authorKomb);
154 154
                }
155 155
                else{
156
                    TeamOrPersonBase authorKomb = (TeamOrPersonBase) state.getRelatedObject(Namespace.AUTHOR_NAMESPACE, kombSplit[i]);
156
                    TeamOrPersonBase authorKomb = (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, kombSplit[i]);
157 157
                    name.setCombinationAuthorship(authorKomb);
158 158
                }
159 159
            }
160 160
        }
161
        else if(authorKombString.trim().equals("auct.")){
161
        else if(authorKombString.trim().equals(RedListUtil.AUCT)){
162 162
            logger.warn("NAMNR: "+id+" AUCT information in AUTOR_KOMB column");
163 163
        }
164 164
        else if(!CdmUtils.isBlank(authorKombString)){
165
            TeamOrPersonBase authorKomb = (TeamOrPersonBase) state.getRelatedObject(Namespace.AUTHOR_NAMESPACE, authorKombString);
165
            TeamOrPersonBase authorKomb = (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, authorKombString);
166 166
            name.setCombinationAuthorship(authorKomb);
167 167
        }
168 168
        //basionym author
......
173 173
                    logger.error("NAMNR: "+id+" Multiple ex basionymn authors found");
174 174
                }
175 175
                if(i==0){
176
                    TeamOrPersonBase authorBasi= (TeamOrPersonBase) state.getRelatedObject(Namespace.AUTHOR_NAMESPACE, basiSplit[i]);
176
                    TeamOrPersonBase authorBasi= (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, basiSplit[i]);
177 177
                    if(CdmUtils.isBlank(authorKombString)){
178 178
                        name.setExCombinationAuthorship(authorBasi);
179 179
                    }
......
182 182
                    }
183 183
                }
184 184
                else{
185
                    TeamOrPersonBase authorBasi= (TeamOrPersonBase) state.getRelatedObject(Namespace.AUTHOR_NAMESPACE, basiSplit[i]);
185
                    TeamOrPersonBase authorBasi= (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, basiSplit[i]);
186 186
                    if(CdmUtils.isBlank(authorKombString)){
187 187
                        name.setCombinationAuthorship(authorBasi);
188 188
                    }
......
192 192
                }
193 193
            }
194 194
        }
195
        else if(authorBasiString.trim().equals("auct.")){
195
        else if(authorBasiString.trim().equals(RedListUtil.AUCT)){
196 196
            name.setAppendedPhrase(authorBasiString);
197 197
        }
198 198
        else if(!CdmUtils.isBlank(authorBasiString)){
199 199
            //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
200
            TeamOrPersonBase authorBasi= (TeamOrPersonBase) state.getRelatedObject(Namespace.AUTHOR_NAMESPACE, authorBasiString);
200
            TeamOrPersonBase authorBasi= (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, authorBasiString);
201 201
            if(CdmUtils.isBlank(authorKombString)){
202 202
                name.setCombinationAuthorship(authorBasi);
203 203
            }
......
216 216
//        if(CdmUtils.isBlank(authorKombString) && !CdmUtils.isBlank(authorBasiString)){
217 217
//            authorString = "("+authorString+")";
218 218
//        }
219
        if(authorString.equals("auct.")){
219
        if(authorString.equals(RedListUtil.AUCT)){
220 220
            authorString = "";
221 221
        }
222 222
        if(!authorString.equals(authorshipCache)){
......
224 224
        }
225 225

  
226 226
        //id
227
        ImportHelper.setOriginalSource(name, state.getTransactionalSourceReference(), id, Namespace.NAME_NAMESPACE);
227
        ImportHelper.setOriginalSource(name, state.getTransactionalSourceReference(), id, RedListUtil.NAME_NAMESPACE);
228 228
        state.getNameMap().put(id, name.getUuid());
229 229

  
230 230
        namesToSave.add(name);
231 231

  
232 232
        //---TAXON---
233 233
        TaxonBase taxonBase = null;
234
        if(gueltString.equals("1") || (name.getAppendedPhrase()!=null && name.getAppendedPhrase().equals("auct."))){
234
        if(gueltString.equals("1") || (name.getAppendedPhrase()!=null && name.getAppendedPhrase().equals(RedListUtil.AUCT))){
235 235
            taxonBase = Taxon.NewInstance(name, null);
236 236
        }
237 237
        else if(gueltString.equals("x") || gueltString.equals("b")){
......
245 245
        taxaToSave.add(taxonBase);
246 246

  
247 247
        //id
248
        ImportHelper.setOriginalSource(taxonBase, state.getTransactionalSourceReference(), id, Namespace.TAXON_NAMESPACE);
248
        ImportHelper.setOriginalSource(taxonBase, state.getTransactionalSourceReference(), id, RedListUtil.TAXON_NAMESPACE);
249 249
        state.getTaxonMap().put(id, taxonBase.getUuid());
250 250
    }
251 251

  
......
303 303
        } catch (SQLException e) {
304 304
            e.printStackTrace();
305 305
        }
306
        result.put(Namespace.AUTHOR_NAMESPACE, authorMap);
306
        result.put(RedListUtil.AUTHOR_NAMESPACE, authorMap);
307 307

  
308 308
        return result;
309 309
    }

Also available in: Unified diff