eu.etaxonomy.taxeditor.navigation,
eu.etaxonomy.taxeditor.navigation.internal,
eu.etaxonomy.taxeditor.navigation.key.polytomous,
+ eu.etaxonomy.taxeditor.navigation.key.polytomous.operation,
eu.etaxonomy.taxeditor.navigation.navigator,
eu.etaxonomy.taxeditor.navigation.navigator.operation,
eu.etaxonomy.taxeditor.navigation.search
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2015 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.navigation.key.polytomous;
+
+/**
+ * @author cmathew
+ * @date 25 Jun 2015
+ *
+ */
+public interface PolytomousKeyViewLabels {
+
+ public static final String DELETE_POLYTOMOUS_KEY_LABEL = "Delete Polytomous Key";
+
+}
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.part.ViewPart;
-import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
conversation = CdmStore.createConversation();
conversation.registerForDataStoreChanges(this);
cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
- CdmApplicationState.getCurrentDataChangeService().register(this);
+
List<PolytomousKey> input = CdmStore.getService(IPolytomousKeyService.class).list(PolytomousKey.class, null, null, null, null);
if(!viewer.getControl().isDisposed()){
viewer.setInput(input);
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2015 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.navigation.key.polytomous.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import eu.etaxonomy.cdm.model.description.PolytomousKey;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewLabels;
+import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.RemotingPolytomousKeyDeleteOperation;
+import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+
+/**
+ * @author cmathew
+ * @date 25 Jun 2015
+ *
+ */
+public class RemotingPolytomousKeyDeleteHandler extends RemotingCdmHandler {
+
+ List<PolytomousKey> keysToDelete;
+ /**
+ * @param label
+ */
+ public RemotingPolytomousKeyDeleteHandler() {
+ super(PolytomousKeyViewLabels.DELETE_POLYTOMOUS_KEY_LABEL);
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public IStatus allowOperations(ExecutionEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
+
+ keysToDelete = selection.toList();
+
+ if(keysToDelete.isEmpty()){
+ return Status.CANCEL_STATUS;
+ }
+
+ boolean confirmation = MessagingUtils.confirmDialog("Confirm deletaion", "Do you want to delete the selected key" + (keysToDelete.size() == 1 ? "" : "s") + "?");
+
+ if(!confirmation) {
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public AbstractOperation prepareOperation(ExecutionEvent event) {
+ return new RemotingPolytomousKeyDeleteOperation(event.getTrigger(),
+ false,
+ keysToDelete);
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
+ */
+ @Override
+ public void onComplete() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2015 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.navigation.key.polytomous.operation;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
+import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
+import eu.etaxonomy.cdm.api.service.UpdateResult;
+import eu.etaxonomy.cdm.model.description.PolytomousKey;
+import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author cmathew
+ * @date 25 Jun 2015
+ *
+ */
+public class RemotingPolytomousKeyDeleteOperation extends RemotingCdmUpdateOperation {
+
+ private final static String LABEL = "Delete Polytomous Key operation";
+
+ private final List<PolytomousKey> keysToDelete;
+ /**
+ * @param label
+ * @param action
+ * @param source
+ * @param async
+ */
+ public RemotingPolytomousKeyDeleteOperation(Object source,
+ boolean async,
+ List<PolytomousKey> keysToDelete) {
+ super(LABEL, Action.Delete, source, async);
+ this.keysToDelete = keysToDelete;
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation#doUpdateExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
+ UpdateResult result = new UpdateResult();
+ for(PolytomousKey key : keysToDelete) {
+ UpdateResult updateResult = CdmStore.getService(IPolytomousKeyService.class).delete(key.getUuid());
+ if(updateResult.isAbort()) {
+ result.setStatus(updateResult.getStatus());
+ result.addExceptions(updateResult.getExceptions());
+ return result;
+ }
+ if(updateResult.isError()) {
+ result.setStatus(updateResult.getStatus());
+ result.addExceptions(updateResult.getExceptions());
+ }
+ }
+ return result;
+ }
+
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2015 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.cdm.model;
+
+import eu.etaxonomy.taxeditor.operations.BaseOperationTest;
+
+/**
+ * @author cmathew
+ * @date 25 Jun 2015
+ *
+ */
+public class PolytomousKeyListEditorTest extends BaseOperationTest {
+
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2015 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.cdm.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.junit.Assert;
+import org.junit.Test;
+
+import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
+import eu.etaxonomy.cdm.model.description.PolytomousKey;
+import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.RemotingPolytomousKeyDeleteOperation;
+import eu.etaxonomy.taxeditor.operations.BaseOperationTest;
+
+/**
+ * @author cmathew
+ * @date 25 Jun 2015
+ *
+ */
+public class PolytomousKeyViewPartTest extends BaseOperationTest {
+
+ IPolytomousKeyService polytomousKeyService = getRemoteApplicationController().getPolytomousKeyService();
+
+ @Test
+ public void testDeletePolytomousKey() throws ExecutionException {
+ List<PolytomousKey> pKeysBeforeDelete = polytomousKeyService.list(PolytomousKey.class, null, null, null, null);
+ int initialCount = pKeysBeforeDelete.size();
+
+ List<PolytomousKey> keysToDelete = new ArrayList<PolytomousKey>();
+ keysToDelete.add(polytomousKeyService.load(UUID.fromString("f82cef88-5a9e-4917-9938-d08bda40836f")));
+ keysToDelete.add(polytomousKeyService.load(UUID.fromString("a00ca7ec-b660-433c-bd14-596826ab2243")));
+ keysToDelete.add(polytomousKeyService.load(UUID.fromString("197bc542-bf5b-4a52-aa66-c65df32c196b")));
+
+ int keysToDeleteCount = keysToDelete.size();
+ operation = new RemotingPolytomousKeyDeleteOperation(sessionOwner,
+ false,
+ keysToDelete);
+ operation.execute(monitor, info);
+
+ List<PolytomousKey> pKeysAfterDelete = polytomousKeyService.list(PolytomousKey.class, null, null, null, null);
+ Assert.assertEquals(initialCount - keysToDeleteCount, pKeysAfterDelete.size());
+ for(PolytomousKey key : keysToDelete) {
+ Assert.assertFalse(pKeysAfterDelete.contains(key));
+ }
+
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?><!--
+ generated by Jailer 4.3, Thu Jun 25 16:36:00 CEST 2015 from cmathew@cmbgbm-t530
+
+ Extraction Model: PolytomousKey where id = 90 or id = 111 or id = 112 or id = 113 or id = 114 or id = 115 or id = 116 (extractionmodel/by-example/SbE-PolytomousKey-16-34-36-489.csv)
+ Database URL: jdbc:mysql://127.0.0.1:3306/local-cyprus
+ Database User: root
+
+ Exported Rows: 7
+ PolytomousKey 7
+
+--><dataset>
+ <PolytomousKey id="90" created="2012-11-23 19:53:37.0" uuid="f82cef88-5a9e-4917-9938-d08bda40836f" protectedtitlecache="true" titleCache="Cleome" root_id="100" startNumber="1"/>
+ <PolytomousKey id="111" created="2013-02-15 16:26:38.0" uuid="a00ca7ec-b660-433c-bd14-596826ab2243" protectedtitlecache="true" titleCache="Ammi" root_id="124" startNumber="1"/>
+ <PolytomousKey id="112" created="2013-02-15 16:31:54.0" uuid="197bc542-bf5b-4a52-aa66-c65df32c196b" protectedtitlecache="true" titleCache="Adonis" root_id="127" startNumber="1"/>
+ <PolytomousKey id="113" created="2013-02-15 16:50:59.0" uuid="2ebacbb0-13f4-4407-8579-d5968e09a905" protectedtitlecache="true" titleCache="Enarthrocarpus" root_id="134" startNumber="1"/>
+ <PolytomousKey id="114" created="2013-02-15 16:54:31.0" uuid="0426418c-5b76-4c19-8177-6bebb4d37329" protectedtitlecache="true" titleCache="Glaucium" root_id="137" startNumber="1"/>
+ <PolytomousKey id="115" created="2013-02-15 17:05:42.0" uuid="6aa69b73-6242-4d3d-85c9-485aab9b1975" protectedtitlecache="true" titleCache="Sagina" root_id="140" startNumber="1"/>
+ <PolytomousKey id="116" created="2013-02-15 17:09:43.0" uuid="cfe7626d-49cc-4dac-acbc-601825deb44a" protectedtitlecache="true" titleCache="Dianthus" root_id="143" startNumber="1"/>
+
+
+</dataset>