From cf077ed7f9ee413d3dea76a6c00dc346e601ff87 Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Thu, 14 Nov 2013 12:14:59 -0600 Subject: [PATCH] Issue #2538 - Check for existing adhoc queries in registry. Peer review comments Change-Id: I95ca889847b230bf5bb93302dfe956593846f1b0 Former-commit-id: 87a4b1bec424f7bd1ee1017300590b0a1a5fdb09 [formerly 87a4b1bec424f7bd1ee1017300590b0a1a5fdb09 [formerly 5fe100c7b1397373c91ac02bf7a6c7c1778fd19a]] Former-commit-id: a80964bc7c6fa3cbc132c31fa9392e92b87691bf Former-commit-id: 4557a06f4237e91b987b1f8b35060bc3bbfa2f20 --- .../subscription/FileNameDlg.java | 37 ++++++++++--------- .../subscription/subset/SubsetManagerDlg.java | 19 ++++++++++ 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/FileNameDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/FileNameDlg.java index 46ba0d9817..eea35962ea 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/FileNameDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/FileNameDlg.java @@ -45,6 +45,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * Mar 16, 2012 mpduff Initial creation. * Dec 17, 2012 1434 mpduff Don't allow underscores in name. + * Nov 14, 2013 2538 mpduff Check for same name entered. * * * @@ -159,23 +160,25 @@ public class FileNameDlg extends CaveSWTDialog { * OK Button action handler. */ private boolean handleOk() { - if ((nameTxt.getText() != null) && (!nameTxt.getText().isEmpty()) - && (!nameTxt.getText().contains("_"))) { - setReturnValue(nameTxt.getText()); - return true; - } else { - String title; - String message; - if (nameTxt.getText() == null || nameTxt.getText().isEmpty()) { - title = "Name Required"; - message = "Name required. A Subscription Name must be entered."; - } else { - title = "Name Invalid"; - message = "Underscore is not a valid character for a subscription name."; - } + String name = nameTxt.getText().trim(); - DataDeliveryUtils.showMessage(getShell(), SWT.OK, title, message); - return false; + String title; + String message; + if (name == null || name.isEmpty()) { + title = "Name Required"; + message = "Name required. A Subscription Name must be entered."; + } else if (name.equals(origName)) { + title = "Different Name Required"; + message = "A different name must be used."; + } else if (name.contains("_") || name.contains(" ")) { + title = "Name Invalid"; + message = "Underscore/space is not a valid character for a subscription name."; + } else { + setReturnValue(name); + return true; } + + DataDeliveryUtils.showMessage(getShell(), SWT.OK, title, message); + return false; } -} +} \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/subset/SubsetManagerDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/subset/SubsetManagerDlg.java index 621442a3a5..51b43c4f02 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/subset/SubsetManagerDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/subset/SubsetManagerDlg.java @@ -54,10 +54,12 @@ import com.raytheon.uf.common.datadelivery.registry.PointDataSet; import com.raytheon.uf.common.datadelivery.registry.SiteSubscription; import com.raytheon.uf.common.datadelivery.registry.Subscription; import com.raytheon.uf.common.datadelivery.registry.Time; +import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler; import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission; import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.common.registry.ebxml.RegistryUtil; import com.raytheon.uf.common.registry.handler.RegistryHandlerException; +import com.raytheon.uf.common.registry.handler.RegistryObjectHandlers; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -133,6 +135,7 @@ import com.raytheon.viz.ui.presenter.IDisplay; * Oct 15, 2013 2477 mpduff Remove debug code. * Oct 23, 2013 2484 dhladky Unique ID for subscriptions updated. * Oct 25, 2013 2292 mpduff Move overlap processing to edex. + * Nov 14, 2013 2538 mpduff Added check for duplicate subscription. * * * @author mpduff @@ -498,6 +501,22 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements boolean valid = this.validated(false); if (valid) { + // Check for existing subscription + ISubscriptionHandler handler = RegistryObjectHandlers + .get(ISubscriptionHandler.class); + try { + if (handler.getByName(nameText.getText()) != null) { + String message = "A query with this name already exists.\n\nPlease enter a different query name."; + DataDeliveryUtils.showMessage(getShell(), SWT.ERROR, + "Duplicate Query Name", message); + return; + } + } catch (RegistryHandlerException e) { + statusHandler + .handle(Priority.PROBLEM, + "Unable to check for an existing subscription by name.", + e); + } AdhocSubscription as = createSubscription(new AdhocSubscription(), Network.OPSNET);