Project

General

Profile

« Previous | Next » 

Revision 0c5520e0

Added by Katja Luther about 6 years ago

fix #6219: delete of synonyms is performed with save in name editor

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/DeleteTaxonBaseHandlerE4.java
19 19
import org.eclipse.jface.viewers.IStructuredSelection;
20 20
import org.eclipse.swt.widgets.Shell;
21 21

  
22
import eu.etaxonomy.cdm.api.application.ICdmRepository;
22 23
import eu.etaxonomy.cdm.api.service.DeleteResult;
24
import eu.etaxonomy.cdm.api.service.ITaxonService;
23 25
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
26
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
24 27
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
25 28
import eu.etaxonomy.cdm.model.common.CdmBase;
26 29
import eu.etaxonomy.cdm.model.taxon.Synonym;
......
31 34
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
32 35
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
33 36
import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
34
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteMisapplicationOperation;
35
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation;
36
import eu.etaxonomy.taxeditor.editor.name.operation.DeleteTaxonBaseOperation;
37
import eu.etaxonomy.taxeditor.model.AbstractUtility;
38 37
import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;
39 38
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
40 39
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
40
import eu.etaxonomy.taxeditor.store.CdmStore;
41 41
import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
42 42

  
43 43
/**
......
81 81
	        }
82 82

  
83 83
		}
84
		TaxonBaseDeletionConfigurator deleteConfig;
85
		 ICdmRepository controller;
84 86

  
87
         controller = CdmStore.getCurrentApplicationConfiguration();
88

  
89
         ITaxonService service = controller.getTaxonService();
90
         DeleteResult result;
85 91
		// synonym
86 92
		if(selectedElement instanceof Synonym){
87
		    SynonymDeletionConfigurator deleteConfig = new SynonymDeletionConfigurator();
93
		    deleteConfig = new SynonymDeletionConfigurator();
88 94
		    if(! DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfig, shell, Messages.DeleteTaxonBaseHandler_CONFIRM_DELETION,  Messages.DeleteTaxonBaseHandler_REALLY_DELETE_SYNONYM)){
89 95
		           return ;
90 96
            }
91
			operation = new DeleteSynonymOperation(commandName, editor.getUndoContext(), deleteConfig, editor.getTaxon(), (Synonym) selectedElement,this, editor, editor.getEditorInput());
97

  
98
//			operation = new DeleteSynonymOperation(commandName, editor.getUndoContext(), deleteConfig, editor.getTaxon(), (Synonym) selectedElement,this, editor, editor.getEditorInput());
92 99

  
93 100
		}
94 101
		// misapplication
95 102
		else if(selectedElement instanceof Taxon && ((Taxon) selectedElement).isMisapplication()){
96
		    TaxonDeletionConfigurator deleteConfig = new TaxonDeletionConfigurator();
103
		    deleteConfig = new TaxonDeletionConfigurator();
97 104
		    if(! DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfig, shell, Messages.DeleteTaxonBaseHandler_CONFIRM_DELETION,  Messages.DeleteTaxonBaseHandler_REALLY_DELETE_MISAPPLICATION)){
98 105
		        return ;
99 106
		    }
100
			operation = new DeleteMisapplicationOperation(commandName, editor.getUndoContext(),  deleteConfig, editor.getTaxon(), (Taxon) selectedElement,this, editor, editor.getEditorInput());
107

  
108
//			operation = new DeleteMisapplicationOperation(commandName, editor.getUndoContext(),  deleteConfig, editor.getTaxon(), (Taxon) selectedElement,this, editor, editor.getEditorInput());
109
//		    editor.getEditorInput().addSynonymToDelete((TaxonBase)selectedElement,deleteConfig);
101 110
		} else {
102 111
			throw new IllegalArgumentException(Messages.DeleteTaxonBaseHandler_ELEMENT_MUST_BE_SYNONYM_MISAPP_CONCEPT);
103 112
		}
104

  
105
		AbstractUtility.executeOperation(operation, sync);
106
		DeleteResult result = ((DeleteTaxonBaseOperation)operation).getResult();
113
		result = service.isDeletable(((TaxonBase)selectedElement).getUuid(), deleteConfig);
114
//		AbstractUtility.executeOperation(operation, sync);
115
//		 = ((DeleteTaxonBaseOperation)operation).getResult();
107 116
		if (result != null){
108 117
    		if (result.isError()){
109 118
                DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteDerivateOperation_DELETE_FAILED, TaxeditorEditorPlugin.PLUGIN_ID);
110 119
            } else if (selectedElement instanceof Synonym){
111
                this.editor.redraw();
120
                editor.getEditorInput().addTaxonBaseToDelete((TaxonBase)selectedElement,deleteConfig);
121
                editor.getTaxon().removeSynonym((Synonym)selectedElement);
122
                editor.setDirty();
112 123
    		    if (!result.getExceptions().isEmpty()){
113 124
                    DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteTaxonBaseHandler_DELETE_SYNONYM_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS, TaxeditorEditorPlugin.PLUGIN_ID);
114 125
                }
115
    		} else if (selectedElement instanceof Taxon && !result.getExceptions().isEmpty()){
116
    	        this.editor.redraw();
117
                DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteTaxonBaseHandler_DELETE_MISAPPLIEDNAME_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS, TaxeditorEditorPlugin.PLUGIN_ID);
126
    		} else if (selectedElement instanceof Taxon ){
127
    		    editor.getTaxon().removeTaxon((Taxon)selectedElement, TaxonRelationshipType.MISAPPLIED_NAME_FOR());
128
    		    editor.getEditorInput().addTaxonBaseToDelete((TaxonBase)selectedElement,deleteConfig);
129
    		    editor.setDirty();
130
    		    if ( !result.getExceptions().isEmpty()){
131
                    DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteTaxonBaseHandler_DELETE_MISAPPLIEDNAME_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS, TaxeditorEditorPlugin.PLUGIN_ID);
132
                }
118 133
    		}
134
      		editor.redraw();
135

  
119 136
		}
120 137
	}
121 138

  

Also available in: Unified diff