Object input = composite.getTaxonNodeTree().getInput();
if(input!=null){
descriptiveDataSet.setTaxonSubtreeFilter(new HashSet<>());//clear existing filter
- Collection<TaxonNodeDto> taxonNodes = (Collection<TaxonNodeDto>) input;
- for (TaxonNodeDto taxonTreeNode : taxonNodes) {
- TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonTreeNode.getUuid());
- descriptiveDataSet.addTaxonSubtree(taxonNode);
+ Collection<TaxonNode> taxonNodes = (Collection<TaxonNode>) input;
+ for (TaxonNode taxonTreeNode : taxonNodes) {
+// TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonTreeNode.getUuid());
+ descriptiveDataSet.addTaxonSubtree(taxonTreeNode);
}
}
TermTree<Feature> characters = composite.getCharacters();
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
import eu.etaxonomy.cdm.api.service.UpdateResult;
+import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO;
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
private CharacterMatrixToolbar toolbar;
private DescriptionTreeFormat treeFormat;
- private List<UUID> descriptionUuidsToDelete;
+// private List<UUID> descriptionUuidsToDelete;
+ Map<RemoveDescriptionsFromDescriptiveDataSetConfigurator, List<UUID>> descriptionUuidsToDelete;
private List<SpecimenNodeWrapper> specimenToAdd;
part.setDirty();
}
- public List<UUID> getDescriptionsToDelete() {
+ public Map<RemoveDescriptionsFromDescriptiveDataSetConfigurator, List<UUID>> getDescriptionsToDelete() {
return descriptionUuidsToDelete;
}
- public void addDescriptionToDelete(UUID descriptionToDelete) {
+ public void addDescriptionToDelete(UUID descriptionToDelete, RemoveDescriptionsFromDescriptiveDataSetConfigurator config) {
if (descriptionUuidsToDelete == null){
- descriptionUuidsToDelete = new ArrayList();
+ descriptionUuidsToDelete = new HashMap<>();
+ }
+ if (descriptionUuidsToDelete.get(config) != null){
+ descriptionUuidsToDelete.get(config).add(descriptionToDelete);
+ }else{
+ List<UUID> uuidList = new ArrayList<>();
+ uuidList.add(descriptionToDelete);
+ this.descriptionUuidsToDelete.put(config, uuidList);
}
- this.descriptionUuidsToDelete.add(descriptionToDelete);
}
import eu.etaxonomy.cdm.api.service.DeleteResult;
import eu.etaxonomy.cdm.api.service.IDescriptionService;
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
+import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
import eu.etaxonomy.cdm.api.service.dto.DescriptionBaseDto;
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
// descriptions.removeAll(matrix.getRowsToSave().values());
matrix.getRowsToMerge().clear();
if (matrix.getDescriptionsToDelete() != null && !matrix.getDescriptionsToDelete().isEmpty()){
- DeleteResult result = CdmStore.getService(IDescriptiveDataSetService.class).removeDescriptions(matrix.getDescriptionsToDelete(), matrix.getDescriptiveDataSet().getUuid());
+ DeleteResult result = new DeleteResult();
+ for (RemoveDescriptionsFromDescriptiveDataSetConfigurator config: matrix.getDescriptionsToDelete().keySet()){
+ result.includeResult(CdmStore.getService(IDescriptiveDataSetService.class).removeDescriptions(matrix.getDescriptionsToDelete().get(config), matrix.getDescriptiveDataSet().getUuid(), config));
+ }
matrix.getDescriptionsToDelete().clear();
}
List<MergeResult<DescriptionBase>> results = CdmStore.getService(IDescriptionService.class).mergeDescriptions(descriptions, matrix.getDescriptiveDataSet().getUuid(), true);
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper;
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixPart;
+import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
/**
* @author k.luther
public class DeleteDescriptionHandler{
@Execute
- public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, UISynchronize sync) {
+ public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ UISynchronize sync) {
CharacterMatrixPart matrixPart = (CharacterMatrixPart) activePart.getObject();
// if(StoreUtil.promptCheckIsDirty(matrixPart)){
// return;
DescriptiveDataSet descriptiveDataSet = matrixPart.getDescriptiveDataSet();
RowWrapperDTO wrapper = (RowWrapperDTO) matrixPart.getSelection().getFirstElement();
DescriptionBase description = wrapper.getDescription().getDescription();
+ RemoveDescriptionsFromDescriptiveDataSetConfigurator deleteConfig = new RemoveDescriptionsFromDescriptiveDataSetConfigurator();
+ if (!DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfig, shell, Messages.DeleteDescriptiveDataSetHandler_DELETE_TITLE, Messages.CharacterMatrix_DELETE_DESCRIPTION)){
+ return;
+ }
boolean ok = matrixPart.getMatrix().getDescriptions().remove(wrapper);
- matrixPart.getMatrix().addDescriptionToDelete(description.getUuid());
+ matrixPart.getMatrix().addDescriptionToDelete(description.getUuid(), deleteConfig);
if (description instanceof SpecimenDescription){
UuidAndTitleCache<SpecimenOrObservationBase> uuidAndTitleCache = new UuidAndTitleCache<>(((SpecimenRowWrapperDTO)wrapper).getSpecimen().getUuid(), ((SpecimenRowWrapperDTO)wrapper).getSpecimen().getId(), ((SpecimenRowWrapperDTO)wrapper).getSpecimen().getTitleCache());
SpecimenNodeWrapper nodeWrapper = new SpecimenNodeWrapper(uuidAndTitleCache,
public static String NameFactsDataView_Lable;
public static String DeleteDescriptiveDatasetHandler_Warning_Message;
public static String DeleteDescriptiveDatasetHandler_Exception_Message;
+ public static String CharacterMatrix_ONLY_REMOVE;
+ public static String CharacterMatrix_DELETE_DESCRIPTION;
static {
// initialize resource bundle
CharacterMatrix_SHOW_HIERARCHY=Show taxon hierarchy
CharacterMatrix_TAXON=Unit
CharacterMatrix_VIEW_CONFIG=View configuration
+CharacterMatrix_ONLY_REMOVE=Only remove from descriptive dataset
+CharacterMatrix_DELETE_DESCRIPTION=Do you really want to delete the description
CharacterMatrixBottomToolbar_AGGREGATE=Aggregate
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?
CharacterMatrixBottomToolbar_AGGREGATION_TITLE=Choose location for the aggregated description
CharacterMatrix_SHOW_HIERARCHY=Baumansicht
CharacterMatrix_TAXON=Unit
CharacterMatrix_VIEW_CONFIG=Ansicht konfigurieren
+CharacterMatrix_ONLY_REMOVE=Nur aus Descriptive Data Set entfernen
+CharacterMatrix_DELETE_DESCRIPTION=Wollen Sie die Beschreibung wirklich löschen?
CharacterMatrixBottomToolbar_AGGREGATE=Aggregation
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?
CharacterMatrixBottomToolbar_AGGREGATION_TITLE=Wählen Sie den Speicherort für die aggregierte Beschreibung
DeleteDescriptiveDataSetHandler_DELETE_FAILED_MESSAGE=Löschen fehlgeschlagen.
DeleteDescriptiveDataSetHandler_DELETE_FAILED_TITLE=Löschen fehlgeschlagen
DeleteDescriptiveDataSetHandler_DELETE_MESSAGE=Wollen Sie wirklich den deskriptiven Datensatz löschen?
+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)
DeleteDescriptiveDataSetHandler_DELETE_TITLE=Löschen bestätigen
DeleteHandler_CONFIRM_DELETION=Löschen bestätigen
DeleteHandler_CONFIRM_DELETION_MESSAGE=Wollen sie die Mediendaten wirklich löschen?
public static String DeleteConfiguration_descriptiveDataSet_deleteAllLiteratureDesc;
public static String DeleteConfiguration_descriptiveDataSet_deleteAllDefaultDesc;
public static String DeleteConfiguration_descriptiveDataSet_deleteAllAggregatedDesc;
+ public static String DeleteConfiguration_descriptiveDataSet_deleteSelection;
public static String AggregationWizardPage_WITHOUT_CHILDREN;
+ public static String DeleteConfiguration_descriptionFromDescriptiveDataSet_onlyRemove;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
DeleteConfiguration_descriptiveDataSet_deleteAllLiteratureDesc=Literature descriptions
DeleteConfiguration_descriptiveDataSet_deleteAllDefaultDesc=Default descriptions
DeleteConfiguration_descriptiveDataSet_deleteAllAggregatedDesc=Aggregated descriptions
+DeleteConfiguration_descriptiveDataSet_deleteSelection=Fully delete the following related descriptions\nUnchecked descriptions stay in the database attached to their taxa/specimens:
+DeleteConfiguration_descriptionFromDescriptiveDataSet_onlyRemove=Remove description only from descriptive dataset
NewGrantedAuthority_AlreadyInDb=The granted authority already exists.
SetSecundumConfiguration_IncludeAcceptedTaxa=Include accepted taxa
DeleteConfiguration_descriptiveDataSet_deleteAllSpecimenDesc=Specimen Beschreibungen
DeleteConfiguration_descriptiveDataSet_deleteAllLiteratureDesc=Literatur Beschreibungen
DeleteConfiguration_descriptiveDataSet_deleteAllDefaultDesc=Default Beschreibungen
-DeleteConfiguration_descriptiveDataSet_deleteAllAggregatedDesc=Aggregierten Beschreibungen
+DeleteConfiguration_descriptiveDataSet_deleteAllAggregatedDesc=Aggregierte Beschreibungen
+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:
+DeleteConfiguration_descriptionFromDescriptiveDataSet_onlyRemove=Entferne Beschriebungen nur aus dem Descriptive Dataset
NewGrantedAuthority_AlreadyInDb=Die GrantedAuthority ist bereits in der DB enthalten.
SetSecundumConfiguration_IncludeAcceptedTaxa=Anwenden auf akzeptierte Taxa
import eu.etaxonomy.cdm.api.service.config.DeleteDescriptiveDataSetConfigurator;
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
composite.addConfiguratorComposite(new DeleteMediaConfiguratorComposite((MediaDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE, fromBulkEditor));
} else if(configurator instanceof DeleteDescriptiveDataSetConfigurator){
composite.addConfiguratorComposite(new DeleteDescriptiveDatasetConfiguratorComposite((DeleteDescriptiveDataSetConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
+ }else if(configurator instanceof RemoveDescriptionsFromDescriptiveDataSetConfigurator){
+ composite.addConfiguratorComposite(new DeleteDescriptionFromDescriptiveDatasetConfiguratorComposite((RemoveDescriptionsFromDescriptiveDataSetConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
}
--- /dev/null
+/**
+* Copyright (C) 2020 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.PojoProperties;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+
+/**
+ * @author k.luther
+ * @since Jun 19, 2020
+ */
+public class DeleteDescriptionFromDescriptiveDatasetConfiguratorComposite extends Composite{
+
+ private final DataBindingContext m_bindingContext;
+
+ private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
+ private final RemoveDescriptionsFromDescriptiveDataSetConfigurator configurator;
+ private Button btnOnlyRemoveFromDataset;
+
+ public DeleteDescriptionFromDescriptiveDatasetConfiguratorComposite(RemoveDescriptionsFromDescriptiveDataSetConfigurator configurator, Composite parent, int style) {
+ super(parent, style);
+
+ this.configurator = configurator;
+ addDisposeListener(new DisposeListener() {
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ toolkit.dispose();
+ }
+ });
+ toolkit.paintBordersFor(this);
+ setLayout(new RowLayout(SWT.VERTICAL));
+ setBackground(getBackground());
+
+
+
+
+ btnOnlyRemoveFromDataset = new Button(this, SWT.CHECK);
+ btnOnlyRemoveFromDataset.setText(Messages.DeleteConfiguration_descriptionFromDescriptiveDataSet_onlyRemove);
+ btnOnlyRemoveFromDataset.setEnabled(true);
+ btnOnlyRemoveFromDataset.setSelection(configurator.isOnlyRemoveDescriptionsFromDataSet());
+ m_bindingContext = initDataBindings();
+ }
+
+ protected DataBindingContext initDataBindings() {
+ DataBindingContext bindingContext = new DataBindingContext();
+
+ IObservableValue observeSelectionBtnDeleteAllSpecimen = WidgetProperties.selection().observe(btnOnlyRemoveFromDataset);
+ IObservableValue deleteAllSpecimenConfiguratorObserveValue = PojoProperties.value("onlyRemoveDescriptionsFromDataSet").observe(configurator);
+ bindingContext.bindValue(observeSelectionBtnDeleteAllSpecimen, deleteAllSpecimenConfiguratorObserveValue, null, null);
+ return bindingContext;
+ }
+
+}
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.FormToolkit;
import eu.etaxonomy.cdm.api.service.config.DeleteDescriptiveDataSetConfigurator;
setLayout(new RowLayout(SWT.VERTICAL));
setBackground(getBackground());
-
+ Label lblDelete = new Label(this, SWT.NONE);
+ lblDelete.setText(Messages.DeleteConfiguration_descriptiveDataSet_deleteSelection);
btnDeleteAllSpecimenDescriptions = new Button(this, SWT.CHECK);