Project

General

Profile

« Previous | Next » 

Revision 5e20e0f2

Added by Patrick Plitzner over 7 years ago

#5448 Fix possible NPE

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java
183 183
    private void addTaxonToClassification(Classification classification, String classificationNamespace, String relationString, final TaxonBase<?> gesamtListeTaxon, final TaxonBase<?> checklisteTaxon, long id, RedListGefaesspflanzenImportState state){
184 184
        Taxon taxon = HibernateProxyHelper.deproxy(state.getRelatedObject(classificationNamespace, String.valueOf(id), TaxonBase.class), Taxon.class);
185 185
        //add concept relation to gesamtliste and checkliste
186
        if(CdmUtils.isNotBlank(relationString) && !relationString.equals(".")){
186
        if(taxon!=null && CdmUtils.isNotBlank(relationString) && !relationString.equals(".")){
187 187
            //if the related concept in gesamtliste/checkliste is a synonym then we
188 188
            //create a relation to the accepted taxon
189 189
            Taxon acceptedGesamtListeTaxon = getAcceptedTaxon(gesamtListeTaxon);
......
210 210
                    taxon.addTaxonRelation(acceptedChecklistTaxon, taxonRelationshipTypeByKey, null, null);
211 211
                }
212 212
            }
213
        }
214 213

  
215
        if(taxon!=null){//not all taxa exist in these classifications
216 214
            taxon.setSec(classification.getReference());
217 215
            taxon.setTitleCache(null);//Reset title cache to see sec ref in title
218 216
            classification.addChildTaxon(taxon, null, null);
217
            getTaxonService().saveOrUpdate(taxon);
218
            getTaxonService().saveOrUpdate(gesamtListeTaxon);
219
            if(checklisteTaxon!=null){
220
                getTaxonService().saveOrUpdate(checklisteTaxon);
221
            }
219 222
        }
220
        getTaxonService().saveOrUpdate(taxon);
221
        getTaxonService().saveOrUpdate(gesamtListeTaxon);
222
        getTaxonService().saveOrUpdate(checklisteTaxon);
223 223
    }
224 224

  
225 225
    private void createParentChildNodes(Classification classification, long id, String gueltString,

Also available in: Unified diff