Project

General

Profile

« Previous | Next » 

Revision b084af2b

Added by Katja Luther almost 6 years ago

ref #7393: fix regression for deleting cascading from relations

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java
13 13
import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
14 14
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
15 15
import eu.etaxonomy.cdm.api.service.IClassificationService;
16
import eu.etaxonomy.cdm.api.service.INameService;
16 17
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
17 18
import eu.etaxonomy.cdm.api.service.ITaxonService;
18 19
import eu.etaxonomy.cdm.api.service.UpdateResult;
19 20
import eu.etaxonomy.cdm.model.common.CdmBase;
21
import eu.etaxonomy.cdm.model.name.HybridRelationship;
22
import eu.etaxonomy.cdm.model.name.TaxonName;
20 23
import eu.etaxonomy.cdm.model.reference.Reference;
21 24
import eu.etaxonomy.cdm.model.taxon.Classification;
22 25
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
......
69 72
            	    parentNodeUuid = parent.getUuid();
70 73
            	}
71 74
            	UpdateResult result;
75
            	if (!taxon.getName().getHybridChildRelations().isEmpty() || !taxon.getName().getHybridParentRelations().isEmpty()){
76
                    Set<TaxonName> namesToSave = new HashSet<>();
77
                    for (HybridRelationship hybridRelationship: taxon.getName().getHybridChildRelations()){
78
                        if (hybridRelationship.getParentName() != taxon.getName()){
79
                            if (!hybridRelationship.getParentName().isPersited()){
80
                                namesToSave.add(hybridRelationship.getParentName());
81
                            }
82
                       }else if (hybridRelationship.getHybridName() != taxon.getName()){
83
                           if (!hybridRelationship.getHybridName().isPersited()){
84
                               namesToSave.add(hybridRelationship.getHybridName());
85
                           }
86
                        }
87

  
88
                    }
89

  
90
                    for (HybridRelationship hybridRelationship: taxon.getName().getHybridParentRelations()){
91
                        if (hybridRelationship.getParentName() != taxon.getName()){
92
                            if (!hybridRelationship.getParentName().isPersited()){
93
                                namesToSave.add(hybridRelationship.getParentName());
94
                            }
95
                       }else if (hybridRelationship.getHybridName() != taxon.getName()){
96
                           if (!hybridRelationship.getHybridName().isPersited()){
97
                               namesToSave.add(hybridRelationship.getHybridName());
98
                           }
99
                        }
100

  
101
                    }
102
                    CdmStore.getService(INameService.class).save(namesToSave);
103
                }
72 104

  
73 105
            	if (taxon.getId() == 0){
74 106
            		result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parentNodeUuid, taxon, parent.getReference(), parent.getMicroReference());
......
81 113
	             	taxonNode.getTaxon().setSec(sec);
82 114
	             	taxonNode.setExcluded(((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).isExcluded());
83 115
	             	taxonNode.setUnplaced(((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).isUnplaced());
116

  
117

  
84 118
	             	MergeResult resultMerge =  CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
85 119
	                 Set<CdmBase> affectedObjects = new HashSet<CdmBase>();
86 120
	                 if (result.getUpdatedObjects().iterator().hasNext()){

Also available in: Unified diff