Issue #2538 - Check for existing adhoc queries in registry.

Peer review comments

Change-Id: I95ca889847b230bf5bb93302dfe956593846f1b0

Former-commit-id: a80964bc7c [formerly 5fe100c7b1397373c91ac02bf7a6c7c1778fd19a]
Former-commit-id: 87a4b1bec4
This commit is contained in:
Mike Duff 2013-11-14 12:14:59 -06:00
parent adc30e817e
commit f6c4ca2bc0
2 changed files with 39 additions and 17 deletions

View file

@ -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.
*
* </pre>
*
@ -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;
}
}
}

View file

@ -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.
* </pre>
*
* @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);