Issue #2538 - Add AdhocSubscripionHander to SubscriptionHandler. Fix problem querying for adhoc subs.

Former-commit-id: 5fc6b9fcc55b6e93c9837c7b99347df8f28fc90a
This commit is contained in:
Mike Duff 2014-01-20 16:52:00 -06:00 committed by Gerrit Code Review
parent ae45dee861
commit bdf6a002f6
9 changed files with 309 additions and 26 deletions

View file

@ -18,6 +18,12 @@
<property name="registryHandler" ref="registryHandler" />
</bean>
</constructor-arg>
<constructor-arg>
<bean
class="com.raytheon.uf.common.datadelivery.registry.handlers.AdhocSubscriptionHandler">
<property name="registryHandler" ref="registryHandler" />
</bean>
</constructor-arg>
</bean>
<bean name="PendingSubscriptionHandler"

View file

@ -21,7 +21,11 @@ package com.raytheon.uf.viz.datadelivery.handlers;
import java.util.List;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.SharedSubscription;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionDeleteRequest;
import com.raytheon.uf.common.datadelivery.registry.handlers.IAdhocSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISharedSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISiteSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
@ -46,6 +50,7 @@ import com.raytheon.uf.common.serialization.comm.RequestRouter;
* Mar 29, 2013 1841 djohnson Composes a userSubscriptionsHandler.
* Apr 05, 2013 1841 djohnson Add shared subscription support.
* May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription.
* Jan 20, 2014 2538 mpduff Added the doesNameExist method.
*
* </pre>
*
@ -62,8 +67,10 @@ public class VizSubscriptionHandler extends SubscriptionHandler {
*/
public VizSubscriptionHandler(
ISiteSubscriptionHandler siteSubscriptionHandler,
ISharedSubscriptionHandler sharedSubscriptionHandler) {
super(siteSubscriptionHandler, sharedSubscriptionHandler);
ISharedSubscriptionHandler sharedSubscriptionHandler,
IAdhocSubscriptionHandler adhocSubscriptionHandler) {
super(siteSubscriptionHandler, sharedSubscriptionHandler,
adhocSubscriptionHandler);
}
/**
@ -72,7 +79,7 @@ public class VizSubscriptionHandler extends SubscriptionHandler {
@Override
public void deleteByIds(String username, List<String> ids)
throws RegistryHandlerException {
SubscriptionDeleteRequest request = new SubscriptionDeleteRequest(ids,
ISubscriptionHandler.class, username);
@ -85,4 +92,40 @@ public class VizSubscriptionHandler extends SubscriptionHandler {
}
}
/**
* Does the name exist for the provided type of subscription?
*
* @param name
* The subscription name to check
* @param clazzes
* List of subscription types
* @return true if the name exists for any of the provided types
* @throws RegistryHandlerException
*/
public boolean doesNameExist(String name, Class... clazzes)
throws RegistryHandlerException {
boolean found = false;
for (Class<?> clazz : clazzes) {
if (found) {
return true;
}
if (clazz == SiteSubscription.class) {
found = getSiteSubscriptionHandler().getByName(name) != null;
continue;
}
if (!found && clazz == SharedSubscription.class) {
found = getSharedSubscriptionHandler().getByName(name) != null;
continue;
}
if (!found && clazz == AdhocSubscription.class) {
found = getAdhocSubscriptionHandler().getByName(name) != null;
continue;
}
}
return found;
}
}

View file

