From: Patrick Plitzner
Date: Wed, 11 Apr 2018 09:56:22 +0000 (+0200)
Subject: ref #7086 Fix potential multiple representation exception
X-Git-Tag: 5.0.0^2~214
X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/80a0c0dc788e2a91a8e8fb380325a4bfd73e1ea3
ref #7086 Fix potential multiple representation exception
---
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/TaxonNodeDropAdapter.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/TaxonNodeDropAdapter.java
index 4f2bdf82a..1d9f5f7ed 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/TaxonNodeDropAdapter.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/TaxonNodeDropAdapter.java
@@ -8,8 +8,6 @@
*/
package eu.etaxonomy.taxeditor.editor.workingSet;
-import java.util.Set;
-
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -17,12 +15,7 @@ import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.ViewerDropAdapter;
import org.eclipse.swt.dnd.TransferData;
-import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
-import eu.etaxonomy.taxeditor.editor.l10n.Messages;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @author pplitzner
@@ -44,18 +37,7 @@ public class TaxonNodeDropAdapter extends ViewerDropAdapter {
@Override
public boolean performDrop(Object data) {
TaxonNodeDto taxonNodeDto = (TaxonNodeDto) ((ITreeSelection) data).getFirstElement();
- TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNodeDto.getUuid());
- //check if node belongs to same classification
- Set taxonSubtreeFilter = workingSetEditor.getWorkingSet().getTaxonSubtreeFilter();
- if(taxonSubtreeFilter!=null && !taxonSubtreeFilter.isEmpty()){
- if(!taxonSubtreeFilter.iterator().next().getClassification().equals(taxonNode.getClassification())){
- MessagingUtils.warningDialog(Messages.TaxonNodeDropAdapter_CLASSIFICATIONS_NO_MATCH, this.getClass(),
- Messages.TaxonNodeDropAdapter_CLASSIFICATIONS_NO_MATCH_MESSAGE);
- return false;
- }
-
- }
- workingSetEditor.addTaxonNode(taxonNode);
+ workingSetEditor.addTaxonNode(taxonNodeDto);
return true;
}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java
index 9abb7bdde..3e9d83e57 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java
@@ -47,6 +47,7 @@ import org.eclipse.swt.widgets.Shell;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.api.service.ITermService;
import eu.etaxonomy.cdm.api.service.IWorkingSetService;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
@@ -56,6 +57,7 @@ import eu.etaxonomy.cdm.model.location.NamedArea;
import eu.etaxonomy.cdm.model.name.Rank;
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
@@ -198,9 +200,17 @@ IPartContentHasDetails, IDirtyMarkable {
composite.getTxt_label().addModifyListener(labelModifyListener);
}
- public void addTaxonNode(TaxonNode taxonNode){
- //load into WS editor session
- taxonNode = getCdmEntitySession().load(taxonNode, false);
+ public void addTaxonNode(TaxonNodeDto taxonNodeDto){
+ TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNodeDto.getUuid());
+ //check if node belongs to same classification
+ Set taxonSubtreeFilter = workingSet.getTaxonSubtreeFilter();
+ if(taxonSubtreeFilter!=null && !taxonSubtreeFilter.isEmpty()){
+ if(!taxonSubtreeFilter.iterator().next().getClassification().equals(taxonNode.getClassification())){
+ MessagingUtils.warningDialog(Messages.TaxonNodeDropAdapter_CLASSIFICATIONS_NO_MATCH, this.getClass(),
+ Messages.TaxonNodeDropAdapter_CLASSIFICATIONS_NO_MATCH_MESSAGE);
+ }
+
+ }
Viewer taxonTreeViewer = getTaxonTreeViewer();
Object input = taxonTreeViewer.getInput();
Collection treeNodes;