Project

General

Profile

« Previous | Next » 

Revision 0c5520e0

Added by Katja Luther about 5 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/e4/TaxonEditorInputE4.java
11 11

  
12 12
import java.util.ArrayList;
13 13
import java.util.Arrays;
14
import java.util.HashMap;
14 15
import java.util.HashSet;
15 16
import java.util.List;
16 17
import java.util.Map;
18
import java.util.Map.Entry;
17 19
import java.util.Set;
18 20
import java.util.UUID;
19 21

  
......
22 24
import eu.etaxonomy.cdm.api.service.IClassificationService;
23 25
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
24 26
import eu.etaxonomy.cdm.api.service.ITaxonService;
27
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
28
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
29
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
25 30
import eu.etaxonomy.cdm.model.common.CdmBase;
26 31
import eu.etaxonomy.cdm.model.name.TaxonName;
27 32
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
......
55 60

  
56 61
    private TaxonNode taxonNode;
57 62

  
63
    private Map<TaxonBase, TaxonBaseDeletionConfigurator> toDelete = new HashMap<>();
64

  
58 65
    private TaxonEditorInputDataChangeBehaviourE4 dataChangeBehavior;
59 66

  
60 67
    private TaxonBase initiallySelectedTaxonBase;
......
275 282
        if (!this.getCdmEntitySession().isActive()){
276 283
            this.getCdmEntitySession().bind();
277 284
        }
285
        for(Entry<TaxonBase, TaxonBaseDeletionConfigurator> entry:toDelete.entrySet()){
286
            delete(entry.getKey(), entry.getValue());
287
        }
288
        toDelete.clear();
278 289
        CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
279 290

  
280 291
    }
281 292

  
293
    /**
294
     * @param key
295
     * @param value
296
     */
297
    private void delete(TaxonBase key, TaxonBaseDeletionConfigurator value) {
298
        if (key instanceof Synonym){
299
            CdmStore.getService(ITaxonService.class).deleteSynonym(((Synonym)key).getUuid(), (SynonymDeletionConfigurator) value);
300
        }else{
301
            CdmStore.getService(ITaxonService.class).deleteTaxon(((Taxon)key).getUuid(), (TaxonDeletionConfigurator) value, null);
302
        }
303

  
304
    }
305

  
282 306
    @Override
283 307
    public Map<Object, List<String>> getPropertyPathsMap() {
284 308
        return null;
......
330 354
        return taxonBasePropertyPaths;
331 355
    }
332 356

  
357
    /**
358
     * @param selectedElement
359
     * @param deleteConfig
360
     */
361
    public void addTaxonBaseToDelete(TaxonBase selectedElement, TaxonBaseDeletionConfigurator deleteConfig) {
362
        this.toDelete.put(selectedElement, deleteConfig);
363

  
364
    }
365

  
333 366
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages.properties
37 37
DeleteTaxonBaseHandler_CONFIRM_DELETION=Confirm Deletion
38 38
DeleteTaxonBaseHandler_ELEMENT_MUST_BE_SYNONYM_MISAPP_CONCEPT=Element has to be Synonym, Misapplication or Concept
39 39
DeleteTaxonBaseHandler_REALLY_DELETE_TAXON=Are you sure you want to delete the selected taxon?
40
DeleteTaxonBaseHandler_REALLY_DELETE_SYNONYM=Are you sure you want to delete the selected synoym, this is irreversible?
40
DeleteTaxonBaseHandler_REALLY_DELETE_SYNONYM=Are you sure you want to delete the selected synoym?
41 41
DeleteTaxonBaseHandler_DELETE_SYNONYM_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS=The Synonym could be deleted, but related object(s) could not be deleted
42 42
DeleteTaxonBaseHandler_DELETE_MISAPPLIEDNAME_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS=The misapplied name could be deleted, but related object(s) could not be deleted
43 43
DeleteTaxonBaseHandler_REALLY_DELETE_MISAPPLICATION=Are you sure you want to delete the selected misapplication, this is irreversible?
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages_de.properties
37 37
DeleteTaxonBaseHandler_CONFIRM_DELETION=L?schen best?tigen
38 38
DeleteTaxonBaseHandler_ELEMENT_MUST_BE_SYNONYM_MISAPP_CONCEPT=Element muss Synonym, Misapplikation oder Konzept sein
39 39
DeleteTaxonBaseHandler_REALLY_DELETE_TAXON=Wollen Sie wirklich das ausgew?hlte Taxon l?schen?
40
DeleteTaxonBaseHandler_REALLY_DELETE_SYNONYM=Wollen Sie das ausgew?hlte Synonym wirklich l?schen, dieser Vorgang ist nicht reversibel.
40
DeleteTaxonBaseHandler_REALLY_DELETE_SYNONYM=Wollen Sie das ausgew?hlte Synonym wirklich l?schen?
41 41
DeleteTaxonBaseHandler_DELETE_SYNONYM_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS=Das Synonym konnte gel?scht werden, aber es gibt noch verkn?pfte Objekte, die nicht gel?scht werden konnten.
42 42
DeleteTaxonBaseHandler_DELETE_MISAPPLIEDNAME_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS=Die Misapplikation konnte gel?scht werden, aber es gibt noch verkn?pfte Objekte, die nicht gel?scht werden konnten.
43 43
DeleteTaxonBaseHandler_REALLY_DELETE_MISAPPLICATION=Wollen Sie die ausgew?hlte Misapplikation wirklich l?schen, dieser Vorgang ist nicht reversibel.
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java
384 384
	public void init(TaxonEditorInputE4 input) {
385 385
		if (this.input != null){
386 386
			this.input.dispose();
387
//			this.acceptedGroup = null;
388
//			this.heterotypicSynonymGroups.clear();
389
//			this.misappliedGroup = null;
387 390
		}
388 391
		if (!(input != null)) {
389 392
            MessagingUtils.error(this.getClass(), new Exception(Messages.TaxonNameEditor_INVALID_INPUT));
......
514 517
	/** {@inheritDoc} */
515 518
	@Override
516 519
    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
517

  
520
	    System.err.println("Bla");
518 521
	}
519 522

  
520 523
	public AbstractGroupedContainerE4 getSelectedContainer() {
......
593 596
	}
594 597

  
595 598
	public AbstractGroupedContainerE4 getContainer(TaxonBase taxonBase) {
596
		List<AbstractGroupedContainerE4> groupedContainers = getGroupedContainers();
599
		@SuppressWarnings("rawtypes")
600
        List<AbstractGroupedContainerE4> groupedContainers = getGroupedContainers();
597 601
		for (AbstractGroupedContainerE4 container : groupedContainers) {
598 602
			if (container.getData().equals(taxonBase)
599 603
					&& container.getNameViewer().getTextWidget() != null) {
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