Revision bb082354
Added by Katja Luther about 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditorPart.java | ||
---|---|---|
36 | 36 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
37 | 37 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
38 | 38 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
39 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
39 | 40 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
40 | 41 |
import eu.etaxonomy.cdm.api.service.dto.TaxonDistributionDTO; |
41 | 42 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
43 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
42 | 44 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
43 | 45 |
import eu.etaxonomy.cdm.persistence.dto.MergeResult; |
44 | 46 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
... | ... | |
228 | 230 |
|
229 | 231 |
protected void saveDistributions() { |
230 | 232 |
Set<TaxonDistributionDTO> coll = new HashSet(); |
231 |
editor.taxonList.forEach(dto->coll.add(dto)); |
|
233 |
editor.getDescriptionsToSave().forEach(dto->coll.add(dto)); |
|
234 |
for (TaxonDistributionDTO dto: coll){ |
|
235 |
Taxon taxon = null; |
|
236 |
for(TaxonDescription desc: dto.getDescriptionsWrapper().getDescriptions()){ |
|
237 |
if (desc.getTaxon() == null){ |
|
238 |
if (taxon == null){ |
|
239 |
taxon = (Taxon)CdmStore.getService(ITaxonService.class).load(dto.getTaxonUuid()); |
|
240 |
} |
|
241 |
taxon.addDescription(desc); |
|
242 |
} |
|
243 |
if (taxon != null){ |
|
244 |
CdmStore.getService(ITaxonService.class).merge(taxon, true); |
|
245 |
} |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
232 | 249 |
List<MergeResult<DescriptionBase>> result = CdmStore.getService(IDescriptionService.class).mergeDescriptionElements(coll, true); |
233 | 250 |
for (MergeResult<DescriptionBase> mergeRes: result ){ |
234 | 251 |
cdmEntitySession.load(mergeRes, true); |
252 |
cdmEntitySession.load(editor.getDefaultSource(), true); |
|
235 | 253 |
} |
236 |
// editor.createTaxonDistributionMap();
|
|
254 |
editor.createTaxonDistributionMap(); |
|
237 | 255 |
conversation.commit(); |
238 | 256 |
this.dirty.setDirty(false); |
239 | 257 |
editor.getDescriptionsToSave().clear(); |
Also available in: Unified diff
ref #7854: fix exceptions in distribution editor when saving new created descriptions