@ -51,6 +51,7 @@ import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSet;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.PointDataSet;
import com.raytheon.uf.common.datadelivery.registry.SharedSubscription;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionType;
@ -68,6 +69,7 @@ import com.raytheon.uf.viz.core.VizAppTaskExecutor;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.datadelivery.common.xml.AreaXML;
import com.raytheon.uf.viz.datadelivery.filter.MetaDataManager;
import com.raytheon.uf.viz.datadelivery.handlers.VizSubscriptionHandler;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.subscription.CreateSubscriptionDlg;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService;
@ -139,6 +141,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Nov 14, 2013 2538 mpduff Added check for duplicate subscription.
* Nov 14, 2013 2548 mpduff Set the subscription type (QUERY OR RECURRING)
* Jan 14, 2014 2459 mpduff Change Subscription status code
* Jan 20, 2014 2538 mpduff Call doesNameExist method to check for dupes
* </pre>
*
* @author mpduff
@ -505,10 +508,13 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
if (valid) {
// Check for existing subscription
ISubscriptionHandler handler = RegistryObjectHandlers
VizSubscriptionHandler handler = (VizSubscriptionHandler) RegistryObjectHandlers
.get(ISubscriptionHandler.class);
String name = nameText.getText();
try {
if (handler.getByName(nameText.getText()) != null) {
if (handler.doesNameExist(name, SiteSubscription.class,
SharedSubscription.class, AdhocSubscription.class)) {
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);

View file

@ -0,0 +1,175 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.datadelivery.registry.handlers;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
/**
* Empty implementation for adhoc subscriptions.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 20, 2014 2538 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class EmptyAdhocSubscriptionHandler implements IAdhocSubscriptionHandler {
@Override
public AdhocSubscription getByName(String name)
throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public List<AdhocSubscription> getByNames(Collection<String> names)
throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public List<AdhocSubscription> getByOwner(String owner)
throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public List<AdhocSubscription> getByGroupName(String group)
throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public List<AdhocSubscription> getByFilters(String group, String officeId)
throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<String> getSubscribedToDataSetNames(String siteId)
throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public List<AdhocSubscription> getActive() throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public List<AdhocSubscription> getActiveForRoute(Network route)
throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public List<AdhocSubscription> getActiveForRoutes(Network... routes)
throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public AdhocSubscription getById(String id) throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public List<AdhocSubscription> getAll() throws RegistryHandlerException {
// TODO Auto-generated method stub
return null;
}
@Override
public void store(AdhocSubscription obj) throws RegistryHandlerException {
// TODO Auto-generated method stub
}
@Override
public void update(AdhocSubscription obj) throws RegistryHandlerException {
// TODO Auto-generated method stub
}
@Override
public void delete(AdhocSubscription obj) throws RegistryHandlerException {
// TODO Auto-generated method stub
}
@Override
public void deleteById(String username, String registryId)
throws RegistryHandlerException {
// TODO Auto-generated method stub
}
@Override
public void deleteByIds(String username, List<String> registryIds)
throws RegistryHandlerException {
// TODO Auto-generated method stub
}
@Override
public void delete(String username, AdhocSubscription obj)
throws RegistryHandlerException {
// TODO Auto-generated method stub
}
@Override
public void delete(Collection<AdhocSubscription> objects)
throws RegistryHandlerException {
// TODO Auto-generated method stub
}
@Override
public void delete(String username, Collection<AdhocSubscription> objects)
throws RegistryHandlerException {
// TODO Auto-generated method stub
}
}

View file

@ -58,6 +58,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
* May 29, 2013 1650 djohnson Fix ability to delete multiple types of subscriptions at once.
* May 31, 2013 1650 djohnson Fix ability to get shared subscriptions by id.
* Sep 11, 2013 2352 mpduff Add siteId to getSubscribedToDataSetNames method.
* Jan 20, 2014 2538 mpduff Added AdhocSubscriptionHandler.
*
* </pre>
*
@ -73,6 +74,8 @@ public class SubscriptionHandler implements ISubscriptionHandler {
private final ISharedSubscriptionHandler sharedSubscriptionHandler;
private final IAdhocSubscriptionHandler adhocSubscriptionHandler;
/**
* Constructor.
*
@ -83,9 +86,11 @@ public class SubscriptionHandler implements ISubscriptionHandler {
*/
public SubscriptionHandler(
ISiteSubscriptionHandler siteSubscriptionHandler,
ISharedSubscriptionHandler sharedSubscriptionHandler) {
ISharedSubscriptionHandler sharedSubscriptionHandler,
IAdhocSubscriptionHandler adhocSubscriptionHandler) {
this.siteSubscriptionHandler = siteSubscriptionHandler;
this.sharedSubscriptionHandler = sharedSubscriptionHandler;
this.adhocSubscriptionHandler = adhocSubscriptionHandler;
}
/**
@ -421,4 +426,25 @@ public class SubscriptionHandler implements ISubscriptionHandler {
}
}
}
/**
* @return the siteSubscriptionHandler
*/
public ISiteSubscriptionHandler getSiteSubscriptionHandler() {
return siteSubscriptionHandler;
}
/**
* @return the sharedSubscriptionHandler
*/
public ISharedSubscriptionHandler getSharedSubscriptionHandler() {
return sharedSubscriptionHandler;
}
/**
* @return the adhocSubscriptionHandler
*/
public IAdhocSubscriptionHandler getAdhocSubscriptionHandler() {
return adhocSubscriptionHandler;
}
}

View file

@ -17,6 +17,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
* ------------ ---------- ----------- --------------------------
* Mar 28, 2012 jspinks Initial creation
* Jun 21, 2012 736 djohnson Add thrift serialization annotations.
* Jan 20, 2014 2538 mpduff Override toString
*
* </pre>
*
@ -36,7 +37,7 @@ public class StringAttribute extends QueryableAttribute<String> {
* Create an StringAttribute with an 'in list' relation.
*
* @param values
* The values to query for.
* The values to query for.
*/
public StringAttribute(List<String> values) {
super(values);
@ -46,53 +47,53 @@ public class StringAttribute extends QueryableAttribute<String> {
* Create a StringAttribute with an equals relation.
*
* @param value
* The value to query for.
* The value to query for.
*/
public StringAttribute(String value) {
super(value);
}
/**
* Create a StringAttribute with a 'like' relation.
*
* @param value
* The value to query for.
*
* The value to query for.
*
* @param isLike
* Specify whether or not comparison should be like.
* Specify whether or not comparison should be like.
*/
public StringAttribute(String value, boolean isLike) {
super(value, isLike);
}
/**
* Return the formatted text of this StringAttribute including
* the processing of a List and like values.
* Return the formatted text of this StringAttribute including the
* processing of a List and like values.
*
* @return The formatted value for this StringAttribute.
*/
@Override
public String getQueryValue() {
if (this.like) {
return "'%"+this.value+"%'";
}
else if (this.values != null) {
StringBuilder sb = new StringBuilder();
for (String t : this.values) {
sb.append("'"+t+"',");
return "'%" + this.value + "%'";
} else if (this.values != null) {
StringBuilder sb = new StringBuilder();
for (String t : this.values) {
sb.append("'" + t + "',");
}
String items = sb.toString();
return items.substring(0,items.length()-1);
return items.substring(0, items.length() - 1);
} else {
return "'"+this.value+"'";
return "'" + this.value + "'";
}
}
}
/**
* Return the type of slot used to contain the value. For
* StringAttribute that is "stringValue".
* Return the type of slot used to contain the value. For StringAttribute
* that is "stringValue".
*
* @return The type of value attribute the slot for this StringAttribute contains.
* @return The type of value attribute the slot for this StringAttribute
* contains.
*
* @see StringValueType
*/
@ -101,4 +102,13 @@ public class StringAttribute extends QueryableAttribute<String> {
return "stringValue";
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return this.value;
}
}

View file

@ -19,6 +19,12 @@
<property name="registryHandler" ref="registryHandler" />
</bean>
</constructor-arg>
<constructor-arg>
<bean
class="com.raytheon.uf.common.datadelivery.registry.handlers.EmptyAdhocSubscriptionHandler">
<property name="registryHandler" ref="registryHandler" />
</bean>
</constructor-arg>
</bean>
<util:list id="subscriptionRoutesToSchedule">

View file

@ -19,6 +19,11 @@
class="com.raytheon.uf.common.datadelivery.registry.handlers.EmptySharedSubscriptionHandler">
</bean>
</constructor-arg>
<constructor-arg>
<bean
class="com.raytheon.uf.common.datadelivery.registry.handlers.EmptyAdhocSubscriptionHandler">
</bean>
</constructor-arg>
</bean>
<util:list id="subscriptionRoutesToSchedule">

View file

@ -19,6 +19,12 @@
<property name="registryHandler" ref="registryHandler" />
</bean>
</constructor-arg>
<constructor-arg>
<bean
class="com.raytheon.uf.common.datadelivery.registry.handlers.AdhocSubscriptionHandler">
<property name="registryHandler" ref="registryHandler" />
</bean>
</constructor-arg>
</bean>
<bean name="PendingSubscriptionHandler"