Project

General

Profile

« Previous | Next » 

Revision 205bdec4

Added by Katja Luther almost 4 years ago

ref #9084: add config to delete description in character matrix

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/DescriptiveDataSetEditor.java
296 296
        Object input = composite.getTaxonNodeTree().getInput();
297 297
        if(input!=null){
298 298
            descriptiveDataSet.setTaxonSubtreeFilter(new HashSet<>());//clear existing filter
299
            Collection<TaxonNodeDto> taxonNodes = (Collection<TaxonNodeDto>) input;
300
            for (TaxonNodeDto taxonTreeNode : taxonNodes) {
301
                TaxonNode taxonNode =  CdmStore.getService(ITaxonNodeService.class).load(taxonTreeNode.getUuid());
302
                descriptiveDataSet.addTaxonSubtree(taxonNode);
299
            Collection<TaxonNode> taxonNodes = (Collection<TaxonNode>) input;
300
            for (TaxonNode taxonTreeNode : taxonNodes) {
301
//                TaxonNode taxonNode =  CdmStore.getService(ITaxonNodeService.class).load(taxonTreeNode.getUuid());
302
                descriptiveDataSet.addTaxonSubtree(taxonTreeNode);
303 303
            }
304 304
        }
305 305
        TermTree<Feature> characters = composite.getCharacters();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
101 101
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
102 102
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
103 103
import eu.etaxonomy.cdm.api.service.UpdateResult;
104
import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
104 105
import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO;
105 106
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
106 107
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
......
191 192
    private CharacterMatrixToolbar toolbar;
192 193

  
193 194
    private DescriptionTreeFormat treeFormat;
194
    private List<UUID> descriptionUuidsToDelete;
195
//    private List<UUID> descriptionUuidsToDelete;
196
    Map<RemoveDescriptionsFromDescriptiveDataSetConfigurator, List<UUID>> descriptionUuidsToDelete;
195 197

  
196 198
    private List<SpecimenNodeWrapper> specimenToAdd;
197 199

  
......
758 760
        part.setDirty();
759 761
    }
