Project

General

Profile

Revision cfcd10fd

IDcfcd10fdba3ebcf4648303b647804dfa6b27fc22
Parent 2394b07d
Child 95468153

Added by Katja Luther about 2 years ago

ref #8526: fix swap syn and acc taxon in service method

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
213 213

  
214 214
        TaxonName taxonName = HibernateProxyHelper.deproxy(acceptedTaxon.getName(), TaxonName.class);
215 215
        //taxonName.removeTaxonBase(acceptedTaxon);
216
        Taxon newTaxon = Taxon.NewInstance(synonymName, synonym.getSec());
216

  
217 217
        List<Synonym> synonyms = new ArrayList<>();
218 218
        for (Synonym syn: acceptedTaxon.getSynonyms()){
219 219
            syn = HibernateProxyHelper.deproxy(syn, Synonym.class);
......
222 222
        for (Synonym syn: synonyms){
223 223
            acceptedTaxon.removeSynonym(syn);
224 224
        }
225

  
225
        Taxon newTaxon = (Taxon)acceptedTaxon.clone();
226
        newTaxon.setName(synonymName);
227
        newTaxon.setSec(synonym.getSec());
226 228
        for (Synonym syn: synonyms){
227 229
            if (!syn.getName().equals(newTaxon.getName())){
228 230
                newTaxon.addSynonym(syn, syn.getType());
......
231 233

  
232 234
        //move all data to new taxon
233 235
        //Move Taxon RelationShips to new Taxon
236
        for(TaxonRelationship taxonRelationship : newTaxon.getTaxonRelations()){
237
            newTaxon.removeTaxonRelation(taxonRelationship);
238
        }
239

  
240

  
234 241
        for(TaxonRelationship taxonRelationship : acceptedTaxon.getTaxonRelations()){
235 242
            Taxon fromTaxon = HibernateProxyHelper.deproxy(taxonRelationship.getFromTaxon());
236 243
            Taxon toTaxon = HibernateProxyHelper.deproxy(taxonRelationship.getToTaxon());
......
256 263

  
257 264

  
258 265
        //Move descriptions to new taxon
259
        List<TaxonDescription> descriptions = new ArrayList<TaxonDescription>( acceptedTaxon.getDescriptions()); //to avoid concurrent modification errors (newAcceptedTaxon.addDescription() modifies also oldtaxon.descritpions())
266
        List<TaxonDescription> descriptions = new ArrayList<TaxonDescription>( newTaxon.getDescriptions()); //to avoid concurrent modification errors (newAcceptedTaxon.addDescription() modifies also oldtaxon.descritpions())
260 267
        for(TaxonDescription description : descriptions){
261 268
            String message = "Description copied from former accepted taxon: %s (Old title: %s)";
262 269
            message = String.format(message, acceptedTaxon.getTitleCache(), description.getTitleCache());
......
270 277
                    }
271 278
                }
272 279
            }
273
            //oldTaxon.removeDescription(description, false);
274
            newTaxon.addDescription(description);
280
//            //oldTaxon.removeDescription(description, false);
281
 //           newTaxon.addDescription(description);
275 282
        }
276 283
        List<TaxonNode> nodes = new ArrayList(acceptedTaxon.getTaxonNodes());
277 284
        for (TaxonNode node: nodes){
......
282 289
            parent.addChildNode(node, null, null);
283 290

  
284 291
        }
285
        Synonym newSynonym = Synonym.NewInstance(taxonName, acceptedTaxon.getSec());
292
        Synonym newSynonym = (Synonym)synonym.clone();
293
        newSynonym.setName(taxonName);
294
        newSynonym.setSec(acceptedTaxon.getSec());
286 295
        if (sameHomotypicGroup){
287 296
            newTaxon.addSynonym(newSynonym, SynonymType.HOMOTYPIC_SYNONYM_OF());
288 297
        }else{

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)