760 762

  
761
    public List<UUID> getDescriptionsToDelete() {
763
    public Map<RemoveDescriptionsFromDescriptiveDataSetConfigurator, List<UUID>> getDescriptionsToDelete() {
762 764
        return descriptionUuidsToDelete;
763 765
    }
764 766

  
765
    public void addDescriptionToDelete(UUID descriptionToDelete) {
767
    public void addDescriptionToDelete(UUID descriptionToDelete, RemoveDescriptionsFromDescriptiveDataSetConfigurator config) {
766 768
        if (descriptionUuidsToDelete == null){
767
            descriptionUuidsToDelete = new ArrayList();
769
            descriptionUuidsToDelete = new HashMap<>();
770
        }
771
        if (descriptionUuidsToDelete.get(config) != null){
772
            descriptionUuidsToDelete.get(config).add(descriptionToDelete);
773
        }else{
774
            List<UUID> uuidList = new ArrayList<>();
775
            uuidList.add(descriptionToDelete);
776
            this.descriptionUuidsToDelete.put(config, uuidList);
768 777
        }
769 778

  
770
        this.descriptionUuidsToDelete.add(descriptionToDelete);
771 779

  
772 780
    }
773 781

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixPart.java
41 41
import eu.etaxonomy.cdm.api.service.DeleteResult;
42 42
import eu.etaxonomy.cdm.api.service.IDescriptionService;
43 43
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
44
import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
44 45
import eu.etaxonomy.cdm.api.service.dto.DescriptionBaseDto;
45 46
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
46 47
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
......
199 200
//        descriptions.removeAll(matrix.getRowsToSave().values());
200 201
        matrix.getRowsToMerge().clear();
201 202
        if (matrix.getDescriptionsToDelete() != null && !matrix.getDescriptionsToDelete().isEmpty()){
202
            DeleteResult result = CdmStore.getService(IDescriptiveDataSetService.class).removeDescriptions(matrix.getDescriptionsToDelete(), matrix.getDescriptiveDataSet().getUuid());
203
            DeleteResult result = new DeleteResult();
204
            for (RemoveDescriptionsFromDescriptiveDataSetConfigurator config: matrix.getDescriptionsToDelete().keySet()){
205
               result.includeResult(CdmStore.getService(IDescriptiveDataSetService.class).removeDescriptions(matrix.getDescriptionsToDelete().get(config), matrix.getDescriptiveDataSet().getUuid(), config));
206
            }
203 207
            matrix.getDescriptionsToDelete().clear();
204 208
        }
205 209
        List<MergeResult<DescriptionBase>> results = CdmStore.getService(IDescriptionService.class).mergeDescriptions(descriptions, matrix.getDescriptiveDataSet().getUuid(), true);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/handler/DeleteDescriptionHandler.java
17 17
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
18 18
import org.eclipse.e4.ui.services.IServiceConstants;
19 19
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.swt.widgets.Shell;
20 21

  
22
import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
21 23
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
22 24
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
23 25
import eu.etaxonomy.cdm.model.description.DescriptionBase;
......
27 29
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper;
28 30
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
29 31
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart;
32
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
33
import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
30 34

  
31 35
/**
32 36
 *  @author k.luther
......
36 40
public class DeleteDescriptionHandler{
37 41

  
38 42
    @Execute
39
    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, UISynchronize sync) {
43
    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
44
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
45
            UISynchronize sync) {
40 46
        CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject();
41 47
//        if(StoreUtil.promptCheckIsDirty(matrixPart)){
42 48
//            return;
......
44 50
        DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet();
45 51
        RowWrapperDTO wrapper = (RowWrapperDTO) matrixPart.getSelection().getFirstElement();
46 52
        DescriptionBase description = wrapper.getDescription().getDescription();
53
        RemoveDescriptionsFromDescriptiveDataSetConfigurator deleteConfig = new RemoveDescriptionsFromDescriptiveDataSetConfigurator();
47 54

  
55
        if (!DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfig, shell, Messages.DeleteDescriptiveDataSetHandler_DELETE_TITLE,  Messages.CharacterMatrix_DELETE_DESCRIPTION)){
56
            return;
57
        }
48 58
        boolean ok = matrixPart.getMatrix().getDescriptions().remove(wrapper);
49
        matrixPart.getMatrix().addDescriptionToDelete(description.getUuid());
59
        matrixPart.getMatrix().addDescriptionToDelete(description.getUuid(), deleteConfig);
50 60
        if (description instanceof SpecimenDescription){
51 61
            UuidAndTitleCache<SpecimenOrObservationBase> uuidAndTitleCache = new UuidAndTitleCache<>(((SpecimenRowWrapperDTO)wrapper).getSpecimen().getUuid(), ((SpecimenRowWrapperDTO)wrapper).getSpecimen().getId(), ((SpecimenRowWrapperDTO)wrapper).getSpecimen().getTitleCache());
52 62
            SpecimenNodeWrapper nodeWrapper = new SpecimenNodeWrapper(uuidAndTitleCache,
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/Messages.java
320 320
    public static String NameFactsDataView_Lable;
321 321
    public static String DeleteDescriptiveDatasetHandler_Warning_Message;
322 322
    public static String DeleteDescriptiveDatasetHandler_Exception_Message;
323
    public static String CharacterMatrix_ONLY_REMOVE;
324
    public static String CharacterMatrix_DELETE_DESCRIPTION;
323 325

  
324 326
    static {
325 327
        // initialize resource bundle
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages.properties
214 214
CharacterMatrix_SHOW_HIERARCHY=Show taxon hierarchy
215 215
CharacterMatrix_TAXON=Unit
216 216
CharacterMatrix_VIEW_CONFIG=View configuration
217
CharacterMatrix_ONLY_REMOVE=Only remove from descriptive dataset
218
CharacterMatrix_DELETE_DESCRIPTION=Do you really want to delete the description
217 219
CharacterMatrixBottomToolbar_AGGREGATE=Aggregate
218 220
CharacterMatrixBottomToolbar_AGGREGATION_MESSAGE=The aggregated description will be stored at the common parent taxon of this data set:\n%s\n\nDo you want to use this taxon?
219 221
CharacterMatrixBottomToolbar_AGGREGATION_TITLE=Choose location for the aggregated description
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages_de.properties
213 213
CharacterMatrix_SHOW_HIERARCHY=Baumansicht
214 214
CharacterMatrix_TAXON=Unit
215 215
CharacterMatrix_VIEW_CONFIG=Ansicht konfigurieren
216
CharacterMatrix_ONLY_REMOVE=Nur aus Descriptive Data Set entfernen
217
CharacterMatrix_DELETE_DESCRIPTION=Wollen Sie die Beschreibung wirklich l?schen?
216 218
CharacterMatrixBottomToolbar_AGGREGATE=Aggregation
217 219
CharacterMatrixBottomToolbar_AGGREGATION_MESSAGE=Die aggregierte Beschreibung wird an das gemeinsame, n?chst-h?here Taxon dieses Datasets gehangen:\n%s\n\nSoll dieses Taxon verwenden werden?
218 220
CharacterMatrixBottomToolbar_AGGREGATION_TITLE=W?hlen Sie den Speicherort f?r die aggregierte Beschreibung
......
253 255
DeleteDescriptiveDataSetHandler_DELETE_FAILED_MESSAGE=L?schen fehlgeschlagen.
254 256
DeleteDescriptiveDataSetHandler_DELETE_FAILED_TITLE=L?schen fehlgeschlagen
255 257
DeleteDescriptiveDataSetHandler_DELETE_MESSAGE=Wollen Sie wirklich den deskriptiven Datensatz l?schen?
258
DeleteDescriptiveDataSetHandler_DELETE_SELECTION=W?hlen Sie welche Beschreibungen komplett gel?scht werden sollen (nicht ausgew?hlte Beschreibungen verbleiben in der Datenbank und verkn?pft mit ihrem Beleg/Taxon)
256 259
DeleteDescriptiveDataSetHandler_DELETE_TITLE=L?schen best?tigen
257 260
DeleteHandler_CONFIRM_DELETION=L?schen best?tigen
258 261
DeleteHandler_CONFIRM_DELETION_MESSAGE=Wollen sie die Mediendaten wirklich l?schen?
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
287 287
    public static String DeleteConfiguration_descriptiveDataSet_deleteAllLiteratureDesc;
288 288
    public static String DeleteConfiguration_descriptiveDataSet_deleteAllDefaultDesc;
289 289
    public static String DeleteConfiguration_descriptiveDataSet_deleteAllAggregatedDesc;
290
    public static String DeleteConfiguration_descriptiveDataSet_deleteSelection;
290 291

  
291 292

  
292 293

  
......
729 730

  
730 731
    public static String AggregationWizardPage_WITHOUT_CHILDREN;
731 732

  
733
    public static String DeleteConfiguration_descriptionFromDescriptiveDataSet_onlyRemove;
734

  
732 735
    static {
733 736
        // initialize resource bundle
734 737
        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
224 224
DeleteConfiguration_descriptiveDataSet_deleteAllLiteratureDesc=Literature descriptions
225 225
DeleteConfiguration_descriptiveDataSet_deleteAllDefaultDesc=Default descriptions
226 226
DeleteConfiguration_descriptiveDataSet_deleteAllAggregatedDesc=Aggregated descriptions
227
DeleteConfiguration_descriptiveDataSet_deleteSelection=Fully delete the following related descriptions\nUnchecked descriptions stay in the database attached to their taxa/specimens:
227 228

  
229
DeleteConfiguration_descriptionFromDescriptiveDataSet_onlyRemove=Remove description only from descriptive dataset
228 230
NewGrantedAuthority_AlreadyInDb=The granted authority already exists.
229 231

  
230 232
SetSecundumConfiguration_IncludeAcceptedTaxa=Include accepted taxa
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
222 222
DeleteConfiguration_descriptiveDataSet_deleteAllSpecimenDesc=Specimen Beschreibungen
223 223
DeleteConfiguration_descriptiveDataSet_deleteAllLiteratureDesc=Literatur Beschreibungen
224 224
DeleteConfiguration_descriptiveDataSet_deleteAllDefaultDesc=Default Beschreibungen
225
DeleteConfiguration_descriptiveDataSet_deleteAllAggregatedDesc=Aggregierten Beschreibungen 
225
DeleteConfiguration_descriptiveDataSet_deleteAllAggregatedDesc=Aggregierte Beschreibungen 
226
DeleteConfiguration_descriptiveDataSet_deleteSelection=W?hlen Sie welche Beschreibungen komplett gel?scht werden sollen\nNicht ausgew?hlte Beschreibungen verbleiben in der Datenbank und verkn?pft mit ihrem Beleg/Taxon:
226 227

  
228
DeleteConfiguration_descriptionFromDescriptiveDataSet_onlyRemove=Entferne Beschriebungen nur aus dem Descriptive Dataset
227 229
NewGrantedAuthority_AlreadyInDb=Die GrantedAuthority ist bereits in der DB enthalten.
228 230

  
229 231
SetSecundumConfiguration_IncludeAcceptedTaxa=Anwenden auf akzeptierte Taxa
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/deleteConfigurator/DeleteConfiguratorDialog.java
20 20
import eu.etaxonomy.cdm.api.service.config.DeleteDescriptiveDataSetConfigurator;
21 21
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
22 22
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
23
import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
23 24
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
24 25
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
25 26
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
......
67 68
            composite.addConfiguratorComposite(new DeleteMediaConfiguratorComposite((MediaDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE, fromBulkEditor));
68 69
        } else if(configurator instanceof DeleteDescriptiveDataSetConfigurator){
69 70
            composite.addConfiguratorComposite(new DeleteDescriptiveDatasetConfiguratorComposite((DeleteDescriptiveDataSetConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
71
        }else if(configurator instanceof RemoveDescriptionsFromDescriptiveDataSetConfigurator){
72
            composite.addConfiguratorComposite(new DeleteDescriptionFromDescriptiveDatasetConfiguratorComposite((RemoveDescriptionsFromDescriptiveDataSetConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
70 73
        }
71 74

  
72 75

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/deleteConfigurator/DeleteDescriptionFromDescriptiveDatasetConfiguratorComposite.java
1
/**
2
* Copyright (C) 2020 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator;
10

  
11
import org.eclipse.core.databinding.DataBindingContext;
12
import org.eclipse.core.databinding.beans.PojoProperties;
13
import org.eclipse.core.databinding.observable.value.IObservableValue;
14
import org.eclipse.jface.databinding.swt.WidgetProperties;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.DisposeEvent;
17
import org.eclipse.swt.events.DisposeListener;
18
import org.eclipse.swt.layout.RowLayout;
19
import org.eclipse.swt.widgets.Button;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Display;
22
import org.eclipse.ui.forms.widgets.FormToolkit;
23

  
24
import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
25
import eu.etaxonomy.taxeditor.l10n.Messages;
26

  
27
/**
28
 * @author k.luther
29
 * @since Jun 19, 2020
30
 */
31
public class DeleteDescriptionFromDescriptiveDatasetConfiguratorComposite extends Composite{
32

  
33
    private final DataBindingContext m_bindingContext;
34

  
35
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
36
    private final RemoveDescriptionsFromDescriptiveDataSetConfigurator configurator;
37
    private Button btnOnlyRemoveFromDataset;
38

  
39
    public DeleteDescriptionFromDescriptiveDatasetConfiguratorComposite(RemoveDescriptionsFromDescriptiveDataSetConfigurator configurator, Composite parent, int style) {
40
        super(parent, style);
41

  
42
        this.configurator = configurator;
43
        addDisposeListener(new DisposeListener() {
44
            @Override
45
            public void widgetDisposed(DisposeEvent e) {
46
                toolkit.dispose();
47
            }
48
        });
49
        toolkit.paintBordersFor(this);
50
        setLayout(new RowLayout(SWT.VERTICAL));
51
        setBackground(getBackground());
52

  
53

  
54

  
55

  
56
        btnOnlyRemoveFromDataset = new Button(this, SWT.CHECK);
57
        btnOnlyRemoveFromDataset.setText(Messages.DeleteConfiguration_descriptionFromDescriptiveDataSet_onlyRemove);
58
        btnOnlyRemoveFromDataset.setEnabled(true);
59
        btnOnlyRemoveFromDataset.setSelection(configurator.isOnlyRemoveDescriptionsFromDataSet());
60
        m_bindingContext = initDataBindings();
61
    }
62

  
63
    protected DataBindingContext initDataBindings() {
64
        DataBindingContext bindingContext = new DataBindingContext();
65

  
66
        IObservableValue observeSelectionBtnDeleteAllSpecimen = WidgetProperties.selection().observe(btnOnlyRemoveFromDataset);
67
        IObservableValue deleteAllSpecimenConfiguratorObserveValue = PojoProperties.value("onlyRemoveDescriptionsFromDataSet").observe(configurator);
68
        bindingContext.bindValue(observeSelectionBtnDeleteAllSpecimen, deleteAllSpecimenConfiguratorObserveValue, null, null);
69
        return bindingContext;
70
    }
71

  
72
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/deleteConfigurator/DeleteDescriptiveDatasetConfiguratorComposite.java
19 19
import org.eclipse.swt.widgets.Button;
20 20
import org.eclipse.swt.widgets.Composite;
21 21
import org.eclipse.swt.widgets.Display;
22
import org.eclipse.swt.widgets.Label;
22 23
import org.eclipse.ui.forms.widgets.FormToolkit;
23 24

  
24 25
import eu.etaxonomy.cdm.api.service.config.DeleteDescriptiveDataSetConfigurator;
......
55 56
        setLayout(new RowLayout(SWT.VERTICAL));
56 57
        setBackground(getBackground());
57 58

  
58

  
59
        Label lblDelete = new Label(this, SWT.NONE);
60
        lblDelete.setText(Messages.DeleteConfiguration_descriptiveDataSet_deleteSelection);
59 61

  
60 62

  
61 63
        btnDeleteAllSpecimenDescriptions = new Button(this, SWT.CHECK);

Also available in: Unified diff