Merge branch 'development' into development_on_RHEL6

Conflicts:
	cots/org.jep.linux64/libjep.so

Former-commit-id: 49422aea62 [formerly 49422aea62 [formerly ecb1c0da101c986ef21bb8514660605926303a71]]
Former-commit-id: d08a652e23
Former-commit-id: adb62df96a
This commit is contained in:
Bryan Kowal 2013-10-31 15:43:29 -05:00
commit 70d4374ce8
114 changed files with 3616 additions and 2766 deletions

View file

@ -1,7 +1,4 @@
com.raytheon.uf.viz.collaboration.display.editor.CreateRemoteDisplay
com.raytheon.uf.viz.collaboration.display.roles.dataprovider.rsc.DataProviderRscData
com.raytheon.uf.viz.collaboration.display.rsc.CollaborationWrapperResourceData
com.raytheon.uf.viz.collaboration.display.rsc.event.SharedResource
com.raytheon.uf.viz.collaboration.display.rsc.event.ResourceCapabilityChanged
com.raytheon.uf.viz.collaboration.display.rsc.event.ResourcePropertiesChanged
com.raytheon.uf.viz.collaboration.display.rsc.telestrator.CollaborationDrawingResourceData
com.raytheon.uf.viz.collaboration.display.rsc.event.ResourcePropertiesChanged

View file

@ -1,7 +1 @@
com.raytheon.uf.viz.core.maps.rsc.MapResourceGroupData
com.raytheon.uf.viz.core.maps.rsc.DbMapResourceData
com.raytheon.uf.viz.core.maps.rsc.DbPointMapResourceData
com.raytheon.uf.viz.core.maps.MapStylePreferenceStore
com.raytheon.uf.viz.core.maps.display.MapRenderableDisplay
com.raytheon.uf.viz.core.maps.display.PlainMapRenderableDisplay
com.raytheon.uf.viz.core.maps.scales.MapScaleRenderableDisplay
com.raytheon.uf.viz.core.maps.MapStylePreferenceStore

View file

@ -154,6 +154,20 @@ public class ProcedureXmlManager {
}
}
/**
* Transofrm an object to XML and store it in the specified file.
*
* @param obj
* Object to store
* @param filePath
* file to store object in.
* @throws SerializationException
*/
public void marshalToFile(Object obj, String filePath)
throws SerializationException {
getManager().marshalToXmlFile(obj, filePath);
}
/**
* Transform some xml in a String to an object of the specified class.
*

View file

@ -1 +0,0 @@
com.raytheon.uf.viz.datadelivery.rsc.DrawBoxResourceData

View file

@ -22,7 +22,6 @@
<constructor-arg ref="subscriptionNotificationService" />
<constructor-arg ref="bandwidthService" />
<constructor-arg ref="permissionsService" />
<constructor-arg ref="subscriptionOverlapService" />
</bean>
<bean name="dataDeliveryServices"

View file

@ -57,9 +57,9 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.datadelivery.filter.MetaDataManager;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.subscription.GroupDefinitionManager;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService.ISubscriptionServiceResult;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.ForceApplyPromptResponse;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceApplyPromptDisplayText;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionServiceResult;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
import com.raytheon.viz.ui.presenter.IDisplay;
import com.raytheon.viz.ui.widgets.duallist.DualList;
@ -96,6 +96,7 @@ import com.raytheon.viz.ui.widgets.duallist.IUpdate;
* May 23, 2013 1650 djohnson Fix creation of new GroupDefinitions.
* May 28, 2013 1650 djohnson More information when failing to schedule subscriptions.
* Jun 13, 2013 2108 mpduff Refactored DataSizeUtils.
* Oct 28, 2013 2292 mpduff Change overlap services.
* </pre>
*
* @author jpiatt
@ -418,14 +419,14 @@ public class UserSelectComp extends Composite implements IUpdate, IDisplay,
}
try {
final ISubscriptionServiceResult result = DataDeliveryServices
final SubscriptionServiceResult result = DataDeliveryServices
.getSubscriptionService().updateWithPendingCheck(
new ArrayList<Subscription>(Sets.union(
groupSubscriptions,
removeFromGroupSubscriptions)), this);
if (result.hasMessageToDisplay()) {
DataDeliveryUtils.showMessage(getShell(), SWT.ICON_INFORMATION,
"Edit Group", result.getMessageToDisplay());
"Edit Group", result.getMessage());
}
} catch (RegistryHandlerException e) {
statusHandler.handle(Priority.PROBLEM,

View file

@ -40,6 +40,7 @@ import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService;
* Nov 09, 2012 1286 djohnson Initial creation
* May 20, 2013 2000 djohnson Add subscription overlap service.
* Jul 26, 2031 2232 mpduff Moved IPermissionsService to common.
* Oct 21, 2013 2292 mpduff Added generics.
*
* </pre>
*
@ -49,7 +50,7 @@ import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService;
public final class DataDeliveryServices {
private static IBandwidthService bandwidthService;
private static IBandwidthService<?, ?> bandwidthService;
private static ISubscriptionService subscriptionService;
@ -59,17 +60,17 @@ public final class DataDeliveryServices {
private static IGroupDefinitionService groupDefinitionService;
private static ISubscriptionOverlapService subscriptionOverlapService;
private static ISubscriptionOverlapService<?, ?> subscriptionOverlapService;
/**
* Spring only constructor. All access should be through static methods.
*/
private DataDeliveryServices(IBandwidthService bandwidthService,
private DataDeliveryServices(IBandwidthService<?, ?> bandwidthService,
ISubscriptionService subscriptionService,
ISubscriptionNotificationService subscriptionNotificationService,
IPermissionsService permissionsService,
IGroupDefinitionService groupDefinitionService,
ISubscriptionOverlapService subscriptionOverlapService) {
ISubscriptionOverlapService<?, ?> subscriptionOverlapService) {
DataDeliveryServices.bandwidthService = bandwidthService;
DataDeliveryServices.subscriptionService = subscriptionService;
DataDeliveryServices.subscriptionNotificationService = subscriptionNotificationService;
@ -92,7 +93,7 @@ public final class DataDeliveryServices {
*
* @return the bandwidthService
*/
public static IBandwidthService getBandwidthService() {
public static IBandwidthService<?, ?> getBandwidthService() {
return DataDeliveryServices.bandwidthService;
}
@ -128,7 +129,7 @@ public final class DataDeliveryServices {
*
* @return the subscriptionOverlapService
*/
public static ISubscriptionOverlapService getSubscriptionOverlapService() {
public static ISubscriptionOverlapService<?, ?> getSubscriptionOverlapService() {
return DataDeliveryServices.subscriptionOverlapService;
}
}

View file

@ -95,7 +95,6 @@ import com.raytheon.uf.viz.datadelivery.common.ui.DurationComp;
import com.raytheon.uf.viz.datadelivery.common.ui.GroupSelectComp;
import com.raytheon.uf.viz.datadelivery.common.ui.PriorityComp;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService.ISubscriptionServiceResult;
import com.raytheon.uf.viz.datadelivery.system.SystemRuleManager;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
@ -142,6 +141,7 @@ import com.raytheon.viz.ui.presenter.components.ComboBoxConf;
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
* Oct 15, 2013 2477 mpduff Fix bug in group settings.
* Oct 23, 2013 2484 dhladky Unique ID for subscriptions updated.
* Oct 21, 2013 2292 mpduff Close dialog on OK.
*
* </pre>
*
@ -526,7 +526,9 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
status = Status.OK;
getShell().setCursor(
getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
handleOkAction();
if (handleOkAction()) {
close();
}
} finally {
if (!getShell().isDisposed()) {
getShell().setCursor(null);
@ -1148,13 +1150,13 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
@Override
protected IStatus run(IProgressMonitor monitor) {
DataDeliveryGUIUtils.markBusyInUIThread(jobShell);
ISubscriptionServiceResult result = storeSubscription(
SubscriptionServiceResult result = storeSubscription(
subscription, username);
if (result != null) {
if (result.isAllowFurtherEditing()) {
return new Status(Status.CANCEL,
CreateSubscriptionDlg.class.getName(),
result.getMessageToDisplay());
result.getMessage());
} else {
SubscriptionStatusSummary sum = result
.getSubscriptionStatusSummary();
@ -1162,7 +1164,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
exchanger.add(sum);
return new Status(Status.OK,
CreateSubscriptionDlg.class.getName(),
result.getMessageToDisplay());
result.getMessage());
}
} else {
return new Status(Status.ERROR,
@ -1266,13 +1268,12 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
if (autoApprove) {
try {
final ISubscriptionServiceResult response = subscriptionService
final SubscriptionServiceResult response = subscriptionService
.update(subscription,
new CancelForceApplyAndIncreaseLatencyDisplayText(
"update", getShell()));
if (response.hasMessageToDisplay()) {
displayPopup(UPDATED_TITLE,
response.getMessageToDisplay());
displayPopup(UPDATED_TITLE, response.getMessage());
}
// If there was a force apply prompt, and the user
@ -1563,9 +1564,9 @@ public class CreateSubscriptionDlg extends CaveSWTDialog {
* the username
* @return true if the dialog can be closed, false otherwise
*/
private ISubscriptionServiceResult storeSubscription(
private SubscriptionServiceResult storeSubscription(
Subscription subscription, String username) {
ISubscriptionServiceResult result = null;
SubscriptionServiceResult result = null;
try {
result = subscriptionService.store(subscription,
new CancelForceApplyAndIncreaseLatencyDisplayText("create",

View file

@ -21,7 +21,6 @@ package com.raytheon.uf.viz.datadelivery.subscription;
import java.util.List;
import com.raytheon.uf.common.datadelivery.bandwidth.data.SubscriptionStatusSummary;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
@ -40,7 +39,7 @@ import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceA
* Nov 20, 2012 1286 djohnson Use IDisplay to display yes/no prompt.
* Nov 28, 2012 1286 djohnson Consolidate more notifications.
* Jul 18, 2013 1653 mpduff Added SubscriptionStatusSummary to ISubscriptionServiceResult
*
* Oct 25, 2013 2292 mpduff Move overlap checks to edex.
* </pre>
*
* @author djohnson
@ -48,42 +47,6 @@ import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceA
*/
public interface ISubscriptionService {
/**
* Contract for the return object of subscription service actions.
*/
public static interface ISubscriptionServiceResult {
/**
* Check whether further editing should occur.
*
* @return true if the UI should not be closed, and the user should be
* allowed to resubmit their action
*/
boolean isAllowFurtherEditing();
/**
* Check whether there is a message to display.
*
* @return true if there is a message to display
*/
boolean hasMessageToDisplay();
/**
* Return the message to display. Should not be called unless
* {@link #hasMessageToDisplay()} returns true.
*
* @return the message to display
*/
String getMessageToDisplay();
/**
* Get the subscription status summary.
*
* @return The SubscriptionStatusSummary
*/
SubscriptionStatusSummary getSubscriptionStatusSummary();
}
/**
* Store the subscription.
*
@ -93,7 +56,7 @@ public interface ISubscriptionService {
* @return the result object
* @throws RegistryHandlerException
*/
ISubscriptionServiceResult store(Subscription subscription,
SubscriptionServiceResult store(Subscription subscription,
IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException;
@ -105,7 +68,7 @@ public interface ISubscriptionService {
* @param displayTextStrategy
* @return the result object
*/
ISubscriptionServiceResult update(Subscription subscription,
SubscriptionServiceResult update(Subscription subscription,
IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException;
@ -118,7 +81,7 @@ public interface ISubscriptionService {
* @return the result object
* @throws RegistryHandlerException
*/
ISubscriptionServiceResult update(List<Subscription> subscriptions,
SubscriptionServiceResult update(List<Subscription> subscriptions,
IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException;
@ -131,7 +94,7 @@ public interface ISubscriptionService {
* @return the result
* @throws RegistryHandlerException
*/
ISubscriptionServiceResult updateWithPendingCheck(
SubscriptionServiceResult updateWithPendingCheck(
List<Subscription> subscriptions,
IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException;
@ -147,7 +110,7 @@ public interface ISubscriptionService {
* @return the result object
* @throws RegistryHandlerException
*/
public ISubscriptionServiceResult store(AdhocSubscription sub,
public SubscriptionServiceResult store(AdhocSubscription sub,
IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException;
}

View file

@ -70,7 +70,6 @@ import com.raytheon.uf.viz.datadelivery.common.ui.ITableChange;
import com.raytheon.uf.viz.datadelivery.common.ui.TableCompConfig;
import com.raytheon.uf.viz.datadelivery.help.HelpManager;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService.ISubscriptionServiceResult;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceApplyPromptDisplayText;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionTableComp.SubscriptionType;
import com.raytheon.uf.viz.datadelivery.subscription.approve.SubscriptionApprovalDlg;
@ -128,6 +127,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Jun 14, 2013 2064 mpduff Check for null/disposed sort column.
* Jul 26, 2013 2232 mpduff Refactored Data Delivery permissions.
* Sep 25. 2013 2409 mpduff Add check for widget disposed after calling configuration.
* Oct 25, 2013 2292 mpduff Move overlap checks to edex.
* </pre>
*
* @author mpduff
@ -876,12 +876,12 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
sub.setActive(activate);
try {
ISubscriptionServiceResult response = subscriptionService
SubscriptionServiceResult response = subscriptionService
.update(sub, forceApplyPromptDisplayText);
if (response.hasMessageToDisplay()) {
DataDeliveryUtils.showMessage(getShell(),
SWT.OK, sub.getName() + " Activated",
response.getMessageToDisplay());
response.getMessage());
}
if (!response.isAllowFurtherEditing()) {

View file

@ -35,14 +35,12 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.raytheon.uf.common.auth.AuthException;
import com.raytheon.uf.common.auth.req.IPermissionsService;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthService;
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
import com.raytheon.uf.common.datadelivery.bandwidth.data.SubscriptionStatusSummary;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
@ -53,10 +51,12 @@ import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.registry.handlers.IPendingSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
import com.raytheon.uf.common.datadelivery.service.subscription.ISubscriptionOverlapService;
import com.raytheon.uf.common.datadelivery.service.subscription.ISubscriptionOverlapService.ISubscriptionOverlapResponse;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapRequest;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapResponse;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -93,6 +93,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
* Jul 26, 2013 2232 mpduff Refactored Data Delivery permissions.
* Sept 25, 2013 1797 dhladky separated time from gridded time
* Oct 12, 2013 2460 dhladky restored adhoc subscriptions to registry storage.
* Oct 22, 2013 2292 mpduff Removed subscriptionOverlapService.
*
* </pre>
*
@ -104,6 +105,11 @@ public class SubscriptionService implements ISubscriptionService {
private static final String PENDING_SUBSCRIPTION_AWAITING_APPROVAL = "The subscription is awaiting approval.\n\n"
+ "A notification message will be generated upon approval.";
private final String OVERLAPPING_SUBSCRIPTIONS = "The following subscriptions overlap with this one "
+ "and are candidates for a shared subscription: ";
private final String DUPLICATE_SUBSCRIPTIONS = "This subscription is completely fulfilled by ";
/**
* Implementation of {@link IDisplayForceApplyPrompt} that uses an SWT
* dialog.
@ -115,8 +121,6 @@ public class SubscriptionService implements ISubscriptionService {
/**
* {@inheritDoc}
*
* @param subscription
*/
@Override
public ForceApplyPromptResponse displayForceApplyPrompt(
@ -168,72 +172,6 @@ public class SubscriptionService implements ISubscriptionService {
private final IDisplayForceApplyPrompt forceApplyPrompt;
private final ISubscriptionOverlapService subscriptionOverlapService;
/**
* Implementation of {@link ISubscriptionServiceResult}.
*/
private final class SubscriptionServiceResult implements
ISubscriptionServiceResult {
private final boolean allowFurtherEditing;
private final String message;
private SubscriptionStatusSummary subStatusSummary;
private SubscriptionServiceResult(String message) {
this(false, message);
}
private SubscriptionServiceResult(boolean allowFurtherEditing,
String message) {
this.allowFurtherEditing = allowFurtherEditing;
this.message = message;
}
/**
* @param b
*/
public SubscriptionServiceResult(boolean allowFurtherEditing) {
this(allowFurtherEditing, null);
}
/**
* {@inheritDoc}
*/
@Override
public boolean isAllowFurtherEditing() {
return allowFurtherEditing;
}
/**
* {@inheritDoc}
*/
@Override
public boolean hasMessageToDisplay() {
return message != null;
}
/**
* {@inheritDoc}
*/
@Override
public String getMessageToDisplay() {
return message;
}
@Override
public SubscriptionStatusSummary getSubscriptionStatusSummary() {
return this.subStatusSummary;
}
public void setSubscriptionStatusSummary(
SubscriptionStatusSummary subscriptionStatusSummary) {
this.subStatusSummary = subscriptionStatusSummary;
}
}
/**
* Result class used internally to denote whether the user should be
* prompted, and any result messages.
@ -335,18 +273,15 @@ public class SubscriptionService implements ISubscriptionService {
* the subscription notification service
* @param bandwidthService
* the bandwidth service
* @param subscriptionOverlapService
*/
@VisibleForTesting
SubscriptionService(ISubscriptionNotificationService notificationService,
IBandwidthService bandwidthService,
IPermissionsService permissionsService,
ISubscriptionOverlapService subscriptionOverlapService,
IDisplayForceApplyPrompt displayForceApplyPrompt) {
this.notificationService = notificationService;
this.bandwidthService = bandwidthService;
this.permissionsService = permissionsService;
this.subscriptionOverlapService = subscriptionOverlapService;
this.forceApplyPrompt = displayForceApplyPrompt;
}
@ -364,18 +299,16 @@ public class SubscriptionService implements ISubscriptionService {
public static ISubscriptionService newInstance(
ISubscriptionNotificationService notificationService,
IBandwidthService bandwidthService,
IPermissionsService permissionsService,
ISubscriptionOverlapService subscriptionOverlapService) {
IPermissionsService permissionsService) {
return new SubscriptionService(notificationService, bandwidthService,
permissionsService, subscriptionOverlapService,
new DisplayForceApplyPrompt());
permissionsService, new DisplayForceApplyPrompt());
}
/**
* {@inheritDoc}
*/
@Override
public ISubscriptionServiceResult store(final Subscription subscription,
public SubscriptionServiceResult store(final Subscription subscription,
IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException {
@ -383,7 +316,6 @@ public class SubscriptionService implements ISubscriptionService {
final String successMessage = "Subscription " + subscription.getName()
+ " has been created.";
final ServiceInteraction action = new ServiceInteraction() {
@Override
public String call() throws RegistryHandlerException {
DataDeliveryHandlers.getSubscriptionHandler().store(
@ -395,7 +327,7 @@ public class SubscriptionService implements ISubscriptionService {
SubscriptionServiceResult result = performAction(subscriptions, action,
displayTextStrategy);
if (!result.allowFurtherEditing) {
if (!result.isAllowFurtherEditing()) {
result.setSubscriptionStatusSummary(bandwidthService
.getSubscriptionStatusSummary(subscription));
}
@ -408,7 +340,7 @@ public class SubscriptionService implements ISubscriptionService {
*
*/
@Override
public ISubscriptionServiceResult update(final Subscription subscription,
public SubscriptionServiceResult update(final Subscription subscription,
IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException {
@ -432,7 +364,7 @@ public class SubscriptionService implements ISubscriptionService {
* {@inheritDoc}
*/
@Override
public ISubscriptionServiceResult update(final List<Subscription> subs,
public SubscriptionServiceResult update(final List<Subscription> subs,
IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException {
@ -455,7 +387,7 @@ public class SubscriptionService implements ISubscriptionService {
* {@inheritDoc}
*/
@Override
public ISubscriptionServiceResult updateWithPendingCheck(
public SubscriptionServiceResult updateWithPendingCheck(
final List<Subscription> subscriptions,
IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException {
@ -558,7 +490,7 @@ public class SubscriptionService implements ISubscriptionService {
* {@inheritDoc}
*/
@Override
public ISubscriptionServiceResult store(final AdhocSubscription sub,
public SubscriptionServiceResult store(final AdhocSubscription sub,
IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException {
@ -568,24 +500,21 @@ public class SubscriptionService implements ISubscriptionService {
final ServiceInteraction action = new ServiceInteraction() {
@Override
public String call() throws RegistryHandlerException {
DataDeliveryHandlers.getSubscriptionHandler().store(
sub);
DataDeliveryHandlers.getSubscriptionHandler().store(sub);
return successMessage;
}
};
SubscriptionServiceResult result = performAction(subscriptions, action,
displayTextStrategy);
if (!result.allowFurtherEditing) {
if (!result.isAllowFurtherEditing()) {
Date date = bandwidthService.getEstimatedCompletionTime(sub);
if (date != null) {
SimpleDateFormat sdf = new SimpleDateFormat(
"MM/dd/yyyy HH:mm zzz");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
result = new SubscriptionServiceResult(
result.getMessageToDisplay()
+ "\n\nEstimated completion time:"
+ sdf.format(date));
result = new SubscriptionServiceResult(result.getMessage()
+ "\n\nEstimated completion time:" + sdf.format(date));
}
}
@ -610,40 +539,28 @@ public class SubscriptionService implements ISubscriptionService {
final IForceApplyPromptDisplayText displayTextStrategy)
throws RegistryHandlerException {
for (Subscription subscription : subscriptions) {
if (!(subscription instanceof AdhocSubscription)) {
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
.getSubscriptionHandler();
final List<Subscription> potentialDuplicates = subscriptionHandler
.getActiveByDataSetAndProvider(
subscription.getDataSetName(),
subscription.getProvider());
List<String> overlappingSubscriptions = Lists.newArrayList();
for (Subscription potentialDuplicate : potentialDuplicates) {
final ISubscriptionOverlapResponse overlapResponse = subscriptionOverlapService
.isOverlapping(potentialDuplicate, subscription);
final String potentialDuplicateName = potentialDuplicate
.getName();
if (overlapResponse.isDuplicate()) {
return new SubscriptionServiceResult(true,
"This subscription would be an exact duplicate of "
+ potentialDuplicateName);
}
if (overlapResponse.isOverlapping()) {
overlappingSubscriptions.add(potentialDuplicateName);
}
}
if (!overlappingSubscriptions.isEmpty()) {
Collections.sort(overlappingSubscriptions);
forceApplyPrompt
.displayMessage(
displayTextStrategy,
StringUtil
.createMessage(
ISubscriptionOverlapService.OVERLAPPING_SUBSCRIPTIONS,
overlappingSubscriptions));
}
SubscriptionOverlapRequest request = new SubscriptionOverlapRequest(
subscriptions);
SubscriptionOverlapResponse response = null;
try {
response = (SubscriptionOverlapResponse) RequestRouter.route(
request, DataDeliveryConstants.DATA_DELIVERY_SERVER);
if (response.isDuplicate()) {
return new SubscriptionServiceResult(true,
StringUtil.createMessage(DUPLICATE_SUBSCRIPTIONS,
response.getSubscriptionNameList()));
}
if (response.isOverlap()) {
List<String> subNames = response.getSubscriptionNameList();
Collections.sort(subNames);
forceApplyPrompt.displayMessage(displayTextStrategy, StringUtil
.createMessage(OVERLAPPING_SUBSCRIPTIONS, subNames));
}
} catch (Exception e) {
statusHandler.error("Error checking subscription overlapping", e);
return new SubscriptionServiceResult(false);
}
try {

View file

@ -0,0 +1,142 @@
/**
* 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.viz.datadelivery.subscription;
import com.raytheon.uf.common.datadelivery.bandwidth.data.SubscriptionStatusSummary;
/**
* Subscription service result object.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 25, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class SubscriptionServiceResult {
/** Edit flag */
private boolean allowFurtherEditing;
/** Response message */
private String message;
/** The subscription status */
private SubscriptionStatusSummary subscriptionStatusSummary;
/**
* Constructor.
*
* @param message
*/
public SubscriptionServiceResult(String message) {
this(false, message);
}
/**
* @param allowFurtherEditing
* @param message
*/
public SubscriptionServiceResult(boolean allowFurtherEditing, String message) {
this.allowFurtherEditing = allowFurtherEditing;
this.message = message;
}
/**
* Constructor
*
* @param allowFurtherEditing
*/
public SubscriptionServiceResult(boolean allowFurtherEditing) {
this(allowFurtherEditing, null);
}
/**
* Constructor
*
* @param message
* @param subscriptionStatusSummary
*/
public SubscriptionServiceResult(String message,
SubscriptionStatusSummary subscriptionStatusSummary) {
this.message = message;
this.subscriptionStatusSummary = subscriptionStatusSummary;
}
/**
* @return the allowFurtherEditing
*/
public boolean isAllowFurtherEditing() {
return allowFurtherEditing;
}
/**
* @param allowFurtherEditing
* the allowFurtherEditing to set
*/
public void setAllowFurtherEditing(boolean allowFurtherEditing) {
this.allowFurtherEditing = allowFurtherEditing;
}
/**
* @return the message
*/
public String getMessage() {
return message;
}
/**
* @param message
* the message to set
*/
public void setMessage(String message) {
this.message = message;
}
/**
* @return the subStatusSummary
*/
public SubscriptionStatusSummary getSubscriptionStatusSummary() {
return subscriptionStatusSummary;
}
/**
* @param subscriptionStatusSummary
* the subStatusSummary to set
*/
public void setSubscriptionStatusSummary(
SubscriptionStatusSummary subscriptionStatusSummary) {
this.subscriptionStatusSummary = subscriptionStatusSummary;
}
/**
* @return true if message is not null
*/
public boolean hasMessageToDisplay() {
return message != null;
}
}

View file

@ -60,8 +60,8 @@ import com.raytheon.uf.viz.datadelivery.help.HelpManager;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.subscription.CancelForceApplyAndIncreaseLatencyDisplayText;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService.ISubscriptionServiceResult;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.ForceApplyPromptResponse;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionServiceResult;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@ -94,6 +94,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Jun 06, 2013 2030 mpduff Refactored help.
* Jul 26, 2013 2232 mpduff Refactored Data Delivery permissions.
* Sep 03, 2013 2315 mpduff Add subscription name to denied approval message.
* Oct 23, 2013 2292 mpduff Move subscription overlap checks to edex.
*
* </pre>
*
@ -530,13 +531,12 @@ public class SubscriptionApprovalDlg extends CaveSWTDialog implements
String exceptionMessage = "Unable to update subscription.";
try {
ISubscriptionServiceResult result = subscriptionService
SubscriptionServiceResult result = subscriptionService
.update(s,
new ApproveSubscriptionForceApplyPromptDisplayText());
if (result.hasMessageToDisplay()) {
DataDeliveryUtils.showMessage(getShell(), SWT.OK,
"Subscription Approved.",
result.getMessageToDisplay());
"Subscription Approved.", result.getMessage());
}
if (!result.isAllowFurtherEditing()) {

View file

@ -68,9 +68,9 @@ import com.raytheon.uf.viz.datadelivery.filter.MetaDataManager;
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
import com.raytheon.uf.viz.datadelivery.subscription.CreateSubscriptionDlg;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService;
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionService.ISubscriptionServiceResult;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.ForceApplyPromptResponse;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceApplyPromptDisplayText;
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionServiceResult;
import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.SubsetXML;
import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.TimeXML;
import com.raytheon.uf.viz.datadelivery.subscription.subset.xml.VerticalXML;
@ -132,6 +132,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Oct 11, 2013 2386 mpduff Refactor DD Front end.
* 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.
* </pre>
*
* @author mpduff
@ -505,12 +506,12 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
return;
}
try {
ISubscriptionServiceResult result = subscriptionService.store(
SubscriptionServiceResult result = subscriptionService.store(
as, this);
if (result.hasMessageToDisplay()) {
DataDeliveryUtils.showMessage(getShell(), SWT.OK,
"Query Scheduled", result.getMessageToDisplay());
"Query Scheduled", result.getMessage());
}
} catch (RegistryHandlerException e) {
statusHandler.handle(Priority.PROBLEM,
@ -540,7 +541,8 @@ public abstract class SubsetManagerDlg extends CaveSWTDialog implements
sub.setOwner((create) ? LocalizationManager.getInstance()
.getCurrentUser() : this.subscription.getOwner());
sub.setOriginatingSite(LocalizationManager.getInstance().getCurrentSite());
sub.setOriginatingSite(LocalizationManager.getInstance()
.getCurrentSite());
return setupCommonSubscriptionAttributes(sub, defaultRoute);
}

View file

@ -1,2 +1 @@
com.raytheon.uf.viz.npp.viirs.rsc.VIIRSResourceData
com.raytheon.uf.viz.npp.viirs.style.VIIRSDataMatchCriteria
com.raytheon.uf.viz.npp.viirs.style.VIIRSDataMatchCriteria

View file

@ -31,7 +31,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.python;bundle-version="1.12.1174",
com.raytheon.uf.common.colormap;bundle-version="1.12.1174",
com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.common.style;bundle-version="1.0.0"
com.raytheon.uf.common.style;bundle-version="1.0.0",
com.raytheon.uf.common.activetable
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.gfe,
com.raytheon.viz.gfe.constants,
@ -52,8 +53,7 @@ Export-Package: com.raytheon.viz.gfe,
com.raytheon.viz.gfe.ui,
com.raytheon.viz.gfe.ui.runtimeui,
com.raytheon.viz.gfe.ui.zoneselector
Import-Package: com.raytheon.uf.common.activetable,
com.raytheon.uf.common.dissemination,
Import-Package: com.raytheon.uf.common.dissemination,
com.raytheon.uf.common.message,
com.raytheon.uf.common.python.concurrent,
com.raytheon.uf.common.serialization.comm,

View file

@ -29,6 +29,7 @@
# ??/??/?? ???????? Initial Creation.
# 05/14/13 1842 dgilling Use GFEVtecUtil to handle NEW
# ETN assignment.
# 09/24/13 1843 dgilling Handle GetNextEtnResponse.
#
#
@ -713,7 +714,7 @@ class HazardsTable(VTECTableUtil.VTECTableUtil):
# Local WFOs do not assign these numbers, so they should have
# numbers < 1000
if phensig not in self.__tpcKeys or self.__siteID4 in self.__sitesIgnoreNatlEtn:
etn_base = GFEVtecUtil.getNextEtn(self.__siteID4, '.'.join(phensig), False) - 1
etn_base = GFEVtecUtil.getNextEtn(self.__siteID4, '.'.join(phensig), False).getNextEtn() - 1
else:
presentyear = time.gmtime(self.__time)[0]
for active in activeTable:

View file

@ -51,6 +51,7 @@
# (e.g. grid[mask] = value)
# Oct 07, 2013 2424 randerso remove use of pytz
# Oct 29, 2013 2476 njensen Improved getting wx/discrete keys in _getGridResults
# Oct 31, 2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
#
########################################################################
import types, string, time, sys
@ -484,7 +485,7 @@ class SmartScript(BaseTool.BaseTool):
if result[0].dtype != numpy.int8:
# scalar
result = result[0]
else:
else:
# discrete or weather
keys = JUtil.javaObjToPyVal(slice.getKeyList())
result.append(keys)
@ -650,7 +651,7 @@ class SmartScript(BaseTool.BaseTool):
slice = DiscreteGridSlice()
bits = self.__dataMgr.getIscDataAccess().getCompositeGrid(gid, exactMatch, slice)
keys = []
for k in slice.getKey():
for k in slice.getKeys():
keys.append(str(k))
args = (bits.__numpy__[0], slice.getDiscreteGrid().__numpy__[0], keys)
return args

View file

@ -72,6 +72,7 @@ import com.vividsolutions.jts.geom.MultiPolygon;
* 30Jan2013 #15719 jdynina Fixed allowed field size to accept more
* than 128 characters
* 02/19/2013 1637 randerso Added throws declarations to translateDataFrom
* 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -102,8 +103,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
DiscreteGridSlice thisSlice = getDiscreteSlice();
Grid2DByte grid = thisSlice.getDiscreteGrid();
if (grid.getXdim() != pointsToSmooth.getXdim()
|| grid.getYdim() != pointsToSmooth.getYdim()) {
if ((grid.getXdim() != pointsToSmooth.getXdim())
|| (grid.getYdim() != pointsToSmooth.getYdim())) {
statusHandler.handle(
Priority.ERROR,
"Dimension mismatch in doSmooth: " + getGrid().getXdim()
@ -121,7 +122,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
getISCGrid(time, slice);
}
originalGrid = slice.getDiscreteGrid();
originalKey = slice.getKey();
originalKey = slice.getKeys();
} catch (CloneNotSupportedException e) {
originalGrid = new Grid2DByte();
originalKey = new DiscreteKey[0];
@ -155,8 +156,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
// uses fewer than nine points if near grid edge,
// but always has at least four values to average.
Arrays.fill(histo, (short) 0);
for (int newx = i - ss; newx <= i + ss; newx++) {
for (int newy = j - ss; newy <= j + ss; newy++) {
for (int newx = i - ss; newx <= (i + ss); newx++) {
for (int newy = j - ss; newy <= (j + ss); newy++) {
// if inside grid limits, make a smoothed value
if (originalGrid.isValid(newx, newy)) {
histo[0xFF & originalGrid.get(newx, newy)]++;
@ -234,7 +235,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
// complex case - translation is necessary
else {
// copy the key from the source to the destination
setKey(((DiscreteGridSlice) sourceGrid.getGridSlice()).getKey());
setKey(((DiscreteGridSlice) sourceGrid.getGridSlice()).getKeys());
// find no discrete key, which is always the 1st one
int nowx = 0;
@ -340,8 +341,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
protected Grid2DBit doPencilStretch(Date time, WxValue value,
Coordinate[] path, Grid2DBit editArea) {
Grid2DByte grid = getGrid();
if (grid.getXdim() != editArea.getXdim()
|| grid.getYdim() != editArea.getYdim()) {
if ((grid.getXdim() != editArea.getXdim())
|| (grid.getYdim() != editArea.getYdim())) {
statusHandler.handle(Priority.ERROR,
"Dimension mismatch in doPencilStretch: " + grid.getXdim()
+ ',' + grid.getYdim() + ' ' + editArea.getXdim()
@ -675,8 +676,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
protected Grid2DBit doCopy(Date time, Grid2DBit pointsToCopy, Point delta) {
DiscreteGridSlice thisSlice = getDiscreteSlice();
Grid2DByte sliceGrid = thisSlice.getDiscreteGrid();
if (sliceGrid.getXdim() != pointsToCopy.getXdim()
|| sliceGrid.getYdim() != pointsToCopy.getYdim()) {
if ((sliceGrid.getXdim() != pointsToCopy.getXdim())
|| (sliceGrid.getYdim() != pointsToCopy.getYdim())) {
throw new IllegalArgumentException("Dimension mismatch in doCopy: "
+ sliceGrid.getXdim() + ',' + sliceGrid.getYdim() + ' '
+ pointsToCopy.getXdim() + ',' + pointsToCopy.getYdim());
@ -695,7 +696,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
getISCGrid(time, slice);
}
originalGrid = slice.getDiscreteGrid();
originalKey = slice.getKey();
originalKey = slice.getKeys();
} catch (CloneNotSupportedException e) {
originalGrid = new Grid2DByte();
originalKey = new DiscreteKey[0];
@ -751,8 +752,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
@Override
protected Grid2DBit doFillIn(Date time, Grid2DBit pointsToFillIn) {
Grid2DByte grid = getGrid();
if (grid.getXdim() != pointsToFillIn.getXdim()
|| grid.getYdim() != pointsToFillIn.getYdim()) {
if ((grid.getXdim() != pointsToFillIn.getXdim())
|| (grid.getYdim() != pointsToFillIn.getYdim())) {
statusHandler.handle(Priority.ERROR,
"Dimension mismatch in doFillIn: " + grid.getXdim() + ','
+ grid.getYdim() + ' ' + pointsToFillIn.getXdim()
@ -814,8 +815,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
boolean done = false;
while (!done) {
// Check for bounds
if (coord.x < 0 || coord.x >= gridCells.getXdim()
|| coord.y < 0 || coord.y >= gridCells.getYdim()) {
if ((coord.x < 0) || (coord.x >= gridCells.getXdim())
|| (coord.y < 0) || (coord.y >= gridCells.getYdim())) {
done = true;
}
// Check for bit set
@ -882,8 +883,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
Grid2DBit points) {
Grid2DByte grid = getGrid();
Point dim = new Point(grid.getXdim(), grid.getYdim());
if (values.getXdim() != dim.x || values.getYdim() != dim.y
|| points.getXdim() != dim.x || points.getYdim() != dim.y) {
if ((values.getXdim() != dim.x) || (values.getYdim() != dim.y)
|| (points.getXdim() != dim.x) || (points.getYdim() != dim.y)) {
throw new IllegalArgumentException(
"bad values/points dimensions for grid for: "
+ this.getParm().getParmID() + " gridDim="
@ -903,7 +904,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
int numValues = values.getXdim() * values.getYdim();
byte[] bp = values.getBuffer().array();
for (int i = 0; i < numValues; i++) {
if ((0xFF & bp[i]) > key.size() - 1) {
if ((0xFF & bp[i]) > (key.size() - 1)) {
throw new IllegalArgumentException(
"Illegal discrete grid (bad values) in gridSet()");
}
@ -915,7 +916,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
parmId.getCompositeName());
// REPLACE mode is easy
if (parm.getParmState().getCombineMode() == ParmState.CombineMode.REPLACE
if ((parm.getParmState().getCombineMode() == ParmState.CombineMode.REPLACE)
|| !overlapping) {
// create remap array
byte[] remap = new byte[256];
@ -1019,7 +1020,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
}
private DiscreteKey[] getKey() {
return ((DiscreteGridSlice) getGridSlice()).getKey();
return ((DiscreteGridSlice) getGridSlice()).getKeys();
}
private void setKey(DiscreteKey[] key) {
@ -1034,8 +1035,8 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
protected boolean doValid() {
String emsg = "Grid contains data which exceeds limits for this parm. ";
if (!getGridTime().isValid() || getParm() == null
|| getGridSlice() == null) {
if (!getGridTime().isValid() || (getParm() == null)
|| (getGridSlice() == null)) {
statusHandler.handle(Priority.PROBLEM,
"Invalid grid time, bad parm or data slice");
return false; // time, parm, or data slice not valid

View file

@ -74,6 +74,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/14/09 1995 bphillip Initial release
* 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -105,6 +106,7 @@ public class ISCDataAccess implements IISCDataAccess {
}
// returns corresponding ISC gridid, parm, grid
@Override
public GridID getISCGridID(GridID id, boolean exactMatch) {
Parm p = this.getISCParm(id.getParm());
@ -150,10 +152,12 @@ public class ISCDataAccess implements IISCDataAccess {
}
}
@Override
public ParmID getISCParmID(ParmID parmID) {
return dataMgr.getParmManager().getISCParmID(parmID);
}
@Override
public Parm getISCParm(Parm p) {
if (p == null) {
@ -185,6 +189,7 @@ public class ISCDataAccess implements IISCDataAccess {
return iscP;
}
@Override
public String getISCSite(Point loc, GridID gid) {
String empty = "";
String officeType = gid.getParm().getOfficeType();
@ -202,6 +207,7 @@ public class ISCDataAccess implements IISCDataAccess {
}
}
@Override
public boolean inOurSite(Point loc, GridID gid) {
// must be our office type to be inOurSite
if (!dataMgr.getOfficeType().equals(gid.getParm().getOfficeType())) {
@ -216,12 +222,14 @@ public class ISCDataAccess implements IISCDataAccess {
}
@Override
public WxValue getDataPoint(GridID gridID, Coordinate worldLoc)
throws GFEServerException {
Coordinate gloc = new Coordinate();
return getDataPoint(gridID, worldLoc, gloc);
}
@Override
public WxValue getDataPoint(GridID gridID, Coordinate worldLoc,
Coordinate gloc) throws GFEServerException {
if (gridID.getParm() == null) {
@ -233,8 +241,8 @@ public class ISCDataAccess implements IISCDataAccess {
boolean inGrid = false;
gloc = MapUtil.latLonToGridCoordinate(worldLoc,
PixelOrientation.UPPER_RIGHT, location);
inGrid = gloc.x >= 0 && gloc.x < location.getNx() && gloc.y >= 0
&& gloc.y < location.getNy();
inGrid = (gloc.x >= 0) && (gloc.x < location.getNx()) && (gloc.y >= 0)
&& (gloc.y < location.getNy());
if (!inGrid) {
return WxValue.defaultValue(gridID.getParm());
}
@ -263,6 +271,7 @@ public class ISCDataAccess implements IISCDataAccess {
}
@Override
public Grid2DBit getCompositeGrid(GridID gid, boolean exactMatch,
ScalarGridSlice slice) {
@ -333,6 +342,7 @@ public class ISCDataAccess implements IISCDataAccess {
return getCompositeGrid(gid, exactMatch, slice);
}
@Override
public Grid2DBit getCompositeGrid(GridID gid, boolean exactMatch,
VectorGridSlice slice) {
@ -397,6 +407,7 @@ public class ISCDataAccess implements IISCDataAccess {
}
@Override
public Grid2DBit getCompositeGrid(GridID gid, boolean exactMatch,
WeatherGridSlice slice) {
@ -484,6 +495,7 @@ public class ISCDataAccess implements IISCDataAccess {
return siteMask.or(ourSiteMask);
}
@Override
public Grid2DBit getCompositeGrid(GridID gid, boolean exactMatch,
DiscreteGridSlice slice) {
@ -519,9 +531,9 @@ public class ISCDataAccess implements IISCDataAccess {
slice.setDiscreteGrid(primary.getDiscreteSlice().getDiscreteGrid()
.clone());
DiscreteKey[] keys = new DiscreteKey[primary.getDiscreteSlice()
.getKey().length];
.getKeys().length];
for (int i = 0; i < keys.length; i++) {
keys[i] = new DiscreteKey(primary.getDiscreteSlice().getKey()[i]);
keys[i] = new DiscreteKey(primary.getDiscreteSlice().getKeys()[i]);
}
slice.setKey(keys);
@ -544,9 +556,9 @@ public class ISCDataAccess implements IISCDataAccess {
// blend the isc grid into the grid/key for those points set
Grid2DByte iscGrid = iscGridData.getDiscreteSlice().getDiscreteGrid();
DiscreteKey[] iscKey = iscGridData.getDiscreteSlice().getKey();
DiscreteKey[] iscKey = iscGridData.getDiscreteSlice().getKeys();
DiscreteKey[] keyList = slice.getKey();
DiscreteKey[] keyList = slice.getKeys();
Map<DiscreteKey, Integer> keyIndexMap = new HashMap<DiscreteKey, Integer>(
keyList.length);
for (int i = 0; i < keyList.length; i++) {
@ -595,7 +607,7 @@ public class ISCDataAccess implements IISCDataAccess {
for (int i = 0; i < available.size(); i++) {
String name = available.get(i).getName();
if (name.length() >= 5 && name.startsWith("ISC_")
if ((name.length() >= 5) && name.startsWith("ISC_")
&& (name.indexOf('_', 4) == -1)) {
String site = name.substring(4);
if (knownSites.contains(site)) {

View file

@ -184,6 +184,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* ant time weighted average.
* Apr 02, 2013 #1774 randerso Fixed a possible deadlock issue.
* Aug 27, 2013 #2302 randerso Fix simultaneous save issue
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -593,7 +594,8 @@ public abstract class Parm implements Comparable<Parm> {
this.grids.acquireReadLock();
try {
if (this.grids.size() > 0 && !getGridInfo().isTimeIndependentParm()) {
if ((this.grids.size() > 0)
&& !getGridInfo().isTimeIndependentParm()) {
return new TimeRange(
this.grids.get(0).getGridTime().getStart(), this.grids
.get(this.grids.size() - 1).getGridTime()
@ -965,7 +967,7 @@ public abstract class Parm implements Comparable<Parm> {
Date[] dateArray = { absTime };
IGridData[] gridData = startParmEdit(dateArray);
if (gridData != null && gridData.length == 1) {
if ((gridData != null) && (gridData.length == 1)) {
return gridData[0];
}
@ -1029,7 +1031,7 @@ public abstract class Parm implements Comparable<Parm> {
IGridData grid = null;
grid = overlappingGrid(absTime);
if (grid != null && isOkToEdit(grid.getGridTime())) {
if ((grid != null) && isOkToEdit(grid.getGridTime())) {
retGrids.add(grid);
affectedTimes.add(grid.getGridTime());
saveUndoTimes.add(grid.getGridTime());
@ -1245,7 +1247,7 @@ public abstract class Parm implements Comparable<Parm> {
boolean invChanged = false;
IGridData leftGrid = overlappingGrid(splitTimeRange.getStart());
if (leftGrid != null
if ((leftGrid != null)
&& !leftGrid.getGridTime().getStart()
.equals(splitTimeRange.getStart())) {
IGridData newGrid = null;
@ -1266,7 +1268,7 @@ public abstract class Parm implements Comparable<Parm> {
IGridData rightGrid = overlappingGrid(new Date(splitTimeRange.getEnd()
.getTime() - 1000));
if (rightGrid != null
if ((rightGrid != null)
&& !rightGrid.getGridTime().getEnd()
.equals(splitTimeRange.getEnd())) {
IGridData newGrid;
@ -1355,10 +1357,10 @@ public abstract class Parm implements Comparable<Parm> {
// in some cases, you can end up with an invalid TR
if (!expTR.isValid()
|| orgTR.getStart().getTime() < replaceRange.getStart()
.getTime()
|| orgTR.getEnd().getTime() > replaceRange.getEnd()
.getTime()) {
|| (orgTR.getStart().getTime() < replaceRange.getStart()
.getTime())
|| (orgTR.getEnd().getTime() > replaceRange.getEnd()
.getTime())) {
continue;
}
@ -1461,8 +1463,8 @@ public abstract class Parm implements Comparable<Parm> {
// add proportional value to existing grid
float timeRatio = (float) intersect.getDuration()
/ (float) orgTR.getDuration();
if (grids.get(j).getGridSlice() instanceof IContinuousSlice
&& grid.getGridSlice() instanceof IContinuousSlice) {
if ((grids.get(j).getGridSlice() instanceof IContinuousSlice)
&& (grid.getGridSlice() instanceof IContinuousSlice)) {
IGridSlice copy;
try {
@ -1656,8 +1658,8 @@ public abstract class Parm implements Comparable<Parm> {
e);
}
if (copy instanceof IContinuousSlice
&& newgrid.getGridSlice() instanceof IContinuousSlice) {
if ((copy instanceof IContinuousSlice)
&& (newgrid.getGridSlice() instanceof IContinuousSlice)) {
((IContinuousSlice) copy).operateEquals(Op.MULTIPLY, timeRatio,
dataManager.getRefManager().fullRefSet().getGrid());
((IContinuousSlice) newgrid.getGridSlice()).operateEquals(
@ -2068,8 +2070,8 @@ public abstract class Parm implements Comparable<Parm> {
ParmID parmId = getParmID();
String siteId = parmId.getDbId().getSiteId();
if (grids.length == 1
&& getGridInfo().getGridType() != GridType.WEATHER) {
if ((grids.length == 1)
&& (getGridInfo().getGridType() != GridType.WEATHER)) {
// nothing to average so we're done, except in the weather case
try {
gridSlice = grids[0].getGridSlice().clone();
@ -2119,8 +2121,8 @@ public abstract class Parm implements Comparable<Parm> {
float dur = gridTR.get(k).getDuration();
for (int i = 0; i < ge.getSpan(0); i++) {
for (int j = 0; j < ge.getSpan(1); j++) {
uSum.set(i, j, uSum.get(i, j) + uGrid.get(i, j) * dur);
vSum.set(i, j, vSum.get(i, j) + vGrid.get(i, j) * dur);
uSum.set(i, j, uSum.get(i, j) + (uGrid.get(i, j) * dur));
vSum.set(i, j, vSum.get(i, j) + (vGrid.get(i, j) * dur));
}
}
}
@ -2184,7 +2186,7 @@ public abstract class Parm implements Comparable<Parm> {
// values that exceed the configured percentage
ArrayList<WeatherSubKey> weightedKeys = new ArrayList<WeatherSubKey>();
for (int k = 0; k < subKeys.size(); k++) {
if ((float) wcount.get(k) / totalDuration > significantPercent) {
if (((float) wcount.get(k) / totalDuration) > significantPercent) {
weightedKeys.add(subKeys.get(k));
}
}
@ -2237,7 +2239,7 @@ public abstract class Parm implements Comparable<Parm> {
Map<DiscreteKey, MutableInteger> values = new HashMap<DiscreteKey, MutableInteger>();
for (int k = 0; k < gridCount; k++) {
DiscreteKey key1[] = ((DiscreteGridSlice) grids[k]
.getGridSlice()).getKey();
.getGridSlice()).getKeys();
Grid2DByte grid1 = ((DiscreteGridSlice) grids[k]
.getGridSlice()).getDiscreteGrid();
// TextString kv = key1[grid1(i, j)].keyAsString();
@ -2323,8 +2325,8 @@ public abstract class Parm implements Comparable<Parm> {
public void adjust(float deltaValue, final Date time,
final ReferenceData refData) {
// Can't adjust weather or discrete
if (getGridInfo().getGridType() == GridType.WEATHER
|| getGridInfo().getGridType() == GridType.DISCRETE) {
if ((getGridInfo().getGridType() == GridType.WEATHER)
|| (getGridInfo().getGridType() == GridType.DISCRETE)) {
return;
}
@ -2348,7 +2350,7 @@ public abstract class Parm implements Comparable<Parm> {
Date[] dateArray = { absTime };
IGridData[] gridData = extendParmEdit(dateArray);
if (gridData != null && gridData.length == 1) {
if ((gridData != null) && (gridData.length == 1)) {
return gridData[0];
}
@ -2434,8 +2436,8 @@ public abstract class Parm implements Comparable<Parm> {
*/
public boolean timeShiftTR(TimeRange tr, int secondsToShift,
boolean copyOnly) {
if (Math.abs(secondsToShift)
% this.gridInfo.getTimeConstraints().getRepeatInterval() != 0) {
if ((Math.abs(secondsToShift) % this.gridInfo.getTimeConstraints()
.getRepeatInterval()) != 0) {
throw new IllegalArgumentException("timeShiftSelectedTR of "
+ secondsToShift + " not an interval of "
+ this.gridInfo.getTimeConstraints().getRepeatInterval()
@ -2443,15 +2445,15 @@ public abstract class Parm implements Comparable<Parm> {
}
// Make sure the given timeRange is valid and there is something to do
if (!tr.isValid() || secondsToShift == 0) {
if (!tr.isValid() || (secondsToShift == 0)) {
return false;
}
// calculate source and destination timeRanges
TimeRange sourceTR = new TimeRange(tr.getStart(), tr.getEnd());
TimeRange destinationTR = new TimeRange(tr.getStart().getTime()
+ secondsToShift * 1000, tr.getEnd().getTime() + secondsToShift
* 1000);
+ (secondsToShift * 1000), tr.getEnd().getTime()
+ (secondsToShift * 1000));
// Create a combinedTR that includes the all blocks it touches
TimeRange combinedTR = destinationTR;
@ -2502,27 +2504,28 @@ public abstract class Parm implements Comparable<Parm> {
for (int i = 0; i < destGrids.length; i++) {
TimeRange tr2 = destGrids[i].getGridTime();
tr2 = new TimeRange(tr2.getStart().getTime() + secondsToShift
* 1000, tr2.getEnd().getTime() + secondsToShift * 1000);
tr2 = new TimeRange(tr2.getStart().getTime()
+ (secondsToShift * 1000), tr2.getEnd().getTime()
+ (secondsToShift * 1000));
destGrids[i].changeValidTime(tr2, true);
destGrids[i].updateHistoryToModified(this.dataManager.getWsId());
}
// Trim the start of the first copied grid, if necessary
if (destGrids[0].getGridTime().getStart().getTime() < sourceTR
.getStart().getTime() + secondsToShift * 1000) {
if (destGrids[0].getGridTime().getStart().getTime() < (sourceTR
.getStart().getTime() + (secondsToShift * 1000))) {
TimeRange newTR = new TimeRange(sourceTR.getStart().getTime()
+ secondsToShift * 1000, destGrids[0].getGridTime()
+ (secondsToShift * 1000), destGrids[0].getGridTime()
.getEnd().getTime());
destGrids[0].changeValidTime(newTR, true);
}
// Trim the end of the last copied grid, if necessary
if (destGrids[destGrids.length - 1].getGridTime().getEnd().getTime() > sourceTR
.getEnd().getTime() + secondsToShift * 1000) {
if (destGrids[destGrids.length - 1].getGridTime().getEnd().getTime() > (sourceTR
.getEnd().getTime() + (secondsToShift * 1000))) {
TimeRange newTR = new TimeRange(destGrids[destGrids.length - 1]
.getGridTime().getStart().getTime(), sourceTR.getEnd()
.getTime() + secondsToShift * 1000);
.getTime() + (secondsToShift * 1000));
destGrids[destGrids.length - 1].changeValidTime(newTR, true);
}
@ -2730,9 +2733,9 @@ public abstract class Parm implements Comparable<Parm> {
IGridData leftGrid = overlappingGrid(timeRange.getStart());
IGridData rightGrid = overlappingGrid(new Date(timeRange.getEnd()
.getTime() - 1000));
if ((leftGrid == null || leftGrid.getGridTime().getStart()
if (((leftGrid == null) || leftGrid.getGridTime().getStart()
.equals(timeRange.getStart()))
&& (rightGrid == null || rightGrid.getGridTime().getEnd()
&& ((rightGrid == null) || rightGrid.getGridTime().getEnd()
.equals(timeRange.getEnd()))) {
return false; // nothing to split
}
@ -3180,8 +3183,8 @@ public abstract class Parm implements Comparable<Parm> {
ParmState.CombineMode cCombineMode = this.parmState.getCombineMode();
if (this.gridInfo.getGridType() == GFERecord.GridType.VECTOR) {
this.parmState.setVectorMode(ParmState.VectorMode.BOTH);
} else if (this.gridInfo.getGridType() == GFERecord.GridType.WEATHER
|| this.gridInfo.getGridType() == GFERecord.GridType.DISCRETE) {
} else if ((this.gridInfo.getGridType() == GFERecord.GridType.WEATHER)
|| (this.gridInfo.getGridType() == GFERecord.GridType.DISCRETE)) {
this.parmState.setCombineMode(ParmState.CombineMode.REPLACE);
}
@ -3198,8 +3201,8 @@ public abstract class Parm implements Comparable<Parm> {
// restore the edit modes
if (this.gridInfo.getGridType() == GFERecord.GridType.VECTOR) {
this.parmState.setVectorMode(cVectorMode);
} else if (this.gridInfo.getGridType() == GFERecord.GridType.WEATHER
|| this.gridInfo.getGridType() == GFERecord.GridType.DISCRETE) {
} else if ((this.gridInfo.getGridType() == GFERecord.GridType.WEATHER)
|| (this.gridInfo.getGridType() == GFERecord.GridType.DISCRETE)) {
this.parmState.setCombineMode(cCombineMode);
}
@ -3367,13 +3370,13 @@ public abstract class Parm implements Comparable<Parm> {
if (interval < tc.getRepeatInterval()) {
interval = tc.getRepeatInterval();
}
if (interval % tc.getRepeatInterval() != 0) {
interval = (interval / tc.getRepeatInterval() + 1)
if ((interval % tc.getRepeatInterval()) != 0) {
interval = ((interval / tc.getRepeatInterval()) + 1)
* tc.getRepeatInterval();
}
}
if (interval == 0 || duration == 0) {
if ((interval == 0) || (duration == 0)) {
gridTimes.add(tr);
}
@ -3415,8 +3418,8 @@ public abstract class Parm implements Comparable<Parm> {
*/
public Parm min(TimeRange timeRange) {
// Can't take the minimum of a weather or discrete type
if (this.gridInfo.getGridType() == GridType.WEATHER
|| this.gridInfo.getGridType() == GridType.DISCRETE) {
if ((this.gridInfo.getGridType() == GridType.WEATHER)
|| (this.gridInfo.getGridType() == GridType.DISCRETE)) {
return null;
}
@ -3478,8 +3481,8 @@ public abstract class Parm implements Comparable<Parm> {
*/
public Parm max(TimeRange timeRange) {
// Can't take the minimum of a weather or discrete type
if (this.gridInfo.getGridType() == GridType.WEATHER
|| this.gridInfo.getGridType() == GridType.DISCRETE) {
if ((this.gridInfo.getGridType() == GridType.WEATHER)
|| (this.gridInfo.getGridType() == GridType.DISCRETE)) {
return null;
}
@ -3541,8 +3544,8 @@ public abstract class Parm implements Comparable<Parm> {
*/
public Parm sum(TimeRange timeRange) {
// Can't take the minimum of a weather or discrete type
if (this.gridInfo.getGridType() == GridType.WEATHER
|| this.gridInfo.getGridType() == GridType.DISCRETE) {
if ((this.gridInfo.getGridType() == GridType.WEATHER)
|| (this.gridInfo.getGridType() == GridType.DISCRETE)) {
return null;
}
@ -3769,7 +3772,7 @@ public abstract class Parm implements Comparable<Parm> {
for (k = 0; k < gridCount; k++) {
DiscreteKey[] key1 = ((DiscreteGridSlice) grids[k]
.getGridSlice()).getKey();
.getGridSlice()).getKeys();
Grid2DByte grid1 = ((DiscreteGridSlice) grids[k]
.getGridSlice()).getDiscreteGrid();
DiscreteKey dkv = key1[grid1.get(i, j)];
@ -3919,16 +3922,16 @@ public abstract class Parm implements Comparable<Parm> {
// left
{
end = mid - 1;
mid = (end - begin) / 2 + begin;
mid = ((end - begin) / 2) + begin;
} else // on the right
{
begin = mid + 1;
mid = (end - begin) / 2 + begin;
mid = ((end - begin) / 2) + begin;
}
}
// Did we find it? Last chance...
if (mid >= 0 && mid < this.grids.size()
if ((mid >= 0) && (mid < this.grids.size())
&& this.grids.get(mid).getGridTime().contains(time)) {
return this.grids.get(mid);
}
@ -4042,7 +4045,7 @@ public abstract class Parm implements Comparable<Parm> {
}
// set duration to interval if needed
if (interval != 0 && duration == 0) {
if ((interval != 0) && (duration == 0)) {
duration = interval;
}
@ -4120,7 +4123,7 @@ public abstract class Parm implements Comparable<Parm> {
// eliminate all of the earlier and the later grids from
// basegrids
if (endIndex != -1 && endIndex < baseGrids.size() - 1) {
if ((endIndex != -1) && (endIndex < (baseGrids.size() - 1))) {
baseGrids.subList(endIndex + 1, baseGrids.size()).clear();
}
if (startIndex >= 1) {
@ -4160,7 +4163,7 @@ public abstract class Parm implements Comparable<Parm> {
break;
}
}
st.setTime(st.getTime() + interval * 1000);
st.setTime(st.getTime() + (interval * 1000));
}
// now split grids if necessary due to interference with base grids
@ -4173,12 +4176,12 @@ public abstract class Parm implements Comparable<Parm> {
if (bgTime.contains(t)) {
break; // can't salvage this one
}
if (bgTime.getStart().compareTo(t.getStart()) <= 0
&& bgTime.getEnd().compareTo(t.getEnd()) < 0) {
if ((bgTime.getStart().compareTo(t.getStart()) <= 0)
&& (bgTime.getEnd().compareTo(t.getEnd()) < 0)) {
newDSTR.add(new TimeRange(bgTime.getEnd(), t.getEnd()));
overlaps = true;
} else if (bgTime.getStart().compareTo(t.getStart()) > 0
&& bgTime.getEnd().compareTo(t.getEnd()) >= 0) {
} else if ((bgTime.getStart().compareTo(t.getStart()) > 0)
&& (bgTime.getEnd().compareTo(t.getEnd()) >= 0)) {
newDSTR.add(new TimeRange(t.getStart(), bgTime
.getStart()));
overlaps = true;
@ -4227,13 +4230,13 @@ public abstract class Parm implements Comparable<Parm> {
interptimes.add(bs.getValidTime());
// if a gap's time range fits in here, append to arrays.
if (i < baseGrids.size() - 1) {
if (i < (baseGrids.size() - 1)) {
IGridSlice nbs = baseGrids.get(i + 1).getGridSlice();
for (j = 0; j < newDSTR.size(); j++) {
TimeRange ntr = newDSTR.get(j);
if (ntr.getStart().compareTo(bs.getValidTime().getEnd()) >= 0
&& ntr.getEnd().compareTo(
nbs.getValidTime().getStart()) <= 0) {
if ((ntr.getStart().compareTo(bs.getValidTime().getEnd()) >= 0)
&& (ntr.getEnd().compareTo(
nbs.getValidTime().getStart()) <= 0)) {
// make an empty NONE type GridSlice for the
// ones to
// be interpolated, and append the time for it.
@ -4469,11 +4472,11 @@ public abstract class Parm implements Comparable<Parm> {
int idx2 = strings.indexOf(parm2);
// parms in strings come before those that aren't
if (idx1 != -1 && idx2 == -1) {
if ((idx1 != -1) && (idx2 == -1)) {
cmp = -1;
} else if (idx1 == -1 && idx2 != -1) {
} else if ((idx1 == -1) && (idx2 != -1)) {
cmp = 1;
} else if (idx1 != -1 && idx2 != -1 && idx1 != idx2) {
} else if ((idx1 != -1) && (idx2 != -1) && (idx1 != idx2)) {
// both are in strings at different indices.
// compare their position in strings.
if (idx1 > idx2) {

View file

@ -49,6 +49,7 @@ import com.raytheon.viz.gfe.core.griddata.WeatherGridData;
* ------------ ---------- ----------- --------------------------
* Jan 12, 2012 dgilling Initial creation
* Oct 29, 2013 2476 njensen Renamed numeric methods to numpy
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -96,7 +97,7 @@ public class CalcVcModGridArg implements IVcModuleArgument {
tempNames.addAll(encodeGridAndMask(gd, mask, i, sb, instance));
sb.append(')');
if (i < argTuples.size() - 1) {
if (i < (argTuples.size() - 1)) {
sb.append(',');
}
}
@ -165,7 +166,7 @@ public class CalcVcModGridArg implements IVcModuleArgument {
jepString.append('(');
jepString.append(name);
jepString.append(',');
DiscreteKey[] keys = grid.getDiscreteSlice().getKey();
DiscreteKey[] keys = grid.getDiscreteSlice().getKeys();
ArrayList<String> stringKeys = new ArrayList<String>(keys.length);
for (DiscreteKey k : keys) {
stringKeys.add(k.toString());

View file

@ -0,0 +1,217 @@
/**
* 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.viz.gfe.dialogs.formatterlauncher;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import com.raytheon.uf.common.activetable.response.GetNextEtnResponse;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
import com.raytheon.viz.ui.dialogs.TextDisplayDlg;
import com.raytheon.viz.ui.dialogs.TextDisplayDlg.Location;
/**
* Dialog displayed to manually confirm ETN assignment when backup partners can
* not be reached
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 23, 2013 #1843 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class ETNConfirmationDialog extends CaveJFACEDialog {
// TODO make this configurable
private static final int MAX_ETN_DELTA = 10;
private String phenSig;
private int proposedEtn;
private Map<String, Integer> resultsByHost;
private List<String> errorMessages;
private Spinner proposedEtnSpinner;
/**
* Dialog constructor
*
* @param parentShell
* @param etnResponse
*/
public ETNConfirmationDialog(Shell parentShell,
GetNextEtnResponse etnResponse) {
super(parentShell);
this.phenSig = etnResponse.getPhensig();
this.proposedEtn = etnResponse.getNextEtn();
this.resultsByHost = etnResponse.getResultsByHost();
this.errorMessages = etnResponse.getErrorMessages();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets
* .Shell)
*/
@Override
protected void configureShell(Shell newShell) {
newShell.setText("Confirm ETN for " + this.phenSig);
super.configureShell(newShell);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveJFACEDialog#createDialogArea(org.eclipse
* .swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite top = (Composite) super.createDialogArea(parent);
GridLayout layout = (GridLayout) top.getLayout();
layout.numColumns = 2;
Label label = new Label(top, SWT.LEFT);
GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
label.setLayoutData(layoutData);
label.setText("Proposed ETN for " + this.phenSig + ":");
proposedEtnSpinner = new Spinner(top, SWT.BORDER);
layoutData = new GridData(SWT.FILL, SWT.CENTER, false, false);
proposedEtnSpinner.setLayoutData(layoutData);
proposedEtnSpinner.setValues(this.proposedEtn, this.proposedEtn,
this.proposedEtn + MAX_ETN_DELTA, 0, 1, 1);
Group group = new Group(top, SWT.NONE);
layout = new GridLayout(2, false);
group.setLayout(layout);
layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
layoutData.horizontalSpan = 2;
group.setLayoutData(layoutData);
group.setText("Partner ETNs");
for (Entry<String, Integer> entry : this.resultsByHost.entrySet()) {
Label host = new Label(group, SWT.LEFT);
layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
host.setLayoutData(layoutData);
host.setText(entry.getKey());
Label etn = new Label(group, SWT.RIGHT);
layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
etn.setLayoutData(layoutData);
String text = entry.getValue() == null ? "ERR" : entry.getValue()
.toString();
etn.setText(text);
}
final Button showErrors = new Button(top, SWT.PUSH);
layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
layoutData.horizontalSpan = 2;
showErrors.setLayoutData(layoutData);
showErrors.setText("Show Errors");
showErrors.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
showErrors.setEnabled(false);
StringBuilder errorText = new StringBuilder();
for (String s : errorMessages) {
errorText.append(s).append('\n');
}
TextDisplayDlg errorDlg = new TextDisplayDlg(
ETNConfirmationDialog.this.getShell(), "Errors",
errorText.toString(), Location.BELOW);
errorDlg.open();
showErrors.setEnabled(true);
}
});
return top;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse
* .swt.widgets.Composite)
*/
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
getButton(IDialogConstants.OK_ID).setText("Transmit");
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
protected void okPressed() {
this.proposedEtn = this.proposedEtnSpinner.getSelection();
super.okPressed();
}
/**
* @return the proposedEtn
*/
public int getProposedEtn() {
return proposedEtn;
}
}

View file

@ -20,6 +20,9 @@
package com.raytheon.viz.gfe.dialogs.formatterlauncher;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@ -37,6 +40,7 @@ import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.activetable.PracticeProductOfftimeRequest;
import com.raytheon.uf.common.activetable.SendPracticeProductRequest;
import com.raytheon.uf.common.activetable.response.GetNextEtnResponse;
import com.raytheon.uf.common.dissemination.OUPRequest;
import com.raytheon.uf.common.dissemination.OUPResponse;
import com.raytheon.uf.common.dissemination.OfficialUserProduct;
@ -52,6 +56,7 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.core.mode.CAVEMode;
import com.raytheon.viz.gfe.product.TextDBUtil;
import com.raytheon.viz.gfe.vtec.GFEVtecUtil;
import com.raytheon.viz.texteditor.util.VtecObject;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
@ -70,6 +75,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 08 MAY 2013 1842 dgilling Use VtecUtil to set product ETNs, fix
* warnings.
* 07 Jun 2013 1981 mpduff Set user's id in OUPRequest as it is now a protected operation.
* 23 Oct 2013 1843 dgilling Ensure that dialog is always closed,
* even on failure, changes for error handling
* of intersite ETN assignment.
* </pre>
*
* @author lvenable
@ -334,46 +342,116 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
// Store/Transmit the product...
if (!countdownThread.threadCancelled()) {
boolean retrieveEtnFailed = false;
try {
productText = GFEVtecUtil.finalizeETNs(productText);
} catch (VizException e) {
statusHandler.handle(Priority.CRITICAL,
"Error setting ETNs for product", e);
sendTransmissionStatus(ConfigData.productStateEnum.Failed);
VizApp.runAsync(new Runnable() {
Set<VtecObject> vtecsToAssignEtn = GFEVtecUtil
.getVtecLinesThatNeedEtn(productText);
Map<String, Integer> etnCache = new HashMap<String, Integer>();
for (VtecObject vtec : vtecsToAssignEtn) {
try {
GetNextEtnResponse serverResponse = GFEVtecUtil.getNextEtn(
vtec.getOffice(), vtec.getPhensig(), true, true);
if (!serverResponse.isOkay()) {
final VtecObject vtecToFix = vtec;
final boolean[] exitLoopContainer = { false };
final Exception[] exceptionContainer = { null };
final GetNextEtnResponse[] responseContainer = { serverResponse };
do {
getDisplay().syncExec(new Runnable() {
@Override
public void run() {
GetNextEtnResponse serverResponse = responseContainer[0];
ETNConfirmationDialog dlg = new ETNConfirmationDialog(
getShell(), serverResponse);
if (dlg.open() == ETNConfirmationDialog.OK) {
int etn = dlg.getProposedEtn();
statusHandler.info(String
.format("User confirmed ETN for %s: %04d",
serverResponse
.getPhensig(),
etn));
try {
GetNextEtnResponse followupResp = GFEVtecUtil.getNextEtn(
vtecToFix.getOffice(),
vtecToFix.getPhensig(),
true, true, true, etn);
responseContainer[0] = followupResp;
} catch (VizException e) {
exceptionContainer[0] = e;
exitLoopContainer[0] = true;
}
} else {
statusHandler
.info("User declined to fix ETN for %s",
serverResponse
.getPhensig());
exitLoopContainer[0] = true;
}
}
});
} while (!responseContainer[0].isOkay()
&& !exitLoopContainer[0]);
if (!responseContainer[0].isOkay()) {
String msg = "Unable to set ETN for phensig "
+ responseContainer[0].getPhensig()
+ "\nStatus: "
+ responseContainer[0].toString();
Exception e = exceptionContainer[0];
if (e == null) {
throw new VizException(msg);
} else {
throw new VizException(msg, e);
}
}
}
etnCache.put(vtec.getPhensig(), serverResponse.getNextEtn());
} catch (VizException e) {
statusHandler.handle(Priority.CRITICAL,
"Error setting ETNs for product", e);
retrieveEtnFailed = true;
VizApp.runAsync(new Runnable() {
@Override
public void run() {
sendTransmissionStatus(ConfigData.productStateEnum.Failed);
StoreTransmitDlg.this.parentEditor.revive();
}
});
break;
}
}
if (!retrieveEtnFailed) {
productText = GFEVtecUtil.finalizeETNs(productText, etnCache);
VizApp.runSync(new Runnable() {
@Override
public void run() {
StoreTransmitDlg.this.parentEditor.revive();
String pid = productIdTF.getText();
if (parentEditor.isTestVTEC()) {
if (isStoreDialog) {
parentEditor.devStore(pid.substring(3));
} else {
parentEditor.devStore(pid.substring(4));
transmitProduct(true);
}
} else {
if (isStoreDialog) {
TextDBUtil.storeProduct(pid, productText,
parentEditor.isTestVTEC());
} else {
transmitProduct(false);
}
}
}
});
return;
}
VizApp.runSync(new Runnable() {
@Override
public void run() {
String pid = productIdTF.getText();
if (parentEditor.isTestVTEC()) {
if (isStoreDialog) {
parentEditor.devStore(pid.substring(3));
} else {
parentEditor.devStore(pid.substring(4));
transmitProduct(true);
}
} else {
if (isStoreDialog) {
TextDBUtil.storeProduct(pid, productText,
parentEditor.isTestVTEC());
} else {
transmitProduct(false);
}
}
}
});
}
// The asyncExec call is used to dispose of the shell since it is

View file

@ -124,6 +124,7 @@ import com.raytheon.viz.gfe.Activator;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 2, 2008 #1161 randerso Initial creation
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -380,7 +381,7 @@ public class DiscreteInterp extends Interp {
findWxTypeGroups(joint, single);
// do joint interpolation if needed.
if (joint.size() > 0 && joint.get(0) != 0 && joint.get(1) != 0) {
if ((joint.size() > 0) && (joint.get(0) != 0) && (joint.get(1) != 0)) {
jointInterpControl(joint, workGrid1, workGrid2, groupGrid1,
groupGrid2, newGrid, fraction, interpResult);
}
@ -441,8 +442,8 @@ public class DiscreteInterp extends Interp {
Grid2DByte grid2 = baseData2.getDiscreteGrid();
// extract the lists of weatherKeys associated with each index grid
DiscreteKey[] keys1 = baseData1.getKey();
DiscreteKey[] keys2 = baseData2.getKey();
DiscreteKey[] keys1 = baseData1.getKeys();
DiscreteKey[] keys2 = baseData2.getKeys();
// Make a list of DiscreteKeys that spans both keys1 and keys2.
@ -711,18 +712,18 @@ public class DiscreteInterp extends Interp {
if (x < 0) {
x = 0;
}
if (x > _xDim - 1) {
if (x > (_xDim - 1)) {
x = _xDim - 1;
}
if (y < 0) {
y = 0;
}
if (y > _yDim - 1) {
if (y > (_yDim - 1)) {
y = _yDim - 1;
}
// if the point has a different and non-zero value
if (grid.get(x, y) != 0 && grid.get(x, y) != wxValue) {
if ((grid.get(x, y) != 0) && (grid.get(x, y) != wxValue)) {
// have found a contiguous point of differing value
// set flag for contiguous point
@ -848,8 +849,8 @@ public class DiscreteInterp extends Interp {
for (j = 1; j < _wxTypeInfoMatrix.getYDim(); j++) {
// if types match, and
// if it contiguous to other types
if (_wxTypeList1.get(i).wxType == _wxTypeInfoMatrix.get(0,
j) && _wxTypeList1.get(i).isContig) {
if ((_wxTypeList1.get(i).wxType == _wxTypeInfoMatrix.get(0,
j)) && _wxTypeList1.get(i).isContig) {
// now there is a list of the types this one
// is contiguous to, but they may not be in
// same order as first column in matrix.
@ -858,10 +859,10 @@ public class DiscreteInterp extends Interp {
// when find it, flag in matrix, but only in
// upper left half: where j>m
for (m = 1; m < _wxTypeInfoMatrix.getXDim(); m++) {
if (j > m
&& _wxTypeInfoMatrix.get(m, 0) == _wxTypeList1
if ((j > m)
&& (_wxTypeInfoMatrix.get(m, 0) == _wxTypeList1
.get(i).contigWxType.get(k)
.intValue()) {
.intValue())) {
_wxTypeInfoMatrix.set(m, j, 1); // done!
}
}
@ -876,14 +877,14 @@ public class DiscreteInterp extends Interp {
for (i = 0; i < _wxTypeList2.size(); i++) {
if (_wxTypeList2.get(i).wxType != 0) {
for (m = 1; m < _wxTypeInfoMatrix.getXDim(); m++) {
if (_wxTypeList2.get(i).wxType == _wxTypeInfoMatrix.get(m,
0) && _wxTypeList2.get(i).isContig) {
if ((_wxTypeList2.get(i).wxType == _wxTypeInfoMatrix.get(m,
0)) && _wxTypeList2.get(i).isContig) {
for (k = 0; k < _wxTypeList2.get(i).contigWxType.size(); k++) {
for (j = 1; j < _wxTypeInfoMatrix.getXDim(); j++) {
if (m > j
&& _wxTypeInfoMatrix.get(0, j) == _wxTypeList2
if ((m > j)
&& (_wxTypeInfoMatrix.get(0, j) == _wxTypeList2
.get(i).contigWxType.get(k)
.intValue()) {
.intValue())) {
_wxTypeInfoMatrix.set(m, j, 1); // done!
}
}
@ -945,9 +946,10 @@ public class DiscreteInterp extends Interp {
// loop over left col
for (n = 1; n < _wxTypeInfoMatrix.getYDim(); n++) {
if (n != m // not on diagonal
&& _wxTypeInfoMatrix.get(m, n) == 1
&& _wxTypeInfoMatrix.get(n, m) == 1) {
if ((n != m // not on diagonal
)
&& (_wxTypeInfoMatrix.get(m, n) == 1)
&& (_wxTypeInfoMatrix.get(n, m) == 1)) {
jointInterp = true;
// add _wxTypeInfoMatrix(m,0) to joint if not already
@ -1080,7 +1082,7 @@ public class DiscreteInterp extends Interp {
for (i = 0; i < joint.size(); i++) {
if (size[i] != 0) {
for (j = i + 1; j < joint.size(); j++) {
if (size[j] > size[i] && size[j] > 0) {
if ((size[j] > size[i]) && (size[j] > 0)) {
tempwx = joint.get(i);
tempsize = size[i];
joint.set(i, joint.get(j));
@ -1178,11 +1180,11 @@ public class DiscreteInterp extends Interp {
// kind of weather wxValue were found in that grid. Reset the
// 0,0 to the other center x,y so the area does not move to the
// corner. It will grow or shrink in the same place.
if (center1.x == 0 && center1.y == 0) {
if ((center1.x == 0) && (center1.y == 0)) {
center1.x = center2.x;
center1.y = center2.y;
}
if (center2.x == 0 && center2.y == 0) {
if ((center2.x == 0) && (center2.y == 0)) {
center2.x = center1.x;
center2.y = center1.y;
}
@ -1208,26 +1210,26 @@ public class DiscreteInterp extends Interp {
y = j + _dy;
// if the translated point is still on visible grid
if (x >= 0 && x < _xDim && y >= 0 && y < _yDim) {
if ((x >= 0) && (x < _xDim) && (y >= 0) && (y < _yDim)) {
// if this point is part of BOTH the original area,
// and part of the final area when translated,
// it is a point in the "core area."
if (_featureStart.get(i, j) == wxValue
&& _featureEnd.get(x, y) == wxValue) {
if ((_featureStart.get(i, j) == wxValue)
&& (_featureEnd.get(x, y) == wxValue)) {
_coreArea.set(i, j, 1);
}
// if it appears in original grid but not in final grid,
// it will "fade away", so note in _fadeArea.
if (_featureStart.get(i, j) == wxValue
&& _featureEnd.get(x, y) != wxValue) {
_fadeArea.set(i + _xDim / 2, j + _yDim / 2, 1);
if ((_featureStart.get(i, j) == wxValue)
&& (_featureEnd.get(x, y) != wxValue)) {
_fadeArea.set(i + (_xDim / 2), j + (_yDim / 2), 1);
// compute distance "dist" from center of
// weather area to this _fadeArea point
dist = (float) Math.sqrt((i - center1.x)
* (i - center1.x) + (j - center1.y)
* (j - center1.y));
dist = (float) Math
.sqrt(((i - center1.x) * (i - center1.x))
+ ((j - center1.y) * (j - center1.y)));
// compute which angle sector this point lies in
deltax = i - center1.x;
@ -1240,8 +1242,8 @@ public class DiscreteInterp extends Interp {
_faControl.set(sector, 1, dist);
}
// set min distance to edge of _fadeArea in this sector
if (dist < _faControl.get(sector, 0)
|| _faControl.get(sector, 0) == 0.0f) {
if ((dist < _faControl.get(sector, 0))
|| (_faControl.get(sector, 0) == 0.0f)) {
_faControl.set(sector, 0, dist);
}
}
@ -1250,11 +1252,12 @@ public class DiscreteInterp extends Interp {
// for original grid points which land
// outside data grid when projected:
// keep 'em as _fadeArea points.
if (_featureStart.get(i, j) == wxValue
&& (x < 0 || x >= _xDim || y < 0 || y >= _yDim)) {
_fadeArea.set(i + _xDim / 2, j + _yDim / 2, 1);
dist = (float) Math.sqrt((i - center1.x) * (i - center1.x)
+ (j - center1.y) * (j - center1.y));
if ((_featureStart.get(i, j) == wxValue)
&& ((x < 0) || (x >= _xDim) || (y < 0) || (y >= _yDim))) {
_fadeArea.set(i + (_xDim / 2), j + (_yDim / 2), 1);
dist = (float) Math
.sqrt(((i - center1.x) * (i - center1.x))
+ ((j - center1.y) * (j - center1.y)));
// compute which angle sector this point lies in
deltax = i - center1.x;
@ -1267,8 +1270,8 @@ public class DiscreteInterp extends Interp {
_faControl.set(sector, 1, dist);
}
// set min distance to edge of _fadeArea in this sector
if (dist < _faControl.get(sector, 0)
|| _faControl.get(sector, 0) == 0.0f) {
if ((dist < _faControl.get(sector, 0))
|| (_faControl.get(sector, 0) == 0.0f)) {
_faControl.set(sector, 0, dist);
}
}
@ -1306,16 +1309,17 @@ public class DiscreteInterp extends Interp {
mainy = y - _dy;
// indices in the _growArea grid:
m = mainx + _xDim / 2;
n = mainy + _yDim / 2;
m = mainx + (_xDim / 2);
n = mainy + (_yDim / 2);
// (make sure (n,m) inside the _growArea grid)
if (m >= 0 && m < 2 * _xDim && n >= 0 && n < 2 * _yDim) {
if ((m >= 0) && (m < (2 * _xDim)) && (n >= 0)
&& (n < (2 * _yDim))) {
_growArea.set(m, n, 1);
// compute distance "dist" from center of
// weather area to this _growArea point
arg = (mainx - center1.x) * (mainx - center1.x)
+ (mainy - center1.y) * (mainy - center1.y);
arg = ((mainx - center1.x) * (mainx - center1.x))
+ ((mainy - center1.y) * (mainy - center1.y));
dist = (float) Math.sqrt(arg);
// compute which angle sector this point lies in
@ -1330,8 +1334,8 @@ public class DiscreteInterp extends Interp {
}
// set min distance to edge of _growArea in this sector
if (dist < _gaControl.get(sector, 0)
|| _gaControl.get(sector, 0) == 0.0f) {
if ((dist < _gaControl.get(sector, 0))
|| (_gaControl.get(sector, 0) == 0.0f)) {
_gaControl.set(sector, 0, dist);
}
}
@ -1373,14 +1377,14 @@ public class DiscreteInterp extends Interp {
// (A) number of radians per sector = 2 * pi /(how many sectors in
// circle)
double step = 2.0 * Math.PI / _numSectors;
double step = (2.0 * Math.PI) / _numSectors;
// compartimentalize into sectors:
sector = (int) (0.5 + (angle + Math.PI) / step) - 1;
sector = (int) (0.5 + ((angle + Math.PI) / step)) - 1;
// (A)
// bad value clamp (should not occur)
if (sector < 0 || sector >= _numSectors) {
if ((sector < 0) || (sector >= _numSectors)) {
sector = 0;
}
@ -1418,8 +1422,8 @@ public class DiscreteInterp extends Interp {
Point center = new Point();
if (num != 0) {
center.x = (int) (0.5 + sumX / num);
center.y = (int) (0.5 + sumY / num);
center.x = (int) (0.5 + (sumX / num));
center.y = (int) (0.5 + (sumY / num));
} else {
center.x = 0;
center.y = 0;
@ -1505,18 +1509,18 @@ public class DiscreteInterp extends Interp {
// Add in points from grow and fade Areas where appropriate.
// loop over coordinates for _growArea and _fadeArea grids
for (int i = 0; i < 2 * _xDim; i++) {
for (int j = 0; j < 2 * _yDim; j++) {
for (int i = 0; i < (2 * _xDim); i++) {
for (int j = 0; j < (2 * _yDim); j++) {
// "i,j" positions for grow or fade area
// as if on on main grid coordinates (there may not actually
// be any main grid points with these indexes).
mainx = i - _xDim / 2;
mainy = j - _yDim / 2;
mainx = i - (_xDim / 2);
mainy = j - (_yDim / 2);
// distance from center of initial area to this g or f area
// point.
dist = Math.sqrt((mainx - center1.x) * (mainx - center1.x)
+ (mainy - center1.y) * (mainy - center1.y));
dist = Math.sqrt(((mainx - center1.x) * (mainx - center1.x))
+ ((mainy - center1.y) * (mainy - center1.y)));
// translated position for this step:
// (coordinates in _growArea and _fadeArea grid system)
@ -1524,8 +1528,8 @@ public class DiscreteInterp extends Interp {
int jj = j + (int) ((_dy * zeta) + 0.5);
// translated position on main grid
tmainy = jj - _yDim / 2;
tmainx = ii - _xDim / 2;
tmainy = jj - (_yDim / 2);
tmainx = ii - (_xDim / 2);
// get angle sector for this point
sector = findAngleSector(mainx - center1.x, mainy - center1.y);
@ -1568,8 +1572,9 @@ public class DiscreteInterp extends Interp {
// from center of moving area, addthis point to the weather
// area.
// (also make sure it's on the main grid!)
if (dist < testGAdist && tmainy >= 0 && tmainx < _xDim
&& tmainx >= 0 && tmainy < _yDim) {
if ((dist < testGAdist) && (tmainy >= 0)
&& (tmainx < _xDim) && (tmainx >= 0)
&& (tmainy < _yDim)) {
newGrid.set(tmainx, tmainy, wxValue);
}
@ -1609,8 +1614,9 @@ public class DiscreteInterp extends Interp {
// only keep a _fadeArea point inside the
// limiting distance
// (also make sure it's on the main grid!)
if (dist < testFAdist && tmainy >= 0 && tmainy < _yDim
&& tmainx >= 0 && tmainx < _xDim) {
if ((dist < testFAdist) && (tmainy >= 0)
&& (tmainy < _yDim) && (tmainx >= 0)
&& (tmainx < _xDim)) {
newGrid.set(tmainx, tmainy, wxValue);
}
}

View file

@ -164,6 +164,7 @@ import com.vividsolutions.jts.geom.Envelope;
* Mar 04, 2013 1637 randerso Fix time matching for ISC grids
* Aug 27, 2013 2287 randerso Fixed scaling and direction of wind arrows
* Sep 23, 2013 2363 bsteffen Add more vector configuration options.
* Oct 31, 2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -340,7 +341,7 @@ public class GFEResource extends
* changed, data appeared/disappeared)
*/
private void resetFrame(TimeRange timeRange) {
if (curTime != null && timeRange.overlaps(curTime.getValidPeriod())) {
if ((curTime != null) && timeRange.overlaps(curTime.getValidPeriod())) {
lastDisplayedTime = null;
issueRefresh();
}
@ -492,7 +493,7 @@ public class GFEResource extends
// hack to get around target.getDefaultFont()-centeredness in
// contourDisplay.
double contourMagnification = magnification * gfeFont.getFontSize()
double contourMagnification = (magnification * gfeFont.getFontSize())
/ target.getDefaultFont().getFontSize();
double density = parm.getDisplayAttributes().getDensity();
@ -509,7 +510,7 @@ public class GFEResource extends
.getValidPeriod());
boolean iscParm = this.parm.isIscParm();
if (gd.length == 0 && !dataManager.getParmManager().iscMode()) {
if ((gd.length == 0) && !dataManager.getParmManager().iscMode()) {
return;
}
@ -519,7 +520,7 @@ public class GFEResource extends
if (!this.curTime.equals(this.lastDisplayedTime)
|| !visMode.equals(this.lastVisMode)
|| this.lastIscMode != dataManager.getParmManager().iscMode()) {
|| (this.lastIscMode != dataManager.getParmManager().iscMode())) {
this.lastDisplayedTime = this.curTime;
this.lastVisMode = visMode;
@ -537,7 +538,7 @@ public class GFEResource extends
if (gd != null) {
IGridSlice gs = null;
if (dataManager.getParmManager().iscMode() && gd.length == 0) {
if (dataManager.getParmManager().iscMode() && (gd.length == 0)) {
GridParmInfo gpi = this.parm.getGridInfo();
GridType gridType = gpi.getGridType();
@ -583,8 +584,8 @@ public class GFEResource extends
gs = gd[0].getGridSlice();
}
if (gs instanceof VectorGridSlice
|| gs instanceof ScalarGridSlice) {
if ((gs instanceof VectorGridSlice)
|| (gs instanceof ScalarGridSlice)) {
if (this.gridDisplay != null) {
this.gridDisplay.dispose();
@ -660,9 +661,8 @@ public class GFEResource extends
mag, dir, descriptor, MapUtil
.getGridGeometry(gs.getGridInfo()
.getGridLoc()),
VECTOR_DENSITY_FACTOR,
false, visTypeToDisplayType(type),
vectorConfig));
VECTOR_DENSITY_FACTOR, false,
visTypeToDisplayType(type), vectorConfig));
break;
case WIND_BARB:
@ -753,7 +753,7 @@ public class GFEResource extends
gid, true, slice);
}
for (DiscreteKey discreteKey : slice.getKey()) {
for (DiscreteKey discreteKey : slice.getKeys()) {
if (discreteKey.isValid()) {
outlineShapes.put(discreteKey, target
@ -1330,9 +1330,9 @@ public class GFEResource extends
Coordinate gridCoord = MapUtil.latLonToGridCoordinate(coord,
PixelOrientation.CENTER, gridLocation);
if (gridCoord.x < 0 || gridCoord.y < 0
|| gridCoord.x >= gridLocation.getNx()
|| gridCoord.y >= gridLocation.getNy()) {
if ((gridCoord.x < 0) || (gridCoord.y < 0)
|| (gridCoord.x >= gridLocation.getNx())
|| (gridCoord.y >= gridLocation.getNy())) {
return;
}
@ -1471,21 +1471,21 @@ public class GFEResource extends
// now see if adjacent grid cells exist containing the
// same data.
if ((xGrid + xLabelGrid > gridDim.x) || (xGrid - 1 < 0)) {
if (((xGrid + xLabelGrid) > gridDim.x) || ((xGrid - 1) < 0)) {
continue;
}
if ((yGrid + yLabelGrid > gridDim.y) || (yGrid - 1 < 0)) {
if (((yGrid + yLabelGrid) > gridDim.y) || ((yGrid - 1) < 0)) {
continue;
}
byte weatherByteVal = byteData.get(xGrid, yGrid);
boolean printLabel = true;
for (int ii = xGrid - 1; ii < xGrid + xLabelGrid; ii++) {
for (int j = yGrid - 1; j < yGrid + yLabelGrid; j++) {
for (int ii = xGrid - 1; ii < (xGrid + xLabelGrid); ii++) {
for (int j = yGrid - 1; j < (yGrid + yLabelGrid); j++) {
if (!parm.getDisplayAttributes().getDisplayMask()
.getAsBoolean(ii, j)
|| byteData.get(ii, j) != weatherByteVal) {
|| (byteData.get(ii, j) != weatherByteVal)) {
printLabel = false;
break;
}
@ -1550,9 +1550,9 @@ public class GFEResource extends
for (xpos = gridOffset; xpos < gridDim.x; xpos += gridInterval) {
yCounter++;
int xCounter = 0;
for (ypos = yCounter % 4 + 1; ypos < gridDim.y - gridOffset; ypos += gridInterval) {
for (ypos = (yCounter % 4) + 1; ypos < (gridDim.y - gridOffset); ypos += gridInterval) {
xCounter++;
int xGrid = xpos + (xCounter % 4 * gridOffset);
int xGrid = xpos + ((xCounter % 4) * gridOffset);
if (xGrid > gridDim.x) {
break;
}

View file

@ -96,6 +96,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Jan 23, 2013 #1524 randerso Fix missing discrete color bar and error when clicking
* on discrete color bar when no grid exists
* Feb 12, 2013 15719 jdynina Fixed out of bounds error in calcGridColorTable
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -213,7 +214,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
public void paint(IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
DataTime currentTime = paintProps.getFramesInfo().getCurrentFrame();
if (parm == null || currentTime == null) {
if ((parm == null) || (currentTime == null)) {
return;
}
@ -241,7 +242,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
DiscreteGridSlice slice = new DiscreteGridSlice();
parm.getDataManager().getIscDataAccess()
.getCompositeGrid(gid, true, slice);
if (slice.getKey().length == 0) {
if (slice.getKeys().length == 0) {
return;
}
iscGridData = new DiscreteGridData(this.parm, slice);
@ -365,7 +366,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
}
// for DISCRETE
else {
DiscreteKey[] dKeys = ((DiscreteGridSlice) gs).getKey();
DiscreteKey[] dKeys = ((DiscreteGridSlice) gs).getKeys();
for (int i = 0; i < 256; i++) {
if (cArray[i]) {
gridWValues.add(new DiscreteWxValue(dKeys[i], parm));
@ -485,7 +486,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
double pickupLabelSize = target.getStringsBounds(dstring)
.getWidth();
double pickupLabelDrawPoint = (minX + (pickupIndex * keywidth) + keywidth / 2)
double pickupLabelDrawPoint = (minX + (pickupIndex * keywidth) + (keywidth / 2))
* xScaleFactor;
pickupLabelMinX = pickupLabelDrawPoint - (pickupLabelSize / 2);
pickupLabelMaxX = pickupLabelDrawPoint + (pickupLabelSize / 2);
@ -535,7 +536,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
maxY, 0.0, seColorBarTickColor, 1.0f);
String keyName = colorEntry.getValue().toString();
labelLoc = (float) (minX + ikeywidth) + (float) keywidth / 2;
labelLoc = (float) (minX + ikeywidth) + ((float) keywidth / 2);
double boxMinXCoord = (minX + ikeywidth) * xScaleFactor;
double boxMaxXCoord = boxMinXCoord + (keywidth * xScaleFactor);
@ -591,15 +592,15 @@ public class DiscreteColorbar implements IColorBarDisplay,
int x = 0;
for (ColorEntry colorEntry : colorTable) {
// calculate the bounding box from x
PixelExtent pe = new PixelExtent(x1 + x * keywidth, x1 + (x + 1)
* keywidth, y1, y2);
PixelExtent pe = new PixelExtent(x1 + (x * keywidth), x1
+ ((x + 1) * keywidth), y1, y2);
Coordinate[] coordinates = new Coordinate[5];
coordinates[0] = new Coordinate(x1 + x * keywidth, y1);
coordinates[1] = new Coordinate(x1 + (x + 1) * keywidth, y1);
coordinates[2] = new Coordinate(x1 + (x + 1) * keywidth, y2);
coordinates[3] = new Coordinate(x1 + x * keywidth, y2);
coordinates[4] = new Coordinate(x1 + x * keywidth, y1);
coordinates[0] = new Coordinate(x1 + (x * keywidth), y1);
coordinates[1] = new Coordinate(x1 + ((x + 1) * keywidth), y1);
coordinates[2] = new Coordinate(x1 + ((x + 1) * keywidth), y2);
coordinates[3] = new Coordinate(x1 + (x * keywidth), y2);
coordinates[4] = new Coordinate(x1 + (x * keywidth), y1);
// draw the shaded rectangle with the correct color(s) and
// pattern(s)

View file

@ -52,7 +52,7 @@ import com.raytheon.viz.gfe.types.MutableInteger;
/**
* Contains a complete histogram for a single grid and parameter
*
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
@ -63,9 +63,10 @@ import com.raytheon.viz.gfe.types.MutableInteger;
* May 29, 2009 2159 rjpeter Optimized sample methods.
* May 24, 2012 673 randerso Added defaulted method calls
* Jun 17, 2013 15951 ryu Fix index to wx/discrete key array
*
* Oct 31, 2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
*
* @author mnash
* @version 1.0
*/
@ -176,7 +177,7 @@ public class HistSample {
* Description : Constructor far HistSample taking a histogram in the form
* of a time range and a sequence of HistPairs, stores the information in
* private data. Counts up the samples and stores that in _numSamplePoints.
*
*
* @param timeRange
* @param histPairs
*/
@ -211,7 +212,7 @@ public class HistSample {
* cached. Sets number of sample points to zero. Calls sampleGrid() to
* sample the grid. If successful, stores the time range and counts up the
* number of sample points.
*
*
* @param gridSlice
* @param sampleArea
* @param cachePoints
@ -251,13 +252,13 @@ public class HistSample {
* for WEATHER. The most common value for DISCRETE. For vector, if
* separateMagDir is true, the magnitude is averaged separately from the
* direction.
*
*
* @param separateMagDir
* @return
*/
public final HistValue average(boolean separateMagDir) {
if (separateMagDir == _averageMagDir && _average != null) {
if ((separateMagDir == _averageMagDir) && (_average != null)) {
return _average;
}
@ -326,7 +327,7 @@ public class HistSample {
* _histPairs.get(i).value().magnitude();
float v = uSum / count;
float u = vSum / count;
float mag = binit((float) Math.sqrt(u * u + v * v),
float mag = binit((float) Math.sqrt((u * u) + (v * v)),
_resolution);
float dir = binit((float) (Math.atan2(u, v) * RAD_TO_DEG),
10.0f);
@ -361,7 +362,7 @@ public class HistSample {
/**
* Description : the square root function
*
*
* @param val
* @return
*/
@ -378,7 +379,7 @@ public class HistSample {
* Returns the standard deviation of each component separately for VECTOR.
* Should not be called for WEATHER. For vector, if separate MagDir is true,
* the magnitude is averaged separately from the direction.
*
*
* @return
*/
public final HistValue stdDev() {
@ -408,7 +409,7 @@ public class HistSample {
float dev = 0.0f;
if (count != 0) {
dev = (float) squareRoot((sum2 - (sum * sum) / count) / count);
dev = (float) squareRoot((sum2 - ((sum * sum) / count)) / count);
}
hs._stdDev = new HistValue(dev);
return _stdDev;
@ -444,10 +445,10 @@ public class HistSample {
float vdev = 0.0f;
if (count != 0) {
dev = (float) squareRoot((sum2 - (sum * sum) / count) / count);
udev = (float) squareRoot((uSum2 - (uSum * uSum) / count)
dev = (float) squareRoot((sum2 - ((sum * sum) / count)) / count);
udev = (float) squareRoot((uSum2 - ((uSum * uSum) / count))
/ count);
vdev = (float) squareRoot((vSum2 - (vSum * vSum) / count)
vdev = (float) squareRoot((vSum2 - ((vSum * vSum) / count))
/ count);
}
hs._stdDev = new HistValue(dev, udev + udev);
@ -470,7 +471,7 @@ public class HistSample {
* the HistPair's for the maximum count value and returns it. In the case
* where more than one entry shares the maximum count value, then only the
* highest value (sort order) value will be returned.
*
*
* @return
*/
public final HistValue mostCommonValue() {
@ -504,7 +505,7 @@ public class HistSample {
* case where more than one entyr shares the maximum count value, then only
* the highest value (sort order) value will be returned. Works only on
* SCALAR and VECTOR.
*
*
* @param resolution
* @return
*/
@ -515,7 +516,7 @@ public class HistSample {
// cached?
if ((_binnedMostCommonValue != null)
&& resolution == _binnedMostCommonValueFactor) {
&& (resolution == _binnedMostCommonValueFactor)) {
return _binnedMostCommonValue;
}
@ -543,11 +544,11 @@ public class HistSample {
* Finds and returns the middle value associated with the sample. The middle
* value is that value that is halfway between the lowest and highest in
* terms of count, and not value. This is a no-op for WEATHER/DISCRETE.
*
*
* @return
*/
public final HistValue middleValue() {
if (_histPairs.size() == 0
if ((_histPairs.size() == 0)
|| _histPairs.get(0).value().dataType()
.equals(GridType.WEATHER)
|| _histPairs.get(0).value().dataType()
@ -564,7 +565,7 @@ public class HistSample {
int runningCount = 0;
for (int i = 0; i < _histPairs.get(i).count(); i++) {
runningCount += _histPairs.get(i).count();
if ((float) runningCount / (float) _numSamplePoints > 0.50) {
if (((float) runningCount / (float) _numSamplePoints) > 0.50) {
hs._middleValue = _histPairs.get(i).value();
return _middleValue;
}
@ -577,11 +578,11 @@ public class HistSample {
* Description : Returns the absolute minimum value for the sample points.
* This is a no-op for WEATHER/DISCRETE. Only the magnitude component for
* VECTOR is used for comparison.
*
*
* @return
*/
public final HistValue absoluteMin() {
if (_histPairs.size() == 0
if ((_histPairs.size() == 0)
|| _histPairs.get(0).value().dataType()
.equals(GridType.WEATHER)
|| _histPairs.get(0).value().dataType()
@ -603,11 +604,11 @@ public class HistSample {
* Description : REturns the absolute maximum value for the sample points.
* This is a no-op for WEATHER/DISCRETE. Only the magnitude component for
* VECTOR is used for comparison.
*
*
* @return
*/
public final HistValue absoluteMax() {
if (_histPairs.size() == 0
if ((_histPairs.size() == 0)
|| _histPairs.get(0).value().dataType()
.equals(GridType.WEATHER)
|| _histPairs.get(0).value().dataType()
@ -643,7 +644,7 @@ public class HistSample {
* most common value is provide for WEATERH. Outliers are eliminated.
* Percent ranges from 0 to 50. For vector, if separateMagDir is true, the
* magnitude is averaged separately from the direction.
*
*
* @param minpercent
* @param maxpercent
* @param separateMagDir
@ -653,17 +654,17 @@ public class HistSample {
boolean separateMagDir) {
HistValue bogus = new HistValue();
HistSample hs = this;
if (_histPairs.size() == 0 || minpercent < 0 || minpercent > 50
|| maxpercent < 0 || maxpercent > 50) {
if ((_histPairs.size() == 0) || (minpercent < 0) || (minpercent > 50)
|| (maxpercent < 0) || (maxpercent > 50)) {
hs._moderatedAverage = new HistValue();
hs._moderatedAverageMinPercent = hs._moderatedAverageMaxPercent = 0;
return _moderatedAverage;
}
// cached value
if (minpercent == _moderatedAverageMinPercent
&& maxpercent == _moderatedAverageMaxPercent
&& _moderatedAverage != null) {
if ((minpercent == _moderatedAverageMinPercent)
&& (maxpercent == _moderatedAverageMaxPercent)
&& (_moderatedAverage != null)) {
return _moderatedAverage;
}
@ -672,8 +673,8 @@ public class HistSample {
hs._moderatedAverageMaxPercent = maxpercent;
float runningCount = 0;
int minlimitCount = (int) (minpercent * _numSamplePoints / 100.0);
int maxlimitCount = (int) ((100 - maxpercent) * _numSamplePoints / 100.0);
int minlimitCount = (int) ((minpercent * _numSamplePoints) / 100.0);
int maxlimitCount = (int) (((100 - maxpercent) * _numSamplePoints) / 100.0);
switch (_histPairs.get(0).value().dataType()) {
case SCALAR: {
@ -684,11 +685,11 @@ public class HistSample {
int maxVCount = (int) runningCount + _histPairs.get(i).count();
int numInclude = 0;
if (minlimitCount > maxVCount || maxlimitCount < minVCount) {
if ((minlimitCount > maxVCount) || (maxlimitCount < minVCount)) {
numInclude = 0;
} else {
numInclude = Math.max(minlimitCount, minVCount)
- Math.min(maxlimitCount, maxVCount) + 1;
numInclude = (Math.max(minlimitCount, minVCount) - Math
.min(maxlimitCount, maxVCount)) + 1;
}
if (numInclude != 0) {
@ -714,11 +715,12 @@ public class HistSample {
+ _histPairs.get(i).count();
int numInclude = 0;
if (minlimitCount > maxVCount || maxlimitCount < minVCount) {
if ((minlimitCount > maxVCount)
|| (maxlimitCount < minVCount)) {
numInclude = 0;
} else {
numInclude = Math.max(minlimitCount, minVCount)
- Math.min(maxlimitCount, maxVCount) + 1;
numInclude = (Math.max(minlimitCount, minVCount) - Math
.min(maxlimitCount, maxVCount)) + 1;
}
if (numInclude != 0) {
int tCount = numInclude;
@ -757,11 +759,12 @@ public class HistSample {
+ _histPairs.get(i).count();
int numInclude = 0;
if (minlimitCount > maxVCount || maxlimitCount < minVCount) {
if ((minlimitCount > maxVCount)
|| (maxlimitCount < minVCount)) {
numInclude = 0;
} else {
numInclude = Math.max(minlimitCount, minVCount)
- Math.min(maxlimitCount, maxVCount) + 1;
numInclude = (Math.max(minlimitCount, minVCount) - Math
.min(maxlimitCount, maxVCount)) + 1;
}
if (numInclude != 0) {
@ -782,7 +785,8 @@ public class HistSample {
}
float u = uSum / count;
float v = vSum / count;
float mag = binit((float) Math.sqrt(u * u + v * v), _resolution);
float mag = binit((float) Math.sqrt((u * u) + (v * v)),
_resolution);
float dir = binit((float) (Math.atan2(u, v) * RAD_TO_DEG),
10.0f);
while (dir < 0.0) {
@ -821,29 +825,29 @@ public class HistSample {
* points. this is a no-op for WEATHER/DISCRETE. Percent should be between 0
* and 50. This routine eliminates the bottom xx% of sample values and
* returns that value.
*
*
* @param percent
* @return
*/
public final HistValue moderatedMin(int percent) {
HistSample hs = this;
if (_histPairs.size() == 0 || percent < 0 || percent > 50
|| _histPairs.get(0).value().dataType() == GridType.WEATHER
|| _histPairs.get(0).value().dataType() == GridType.DISCRETE) {
if ((_histPairs.size() == 0) || (percent < 0) || (percent > 50)
|| (_histPairs.get(0).value().dataType() == GridType.WEATHER)
|| (_histPairs.get(0).value().dataType() == GridType.DISCRETE)) {
hs._moderatedMin = new HistValue();
hs._moderatedMinPercent = 0;
return _moderatedMin; // default histValue()
}
// cached?
if (_moderatedMinPercent == percent && _moderatedMin != null) {
if ((_moderatedMinPercent == percent) && (_moderatedMin != null)) {
return _moderatedMin;
}
hs._moderatedMinPercent = percent;
float runningCount = 0;
float limitCount = (float) (percent * _numSamplePoints / 100.0);
float limitCount = (float) ((percent * _numSamplePoints) / 100.0);
for (int i = 0; i < _histPairs.size(); i++) {
runningCount += _histPairs.get(i).count();
@ -865,15 +869,15 @@ public class HistSample {
* points. This is a no-op for WEATHER/DISCRETE. Percent should be between 0
* and 50. This routine eliminates the top 15% of sample values and returns
* that value.
*
*
* @param percent
* @return
*/
public final HistValue moderatedMax(int percent) {
HistSample hs = this;
if (_histPairs.size() == 0
|| percent < 0
|| percent > 50
if ((_histPairs.size() == 0)
|| (percent < 0)
|| (percent > 50)
|| _histPairs.get(0).value().dataType()
.equals(GridType.WEATHER)
|| _histPairs.get(0).value().dataType()
@ -884,14 +888,14 @@ public class HistSample {
}
// cached?
if (_moderatedMax != null && _moderatedMaxPercent == percent) {
if ((_moderatedMax != null) && (_moderatedMaxPercent == percent)) {
return _moderatedMax;
}
hs._moderatedMaxPercent = percent;
float runningCount = 0;
float limitCount = (float) (percent * _numSamplePoints / 100.0);
float limitCount = (float) ((percent * _numSamplePoints) / 100.0);
for (int i = _histPairs.size() - 1; i >= 0; i--) {
runningCount += _histPairs.get(i).count();
@ -922,7 +926,7 @@ public class HistSample {
* most common value is provided for WEATHER/DISCRETE. Outliers are
* eliminated based on standard deviation. For vector, if separateMagDir is
* true, the magnitude is averaged separately from the direction.
*
*
* @param minStdD
* @param maxStdD
* @param separateMagDir
@ -933,7 +937,7 @@ public class HistSample {
HistValue bogus = new HistValue();
HistSample hs = this;
if (_histPairs.size() == 0 || minStdD < 0 || maxStdD < 0) {
if ((_histPairs.size() == 0) || (minStdD < 0) || (maxStdD < 0)) {
hs._stdDevAvgMinStdD = hs._stdDevAvgMaxStdD = 0;
hs._stdDevMagDir = false;
hs._stdDevAvg = new HistValue();
@ -941,9 +945,9 @@ public class HistSample {
}
// use cached value if possible
if (_stdDevAvg != null && _stdDevAvgMinStdD == minStdD
&& _stdDevAvgMaxStdD == maxStdD
&& separateMagDir == _stdDevMagDir) {
if ((_stdDevAvg != null) && (_stdDevAvgMinStdD == minStdD)
&& (_stdDevAvgMaxStdD == maxStdD)
&& (separateMagDir == _stdDevMagDir)) {
return _stdDevAvg;
}
@ -955,13 +959,13 @@ public class HistSample {
case SCALAR: {
float sDev = stdDev().scalar();
float avg = average(true).scalar();
float minValue = avg - minStdD * sDev;
float maxValue = avg + maxStdD * sDev;
float minValue = avg - (minStdD * sDev);
float maxValue = avg + (maxStdD * sDev);
float sum = 0.0f;
int count = 0;
for (int i = 0; i < _histPairs.size(); i++) {
float v = _histPairs.get(i).value().scalar();
if (v >= minValue && v <= maxValue) {
if ((v >= minValue) && (v <= maxValue)) {
sum += _histPairs.get(i).count() * v;
count += _histPairs.get(i).count();
}
@ -975,8 +979,8 @@ public class HistSample {
case VECTOR: {
float sDev = stdDev().scalar();
float avg = average(true).scalar();
float minValue = avg - minStdD * sDev;
float maxValue = avg + maxStdD * sDev;
float minValue = avg - (minStdD * sDev);
float maxValue = avg + (maxStdD * sDev);
float sum = 0.0f;
int count = 0;
float uSum = 0.0f;
@ -984,7 +988,7 @@ public class HistSample {
if (separateMagDir) {
for (int i = 0; i < _histPairs.size(); i++) {
float v = _histPairs.get(i).value().magnitude();
if (v >= minValue && v <= maxValue) {
if ((v >= minValue) && (v <= maxValue)) {
int tCount = _histPairs.get(i).count();
sum += tCount * _histPairs.get(i).value().magnitude();
count += tCount;
@ -1018,7 +1022,7 @@ public class HistSample {
} else {
for (int i = 0; i < _histPairs.size(); i++) {
float v = _histPairs.get(i).value().magnitude();
if (v >= minValue && v <= maxValue) {
if ((v >= minValue) && (v <= maxValue)) {
int tCount = _histPairs.get(i).count();
count += tCount;
uSum += tCount
@ -1038,7 +1042,7 @@ public class HistSample {
}
float u = uSum / count;
float v = vSum / count;
float mag = binit((float) (Math.sqrt(u * u + v * v)),
float mag = binit((float) (Math.sqrt((u * u) + (v * v))),
_resolution);
float dir = binit((float) (Math.atan2(u, v) * RAD_TO_DEG),
10.0f);
@ -1075,15 +1079,15 @@ public class HistSample {
* Description : Returns the representative minimum value for the sample
* points. This is a no-op for WEATHER/DISCRETE. Based on standard
* deviations.
*
*
* @param stdD
* @return
*/
public final HistValue stdDevMin(float stdD) {
HistSample hs = this;
if (_histPairs.size() == 0
|| stdD < 0
if ((_histPairs.size() == 0)
|| (stdD < 0)
|| _histPairs.get(0).value().dataType()
.equals(GridType.WEATHER)
|| _histPairs.get(0).value().dataType()
@ -1094,7 +1098,7 @@ public class HistSample {
}
// use cached value if possible
if (_stdDevMin != null && _stdDevMinD == stdD) {
if ((_stdDevMin != null) && (_stdDevMinD == stdD)) {
return _stdDevMin;
}
@ -1102,7 +1106,7 @@ public class HistSample {
float sDev = stdDev().scalar();
float avg = average(true).scalar();
float minValue = avg - stdD * sDev;
float minValue = avg - (stdD * sDev);
if (_histPairs.get(0).value().scalar() > minValue) {
minValue = _histPairs.get(0).value().scalar();
}
@ -1118,15 +1122,15 @@ public class HistSample {
* Description : Returns the representative maximum value for the sample
* points. This is a no-op for WEATHER/DISCRETE. Based on standard
* deviations.
*
*
* @param stdD
* @return
*/
public final HistValue stdDevMax(float stdD) {
HistSample hs = this;
if (_histPairs.size() == 0
|| stdD < 0
if ((_histPairs.size() == 0)
|| (stdD < 0)
|| _histPairs.get(0).value().dataType()
.equals(GridType.DISCRETE)
|| _histPairs.get(0).value().dataType()
@ -1137,14 +1141,14 @@ public class HistSample {
}
// use cached value if possible
if (_stdDevMax != null && _stdDevMaxD == stdD) {
if ((_stdDevMax != null) && (_stdDevMaxD == stdD)) {
return _stdDevMax;
}
hs._stdDevMaxD = stdD;
float sDev = stdDev().scalar();
float avg = average(true).scalar();
float maxValue = avg + stdD * sDev;
float maxValue = avg + (stdD * sDev);
if (_histPairs.get(_histPairs.size() - 1).value().scalar() < maxValue) {
maxValue = _histPairs.get(_histPairs.size() - 1).value().scalar();
}
@ -1156,14 +1160,14 @@ public class HistSample {
/**
* OUtputs the histogram for this grid, but binned by the specified float
* value. This only applies to SCALAR and VECTOR data.
*
*
* @param resolution
* @return
*/
public List<HistPair> binnedHistogram(float resolution) {
HistSample hs = this;
if (_histPairs.size() == 0
|| resolution <= 0.0
if ((_histPairs.size() == 0)
|| (resolution <= 0.0)
|| _histPairs.get(0).value().dataType().equals(GridType.NONE)
|| _histPairs.get(0).value().dataType()
.equals(GridType.WEATHER)
@ -1230,7 +1234,7 @@ public class HistSample {
/**
* Description : Bins the data sample based on the resolution
*
*
* @param v
* @param resolution
* @return
@ -1255,7 +1259,7 @@ public class HistSample {
* that the grid is valid and grid and Grid2DBit sizes match. Ensures there
* are points in the sample area. Switch cases on data type and then
* extracts out the data for each sample point.
*
*
* @param grid
* @param area
* @param cachePoints
@ -1310,7 +1314,7 @@ public class HistSample {
/**
* If the sample was of scalars this function is called
*
*
* @param grid
* @param area
* @param cachePoints
@ -1469,7 +1473,7 @@ public class HistSample {
ParmID parmId = grid.getGridInfo().getParmID();
Grid2DByte gs = ((DiscreteGridSlice) grid).getDiscreteGrid();
String siteId = parmId.getDbId().getSiteId();
DiscreteKey[] key = ((DiscreteGridSlice) grid).getKey();
DiscreteKey[] key = ((DiscreteGridSlice) grid).getKeys();
for (int x = ll.x; x <= ur.x; x++) {
for (int y = ll.y; y <= ur.y; y++) {
if (area.get(x, y) != 0) {
@ -1525,7 +1529,7 @@ public class HistSample {
/**
* Description : counts the number of sample points and returns the number
*
*
* @return
*/
private int countSamplePoints() {
@ -1553,7 +1557,7 @@ public class HistSample {
/**
* Description : Returns the sample's valid time
*
*
* @return
*/
public final TimeRange validTime() {
@ -1562,7 +1566,7 @@ public class HistSample {
/**
* Description : Returns the histogram associated with this sample
*
*
* @return
*/
public final HistPair[] histogram() {
@ -1571,7 +1575,7 @@ public class HistSample {
/**
* Description : Returns the number of points associated with this sample
*
*
* @return
*/
public int numOfPoints() {

View file

@ -70,6 +70,7 @@ import com.raytheon.viz.gfe.core.wxvalue.WxValue;
* ------------ ---------- ----------- --------------------------
* Oct 20, 2008 njensen Initial creation
* Oct 29, 2013 2476 njensen Renamed numeric methods to numpy
* 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
* </pre>
*
* @author njensen
@ -201,7 +202,7 @@ public class SmartToolController extends BaseGfePyController {
Set<String> set = null;
String[] tools = new String[0];
try {
if (parmName == null && parmTypeName == null) {
if ((parmName == null) && (parmTypeName == null)) {
set = (Set<String>) execute("getScripts", INTERFACE, null);
} else {
HashMap<String, Object> argMap = new HashMap<String, Object>(2);
@ -325,7 +326,7 @@ public class SmartToolController extends BaseGfePyController {
jep.set("discreteGridData", grid);
jep.eval("discreteGridNumpy = discreteGridData.__numpy__");
jep.eval("discreteGridNumpy = discreteGridNumpy[0]");
DiscreteKey[] keys = grid.getDiscreteSlice().getKey();
DiscreteKey[] keys = grid.getDiscreteSlice().getKeys();
ArrayList<String> stringKeys = new ArrayList<String>();
for (DiscreteKey k : keys) {
stringKeys.add(k.toString());

View file

@ -20,12 +20,15 @@
package com.raytheon.viz.gfe.vtec;
import java.util.Collection;
import java.util.HashMap;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.raytheon.uf.common.activetable.response.GetNextEtnResponse;
import com.raytheon.uf.common.util.StringUtil;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.texteditor.util.VtecObject;
import com.raytheon.viz.texteditor.util.VtecUtil;
@ -50,6 +53,7 @@ import com.raytheon.viz.texteditor.util.VtecUtil;
* multiple NEW segments with the same
* phensig.
* Aug 29, 2013 #1843 dgilling Add hooks for inter-site ETN assignment.
* Oct 21, 2013 #1843 dgilling Use new GetNextEtnResponse.
*
* </pre>
*
@ -78,29 +82,152 @@ public class GFEVtecUtil {
throw new AssertionError();
}
public static int getNextEtn(String office, String phensig, boolean lockEtn)
throws VizException {
return getNextEtn(office, phensig, lockEtn, false);
/**
* Gets the next available ETN for a specific product and office.
*
* @param office
* The 4-character site ID of the office.
* @param phensig
* The phenomenon and significance of the hazard concatenated
* with a '.' (e.g., TO.W or DU.Y)
* @param lockEtn
* Whether or not to request an exclusive ETN--if true, this will
* cause the server to increment its running ETN sequence to the
* next number after determining the next ETN for this request.
* If false, the next ETN will be returned, but it will not
* increment the server's running sequence, so the ETN return
* could be used by another client that makes a
* GetNextEtnRequest.
* @return The next ETN in sequence, given the office and phensig.
* @throws VizException
* If an error occurred sending the request to the server.
*/
public static GetNextEtnResponse getNextEtn(String office, String phensig,
boolean lockEtn) throws VizException {
return getNextEtn(office, phensig, lockEtn, false, false, null);
}
public static int getNextEtn(String office, String phensig,
/**
* Gets the next available ETN for a specific product and office.
*
* @param office
* The 4-character site ID of the office.
* @param phensig
* The phenomenon and significance of the hazard concatenated
* with a '.' (e.g., TO.W or DU.Y)
* @param lockEtn
* Whether or not to request an exclusive ETN--if true, this will
* cause the server to increment its running ETN sequence to the
* next number after determining the next ETN for this request.
* If false, the next ETN will be returned, but it will not
* increment the server's running sequence, so the ETN return
* could be used by another client that makes a
* GetNextEtnRequest.
* @param performISC
* Whether or not to collaborate with neighboring sites to
* determine the next ETN. See {@link
* GetNextEtnUtil#getNextEtnFromPartners(String, ActiveTableMode,
* String, Calendar, List<IRequestRouter>)} for more information.
* @return The next ETN in sequence, given the office and phensig.
* @throws VizException
* If an error occurred sending the request to the server.
*/
public static GetNextEtnResponse getNextEtn(String office, String phensig,
boolean lockEtn, boolean performISC) throws VizException {
return VtecUtil.getNextEtn(office, phensig, lockEtn, performISC);
return getNextEtn(office, phensig, lockEtn, performISC, false, null);
}
public static String finalizeETNs(String message) throws VizException {
if (Strings.isNullOrEmpty(message)) {
return message;
/**
* Gets the next available ETN for a specific product and office.
*
* @param office
* The 4-character site ID of the office.
* @param phensig
* The phenomenon and significance of the hazard concatenated
* with a '.' (e.g., TO.W or DU.Y)
* @param lockEtn
* Whether or not to request an exclusive ETN--if true, this will
* cause the server to increment its running ETN sequence to the
* next number after determining the next ETN for this request.
* If false, the next ETN will be returned, but it will not
* increment the server's running sequence, so the ETN return
* could be used by another client that makes a
* GetNextEtnRequest.
* @param performISC
* Whether or not to collaborate with neighboring sites to
* determine the next ETN. See {@link
* GetNextEtnUtil#getNextEtnFromPartners(String, ActiveTableMode,
* String, Calendar, List<IRequestRouter>)} for more information.
* @param reportOnlyConflict
* Affects which kinds of errors get reported back to the
* requestor. If true, only cases where the value of
* <code>etnOverride</code> is less than or equal to the last ETN
* used by this site or any of its partners will be reported.
* Else, all significant errors will be reported back.
* @param etnOverride
* Allows the user to influence the next ETN assigned by using
* this value unless it is less than or equal to the last ETN
* used by this site or one of its partners.
* @return The next ETN in sequence, given the office and phensig.
* @throws VizException
* If an error occurred sending the request to the server.
*/
public static GetNextEtnResponse getNextEtn(String office, String phensig,
boolean lockEtn, boolean performISC, boolean reportOnlyConflict,
Integer etnOverride) throws VizException {
return VtecUtil.getNextEtn(office, phensig, lockEtn, performISC,
reportOnlyConflict, etnOverride);
}
/**
* Reads through a GFE VTEC product and returns VTEC lines with NEW action
* codes that need to be assigned an ETN.
*
* @param product
* The product's text.
* @return A <code>Set</code> of <code>VtecObject</code>s that need to have
* a new ETN assigned to them.
*/
public static Set<VtecObject> getVtecLinesThatNeedEtn(String product) {
if (StringUtil.isEmptyString(product)) {
return Collections.emptySet();
}
// With GFE VTEC products, it's possible to have multiple segments with
// NEW vtec action codes and the same phensig. For this reason,
// HazardsTable.py implemented a "cache" that would ensure all NEWs for
// the same phensig would be assigned the same ETN. This Map replicates
// that legacy behavior.
Map<String, Integer> etnCache = new HashMap<String, Integer>();
Set<VtecObject> phensigs = new HashSet<VtecObject>();
Matcher vtecMatcher = VtecUtil.VTEC_REGEX.matcher(message);
Matcher vtecMatcher = VtecUtil.VTEC_REGEX.matcher(product);
while (vtecMatcher.find()) {
VtecObject vtec = new VtecObject(vtecMatcher.group());
if (("NEW".equals(vtec.getAction()))
&& ((!NATIONAL_PHENSIGS.contains(vtec.getPhensig())) || (IGNORE_NATIONAL_ETN
.contains(vtec.getOffice()) && TROPICAL_PHENSIGS
.contains(vtec.getPhensig())))) {
phensigs.add(vtec);
}
}
return phensigs;
}
/**
* For any NEW VTEC lines contained within the specified product texts,
* generates a <code>GetNextEtnRequest</code> to retrieve the next canonical
* ETN in sequence for the given phensig.
*
* @param product
* The product's text.
* @return The product's text with any NEW VTEC lines having their ETN
* values replaced with the next ETN in sequence.
* @throws VizException
* If an error occurred sending the request to the server.
*/
public static String finalizeETNs(String product,
Map<String, Integer> etnCache) {
if (StringUtil.isEmptyString(product)) {
return product;
}
Matcher vtecMatcher = VtecUtil.VTEC_REGEX.matcher(product);
StringBuffer finalOutput = new StringBuffer();
while (vtecMatcher.find()) {
VtecObject vtec = new VtecObject(vtecMatcher.group());
@ -111,13 +238,13 @@ public class GFEVtecUtil {
&& ((!NATIONAL_PHENSIGS.contains(vtec.getPhensig())) || (IGNORE_NATIONAL_ETN
.contains(vtec.getOffice()) && TROPICAL_PHENSIGS
.contains(vtec.getPhensig())))) {
// With GFE VTEC products, it's possible to have multiple
// segments with NEW vtec action codes and the same phensig. For
// this reason, HazardsTable.py implemented a "cache" that would
// ensure all NEWs for the same phensig would be assigned the
// same ETN. The etnCache Map replicaes this behavior.
String cacheKey = vtec.getPhensig();
Integer newEtn = etnCache.get(cacheKey);
if (newEtn == null) {
newEtn = getNextEtn(vtec.getOffice(), vtec.getPhensig(),
true, true);
etnCache.put(cacheKey, newEtn);
}
vtec.setSequence(newEtn);
}
vtecMatcher

View file

@ -1,9 +1,2 @@
com.raytheon.viz.grid.xml.ParameterList
com.raytheon.viz.grid.xml.ParameterMapping
com.raytheon.viz.grid.rsc.GridResourceData
com.raytheon.viz.grid.rsc.FfgVizGroupResourceData
com.raytheon.viz.grid.rsc.RcmResourceData
com.raytheon.viz.grid.rsc.GridLoadProperties
com.raytheon.viz.grid.rsc.DataMappedGridResourceData
com.raytheon.viz.grid.rsc.general.DifferenceGridResourceData
com.raytheon.viz.grid.GridProductBrowserDataDefinition
com.raytheon.viz.grid.xml.ParameterMapping

View file

@ -1,5 +1,2 @@
com.raytheon.viz.hydro.ui.HydroMapRenderableDisplay
com.raytheon.viz.hydro.timeseries.ShefIssueXML
com.raytheon.viz.hydro.appsdefaults.SHEFAppsDefaultsXML
com.raytheon.viz.hydro.resource.DamLocationResourceData
com.raytheon.viz.hydro.resource.MultiPointResourceData

View file

@ -1,4 +1,2 @@
com.raytheon.viz.redbook.RedbookWMOMap
com.raytheon.viz.redbook.rsc.RedbookResourceData
com.raytheon.viz.redbookua.rsc.RedbookUpperAirResourceData
com.raytheon.viz.redbook.rsc.RedbookProductBrowserDataDefinition

View file

@ -25,7 +25,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.dataplugin.radar;bundle-version="1.0.0",
com.raytheon.uf.viz.localization,
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin.warning;bundle-version="1.12.1174"
com.raytheon.uf.common.dataplugin.warning;bundle-version="1.12.1174",
com.raytheon.uf.common.activetable
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.texteditor,
com.raytheon.viz.texteditor.alarmalert.dialogs,
@ -38,8 +39,7 @@ Export-Package: com.raytheon.viz.texteditor,
com.raytheon.viz.texteditor.scripting.runner,
com.raytheon.viz.texteditor.util
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.uf.common.activetable,
com.raytheon.uf.common.comm,
Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.warning.util,
com.raytheon.uf.common.dissemination,
com.raytheon.uf.common.message,

View file

@ -27,6 +27,7 @@ import java.util.regex.Pattern;
import com.raytheon.uf.common.activetable.ActiveTableMode;
import com.raytheon.uf.common.activetable.GetNextEtnRequest;
import com.raytheon.uf.common.activetable.response.GetNextEtnResponse;
import com.raytheon.uf.common.time.SimulatedTime;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
@ -44,6 +45,7 @@ import com.raytheon.viz.core.mode.CAVEMode;
* Feb 09, 2009 bwoodle Initial creation
* May 08, 2013 #1842 dgilling Code cleanup.
* Aug 29, 2013 #1843 dgilling Use new GetNextEtnRequest constructor.
* Oct 21, 2013 #1843 dgilling Use new GetNextEtnResponse.
*
* </pre>
*
@ -106,8 +108,10 @@ public class VtecUtil {
}
if (vtec.getAction().equals("NEW")) {
vtec.setSequence(getNextEtn(vtec.getOffice(), vtec.getPhenomena()
+ "." + vtec.getSignificance(), lockEtn));
int nextEtn = getNextEtn(vtec.getOffice(),
vtec.getPhenomena() + "." + vtec.getSignificance(), lockEtn)
.getNextEtn();
vtec.setSequence(nextEtn);
}
return replaceFirstVtecString(message, vtec);
}
@ -133,9 +137,9 @@ public class VtecUtil {
* If an error occurs while submitting or processing the remote
* request.
*/
public static int getNextEtn(String office, String phensig, boolean lockEtn)
throws VizException {
return getNextEtn(office, phensig, lockEtn, false);
public static GetNextEtnResponse getNextEtn(String office, String phensig,
boolean lockEtn) throws VizException {
return getNextEtn(office, phensig, lockEtn, false, false, null);
}
/**
@ -159,26 +163,37 @@ public class VtecUtil {
* determine the next ETN. See {@link
* GetNextEtnUtil#getNextEtnFromPartners(String, ActiveTableMode,
* String, Calendar, List<IRequestRouter>)} for more information.
* @param reportOnlyConflict
* Affects which kinds of errors get reported back to the
* requestor. If true, only cases where the value of
* <code>etnOverride</code> is less than or equal to the last ETN
* used by this site or any of its partners will be reported.
* Else, all significant errors will be reported back.
* @param etnOverride
* Allows the user to influence the next ETN assigned by using
* this value unless it is less than or equal to the last ETN
* used by this site or one of its partners.
* @return The next ETN in sequence, given the office and phensig.
* @throws VizException
* If an error occurs while submitting or processing the remote
* request.
*/
public static int getNextEtn(String office, String phensig,
boolean lockEtn, boolean performISC) throws VizException {
public static GetNextEtnResponse getNextEtn(String office, String phensig,
boolean lockEtn, boolean performISC, boolean reportOnlyConflict,
Integer etnOverride) throws VizException {
Calendar currentTime = Calendar.getInstance();
currentTime.setTime(SimulatedTime.getSystemTime().getTime());
ActiveTableMode activeTable = (CAVEMode.getMode()
.equals(CAVEMode.PRACTICE)) ? ActiveTableMode.PRACTICE
: ActiveTableMode.OPERATIONAL;
GetNextEtnRequest req = new GetNextEtnRequest(office, activeTable,
phensig, currentTime, lockEtn, performISC);
phensig, currentTime, lockEtn, performISC, reportOnlyConflict,
etnOverride);
int rval = 1;
Integer resp = (Integer) ThriftClient.sendRequest(req);
if (resp != null) {
rval = resp;
}
GetNextEtnResponse resp = (GetNextEtnResponse) ThriftClient
.sendRequest(req);
GetNextEtnResponse rval = (resp != null) ? resp
: new GetNextEtnResponse(1, phensig);
return rval;
}

View file

@ -35,10 +35,10 @@ import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.procedures.Bundle;
import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.UiPlugin;
import com.raytheon.viz.ui.UiUtil;
@ -50,9 +50,11 @@ import com.raytheon.viz.ui.UiUtil;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 29, 2007 chammack Initial Creation.
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jan 29, 2007 chammack Initial Creation.
* Oct 22, 2013 2491 bsteffen Switch serialization to
* ProcedureXmlManager
*
* </pre>
*
@ -108,7 +110,7 @@ public class SaveBundle extends AbstractHandler {
try {
Bundle bundle = extractCurrentBundle();
SerializationUtil.jaxbMarshalToXmlFile(bundle, fileName);
ProcedureXmlManager.getInstance().marshalToFile(bundle, fileName);
} catch (Exception e) {
Status status = new Status(Status.ERROR, UiPlugin.PLUGIN_ID, 0,
"Error occurred during bundle save.", e);

View file

@ -19,14 +19,13 @@
**/
package com.raytheon.viz.ui.cmenu;
import javax.xml.bind.JAXBException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.DisplayType;
@ -35,15 +34,18 @@ import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.DisplayTypeCapability;
/**
* TODO Add Description
* Duplicate a resource but with a different display type. Works only on
* resources with the {@link DisplayTypeCapability}.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 26, 2010 bsteffen Initial creation
* Aug 10, 2011 njensen Added runWithEvent
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Apr 26, 2010 bsteffen Initial creation
* Aug 10, 2011 njensen Added runWithEvent
* Oct 22, 2013 2491 bsteffen Switch serialization to
* ProcedureXmlManager
*
* </pre>
*
@ -63,11 +65,12 @@ public abstract class LoadAsDisplayTypeAction extends AbstractRightClickAction {
@Override
public void run() {
try {
ProcedureXmlManager jaxb = ProcedureXmlManager.getInstance();
ResourcePair rp = selectedRsc;
ResourceGroup group = new ResourceGroup();
group.getResourceList().add(rp);
String xml = SerializationUtil.marshalToXml(group);
group = (ResourceGroup) SerializationUtil.unmarshalFromXml(xml);
String xml = jaxb.marshal(group);
group = jaxb.unmarshal(ResourceGroup.class, xml);
rp = group.getResourceList().get(0);
rp.setProperties(new ResourceProperties());
rp.getLoadProperties()
@ -77,7 +80,7 @@ public abstract class LoadAsDisplayTypeAction extends AbstractRightClickAction {
.setDisplayType(getDisplayType());
rp.instantiateResource(getDescriptor());
getDescriptor().getResourceList().add(rp);
} catch (JAXBException e) {
} catch (SerializationException e) {
statusHandler.handle(Priority.PROBLEM,
"Unexpected error cloning resource", e);
} catch (VizException e) {

View file

@ -0,0 +1,166 @@
/**
* 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.viz.ui.dialogs;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
* Generic <code>Dialog</code> to display a multi-line block of text in a
* re-sizable and scrollable window.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 23, 2013 #1843 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class TextDisplayDlg extends CaveJFACEDialog {
/**
* Location of this dialog relative to it's parent.
*/
public static enum Location {
ABOVE, BELOW, LEFT, RIGHT, CENTERED
}
private String title;
private String contents;
private Location location;
/**
* @param parentShell
* @param title
* @param contents
*/
public TextDisplayDlg(Shell parentShell, String title, String contents,
Location location) {
super(parentShell);
this.title = title;
this.contents = contents;
this.location = location;
this.setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets
* .Shell)
*/
@Override
protected void configureShell(Shell newShell) {
newShell.setText(this.title);
super.configureShell(newShell);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveJFACEDialog#createDialogArea(org.eclipse
* .swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite top = (Composite) super.createDialogArea(parent);
Text contents = new Text(top, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY
| SWT.V_SCROLL | SWT.H_SCROLL);
Rectangle screenBounds = this.getShell().getMonitor().getBounds();
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
layoutData.widthHint = screenBounds.width / 2;
layoutData.heightHint = screenBounds.height / 4;
contents.setLayoutData(layoutData);
contents.setText(this.contents);
return top;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.dialogs.Dialog#getInitialLocation(org.eclipse.swt.graphics
* .Point)
*/
@Override
protected Point getInitialLocation(Point initialSize) {
Rectangle parentBounds = getParentShell().getBounds();
Rectangle myBounds = getShell().getBounds();
int x = parentBounds.x + ((parentBounds.width - myBounds.width) / 2);
int y = parentBounds.y + ((parentBounds.height - myBounds.height) / 2);
;
switch (this.location) {
case ABOVE:
y = parentBounds.y - myBounds.height;
break;
case BELOW:
y = parentBounds.y + parentBounds.height;
break;
case LEFT:
x = parentBounds.x - myBounds.width;
break;
case RIGHT:
x = parentBounds.x + parentBounds.width;
break;
case CENTERED:
break;
}
Point location = new Point(x, y);
return location;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveJFACEDialog#createButtonBar(org.eclipse
* .swt.widgets.Composite)
*/
@Override
protected Control createButtonBar(Composite parent) {
// no buttons
return null;
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -71,6 +71,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* ------------ ---------- ----------- --------------------------
* Apr 13, 2011 #8393 dgilling Initial creation
* 02/19/13 #1637 randerso Added exception handling for Discrete and Weather
* 10/31/2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -139,7 +140,7 @@ public class ASCIIGrid {
* @return
*/
public boolean translateGrid(int index, GridParmInfo destGPI) {
if ((index < 0) || (index > gridSlices.size() - 1)) {
if ((index < 0) || (index > (gridSlices.size() - 1))) {
return false;
}
@ -337,7 +338,7 @@ public class ASCIIGrid {
for (int i = discrete.getDiscreteGrid().getYdim() - 1; i >= 0; i--) {
for (int j = 0; j < discrete.getDiscreteGrid()
.getXdim(); j++) {
String key = discrete.getKey()[discrete
String key = discrete.getKeys()[discrete
.getDiscreteGrid().get(j, i)].toString();
outputStream.println(key);
}

View file

@ -111,6 +111,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
* 06/13/13 #2044 randerso Pass in GridDbConfig as construction parameter
* 07/30/13 #2057 randerso Added a static deleteDatabase method
* 08/05/13 #1571 randerso Refactored to store GridParmInfo and ParmStorageinfo in postgres database
* 10/31/2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -1664,7 +1665,7 @@ public class IFPGridDatabase extends GridDatabase {
StringBuffer sb = new StringBuffer();
boolean first = true;
for (DiscreteKey key : slice.getKey()) {
for (DiscreteKey key : slice.getKeys()) {
if (first) {
first = false;
} else {

View file

@ -68,7 +68,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Aug 11, 2009 njensen Initial creation
* Mar 06, 2013 1735 rferrel Change to retrieve multiple points
* in a single grid request.
* Jun 13, 2013 #2044 randerso Refactored to use IFPServer
* Jun 13, 2013 #2044 randerso Refactored to use IFPServer
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -213,7 +214,7 @@ public class GetPointDataHandler extends BaseGfeRequestHandler implements
} else if (slice instanceof DiscreteGridSlice) {
DiscreteGridSlice gs = (DiscreteGridSlice) slice;
byte value = gs.getDiscreteGrid().get(x, y);
String key = gs.getKey()[value].toString();
String key = gs.getKeys()[value].toString();
Type type = Type.STRING;
view.setData(param, type, unit, key);
}

View file

@ -70,6 +70,7 @@ from com.raytheon.uf.common.localization import LocalizationContext_Localization
# 08/09/2013 1571 randerso Changed projections to use the Java
# ProjectionType enumeration
# 09/20/13 2405 dgilling Clip grids before inserting into cache.
# 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
#
# Original A1 BATCH WRITE COUNT was 10, we found doubling that
@ -140,18 +141,12 @@ class WECache(object):
elif gridType == "VECTOR":
vecGrids = grid.__numpy__
return (clipToExtrema(vecGrids[0], clipArea), clipToExtrema(vecGrids[1], clipArea))
elif gridType == "WEATHER":
elif gridType == "WEATHER" or gridType =="DISCRETE":
keys = grid.getKeys()
keyList = []
for theKey in keys:
keyList.append(theKey.toString())
return (clipToExtrema(grid.__numpy__[0], clipArea), keyList)
elif gridType =="DISCRETE":
keys = grid.getKey()
keyList = []
for theKey in keys:
keyList.append(theKey.toString())
return (clipToExtrema(grid.__numpy__[0], clipArea), keyList)
def __encodeGridHistory(self, histories):
retVal = []

View file

@ -82,6 +82,7 @@ from com.raytheon.uf.edex.database.cluster import ClusterTask
# 06/05/13 2063 dgilling Change __siteInDbGrid() to
# call IFPWE.history() like A1.
# 09/05/13 2307 dgilling Fix breakage caused by #2044.
# 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
#
#
@ -204,18 +205,12 @@ class WECache(object):
elif gridType == "VECTOR":
vecGrids = grid.__numpy__
return (vecGrids[0], vecGrids[1])
elif gridType == "WEATHER":
elif gridType == "WEATHER" or gridType =="DISCRETE":
keys = grid.getKeys()
keyList = []
for theKey in keys:
keyList.append(theKey.toString())
return (grid.__numpy__[0], keyList)
elif gridType =="DISCRETE":
keys = grid.getKey()
keyList = []
for theKey in keys:
keyList.append(theKey.toString())
return (grid.__numpy__[0], keyList)
def __encodeGridHistory(self, histories):
retVal = []

View file

@ -21,4 +21,5 @@ Require-Bundle: com.raytheon.uf.common.serialization,
com.raytheon.uf.common.message;bundle-version="1.12.1174",
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
com.raytheon.uf.common.python;bundle-version="1.12.1174",
org.jep;bundle-version="1.0.0"
org.jep;bundle-version="1.0.0",
com.raytheon.uf.common.util;bundle-version="1.12.1174"

View file

@ -34,7 +34,8 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 14, 2011 rjpeter Initial creation
* Aug 26, 2013 #1843 dgilling Add performISC field, proper constructors.
* Oct 21, 2013 #1843 dgilling Add performISC and reportConflictOnly
* fields, proper constructors.
*
* </pre>
*
@ -62,39 +63,89 @@ public class GetNextEtnRequest implements IServerRequest {
@DynamicSerializeElement
private boolean performISC;
@DynamicSerializeElement
private boolean reportConflictOnly;
@DynamicSerializeElement
private Integer etnOverride;
public GetNextEtnRequest() {
// no-op, for dynamic serialize support
}
/**
* Constructs a GetNextEtnRequest.
*
* @param siteID
* The 4-character site ID of the office.
* @param mode
* Active table mode.
* @param phensig
* The phenomenon and significance of the hazard concatenated
* with a '.' (e.g., TO.W or DU.Y)
* @param currentTime
* <code>Calendar</code> representing time (needed for DRT mode).
* @param lockEtn
* Whether or not to request an exclusive ETN--if true, this will
* cause the server to increment its running ETN sequence to the
* next number after determining the next ETN for this request.
* If false, the next ETN will be returned, but it will not
* increment the server's running sequence, so the ETN return
* could be used by another client that makes a
* GetNextEtnRequest.
*/
public GetNextEtnRequest(String siteID, ActiveTableMode mode,
String phensig, Calendar currentTime, boolean lockEtn) {
this(siteID, mode, phensig, currentTime, lockEtn, false);
this(siteID, mode, phensig, currentTime, lockEtn, false, false, null);
}
/**
* Constructs a GetNextEtnRequest.
*
* @param siteID
* The 4-character site ID of the office.
* @param mode
* Active table mode.
* @param phensig
* The phenomenon and significance of the hazard concatenated
* with a '.' (e.g., TO.W or DU.Y)
* @param currentTime
* <code>Calendar</code> representing time (needed for DRT mode).
* @param lockEtn
* Whether or not to request an exclusive ETN--if true, this will
* cause the server to increment its running ETN sequence to the
* next number after determining the next ETN for this request.
* If false, the next ETN will be returned, but it will not
* increment the server's running sequence, so the ETN return
* could be used by another client that makes a
* GetNextEtnRequest.
* @param performISC
* Whether or not to collaborate with neighboring sites to
* determine the next ETN. See {@link
* GetNextEtnUtil#getNextEtnFromPartners(String, ActiveTableMode,
* String, Calendar, List<IRequestRouter>)} for more information.
* @param reportConflictOnly
* Affects which kinds of errors get reported back to the
* requestor. If true, only cases where the value of
* <code>etnOverride</code> is less than or equal to the last ETN
* used by this site or any of its partners will be reported.
* Else, all significant errors will be reported back.
* @param etnOverride
* Allows the user to influence the next ETN assigned by using
* this value unless it is less than or equal to the last ETN
* used by this site or one of its partners.
*/
public GetNextEtnRequest(String siteID, ActiveTableMode mode,
String phensig, Calendar currentTime, boolean lockEtn,
boolean performISC) {
boolean performISC, boolean reportConflictOnly, Integer etnOverride) {
this.siteID = siteID;
this.mode = mode;
this.phensig = phensig;
this.currentTime = currentTime;
this.lockEtn = lockEtn;
this.performISC = performISC;
this.reportConflictOnly = reportConflictOnly;
this.etnOverride = etnOverride;
}
public String getSiteID() {
@ -144,4 +195,20 @@ public class GetNextEtnRequest implements IServerRequest {
public void setPerformISC(boolean performISC) {
this.performISC = performISC;
}
public boolean isReportConflictOnly() {
return reportConflictOnly;
}
public void setReportConflictOnly(boolean reportConflictOnly) {
this.reportConflictOnly = reportConflictOnly;
}
public Integer getEtnOverride() {
return etnOverride;
}
public void setEtnOverride(Integer etnOverride) {
this.etnOverride = etnOverride;
}
}

View file

@ -36,6 +36,7 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 19, 2013 #1843 dgilling Initial creation
* Oct 21, 2013 #1843 dgilling Add ETN override field.
*
* </pre>
*
@ -61,17 +62,27 @@ public class LockAndGetNextEtnRequest implements IServerRequest {
@DynamicSerializeElement
private Calendar currentTime;
@DynamicSerializeElement
private Integer etnOverride;
public LockAndGetNextEtnRequest() {
// default constructor for thrift/dynamicserialize
}
public LockAndGetNextEtnRequest(String siteID, String requestorSiteID,
ActiveTableMode mode, String phensig, Calendar currentTime) {
this(siteID, requestorSiteID, mode, phensig, currentTime, null);
}
public LockAndGetNextEtnRequest(String siteID, String requestorSiteID,
ActiveTableMode mode, String phensig, Calendar currentTime,
Integer etnOverride) {
this.siteID = siteID;
this.requestorSiteID = requestorSiteID;
this.mode = mode;
this.phensig = phensig;
this.currentTime = currentTime;
this.etnOverride = etnOverride;
}
public String getSiteID() {
@ -113,4 +124,12 @@ public class LockAndGetNextEtnRequest implements IServerRequest {
public void setCurrentTime(Calendar currentTime) {
this.currentTime = currentTime;
}
public Integer getEtnOverride() {
return etnOverride;
}
public void setEtnOverride(Integer etnOverride) {
this.etnOverride = etnOverride;
}
}

View file

@ -0,0 +1,144 @@
/**
* 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.activetable.response;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.util.CollectionUtil;
import com.raytheon.uf.common.util.StringUtil;
/**
* Response type for <code>GetNextEtnRequest</code>. Contains the next ETN to
* use and a list of hosts that could not be contacted during the process to
* determine the next ETN.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 24, 2013 #1843 dgilling Initial creation
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
@DynamicSerialize
public final class GetNextEtnResponse {
@DynamicSerializeElement
private int nextEtn;
@DynamicSerializeElement
private String phensig;
@DynamicSerializeElement
private Map<String, Integer> resultsByHost;
@DynamicSerializeElement
private List<String> errorMessages;
public GetNextEtnResponse() {
// for Dynamic Serialize use only.
}
public GetNextEtnResponse(int nextEtn, String phensig) {
this(nextEtn, phensig, new HashMap<String, Integer>(),
new ArrayList<String>());
this.resultsByHost.put("localhost", this.nextEtn);
}
public GetNextEtnResponse(int nextEtn, String phensig,
Map<String, Integer> resultsByHost, List<String> errorMessages) {
this.nextEtn = nextEtn;
this.phensig = phensig;
this.resultsByHost = resultsByHost;
this.errorMessages = errorMessages;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GetNextEtnResponse [nextEtn=");
builder.append(nextEtn);
builder.append(", phensig=");
builder.append(phensig);
builder.append(", resultsByHost=");
builder.append(resultsByHost);
builder.append(", errorMessages=");
builder.append(errorMessages);
builder.append("]");
return builder.toString();
}
public boolean isOkay() {
return errorMessages.isEmpty();
}
public String getError() {
return !isOkay() ? StringUtil.join(errorMessages, '\n') : "";
}
public void addErrorMessage(String message) {
if (CollectionUtil.isNullOrEmpty(errorMessages)) {
errorMessages = new ArrayList<String>();
}
errorMessages.add(message);
}
public int getNextEtn() {
return nextEtn;
}
public void setNextEtn(int nextEtn) {
this.nextEtn = nextEtn;
}
public String getPhensig() {
return phensig;
}
public void setPhensig(String phensig) {
this.phensig = phensig;
}
public Map<String, Integer> getResultsByHost() {
return resultsByHost;
}
public void setResultsByHost(Map<String, Integer> resultsByHost) {
this.resultsByHost = resultsByHost;
}
public List<String> getErrorMessages() {
return errorMessages;
}
public void setErrorMessages(List<String> errorMessages) {
this.errorMessages = errorMessages;
}
}

View file

@ -20,19 +20,9 @@
package com.raytheon.uf.common.datadelivery.registry.handlers;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.Lists;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.ebxml.AdhocSubscriptionQuery;
import com.raytheon.uf.common.datadelivery.registry.ebxml.SubscriptionFilterableQuery;
import com.raytheon.uf.common.registry.RegistryQueryResponse;
import com.raytheon.uf.common.registry.handler.IRegistryObjectHandler;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
/**
* {@link IRegistryObjectHandler} implementation for {@link AdhocSubscription}.
@ -45,6 +35,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
* ------------ ---------- ----------- --------------------------
* Oct 05, 2012 1241 djohnson Initial creation.
* Oct 12, 2013 2460 dhladky restored.
* Oct 25, 2013 2292 mpduff Removed unused imports.
*
* </pre>
*
@ -60,22 +51,18 @@ public class AdhocSubscriptionHandler extends
*/
@Override
protected AdhocSubscriptionQuery getQuery() {
return new AdhocSubscriptionQuery();
}
/**
*
* {@inheritDoc}
*/
@Override
protected Class<AdhocSubscription> getRegistryObjectClass() {
return AdhocSubscription.class;
}
}
}

View file

@ -5,12 +5,8 @@
<bean id="subscriptionNotificationService"
class="com.raytheon.uf.common.datadelivery.service.SendToServerSubscriptionNotificationService" />
<bean id="subscriptionDuplicateChecker"
class="com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionDuplicateChecker" />
<bean id="subscriptionOverlapService"
class="com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapService">
<constructor-arg ref="subscriptionDuplicateChecker" />
</bean>
</beans>

View file

@ -4,6 +4,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* Configuration for the {@link ISubscriptionOverlapService}.
*
@ -13,7 +14,8 @@ import javax.xml.bind.annotation.XmlRootElement;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sept 24, 2013 2386 dhladky Grid Subscription Overlap
* Sep 24, 2013 2386 dhladky Grid Subscription Overlap
* Oct 21, 2013 2292 mpduff Change overlap rules
*
* </pre>
*
@ -23,7 +25,7 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class GridSubscriptionOverlapConfig extends SubscriptionOverlapConfig {
@XmlElement(required = true)
private int maxAllowedForecastHourDuplication;
@ -34,7 +36,7 @@ public class GridSubscriptionOverlapConfig extends SubscriptionOverlapConfig {
* Constructor.
*/
public GridSubscriptionOverlapConfig() {
}
/**
@ -50,7 +52,7 @@ public class GridSubscriptionOverlapConfig extends SubscriptionOverlapConfig {
int maxAllowedForecastHourDuplication,
int maxAllowedCycleDuplication, int maxAllowedSpatialDuplication,
SubscriptionOverlapMatchStrategy matchStrategy) {
this.maxAllowedParameterDuplication = maxAllowedParameterDuplication;
this.maxAllowedForecastHourDuplication = maxAllowedForecastHourDuplication;
this.maxAllowedCycleDuplication = maxAllowedCycleDuplication;
@ -90,32 +92,15 @@ public class GridSubscriptionOverlapConfig extends SubscriptionOverlapConfig {
}
/**
* Check whether the given duplication percents indicate an overlapping
* subscription.
*
* @param parameterDuplicationPercent
* @param forecastHourDuplicationPercent
* @param cycleDuplicationPercent
* @param spatialDuplicationPercent
* @return true if the subscription should be considered overlapping
* {@inheritDoc}
*/
public boolean isOverlapping(int parameterDuplicationPercent,
int forecastHourDuplicationPercent, int cycleDuplicationPercent,
int spatialDuplicationPercent) {
// Pass through to the match strategy
return this.matchStrategy.isOverlapping(this,
parameterDuplicationPercent, forecastHourDuplicationPercent,
cycleDuplicationPercent, spatialDuplicationPercent);
}
@Override
public SubscriptionOverlapConfig getNeverOverlaps() {
return new GridSubscriptionOverlapConfig(
ISubscriptionOverlapService.ONE_HUNDRED_PERCENT,
ISubscriptionOverlapService.ONE_HUNDRED_PERCENT,
ISubscriptionOverlapService.ONE_HUNDRED_PERCENT,
ISubscriptionOverlapService.ONE_HUNDRED_PERCENT,
SubscriptionOverlapConfig.ONE_HUNDRED_PERCENT,
SubscriptionOverlapConfig.ONE_HUNDRED_PERCENT,
SubscriptionOverlapConfig.ONE_HUNDRED_PERCENT,
SubscriptionOverlapConfig.ONE_HUNDRED_PERCENT,
SubscriptionOverlapMatchStrategy.MATCH_ALL);
}
}

View file

@ -1,99 +0,0 @@
/**
* 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.service.subscription;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
/**
* Checks for duplication among subscriptions.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 02, 2013 2000 djohnson Initial creation
* Sept 24, 2013 2386 dhladky Added a method
* Oct 2, 2013 1797 dhladky More Generics
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public interface ISubscriptionDuplicateChecker<T extends Time, C extends Coverage> {
/**
* Returns the percent, 0-100, of how many parameters from sub2 are
* satisfied by sub1.
*
* @param sub1
* @param sub2
*
* @return 0-100
*/
int getParameterDuplicationPercent(Subscription<T, C> sub1, Subscription<T, C> sub2);
/**
* Returns the percent, 0-100, of how many forecast hours from sub2 are
* satisfied by sub1.
*
* @param sub1
* @param sub2
*
* @return 0-100
*/
int getForecastHourDuplicationPercent(Subscription<T, C> sub1, Subscription<T, C> sub2);
/**
* Returns the percent, 0-100, of how similar the time is from sub2 to sub1.
*
* @param sub1
* @param sub2
*
* @return 0-100
*/
int getTimeDuplicationPercent(Subscription<T, C> sub1, Subscription<T, C> sub2);
/**
* Returns the percent, 0-100, of how many cycle hours from sub2 are
* satisfied by sub1.
*
* @param sub1
* @param sub2
*
* @return 0-100
*/
int getCycleDuplicationPercent(Subscription<T, C> sub2, Subscription<T, C> sub1);
/**
* Returns the percent, 0-100, of how much spatial coverage from sub2 is
* satisfied by sub1.
*
* @param sub1
* @param sub2
*
* @return 0-100
*/
int getSpatialDuplicationPercent(Subscription<T, C> sub1, Subscription<T, C> sub2);
}

View file

@ -19,16 +19,13 @@
**/
package com.raytheon.uf.common.datadelivery.service.subscription;
import java.util.Map;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.localization.exception.LocalizationException;
/**
* Checks subscriptions to see if they would be considered duplicates.
* Reads and writes overlap config files for code in common.
*
* <pre>
*
@ -36,54 +33,19 @@ import com.raytheon.uf.common.localization.exception.LocalizationException;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 09, 2013 2000 djohnson Initial creation
* Oct 1, 2013 1797 dhladky More Generics
* May 09, 2013 2000 djohnson Initial creation
* Oct 1, 2013 1797 dhladky More Generics
* Oct 21, 2013 2292 mpduff Changed service to read/write config files.
*
* </pre>
*
* @author djohnson
* @version 1.0
* @param <T>
* @param <C>
*/
public interface ISubscriptionOverlapService<T extends Time, C extends Coverage> {
int ONE_HUNDRED_PERCENT = 100;
String OVERLAPPING_SUBSCRIPTIONS = "The following subscriptions overlap with this one "
+ "and are candidates for a shared subscription: ";
/**
* Response interface for a subscription overlap check.
*/
public static interface ISubscriptionOverlapResponse {
/**
* Check whether the two subscriptions were exact duplicates.
*
* @return true if the subscriptions are duplicates
*/
boolean isDuplicate();
/**
* Check whether the two subscriptions were determined to overlap.
*
* @return true if the subscriptions should be considered as overlapping
* according to the configuration
*/
boolean isOverlapping();
};
/**
* Returns whether sub2 exceeds configured overlap criteria to sub1
* according to the configuration.
*
* @param sub1
* @param sub2
*
* @return the overlap check response
*/
ISubscriptionOverlapResponse isOverlapping(Subscription<T, C> sub1,
Subscription<T, C> sub2);
/**
* Writes a new configuration file.
*
@ -96,11 +58,11 @@ public interface ISubscriptionOverlapService<T extends Time, C extends Coverage>
throws LocalizationException;
/**
* Read the configuration.
* Get the overlap config file for this data type.
*
* @return the configurations
* @throws LocalizationException
* on error reading the configuration
* @param type
* The data type
* @return the config file for the data type
*/
Map<DataType, SubscriptionOverlapConfig> readConfig() throws LocalizationException;
SubscriptionOverlapConfig getConfigFile(DataType type);
}

View file

@ -5,6 +5,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* Configuration for the {@link ISubscriptionOverlapService}.
*
@ -14,7 +15,8 @@ import javax.xml.bind.annotation.XmlRootElement;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sept 24, 2013 2386 dhladky Point Subscription Overlap
* Sep 24, 2013 2386 dhladky Point Subscription Overlap
* Oct 21, 2013 2292 mpduff Changes for new implementation of point rules
*
* </pre>
*
@ -32,7 +34,7 @@ public class PointSubscriptionOverlapConfig extends SubscriptionOverlapConfig {
* Constructor.
*/
public PointSubscriptionOverlapConfig() {
}
/**
@ -40,13 +42,11 @@ public class PointSubscriptionOverlapConfig extends SubscriptionOverlapConfig {
*
* @param maxAllowedParameterDuplication
* @param maxAllowedTimeDuplication
* @param notUsed
* @param maxAllowedSpatialDuplication
* @param matchStrategy
*/
public PointSubscriptionOverlapConfig(int maxAllowedParameterDuplication,
int maxAllowedTimeDuplication, int notUsed,
int maxAllowedSpatialDuplication,
int maxAllowedTimeDuplication, int maxAllowedSpatialDuplication,
SubscriptionOverlapMatchStrategy matchStrategy) {
this.maxAllowedParameterDuplication = maxAllowedParameterDuplication;
@ -63,42 +63,22 @@ public class PointSubscriptionOverlapConfig extends SubscriptionOverlapConfig {
}
/**
* @param maxAllowedForecastHourDuplication
* the maxAllowedForecastHourDuplication to set
* @param maxAllowedTimeDuplication
* the maxAllowedTimeDuplication to set
*/
public void setMaxAllowedTimeDuplication(int maxAllowedTimeDuplication) {
this.maxAllowedTimeDuplication = maxAllowedTimeDuplication;
}
/**
* Check whether the given duplication percents indicate an overlapping
* subscription.
*
* @param parameterDuplicationPercent
* @param timeDuplicationPercent
* @param notUsed
* @param spatialDuplicationPercent
* @return true if the subscription should be considered overlapping
* {@inheritDoc}
*/
public boolean isOverlapping(int parameterDuplicationPercent,
int timeDuplicationPercent, int notUsed,
int spatialDuplicationPercent) {
// Pass through to the match strategy
return this.matchStrategy.isOverlapping(this,
parameterDuplicationPercent, timeDuplicationPercent, notUsed,
spatialDuplicationPercent);
}
@Override
public SubscriptionOverlapConfig getNeverOverlaps() {
return new PointSubscriptionOverlapConfig(
ISubscriptionOverlapService.ONE_HUNDRED_PERCENT,
ISubscriptionOverlapService.ONE_HUNDRED_PERCENT,
ISubscriptionOverlapService.ONE_HUNDRED_PERCENT,
ISubscriptionOverlapService.ONE_HUNDRED_PERCENT,
SubscriptionOverlapConfig.ONE_HUNDRED_PERCENT,
SubscriptionOverlapConfig.ONE_HUNDRED_PERCENT,
SubscriptionOverlapConfig.ONE_HUNDRED_PERCENT,
SubscriptionOverlapMatchStrategy.MATCH_ALL);
}
}

View file

@ -1,181 +0,0 @@
/**
* 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.service.subscription;
import java.util.Collection;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
import com.raytheon.uf.common.datadelivery.registry.PointTime;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.CollectionUtil;
/**
* Checks for duplication among subscriptions.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 02, 2013 2000 djohnson Initial creation
* Sept 24, 2013 2386 dhladky Made multi-data type
* Sept 25, 2013 1797 dhladky separated time from griddedtime
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class SubscriptionDuplicateChecker<T extends Time, C extends Coverage> implements
ISubscriptionDuplicateChecker<T, C> {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(SubscriptionDuplicateChecker.class);
private static final String UNABLE_TO_DETERMINE_SPATIAL_OVERLAP = "Unable to determine spatial overlap. "
+ "Subscriptions will not be considered to be overlapping spatially.";
/**
* {@inheritDoc}
*/
@Override
public int getParameterDuplicationPercent(Subscription<T, C> sub1,
Subscription<T, C> sub2) {
return getDuplicationPercent(sub1.getParameter(), sub2.getParameter());
}
/**
* {@inheritDoc}
*/
@Override
public int getForecastHourDuplicationPercent(Subscription<T, C> sub1,
Subscription<T, C> sub2) {
if (sub1.getTime() instanceof GriddedTime) {
GriddedTime gtime1 = (GriddedTime) sub1.getTime();
GriddedTime gtime2 = (GriddedTime) sub2.getTime();
return getDuplicationPercent(gtime1.getSelectedTimeIndices(),
gtime2.getSelectedTimeIndices());
} else {
throw new IllegalArgumentException(sub1.getTime().getClass()
+ " Config not yet Implemented!");
}
}
/**
* {@inheritDoc}
*/
@Override
public int getCycleDuplicationPercent(Subscription<T, C> sub1,
Subscription<T, C> sub2) {
if (sub1.getTime() instanceof GriddedTime) {
GriddedTime gtime1 = (GriddedTime) sub1.getTime();
GriddedTime gtime2 = (GriddedTime) sub2.getTime();
return getDuplicationPercent(gtime1.getCycleTimes(),
gtime2.getCycleTimes());
} else {
throw new IllegalArgumentException(sub1.getTime().getClass()
+ " Config not yet Implemented!");
}
}
/**
* {@inheritDoc}
*/
@Override
public int getTimeDuplicationPercent(Subscription<T, C> sub1,
Subscription<T, C> sub2) {
if (sub1.getTime() instanceof PointTime) {
PointTime ptime1 = (PointTime) sub1.getTime();
PointTime ptime2 = (PointTime) sub2.getTime();
return getDuplicationPercent(ptime1.getTimes(), ptime2.getTimes());
} else {
return 0;
}
}
/**
* {@inheritDoc}
*/
@Override
public int getSpatialDuplicationPercent(Subscription<T, C> sub1, Subscription<T, C> sub2) {
final Coverage sub1Coverage = sub1.getCoverage();
final Coverage sub2Coverage = sub2.getCoverage();
if (sub1Coverage != null && sub2Coverage != null) {
final ReferencedEnvelope sub1Envelope = sub1Coverage
.getRequestEnvelope();
final ReferencedEnvelope sub2Envelope = sub2Coverage
.getRequestEnvelope();
if (sub1Envelope != null && sub2Envelope != null) {
try {
ReferencedEnvelope intersection = MapUtil
.reprojectAndIntersect(sub1Envelope, sub2Envelope);
final double intersectionArea = intersection.getArea();
return (int) ((intersectionArea * 100) / sub2Envelope
.getArea());
} catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM,
UNABLE_TO_DETERMINE_SPATIAL_OVERLAP, e);
}
}
}
return 0;
}
private <M> int getDuplicationPercent(Collection<M> coll1,
Collection<M> coll2) {
int numberSatisfiedByFirstCollection = 0;
if (!CollectionUtil.isNullOrEmpty(coll1)
&& !CollectionUtil.isNullOrEmpty(coll2)) {
for (M entry : coll2) {
if (coll1.contains(entry)) {
numberSatisfiedByFirstCollection++;
}
}
// Convert percent to 0-100
return (numberSatisfiedByFirstCollection * 100) / (coll2.size());
}
return 0;
}
}

View file

@ -33,8 +33,9 @@ import javax.xml.bind.annotation.XmlRootElement;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 08, 2013 2000 djohnson Initial creation
* Sept 24, 2013 2386 dhladky Abstracted for more types
* May 08, 2013 2000 djohnson Initial creation
* Sep 24, 2013 2386 dhladky Abstracted for more types
* Oct 21, 2013 2292 mpduff Changes for point type implementation
*
* </pre>
*
@ -44,13 +45,14 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public abstract class SubscriptionOverlapConfig {
public final static transient int ONE_HUNDRED_PERCENT = 100;
@XmlElement(required = true)
protected int maxAllowedParameterDuplication;
@XmlElement(required = true)
protected int maxAllowedSpatialDuplication;
@XmlElement(required = true)
protected SubscriptionOverlapMatchStrategy matchStrategy;
@ -107,20 +109,6 @@ public abstract class SubscriptionOverlapConfig {
this.matchStrategy = matchStrategy;
}
/**
* Check whether the given duplication percents indicate an overlapping
* subscription.
*
* @param parameterDuplicationPercent
* @param forecastHourOrTimeDuplicationPercent
* @param cycleOrNotUsedDuplicationPercent
* @param spatialDuplicationPercent
* @return true if the subscription should be considered overlapping
*/
public abstract boolean isOverlapping(int parameterDuplicationPercent,
int forecastHourOrTimeDuplicationPercent, int cycleOrNotUsedDuplicationPercent,
int spatialDuplicationPercent);
/**
* setup a default never overlapping config
*/

View file

@ -31,8 +31,10 @@ import javax.xml.bind.annotation.XmlEnum;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 14, 2013 2000 djohnson Initial creation
* Sept 24, 2013 2386 dhladky Added impl for other types besides grid
* May 14, 2013 2000 djohnson Initial creation
* Sep 24, 2013 2386 dhladky Added impl for other types besides grid
* Oct 21, 2013 2292 mpduff Moved overlap calculation logic out
*
*
* </pre>
*
@ -41,195 +43,16 @@ import javax.xml.bind.annotation.XmlEnum;
*/
@XmlEnum
public enum SubscriptionOverlapMatchStrategy {
AT_LEAST_HALF {
@Override
public boolean isOverlapping(SubscriptionOverlapConfig config,
int parameterDuplicationPercent,
int forecastHourDuplicationPercent,
int cycleDuplicationPercent, int spatialDuplicationPercent) {
boolean[] toCheck = null;
AT_LEAST_HALF("At Least Half"), MATCH_ALL("Match All"), MATCH_ANY(
"Match Any");
final boolean exceedsAllowedParameterDuplication = parameterDuplicationPercent > config
.getMaxAllowedParameterDuplication();
final boolean exceedsAllowedSpatialDuplication = spatialDuplicationPercent > config
.getMaxAllowedSpatialDuplication();
private final String displayString;
// gridded products
if (config instanceof GridSubscriptionOverlapConfig) {
GridSubscriptionOverlapConfig gconfig = (GridSubscriptionOverlapConfig) config;
final boolean exceedsAllowedForecastHourDuplication = forecastHourDuplicationPercent > gconfig
.getMaxAllowedForecastHourDuplication();
final boolean exceedsAllowedCycleDuplication = cycleDuplicationPercent > gconfig
.getMaxAllowedCycleDuplication();
toCheck = new boolean[] { exceedsAllowedParameterDuplication,
exceedsAllowedForecastHourDuplication,
exceedsAllowedCycleDuplication,
exceedsAllowedSpatialDuplication };
}
// point products
else if (config instanceof PointSubscriptionOverlapConfig) {
PointSubscriptionOverlapConfig pconfig = (PointSubscriptionOverlapConfig) config;
final boolean exceedsAllowedTimeDuplication = forecastHourDuplicationPercent > pconfig
.getMaxAllowedTimeDuplication();
toCheck = new boolean[] { exceedsAllowedParameterDuplication,
exceedsAllowedTimeDuplication,
exceedsAllowedSpatialDuplication };
} else {
throw new IllegalArgumentException("Data type "+config.getClass()+" has no implementation");
}
final int numBooleans = toCheck.length;
final int halfNumBooleans = numBooleans / 2;
int exceeded = 0;
for (boolean check : toCheck) {
if (check) {
exceeded++;
if (exceeded >= halfNumBooleans) {
return true;
}
}
}
return false;
}
@Override
public String getDisplayString() {
return "At Least Half";
}
},
MATCH_ALL {
@Override
public boolean isOverlapping(SubscriptionOverlapConfig config,
int parameterDuplicationPercent,
int forecastHourDuplicationPercent,
int cycleDuplicationPercent, int spatialDuplicationPercent) {
boolean response = false;
final boolean exceedsAllowedParameterDuplication = parameterDuplicationPercent > config
.getMaxAllowedParameterDuplication();
final boolean exceedsAllowedSpatialDuplication = spatialDuplicationPercent > config
.getMaxAllowedSpatialDuplication();
// gridded products
if (config instanceof GridSubscriptionOverlapConfig) {
GridSubscriptionOverlapConfig gconfig = (GridSubscriptionOverlapConfig) config;
final boolean exceedsAllowedForecastHourDuplication = forecastHourDuplicationPercent > gconfig
.getMaxAllowedForecastHourDuplication();
final boolean exceedsAllowedCycleDuplication = cycleDuplicationPercent > gconfig
.getMaxAllowedCycleDuplication();
response = exceedsAllowedParameterDuplication
&& exceedsAllowedForecastHourDuplication
&& exceedsAllowedCycleDuplication
&& exceedsAllowedSpatialDuplication;
// point products
} else if (config instanceof PointSubscriptionOverlapConfig) {
PointSubscriptionOverlapConfig pconfig = (PointSubscriptionOverlapConfig) config;
final boolean exceedsAllowedTimeDuplication = forecastHourDuplicationPercent > pconfig
.getMaxAllowedTimeDuplication();
response = exceedsAllowedParameterDuplication
&& exceedsAllowedTimeDuplication
&& exceedsAllowedSpatialDuplication;
} else {
throw new IllegalArgumentException("Data type "+config.getClass()+" has no implementation");
}
return response;
}
@Override
public String getDisplayString() {
return "Match All";
}
},
MATCH_ANY {
@Override
public boolean isOverlapping(SubscriptionOverlapConfig config,
int parameterDuplicationPercent,
int forecastHourDuplicationPercent,
int cycleDuplicationPercent, int spatialDuplicationPercent) {
boolean response = false;
final boolean exceedsAllowedParameterDuplication = parameterDuplicationPercent > config
.getMaxAllowedParameterDuplication();
final boolean exceedsAllowedSpatialDuplication = spatialDuplicationPercent > config
.getMaxAllowedSpatialDuplication();
// gridded products
if (config instanceof GridSubscriptionOverlapConfig) {
GridSubscriptionOverlapConfig gconfig = (GridSubscriptionOverlapConfig) config;
final boolean exceedsAllowedForecastHourDuplication = forecastHourDuplicationPercent > gconfig
.getMaxAllowedForecastHourDuplication();
final boolean exceedsAllowedCycleDuplication = cycleDuplicationPercent > gconfig
.getMaxAllowedCycleDuplication();
response = exceedsAllowedParameterDuplication
|| exceedsAllowedForecastHourDuplication
|| exceedsAllowedCycleDuplication
|| exceedsAllowedSpatialDuplication;
}
// point products
else if (config instanceof PointSubscriptionOverlapConfig) {
PointSubscriptionOverlapConfig pconfig = (PointSubscriptionOverlapConfig) config;
final boolean exceedsAllowedTimeDuplication = forecastHourDuplicationPercent > pconfig
.getMaxAllowedTimeDuplication();
response = exceedsAllowedParameterDuplication
|| exceedsAllowedTimeDuplication
|| exceedsAllowedSpatialDuplication;
} else {
throw new IllegalArgumentException("Data type "+config.getClass()+" has no implementation");
}
return response;
}
@Override
public String getDisplayString() {
return "Match Any";
}
};
/**
* Check whether the given duplication percents indicate an overlapping
* subscription.
*
* @param config
* @param parameterDuplicationPercent
* @param forecastHourDuplicationPercent or timeDuplicatePercent
* @param cycleDuplicationPercent or notUsed
* @param spatialDuplicationPercent
* @return true if the subscription should be considered overlapping
*/
public abstract boolean isOverlapping(SubscriptionOverlapConfig config,
int parameterDuplicationPercent,
int forecastHourDuplicationPercent, int cycleDuplicationPercent,
int spatialDuplicationPercent);
/**
* Get the display string.
*
* @return the display string
*/
public abstract String getDisplayString();
}
private SubscriptionOverlapMatchStrategy(String displayString) {
this.displayString = displayString;
}
public String getDisplayString() {
return displayString;
}
};

View file

@ -0,0 +1,86 @@
/**
* 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.service.subscription;
import java.util.List;
import com.google.common.collect.Lists;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
/**
* Subscription overlap request object.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 24, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
@DynamicSerialize
public class SubscriptionOverlapRequest implements IServerRequest {
@DynamicSerializeElement
private List<Subscription> subscriptionList;
/**
* Constructor.
*/
public SubscriptionOverlapRequest() {
}
/**
* Constructor.
*
* @param subscriptionList
* - list of subscriptions
*/
public SubscriptionOverlapRequest(List<Subscription> subscriptionList) {
this.subscriptionList = subscriptionList;
}
/**
* @return the subscriptionList
*/
public List<Subscription> getSubscriptionList() {
if (subscriptionList == null) {
subscriptionList = Lists.newArrayListWithCapacity(0);
}
return subscriptionList;
}
/**
* @param subscriptionList
* the subscriptionList to set
*/
public void setSubscriptionList(List<Subscription> subscriptionList) {
this.subscriptionList = subscriptionList;
}
}

View file

@ -0,0 +1,114 @@
/**
* 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.service.subscription;
import java.util.List;
import com.google.common.collect.Lists;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* Subscription overlap response object.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 24, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
@DynamicSerialize
public class SubscriptionOverlapResponse {
@DynamicSerializeElement
private boolean overlap;
@DynamicSerializeElement
private boolean duplicate;
@DynamicSerializeElement
private List<String> subscriptionNameList;
/**
* @return the overlap
*/
public boolean isOverlap() {
return overlap;
}
/**
* @param overlap
* the overlap to set
*/
public void setOverlap(boolean overlap) {
this.overlap = overlap;
}
/**
* @return the duplicate
*/
public boolean isDuplicate() {
return duplicate;
}
/**
* @param duplicate
* the duplicate to set
*/
public void setDuplicate(boolean duplicate) {
this.duplicate = duplicate;
}
/**
* @return the subscriptionNameList
*/
public List<String> getSubscriptionNameList() {
if (subscriptionNameList == null) {
subscriptionNameList = Lists.newArrayListWithCapacity(0);
}
return subscriptionNameList;
}
/**
* @param subscriptionNameList
* the subscriptionNameList to set
*/
public void setSubscriptionNameList(List<String> subscriptionNameList) {
this.subscriptionNameList = subscriptionNameList;
}
/**
* @param name
*/
public void addSubscriptionName(String name) {
if (subscriptionNameList == null) {
subscriptionNameList = Lists.newArrayList();
}
this.subscriptionNameList.add(name);
}
}

View file

@ -19,15 +19,13 @@
**/
package com.raytheon.uf.common.datadelivery.service.subscription;
import java.util.HashMap;
import java.util.Map;
import java.io.File;
import java.util.MissingResourceException;
import javax.xml.bind.JAXBException;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
@ -43,7 +41,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.FileUtil;
/**
* Checks subscriptions to see if they would be considered duplicates.
* Read/Write subscription overlap config files.
*
* <pre>
*
@ -55,7 +53,7 @@ import com.raytheon.uf.common.util.FileUtil;
* Jun 04, 2013 223 mpduff Get base file if site doesn't exist.
* Sept 23, 2013 2283 dhladky Updated for multiple configs
* Oct 03, 2013 2386 mpduff Moved the subscription overlap rules files into the rules directory.
*
* Oct 25, 2013 2292 mpduff Move overlap checks to edex.
* </pre>
*
* @author djohnson
@ -64,47 +62,6 @@ import com.raytheon.uf.common.util.FileUtil;
public class SubscriptionOverlapService<T extends Time, C extends Coverage>
implements ISubscriptionOverlapService<T, C> {
/**
* Base response object implementing {@link ISubscriptionOverlapResponse}.
*/
public class SubscriptionOverlapResponse implements
ISubscriptionOverlapResponse {
private final boolean duplicate;
private final boolean overlapping;
/**
* Constructor.
*
* @param duplicate
* @param overlapping
*/
public SubscriptionOverlapResponse(boolean duplicate,
boolean overlapping) {
this.duplicate = duplicate;
this.overlapping = overlapping;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isDuplicate() {
return duplicate;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isOverlapping() {
return overlapping;
}
}
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(SubscriptionOverlapService.class);
@ -114,9 +71,7 @@ public class SubscriptionOverlapService<T extends Time, C extends Coverage>
private static final String SUBSCRIPTION_OVERLAP_CONFIG_FILE_ROOT = "SubscriptionOverlapRules.xml";
private static final String SUBSCRIPTION_OVERLAP_CONFIG_FILE_PATH = FileUtil
.join("datadelivery", "systemManagement", "rules");
private final ISubscriptionDuplicateChecker<T, C> duplicateChecker;
.join("datadelivery", "systemManagement", "rules", File.separator);
private final JAXBManager jaxbManager;
@ -125,10 +80,7 @@ public class SubscriptionOverlapService<T extends Time, C extends Coverage>
*
* @param duplicateChecker
*/
public SubscriptionOverlapService(
ISubscriptionDuplicateChecker<T, C> duplicateChecker) {
this.duplicateChecker = duplicateChecker;
public SubscriptionOverlapService() {
try {
@SuppressWarnings("rawtypes")
Class[] clazzes = new Class[] { SubscriptionOverlapConfig.class,
@ -140,27 +92,6 @@ public class SubscriptionOverlapService<T extends Time, C extends Coverage>
}
}
/**
* {@inheritDoc}
*/
@Override
public ISubscriptionOverlapResponse isOverlapping(Subscription<T, C> sub1,
Subscription<T, C> sub2) {
// Ignore requests to compare with itself
if (sub1.getName().equals(sub2.getName())) {
return new SubscriptionOverlapResponse(false, false);
}
// Ignore requests where the two subscriptions are of different types
if (!sub1.getDataSetType().equals(sub2.getDataSetType())) {
return new SubscriptionOverlapResponse(false, false);
}
SubscriptionOverlapConfig config = getConfigFile(sub1.getDataSetType());
return getOverlap(config, sub1, sub2);
}
/**
* {@inheritDoc}
*/
@ -191,95 +122,14 @@ public class SubscriptionOverlapService<T extends Time, C extends Coverage>
configFile.jaxbMarshal(config, jaxbManager);
}
/**
* {@inheritDoc}
*
* @throws LocalizationException
*/
@Override
public Map<DataType, SubscriptionOverlapConfig> readConfig()
throws LocalizationException {
HashMap<DataType, SubscriptionOverlapConfig> configs = new HashMap<DataType, SubscriptionOverlapConfig>();
for (DataType type : DataType.values()) {
SubscriptionOverlapConfig config = getConfigFile(type);
if (config != null) {
configs.put(type, config);
}
}
return configs;
}
/**
* Process a set of Gridded subscriptions for duplication;
*
* @param config
* @param sub1
* @param sub2
* @return
*/
private SubscriptionOverlapResponse processGriddedSubscriptionOverlap(
GridSubscriptionOverlapConfig config, Subscription<T, C> sub1,
Subscription<T, C> sub2) {
final int parameterDuplicationPercent = duplicateChecker
.getParameterDuplicationPercent(sub1, sub2);
final int forecastHourDuplicationPercent = duplicateChecker
.getForecastHourDuplicationPercent(sub1, sub2);
final int cycleDuplicationPercent = duplicateChecker
.getCycleDuplicationPercent(sub1, sub2);
final int spatialDuplicationPercent = duplicateChecker
.getSpatialDuplicationPercent(sub1, sub2);
final boolean overlaps = config.isOverlapping(
parameterDuplicationPercent, forecastHourDuplicationPercent,
cycleDuplicationPercent, spatialDuplicationPercent);
final boolean duplicate = (parameterDuplicationPercent == ONE_HUNDRED_PERCENT)
&& (forecastHourDuplicationPercent == ONE_HUNDRED_PERCENT)
&& (cycleDuplicationPercent == ONE_HUNDRED_PERCENT)
&& (spatialDuplicationPercent == ONE_HUNDRED_PERCENT);
return new SubscriptionOverlapResponse(duplicate, overlaps);
}
/***
* Process a set of Point subscriptions for duplication
*
* @param config
* @param sub1
* @param sub2
* @return
*/
private SubscriptionOverlapResponse processPointSubscriptionOverlap(
PointSubscriptionOverlapConfig config, Subscription<T, C> sub1,
Subscription<T, C> sub2) {
final int parameterDuplicationPercent = duplicateChecker
.getParameterDuplicationPercent(sub1, sub2);
final int timeDuplicationPercent = duplicateChecker
.getTimeDuplicationPercent(sub1, sub2);
final int spatialDuplicationPercent = duplicateChecker
.getSpatialDuplicationPercent(sub1, sub2);
final boolean overlaps = config.isOverlapping(
parameterDuplicationPercent, timeDuplicationPercent, 0,
spatialDuplicationPercent);
final boolean duplicate = (parameterDuplicationPercent == ONE_HUNDRED_PERCENT)
&& (timeDuplicationPercent == ONE_HUNDRED_PERCENT)
&& (spatialDuplicationPercent == ONE_HUNDRED_PERCENT);
return new SubscriptionOverlapResponse(duplicate, overlaps);
}
/**
* Gets the overlap config file by type
*
* @param type
* @return
*/
private SubscriptionOverlapConfig getConfigFile(DataType type) {
@Override
public SubscriptionOverlapConfig getConfigFile(DataType type) {
final IPathManager pathManager = PathManagerFactory.getPathManager();
LocalizationFile localizationFile = null;
@ -321,31 +171,4 @@ public class SubscriptionOverlapService<T extends Time, C extends Coverage>
return config;
}
/**
* Gets the SubscriptionOverlapResponse by type
*
* @param config
* @param sub1
* @param sub2
* @return
*/
private SubscriptionOverlapResponse getOverlap(
SubscriptionOverlapConfig config, Subscription<T, C> sub1,
Subscription<T, C> sub2) {
SubscriptionOverlapResponse response = null;
DataType type = sub1.getDataSetType();
if (type == DataType.GRID) {
response = processGriddedSubscriptionOverlap(
(GridSubscriptionOverlapConfig) config, sub1, sub2);
} else if (type == DataType.POINT) {
response = processPointSubscriptionOverlap(
(PointSubscriptionOverlapConfig) config, sub1, sub2);
} else {
throw new IllegalArgumentException(type
+ " Config not yet Implemented!");
}
return response;
}
}

View file

@ -36,7 +36,6 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo;
import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey;
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DByte;
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DFloat;
import com.raytheon.uf.common.dataplugin.gfe.grid.IGrid2D;
@ -73,6 +72,7 @@ import com.raytheon.uf.common.util.StringUtil;
* May 02, 2013 1949 bsteffen Update GFE data access in Product
* Browser, Volume Browser, and Data Access
* Framework.
* 10/31/2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
*
* </pre>
*
@ -221,7 +221,7 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
} else if (slice instanceof DiscreteGridSlice) {
DiscreteGridSlice castedSlice = (DiscreteGridSlice) slice;
data = castedSlice.getDiscreteGrid();
DiscreteKey[] dKeys = castedSlice.getKey();
Object[] dKeys = castedSlice.getKeys();
String[] keys = new String[dKeys.length];
for (int i = 0; i < dKeys.length; i++) {
keys[i] = dKeys[i].toString();
@ -285,7 +285,7 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
}
private GFERecord asGFERecord(Object obj) {
if (obj instanceof GFERecord == false) {
if ((obj instanceof GFERecord) == false) {
throw new DataRetrievalException(this.getClass().getSimpleName()
+ " cannot handle " + obj.getClass().getSimpleName());
}

View file

@ -44,7 +44,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.TimeRange;
/**
* TODO Add Description
* Grid slice for Discrete weather elements
*
* <pre>
* SOFTWARE HISTORY
@ -58,6 +58,7 @@ import com.raytheon.uf.common.time.TimeRange;
* 08/13/2013 1571 randerso Removed toString to stop it from hanging the
* debugger when trying to display the grid
* 10/29/2013 2476 njensen Updated getNumpy() and added getKeyList()
* 10/31/2013 2508 randerso Added getKeys(), deprecated getKey()
* </pre>
*
* @author chammack
@ -75,7 +76,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
private String cacheId;
@DynamicSerializeElement
private DiscreteKey[] key;
private DiscreteKey[] keys;
/**
* Constructor for serialization only.
@ -97,7 +98,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
Grid2DByte aGrid, DiscreteKey[] aKey) {
super(validTime, gfeRecord);
setDiscreteGrid(aGrid);
key = aKey;
keys = aKey;
}
/**
@ -113,7 +114,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
GridDataHistory[] history, Grid2DByte aGrid, DiscreteKey[] aKey) {
super(validTime, gpi, history);
setDiscreteGrid(aGrid);
key = aKey;
keys = aKey;
}
public DiscreteGridSlice(TimeRange validTime, GridParmInfo gpi,
@ -151,8 +152,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
Grid2DByte grid = rhs.getDiscreteGrid().clone();
setDiscreteGrid(grid);
this.key = new DiscreteKey[rhs.key.length];
System.arraycopy(rhs.key, 0, this.key, 0, rhs.key.length);
this.keys = new DiscreteKey[rhs.keys.length];
System.arraycopy(rhs.keys, 0, this.keys, 0, rhs.keys.length);
}
@Override
@ -178,11 +179,11 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
discreteGrid.assign(gsDiscreteGrid);
setDiscreteGrid(discreteGrid);
this.key = new DiscreteKey[slice.key.length];
System.arraycopy(slice.key, 0, this.key, 0, slice.key.length);
this.keys = new DiscreteKey[slice.keys.length];
System.arraycopy(slice.keys, 0, this.keys, 0, slice.keys.length);
} else {
setDiscreteGrid(null);
this.key = new DiscreteKey[0];
this.keys = new DiscreteKey[0];
}
}
@ -237,8 +238,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
byte[] thisData = grid.getBuffer().array();
byte[] rhsData = rhsGrid.getBuffer().array();
for (int i = 0; i < thisData.length; i++) {
if (!this.key[0xFF & thisData[i]]
.equals(rhsDiscreteGridSlice.key[0xFF & rhsData[i]])) {
if (!this.keys[0xFF & thisData[i]]
.equals(rhsDiscreteGridSlice.keys[0xFF & rhsData[i]])) {
return false;
}
}
@ -254,7 +255,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
* @return null if everything was ok, otherwise the reason why not
*/
public String checkKeyAndData() {
int keyLength = key.length;
int keyLength = keys.length;
Grid2DByte discreteGrid = getDiscreteGrid();
byte[] b = discreteGrid.getBuffer().array();
for (int i = 0; i < b.length; i++) {
@ -278,10 +279,10 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
* @return null if the key is ok, otherwise the reason why not
*/
public String checkKey() {
for (int i = 0; i < key.length; i++) {
if (!this.key[i].isValid()) {
for (int i = 0; i < keys.length; i++) {
if (!this.keys[i].isValid()) {
return "Invalid Key found in Grid. Key Position is " + i
+ " Key is: " + key[i].getOrigStr();
+ " Key is: " + keys[i].getOrigStr();
}
}
return null;
@ -316,19 +317,19 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
// find a key match
byte dByte = 0;
boolean found = false;
for (int k = 0; k < key.length; k++) {
if (key[k].equals(aValue)) {
for (int k = 0; k < keys.length; k++) {
if (keys[k].equals(aValue)) {
dByte = (byte) k;
found = true;
}
}
if (!found) {
DiscreteKey newKey[] = new DiscreteKey[key.length + 1];
System.arraycopy(key, 0, newKey, 0, key.length);
DiscreteKey newKey[] = new DiscreteKey[keys.length + 1];
System.arraycopy(keys, 0, newKey, 0, keys.length);
newKey[newKey.length - 1] = aValue;
key = newKey;
dByte = (byte) (key.length - 1);
keys = newKey;
dByte = (byte) (keys.length - 1);
}
for (int i = ll.x; i <= ur.x; i++) {
@ -370,23 +371,23 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
if (editArea.get(i, j) != 0) {
// Get the DiscreteKey from the source grid
byte dByte = gsDiscreteGrid.get(i, j);
DiscreteKey dKey = gs.key[0xFF & dByte];
DiscreteKey dKey = gs.keys[0xFF & dByte];
// See if this key already exists in target grid
boolean found = false;
byte keyIndex = 0;
for (int k = 0; k < key.length; k++) {
if (key[k] == dKey) {
for (int k = 0; k < keys.length; k++) {
if (keys[k] == dKey) {
found = true;
keyIndex = (byte) k;
}
}
if (!found) // not found, so add the key
{
DiscreteKey newKey[] = new DiscreteKey[key.length + 1];
System.arraycopy(key, 0, newKey, 0, key.length);
DiscreteKey newKey[] = new DiscreteKey[keys.length + 1];
System.arraycopy(keys, 0, newKey, 0, keys.length);
newKey[newKey.length - 1] = dKey;
key = newKey;
keyIndex = (byte) (key.length - 1);
keys = newKey;
keyIndex = (byte) (keys.length - 1);
}
discreteGrid.set(i, j, keyIndex);
@ -414,19 +415,19 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
// find a key match
byte dByte = 0;
boolean found = false;
for (int k = 0; k < key.length; k++) {
if (key[k].equals(aValue)) {
for (int k = 0; k < keys.length; k++) {
if (keys[k].equals(aValue)) {
dByte = (byte) k;
found = true;
}
}
if (!found) {
DiscreteKey newKey[] = new DiscreteKey[key.length + 1];
System.arraycopy(key, 0, newKey, 0, key.length);
DiscreteKey newKey[] = new DiscreteKey[keys.length + 1];
System.arraycopy(keys, 0, newKey, 0, keys.length);
newKey[newKey.length - 1] = aValue;
key = newKey;
dByte = (byte) (key.length - 1);
keys = newKey;
dByte = (byte) (keys.length - 1);
}
Grid2DByte discreteGrid = getDiscreteGrid();
@ -448,22 +449,22 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
Grid2DByte discreteGrid = gs.discreteGrid.clone();
List<DiscreteKey> currentKeys = new ArrayList<DiscreteKey>(
Arrays.asList(this.key));
Arrays.asList(this.keys));
byte[] data = discreteGrid.getBuffer().array();
int thisB;
for (int i = 0; i < data.length; i++) {
thisB = 0xFF & data[i];
byte keyIndex;
if ((keyIndex = (byte) currentKeys.indexOf(gs.key[thisB])) != -1) {
if ((keyIndex = (byte) currentKeys.indexOf(gs.keys[thisB])) != -1) {
data[i] = keyIndex;
} else {
data[i] = (byte) currentKeys.size();
currentKeys.add(new DiscreteKey(gs.key[thisB]));
currentKeys.add(new DiscreteKey(gs.keys[thisB]));
}
}
setDiscreteGrid(discreteGrid);
this.key = currentKeys.toArray(new DiscreteKey[currentKeys.size()]);
this.keys = currentKeys.toArray(new DiscreteKey[currentKeys.size()]);
return true;
}
@ -478,7 +479,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
*/
public Grid2DBit eq(DiscreteKey value) {
if (!value.isValid()) {
throw new IllegalArgumentException("Supplied key is invalid");
throw new IllegalArgumentException("Supplied keys is invalid");
}
Grid2DByte discreteGrid = getDiscreteGrid();
@ -489,8 +490,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
// Get or make a Discrete
byte dByte = 0;
boolean found = false;
for (int k = 0; k < key.length; k++) {
if (key[k].equals(value)) {
for (int k = 0; k < keys.length; k++) {
if (keys[k].equals(value)) {
dByte = (byte) k;
found = true;
}
@ -545,17 +546,17 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
// Check for each value
// Get the list of subkey permutations from the value given
List<String> searchKeys = key[0].descriptionSubKeys(value);
List<String> searchKeys = keys[0].descriptionSubKeys(value);
// Get the byte values that correspond to the specified textStrings
List<Byte> byteValues = new ArrayList<Byte>();
// Check each discrete key for a match of a subkey
for (int i = 0; i < key.length; i++) {
for (int i = 0; i < keys.length; i++) {
// Check each subkey
for (int j = 0; j < key[i].getSubKeys().size(); j++) {
for (int j = 0; j < keys[i].getSubKeys().size(); j++) {
for (int k = 0; k < searchKeys.size(); k++) {
if (key[i].getSubKeys().get(j).equals(searchKeys.get(k))) {
if (keys[i].getSubKeys().get(j).equals(searchKeys.get(k))) {
byteValues.add((byte) i);
break;
}
@ -604,7 +605,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
byte[] rhsB = gs.getDiscreteGrid().getBuffer().array();
byte[] b = bits.getBuffer().array();
for (int i = 0; i < thisB.length; i++) {
if (key[0xFF & thisB[i]].equals(gs.key[0xFF & rhsB[i]])) {
if (keys[0xFF & thisB[i]].equals(gs.keys[0xFF & rhsB[i]])) {
b[i] = (byte) 1;
}
}
@ -639,9 +640,9 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
* for duplicate keys, set all locations in grid that match that key to
* the "first" of the duplicate keys
*/
for (int i = 0; i < (key.length - 1); i++) {
for (int j = i; j < key.length; j++) {
if (key[i].equals(key[j])) {
for (int i = 0; i < (keys.length - 1); i++) {
for (int j = i; j < keys.length; j++) {
if (keys[i].equals(keys[j])) {
discreteGrid.setAllOfValue((byte) j, (byte) i);
}
}
@ -666,11 +667,11 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
.hasNext(); keyIndex++) {
byte thisByte = usedKeysI.next();
discreteGrid.setAllOfValue(thisByte, (byte) keyIndex);
newKey[keyIndex] = key[0xFF & thisByte];
newKey[keyIndex] = keys[0xFF & thisByte];
}
setDiscreteGrid(discreteGrid);
key = newKey;
keys = newKey;
}
@Override
@ -688,9 +689,9 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
aGrid = aGrid.clone();
}
DiscreteKey[] aKey = new DiscreteKey[this.key.length];
DiscreteKey[] aKey = new DiscreteKey[this.keys.length];
for (int i = 0; i < aKey.length; i++) {
aKey[i] = new DiscreteKey(this.key[i]);
aKey[i] = new DiscreteKey(this.keys[i]);
}
return new DiscreteGridSlice(aValidTime, aGpi, aHistory, aGrid, aKey);
}
@ -742,12 +743,23 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
}
/**
* Return the discrete key
* Return the discrete keys
*
* @return the discrete key
* @return the discrete keys
* @deprecated use getKeys() instead
*/
@Deprecated
public DiscreteKey[] getKey() {
return this.key;
return this.keys;
}
/**
* Return the discrete keys
*
* @return the discrete keys
*/
public DiscreteKey[] getKeys() {
return this.keys;
}
public void setDiscreteGrid(Grid2DByte grid) {
@ -781,7 +793,7 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
}
public void setKey(DiscreteKey[] key) {
this.key = key;
this.keys = key;
}
public void setKey(List<DiscreteKey[]> key) {
@ -854,8 +866,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
}
public List<String> getKeyList() {
List<String> list = new ArrayList<String>(key.length);
for (DiscreteKey k : key) {
List<String> list = new ArrayList<String>(keys.length);
for (DiscreteKey k : keys) {
list.add(k.toString());
}
return list;

View file

@ -20,10 +20,13 @@
package com.raytheon.uf.edex.activetable;
import com.raytheon.uf.common.activetable.GetNextEtnRequest;
import com.raytheon.uf.common.activetable.response.GetNextEtnResponse;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* TODO Add Description
* Request handler for <code>GetNextEtnRequest</code>. Returns the next ETN to
* use for the given office id, phensig, and active table (PRACTICE or
* OPERATIONAL).
*
* <pre>
*
@ -31,6 +34,7 @@ import com.raytheon.uf.common.serialization.comm.IRequestHandler;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 15, 2011 rjpeter Initial creation
* Oct 21, 2013 #1843 dgilling Change return type.
*
* </pre>
*
@ -41,12 +45,14 @@ import com.raytheon.uf.common.serialization.comm.IRequestHandler;
public class GetNextEtnHandler implements IRequestHandler<GetNextEtnRequest> {
@Override
public Integer handleRequest(GetNextEtnRequest request) throws Exception {
Integer nextEtn = GetNextEtnUtil.getNextEtn(request.getSiteID(),
request.getMode(), request.getPhensig(),
public GetNextEtnResponse handleRequest(GetNextEtnRequest request)
throws Exception {
GetNextEtnResponse response = GetNextEtnUtil.getNextEtn(
request.getSiteID(), request.getMode(), request.getPhensig(),
request.getCurrentTime(), request.isLockEtn(),
request.isPerformISC());
return nextEtn;
request.isPerformISC(), request.isReportConflictOnly(),
request.getEtnOverride());
return response;
}
}

View file

@ -28,9 +28,13 @@ import java.net.UnknownHostException;
import java.rmi.RemoteException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Queue;
import java.util.SortedMap;
@ -40,6 +44,7 @@ import com.raytheon.edex.site.SiteUtil;
import com.raytheon.uf.common.activetable.ActiveTableMode;
import com.raytheon.uf.common.activetable.request.LockAndGetNextEtnRequest;
import com.raytheon.uf.common.activetable.request.UnlockAndSetNextEtnRequest;
import com.raytheon.uf.common.activetable.response.GetNextEtnResponse;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
@ -79,7 +84,7 @@ public final class GetNextEtnUtil {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GetNextEtnUtil.class);
private static final String CONFIG_FILE_NAME = "remote-etn-partners.properties";
public static final String CONFIG_FILE_NAME = "remote-etn-partners.properties";
private static final String NEXT_ETN_LOCK = "ActiveTableNextEtn";
@ -121,29 +126,59 @@ public final class GetNextEtnUtil {
* <code>isLock</code> is false, this flag is effectively false
* and your configured remote partners will not be contacted to
* determine the next ETN.
* @return The next ETN to be used in sequence.
* @param reportConflictOnly
* Affects which kinds of errors get reported back to the
* requestor. If true, only cases where the value of
* <code>etnOverride</code> is less than or equal to the last ETN
* used by this site or any of its partners will be reported.
* Else, all significant errors will be reported back.
* @param etnOverride
* Allows the user to influence the next ETN assigned by using
* this value unless it is less than or equal to the last ETN
* used by this site or one of its partners.
* @return A <code>GetNextEtnResponse</code> containing the next ETN to use
* and any hosts that couldn't be contacted during this process.
*/
public static Integer getNextEtn(String siteId, ActiveTableMode mode,
String phensig, Calendar currentTime, boolean isLock,
boolean performISC) {
List<IRequestRouter> hostsToQuery = Collections.emptyList();
public static GetNextEtnResponse getNextEtn(String siteId,
ActiveTableMode mode, String phensig, Calendar currentTime,
boolean isLock, boolean performISC, boolean reportConflictOnly,
Integer etnOverride) {
SortedMap<String, IRequestRouter> hostsToQuery = new TreeMap<String, IRequestRouter>();
List<String> readEtnSourcesErrors = Collections.emptyList();
if (performISC) {
hostsToQuery = GetNextEtnUtil.getRemoteEtnSources(siteId);
try {
hostsToQuery = GetNextEtnUtil.getRemoteEtnSources(siteId);
} catch (UnknownHostException e) {
readEtnSourcesErrors = Arrays.asList(
"Falling back to local ETN calculation: ",
"Could not perform reverse lookup for localhost: "
+ e.getLocalizedMessage());
} catch (IOException e) {
readEtnSourcesErrors = Arrays.asList(
"Falling back to local ETN calculation: ",
"Could not read configuration file " + CONFIG_FILE_NAME
+ ": " + e.getLocalizedMessage());
}
}
int nextEtn;
if (performISC && isLock && (!hostsToQuery.isEmpty())) {
nextEtn = GetNextEtnUtil.getNextEtnFromPartners(siteId, mode,
phensig, currentTime, hostsToQuery);
GetNextEtnResponse response;
if (performISC && isLock && (!hostsToQuery.isEmpty())
&& (readEtnSourcesErrors.isEmpty())) {
response = GetNextEtnUtil.getNextEtnFromPartners(siteId, mode,
phensig, currentTime, hostsToQuery, reportConflictOnly,
etnOverride);
} else {
nextEtn = GetNextEtnUtil.getNextEtnFromLocal(siteId, mode, phensig,
currentTime, isLock);
int nextEtn = GetNextEtnUtil.getNextEtnFromLocal(siteId, mode,
phensig, currentTime, isLock);
response = new GetNextEtnResponse(nextEtn, phensig);
response.setErrorMessages(readEtnSourcesErrors);
}
return nextEtn;
return response;
}
private static List<IRequestRouter> getRemoteEtnSources(String siteId) {
private static SortedMap<String, IRequestRouter> getRemoteEtnSources(
String siteId) throws IOException, UnknownHostException {
Properties etnBackupProps = new Properties();
FileInputStream fis = null;
try {
@ -156,11 +191,11 @@ public final class GetNextEtnUtil {
etnBackupProps.load(fis);
} catch (FileNotFoundException e) {
statusHandler.error(CONFIG_FILE_NAME + " file does not exist!", e);
return Collections.emptyList();
return new TreeMap<String, IRequestRouter>();
} catch (IOException e) {
statusHandler.error("Error reading " + CONFIG_FILE_NAME + " file!",
e);
return Collections.emptyList();
throw e;
} finally {
if (fis != null) {
try {
@ -172,6 +207,8 @@ public final class GetNextEtnUtil {
}
}
String localhostFQDN = getLocalhostFQDN();
String[] tokens = etnBackupProps.getProperty("BACKUP.HOSTS." + siteId,
"").split(",");
@ -182,17 +219,7 @@ public final class GetNextEtnUtil {
for (String token : tokens) {
String host = token.trim().toLowerCase();
if ("localhost".equals(host)) {
try {
host = InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
statusHandler.error(
"Unable to retrieve host name for localhost.", e);
statusHandler
.handle(Priority.CRITICAL,
"ETN assignment will not be able to query local server for used ETNs. Please check your network configuration and "
+ CONFIG_FILE_NAME + ".");
continue;
}
continue;
}
IRequestRouter reqHandler = new RemoteServerRequestRouter("http://"
@ -200,7 +227,11 @@ public final class GetNextEtnUtil {
sources.put(host, reqHandler);
}
return new ArrayList<IRequestRouter>(sources.values());
IRequestRouter reqHandler = new RemoteServerRequestRouter("http://"
+ localhostFQDN + ":9581/services");
sources.put(localhostFQDN, reqHandler);
return sources;
}
/**
@ -244,10 +275,13 @@ public final class GetNextEtnUtil {
* needed if only determining a preliminary ETN. Required to be
* set to <code>true</code> if you want to actually move the
* sequence forward.
* @param etnOverride
* TODO
* @return The next ETN to be used in sequence.
*/
public static int lockAndGetNextEtn(String siteId, ActiveTableMode mode,
String phensig, Calendar currentTime, boolean isLock) {
String phensig, Calendar currentTime, boolean isLock,
Integer etnOverride) {
String lockName = getEtnClusterLockName(siteId, mode);
ClusterTask ct = null;
if (isLock) {
@ -264,19 +298,25 @@ public final class GetNextEtnUtil {
currentTime);
int nextEtn = (lastEtn != null) ? lastEtn + 1 : 1;
String year = Integer.toString(currentTime.get(Calendar.YEAR));
String eInfo = ct.getExtraInfo();
if ((!StringUtil.isEmptyString(eInfo)) && (eInfo.startsWith(year))) {
// parse year info
try {
int ctNextEtn = Integer
.parseInt(eInfo.substring(year.length() + 1)) + 1;
nextEtn = Math.max(nextEtn, ctNextEtn);
} catch (NumberFormatException e) {
statusHandler.error(
"Caught excetion parsing etn from cluster_task", e);
int sysNextEtn = -1;
if (etnOverride == null) {
String year = Integer.toString(currentTime.get(Calendar.YEAR));
String eInfo = ct.getExtraInfo();
if ((!StringUtil.isEmptyString(eInfo)) && (eInfo.startsWith(year))) {
// parse year info
try {
sysNextEtn = Integer
.parseInt(eInfo.substring(year.length() + 1)) + 1;
} catch (NumberFormatException e) {
statusHandler
.error("Caught exception parsing etn from cluster_task",
e);
}
}
} else {
sysNextEtn = etnOverride.intValue();
}
nextEtn = Math.max(nextEtn, sysNextEtn);
return nextEtn;
}
@ -330,7 +370,7 @@ public final class GetNextEtnUtil {
ActiveTableMode mode, String phensig, Calendar currentTime,
boolean isLock) {
int nextEtn = lockAndGetNextEtn(siteId, mode, phensig, currentTime,
isLock);
isLock, null);
if (isLock) {
setNextEtnAndUnlock(siteId, mode, phensig,
currentTime.get(Calendar.YEAR), nextEtn);
@ -360,50 +400,88 @@ public final class GetNextEtnUtil {
* @param hostsToQuery
* The remote hosts to query. This should also include the local
* EDEX instance initiating this operation.
* @return The next ETN to be used in sequence.
* @param reportConflictOnly
* Affects which kinds of errors get reported back to the
* requestor. If true, only cases where the value of
* <code>etnOverride</code> is less than or equal to the last ETN
* used by this site or any of its partners will be reported.
* Else, all significant errors will be reported back.
* @param etnOverride
* Allows the user to influence the next ETN assigned by using
* this value unless it is less than or equal to the last ETN
* used by this site or one of its partners.
* @return A <code>GetNextEtnResponse</code> containing the next ETN to use
* and any hosts that couldn't be contacted during this process.
* @throws UnknownHostException
*/
public static Integer getNextEtnFromPartners(String siteId,
public static GetNextEtnResponse getNextEtnFromPartners(String siteId,
ActiveTableMode mode, String phensig, Calendar currentTime,
List<IRequestRouter> hostsToQuery) {
Queue<IRequestRouter> lockQueue = new ArrayDeque<IRequestRouter>(
hostsToQuery);
Queue<IRequestRouter> unlockQueue = Collections
.asLifoQueue(new ArrayDeque<IRequestRouter>(hostsToQuery.size()));
SortedMap<String, IRequestRouter> hostsToQuery,
boolean reportConflictOnly, Integer etnOverride) {
Queue<Entry<String, IRequestRouter>> unlockQueue = Collections
.asLifoQueue(new ArrayDeque<Entry<String, IRequestRouter>>(
hostsToQuery.size()));
Map<String, Integer> resultsByHost = new HashMap<String, Integer>(
hostsToQuery.size(), 1f);
List<String> errors = new ArrayList<String>();
String mySiteId = SiteUtil.getSite();
IServerRequest getAndLockReq = new LockAndGetNextEtnRequest(siteId,
mySiteId, mode, phensig, currentTime);
int nextEtn = 1;
for (IRequestRouter router : lockQueue) {
mySiteId, mode, phensig, currentTime, etnOverride);
for (Entry<String, IRequestRouter> host : hostsToQuery.entrySet()) {
IRequestRouter router = host.getValue();
String hostName = host.getKey();
Integer partnersNextEtn = null;
try {
Integer partersNextEtn = (Integer) GetNextEtnUtil
.sendThriftRequest(router, getAndLockReq);
nextEtn = Math.max(nextEtn, partersNextEtn);
unlockQueue.add(router);
partnersNextEtn = (Integer) GetNextEtnUtil.sendThriftRequest(
router, getAndLockReq);
unlockQueue.add(host);
} catch (RemoteException e) {
statusHandler
.handle(Priority.WARN,
"Error occurred contacting one of the remote ETN partners.",
e);
String message = "Error occurred contacting remote ETN partner ["
+ hostName + "]: " + e.getLocalizedMessage();
if (!reportConflictOnly) {
errors.add(message);
}
statusHandler.handle(Priority.WARN, message, e);
}
resultsByHost.put(hostName, partnersNextEtn);
}
int nextEtn = 1;
for (Entry<String, Integer> entry : resultsByHost.entrySet()) {
int partnerEtn = (entry.getValue() != null) ? entry.getValue() : -1;
nextEtn = Math.max(nextEtn, partnerEtn);
if ((etnOverride != null) && (etnOverride < partnerEtn)) {
String message = "User-provided ETN value of "
+ etnOverride.toString()
+ " conflicts with calculated ETN value " + partnerEtn
+ " from host " + entry.getKey();
errors.add(message);
statusHandler.warn(message);
}
}
IServerRequest unlockReq = new UnlockAndSetNextEtnRequest(siteId,
mySiteId, mode, currentTime.get(Calendar.YEAR), phensig,
nextEtn);
for (IRequestRouter router : unlockQueue) {
for (Entry<String, IRequestRouter> host : unlockQueue) {
IRequestRouter router = host.getValue();
try {
GetNextEtnUtil.sendThriftRequest(router, unlockReq);
} catch (RemoteException e) {
statusHandler
.handle(Priority.WARN,
"Error occurred unlocking one of the remote ETN partners.",
e);
String message = "Error occurred unlocking remote ETN partner ["
+ host.getKey() + "]: " + e.getLocalizedMessage();
if (!reportConflictOnly) {
errors.add(message);
}
statusHandler.handle(Priority.WARN, message, e);
}
}
return nextEtn;
return new GetNextEtnResponse(nextEtn, phensig, resultsByHost, errors);
}
private static Object sendThriftRequest(final IRequestRouter router,
@ -429,4 +507,17 @@ public final class GetNextEtnUtil {
return retVal;
}
private static String getLocalhostFQDN() throws UnknownHostException {
try {
return InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
statusHandler.error("Unable to retrieve host name for localhost.",
e);
statusHandler
.handle(Priority.CRITICAL,
"ETN assignment will not be able to query local server for used ETNs. Please check your network configuration.");
throw e;
}
}
}

View file

@ -36,6 +36,7 @@ import com.raytheon.uf.edex.activetable.GetNextEtnUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 19, 2013 #1843 dgilling Initial creation
* Oct 23, 2013 #1843 dgilling Update with ETN override.
*
* </pre>
*
@ -64,6 +65,6 @@ public class LockAndGetNextEtnHandler implements
+ request.getSiteID() + "]: phensig= " + request.getPhensig());
return GetNextEtnUtil.lockAndGetNextEtn(request.getSiteID(),
request.getMode(), request.getPhensig(),
request.getCurrentTime(), true);
request.getCurrentTime(), true, request.getEtnOverride());
}
}

View file

@ -12,12 +12,12 @@
#
# To configure remote ETN querying for a specific site id: you must add an
# entry to the site version of this file that looks like the following:
# BACKUP.HOSTS.KXYZ=ec-xyz,ec-yyy,ec-zzz
# BACKUP.HOSTS.KXYZ=ec-yyy,ec-zzz
#
# Now, when generating VTEC products for site KXYZ, EDEX will query hosts
# ec-xyz,ec-yyy, and ec-zzz for the last ETN used for KXYZ. Note that you must
# include the host name for this EDEX server in the list of hosts if you want
# "localhost" to be in the hosts queried for the next ETN.
# ec-yyy and ec-zzz for the last ETN used for KXYZ. Note that "localhost"
# will automatically be queried for the next ETN so there is no
# requirement to add it to the list of entries.
#
# There should only ever be one localized copy of this file on the EDEX server,
# and it should be located at
@ -26,4 +26,4 @@
# querying (say, in case of service backup), you just add a new BACKUP.HOSTS
# entry to this file.
#
# CONFIGURATION ENTRIES GO BELOW
# CONFIGURATION ENTRIES GO BELOW

View file

@ -30,4 +30,7 @@ Require-Bundle: com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.edex.pointdata;bundle-version="1.12.1174",
com.raytheon.uf.common.dataquery;bundle-version="1.0.0",
com.raytheon.uf.edex.database;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174"
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
org.geotools;bundle-version="2.6.4",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
com.raytheon.edex.common;bundle-version="1.12.1174"

View file

@ -39,4 +39,14 @@
<constructor-arg ref="providerKeyRequestServiceHandler" />
</bean>
<bean id="overlapRequestServiceHandler"
class="com.raytheon.uf.edex.datadelivery.service.services.overlap.SubscriptionOverlapHandler" />
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapRequest" />
<constructor-arg ref="overlapRequestServiceHandler" />
</bean>
</beans>

View file

@ -0,0 +1,177 @@
/**
* 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.edex.datadelivery.service.services.overlap;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.service.subscription.GridSubscriptionOverlapConfig;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapConfig;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy;
/**
* Gridded overlap data object.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 17, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
* @param <T>
*/
public class GridOverlapData<T extends GriddedTime, C extends GriddedCoverage>
extends OverlapData<GriddedTime, GriddedCoverage> {
/** Number of grid attributes */
private final int numberOfGridAttributes = 2;
/** Forecast hour duplication percent */
private int fcstHrDuplication = -999;
/** Cycle time duplication percetn */
private int cycleDuplication = -999;
/** Forecast hour pass flag */
private boolean fcstHrPass = false;
/** Cycle time pass flag */
private boolean cyclePass = false;
/**
* Constructor.
*
* @param sub1
* @param sub2
* @param config
*/
public GridOverlapData(Subscription sub1, Subscription sub2,
SubscriptionOverlapConfig config) {
super(sub1, sub2, config);
}
/**
* Calculates the percent, 0-100, of how many cycle hours from sub2 are
* satisfied by sub1.
*
* @param sub1
* @param sub2
*/
public void calculateCycleDuplicationPercent(
Subscription<GriddedTime, GriddedCoverage> sub1,
Subscription<GriddedTime, GriddedCoverage> sub2) {
GriddedTime gtime1 = sub1.getTime();
GriddedTime gtime2 = sub2.getTime();
cycleDuplication = this.getDuplicationPercent(gtime1.getCycleTimes(),
gtime2.getCycleTimes());
}
/**
* Calculates the percent, 0-100, of how many forecast hours from sub2 are
* satisfied by sub1.
*
* @param sub1
* @param sub2
*/
public void calculateForecastHourDuplicationPercent(
Subscription<GriddedTime, GriddedCoverage> sub1,
Subscription<GriddedTime, GriddedCoverage> sub2) {
GriddedTime gtime1 = sub1.getTime();
GriddedTime gtime2 = sub2.getTime();
fcstHrDuplication = getDuplicationPercent(
gtime1.getSelectedTimeIndices(),
gtime2.getSelectedTimeIndices());
}
/**
* {@inheritDoc}
*/
@Override
protected void determineOverlapping() {
super.determineOverlapping();
calculateCycleDuplicationPercent(sub1, sub2);
calculateForecastHourDuplicationPercent(sub1, sub2);
GridSubscriptionOverlapConfig config = (GridSubscriptionOverlapConfig) this.config;
fcstHrPass = fcstHrDuplication > config
.getMaxAllowedForecastHourDuplication();
cyclePass = cycleDuplication > config.getMaxAllowedCycleDuplication();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isOverlapping() {
determineOverlapping();
boolean response = false;
if (matchStrategy == SubscriptionOverlapMatchStrategy.MATCH_ALL) {
response = cyclePass && fcstHrPass && parameterPass && spatialPass;
} else if (matchStrategy == SubscriptionOverlapMatchStrategy.MATCH_ANY) {
response = cyclePass || fcstHrPass || parameterPass || spatialPass;
} else if (matchStrategy == SubscriptionOverlapMatchStrategy.AT_LEAST_HALF) {
int halfNumAttrs = (numberOfGridAttributes + numberOfCommonAttributes) / 2;
List<Boolean> toCheck = new ArrayList<Boolean>();
toCheck.add(cyclePass);
toCheck.add(fcstHrPass);
toCheck.add(parameterPass);
toCheck.add(spatialPass);
int exceeded = 0;
for (boolean check : toCheck) {
if (check) {
exceeded++;
if (exceeded >= halfNumAttrs) {
response = true;
break;
}
}
}
}
return response;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isDuplicate() {
determineOverlapping();
return cycleDuplication == ONE_HUNDRED_PERCENT
&& fcstHrDuplication == ONE_HUNDRED_PERCENT
&& parameterDuplication == ONE_HUNDRED_PERCENT
&& spatialDuplication == ONE_HUNDRED_PERCENT;
}
}

View file

@ -0,0 +1,209 @@
/**
* 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.edex.datadelivery.service.services.overlap;
import java.util.Collection;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapConfig;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.CollectionUtil;
/**
* Parent Overlap Data Object. This object holds the data needed to calculate
* overlapping of subscriptions.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 17, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
* @param <T>
* @param <C>
*/
public abstract class OverlapData<T extends Time, C extends Coverage> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(OverlapData.class);
protected final int ONE_HUNDRED_PERCENT = 100;
private final String UNABLE_TO_DETERMINE_SPATIAL_OVERLAP = "Unable to determine spatial overlap. "
+ "Subscriptions will not be considered to be overlapping spatially.";
/** The number of common attributes (in this class) */
protected final int numberOfCommonAttributes = 2;
/** Spatial duplication percent */
protected int spatialDuplication = -999;
/** parameter duplication percent */
protected int parameterDuplication = -999;
/** Spatial pass flag */
protected boolean spatialPass = false;
/** Parameter pass flag */
protected boolean parameterPass = false;
/** The subscription match strategy */
protected SubscriptionOverlapMatchStrategy matchStrategy;
/** The subscription overlap config object */
protected SubscriptionOverlapConfig config;
/** Subscription 1 */
protected Subscription<T, C> sub1;
/** Subscription 2 */
protected Subscription<T, C> sub2;
/**
* Constructor.
*
* @param sub1
* @param sub2
* @param config
*/
public OverlapData(Subscription<T, C> sub1, Subscription<T, C> sub2,
SubscriptionOverlapConfig config) {
this.sub1 = sub1;
this.sub2 = sub2;
this.config = config;
this.matchStrategy = config.getMatchStrategy();
}
/**
* Calculates the percent, 0-100, of how much spatial coverage from sub2 is
* satisfied by sub1.
*
* @param sub1
* @param sub2
*/
protected void calculateSpatialDuplicationPercent(Subscription<T, C> sub1,
Subscription<T, C> sub2) {
final Coverage sub1Coverage = sub1.getCoverage();
final Coverage sub2Coverage = sub2.getCoverage();
if (sub1Coverage != null && sub2Coverage != null) {
final ReferencedEnvelope sub1Envelope = sub1Coverage
.getRequestEnvelope();
final ReferencedEnvelope sub2Envelope = sub2Coverage
.getRequestEnvelope();
if (sub1Envelope != null && sub2Envelope != null) {
// try {
ReferencedEnvelope intersection;
try {
intersection = MapUtil.reprojectAndIntersect(sub1Envelope,
sub2Envelope);
final double intersectionArea = intersection.getArea();
spatialDuplication = (int) ((intersectionArea * 100) / sub2Envelope
.getArea());
} catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM,
UNABLE_TO_DETERMINE_SPATIAL_OVERLAP, e);
}
}
}
}
/**
* Calculates the percent, 0-100, of how many parameters from sub2 are
* satisfied by sub1.
*
* @param sub1
* @param sub2
*/
protected void calculateParameterDuplicationPercent(
Subscription<T, C> sub1, Subscription<T, C> sub2) {
parameterDuplication = getDuplicationPercent(sub1.getParameter(),
sub2.getParameter());
}
/**
* Determine the overlap values
*/
protected void determineOverlapping() {
calculateParameterDuplicationPercent(sub1, sub2);
calculateSpatialDuplicationPercent(sub1, sub2);
this.parameterPass = this.parameterDuplication > config
.getMaxAllowedParameterDuplication();
this.spatialPass = this.spatialDuplication > config
.getMaxAllowedSpatialDuplication();
}
/**
* Calculate the duplication percent of the two collections.
*
* @param coll1
* @param coll2
* @return
*/
protected <M> int getDuplicationPercent(Collection<M> coll1,
Collection<M> coll2) {
int numberSatisfiedByFirstCollection = 0;
if (!CollectionUtil.isNullOrEmpty(coll1)
&& !CollectionUtil.isNullOrEmpty(coll2)) {
for (M entry : coll2) {
if (coll1.contains(entry)) {
numberSatisfiedByFirstCollection++;
}
}
// Convert percent to 0-100
return (numberSatisfiedByFirstCollection * 100) / (coll2.size());
}
return 0;
}
/**
* Are the two subscriptions considered overlapping
*
* @return true if overlapping
*/
public abstract boolean isOverlapping();
/**
* Are the two subscriptions duplicates
*
* @return true if duplicates
*/
public abstract boolean isDuplicate();
}

View file

@ -0,0 +1,82 @@
/**
* 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.edex.datadelivery.service.services.overlap;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
import com.raytheon.uf.common.datadelivery.registry.PointTime;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.service.subscription.ISubscriptionOverlapService;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapConfig;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapService;
/**
* Overlap data factory
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 22, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
* @param <T>
* @param <C>
*/
public class OverlapDataFactory<T extends Time, C extends Coverage> {
private static SubscriptionOverlapConfig config;
/**
* Get the overlap data object.
*
* @param sub1
* @param sub2
* @return
*/
public static OverlapData<?, ?> getOverlapData(Subscription<?, ?> sub1,
Subscription<?, ?> sub2) {
if (sub1.getDataSetType() != sub2.getDataSetType()) {
throw new IllegalArgumentException(
"Subscriptions must be of the same data type.");
}
ISubscriptionOverlapService<?, ?> overlapService = new SubscriptionOverlapService();
DataType dt = sub1.getDataSetType();
config = overlapService.getConfigFile(dt);
if (dt == DataType.GRID) {
return new GridOverlapData<GriddedTime, GriddedCoverage>(sub1,
sub2, config);
} else if (dt == DataType.POINT) {
return new PointOverlapData<PointTime, Coverage>(sub1, sub2, config);
}
throw new IllegalArgumentException("Invalid Data Type: "
+ sub1.getDataSetType());
}
}

View file

@ -0,0 +1,150 @@
/**
* 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.edex.datadelivery.service.services.overlap;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.PointTime;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.service.subscription.PointSubscriptionOverlapConfig;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapConfig;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy;
/**
* Point overlap data object.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 17, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class PointOverlapData<T extends PointTime, C extends Coverage> extends
OverlapData<PointTime, Coverage> {
/** Number of point attributes */
private final int numberOfPointAttributes = 1;
/** Time duplication percent */
private int timeDuplication = -999;
/** Time duplication pass flag */
private boolean timeDuplicationPass = false;
/**
* Constructor.
*
* @param sub1
* @param sub2
* @param config
*/
public PointOverlapData(Subscription sub1, Subscription sub2,
SubscriptionOverlapConfig config) {
super(sub1, sub2, config);
}
/**
* Calculates the percent, 0-100, of how similar the time is from sub2 to
* sub1.
*
* @param sub1
* @param sub2
*/
private void calculateTimeDuplicationPercent(
Subscription<PointTime, Coverage> sub1,
Subscription<PointTime, Coverage> sub2) {
PointTime ptime1 = sub1.getTime();
PointTime ptime2 = sub2.getTime();
List<Integer> intervalList1 = new ArrayList<Integer>();
intervalList1.add(ptime1.getInterval());
List<Integer> intervalList2 = new ArrayList<Integer>();
intervalList2.add(ptime2.getInterval());
timeDuplication = getDuplicationPercent(intervalList1, intervalList2);
}
/**
* {@inheritDoc}
*/
@Override
protected void determineOverlapping() {
super.determineOverlapping();
PointSubscriptionOverlapConfig config = (PointSubscriptionOverlapConfig) this.config;
calculateTimeDuplicationPercent(sub1, sub2);
this.timeDuplicationPass = this.timeDuplication > config
.getMaxAllowedTimeDuplication();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isOverlapping() {
determineOverlapping();
boolean response = false;
if (this.matchStrategy == SubscriptionOverlapMatchStrategy.MATCH_ALL) {
response = this.parameterPass && this.spatialPass
&& this.timeDuplicationPass;
} else if (matchStrategy == SubscriptionOverlapMatchStrategy.MATCH_ANY) {
response = this.parameterPass || this.spatialPass
|| this.timeDuplicationPass;
} else if (matchStrategy == SubscriptionOverlapMatchStrategy.AT_LEAST_HALF) {
int halfNumAttrs = (numberOfPointAttributes + numberOfCommonAttributes) / 2;
List<Boolean> toCheck = new ArrayList<Boolean>(3);
toCheck.add(timeDuplicationPass);
toCheck.add(spatialPass);
toCheck.add(parameterPass);
int exceeded = 0;
for (boolean check : toCheck) {
if (check) {
exceeded++;
if (exceeded >= halfNumAttrs) {
response = true;
}
}
}
}
return response;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isDuplicate() {
determineOverlapping();
return timeDuplication == ONE_HUNDRED_PERCENT
&& parameterDuplication == ONE_HUNDRED_PERCENT
&& spatialDuplication == ONE_HUNDRED_PERCENT;
}
}

View file

@ -0,0 +1,115 @@
/**
* 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.edex.datadelivery.service.services.overlap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import com.raytheon.edex.site.SiteUtil;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapRequest;
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapResponse;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* Edex handler for subscription overlap requests.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 24, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class SubscriptionOverlapHandler implements
IRequestHandler<SubscriptionOverlapRequest> {
/**
* {@inheritDoc}
*/
@Override
public Object handleRequest(SubscriptionOverlapRequest request)
throws Exception {
String siteId = SiteUtil.getSite();
List<Subscription> subscriptions = request.getSubscriptionList();
List<String> duplicateList = new LinkedList<String>();
SubscriptionOverlapResponse response = new SubscriptionOverlapResponse();
for (Subscription subscription : subscriptions) {
if (!(subscription instanceof AdhocSubscription)) {
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
.getSubscriptionHandler();
final List<Subscription> potentialDuplicates = subscriptionHandler
.getActiveByDataSetAndProvider(
subscription.getDataSetName(),
subscription.getProvider());
DataType dataType = subscription.getDataSetType();
Set<String> overlappingSubscriptions = new HashSet<String>();
for (Subscription potentialDuplicate : potentialDuplicates) {
OverlapData od = OverlapDataFactory.getOverlapData(
subscription, potentialDuplicate);
if (od.isDuplicate()) {
// If the subscription is local then it is flagged
// as a duplicate, otherwise it is marked as overlap.
if (potentialDuplicate.getOfficeIDs().contains(siteId)) {
duplicateList.add(potentialDuplicate.getName());
} else {
overlappingSubscriptions.add(potentialDuplicate
.getName());
}
}
if (od.isOverlapping()) {
overlappingSubscriptions.add(potentialDuplicate
.getName());
}
}
if (!overlappingSubscriptions.isEmpty()) {
List<String> overlapList = new ArrayList<String>(
overlappingSubscriptions);
Collections.sort(overlapList);
response.setSubscriptionNameList(overlapList);
}
response.setDuplicate(!duplicateList.isEmpty());
response.setOverlap(!overlappingSubscriptions.isEmpty());
}
}
return response;
}
}

View file

@ -7,5 +7,4 @@ gov.noaa.nws.ncep.ui.pgen.tca.WaterBreakpointList
gov.noaa.nws.ncep.ui.pgen.tca.CoastBreakpointList
gov.noaa.nws.ncep.ui.pgen.file.Products
gov.noaa.nws.ncep.ui.pgen.producttypes.ProductTypes
gov.noaa.nws.ncep.ui.pgen.rsc.PgenResourceData
gov.noaa.nws.ncep.ui.pgen.attrdialog.SpcPhoneList

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.edex.common.dataRecords.NcFloatDataRecord

View file

@ -1,6 +1,4 @@
gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.PlotResourceData
gov.noaa.nws.ncep.viz.rsc.plotdata.parameters.PlotParameterDefn
gov.noaa.nws.ncep.viz.rsc.plotdata.parameters.PlotParameterDefns
gov.noaa.nws.ncep.viz.rsc.plotdata.plotModels.elements.PlotModel
gov.noaa.nws.ncep.viz.rsc.plotdata.conditionalfilter.ConditionalFilter
gov.noaa.nws.ncep.viz.rsc.plotdata.rsc.TafPlotInfoRetriever
gov.noaa.nws.ncep.viz.rsc.plotdata.conditionalfilter.ConditionalFilter

View file

@ -28,6 +28,7 @@ import java.util.List;
import org.junit.Test;
import com.google.common.collect.Lists;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.PendingSharedSubscription;
import com.raytheon.uf.common.datadelivery.registry.PendingSharedSubscriptionFixture;
@ -45,7 +46,8 @@ import com.raytheon.uf.edex.registry.ebxml.dao.AbstractRegistryTest;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 29, 2013 1650 djohnson Initial creation
* May 29, 2013 1650 djohnson Initial creation
* Oct 22, 2013 2292 mpduff Implement multiple data types.
*
* </pre>
*
@ -59,9 +61,9 @@ public class PendingSubscriptionHandlerTest extends AbstractRegistryTest {
throws RegistryHandlerException {
final PendingSiteSubscription siteSubscription = PendingSiteSubscriptionFixture.INSTANCE
.get();
.get(DataType.GRID);
final PendingSharedSubscription sharedSubscription = PendingSharedSubscriptionFixture.INSTANCE
.get();
.get(DataType.GRID);
storeSubscriptionsForPendingAssociations(siteSubscription,
sharedSubscription);
@ -85,9 +87,9 @@ public class PendingSubscriptionHandlerTest extends AbstractRegistryTest {
throws RegistryHandlerException {
final PendingSiteSubscription siteSubscription = PendingSiteSubscriptionFixture.INSTANCE
.get();
.get(DataType.GRID);
final PendingSharedSubscription sharedSubscription = PendingSharedSubscriptionFixture.INSTANCE
.get();
.get(DataType.GRID);
storeSubscriptionsForPendingAssociations(siteSubscription,
sharedSubscription);

View file

@ -29,6 +29,7 @@ import java.util.List;
import org.junit.Test;
import com.google.common.collect.Lists;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.SharedSubscription;
import com.raytheon.uf.common.datadelivery.registry.SharedSubscriptionFixture;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
@ -48,6 +49,7 @@ import com.raytheon.uf.edex.registry.ebxml.dao.AbstractRegistryTest;
* ------------ ---------- ----------- --------------------------
* May 29, 2013 1650 djohnson Initial creation
* May 31, 2013 1650 djohnson Fix ability to get shared subscriptions by id.
* Oct 21, 2013 2292 mpduff Implemented point data type
*
* </pre>
*
@ -60,9 +62,9 @@ public class SubscriptionHandlerTest extends AbstractRegistryTest {
public void canDeleteMixedSiteAndSharedSubscriptions()
throws RegistryHandlerException {
final SiteSubscription siteSubscription = SiteSubscriptionFixture.INSTANCE
.get();
.get(DataType.GRID);
final SharedSubscription sharedSubscription = SharedSubscriptionFixture.INSTANCE
.get();
.get(DataType.GRID);
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
.getSubscriptionHandler();
@ -81,9 +83,9 @@ public class SubscriptionHandlerTest extends AbstractRegistryTest {
public void canDeleteMixedSiteAndSharedSubscriptionsWithUsername()
throws RegistryHandlerException {
final SiteSubscription siteSubscription = SiteSubscriptionFixture.INSTANCE
.get();
.get(DataType.GRID);
final SharedSubscription sharedSubscription = SharedSubscriptionFixture.INSTANCE
.get();
.get(DataType.GRID);
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
.getSubscriptionHandler();
@ -102,7 +104,7 @@ public class SubscriptionHandlerTest extends AbstractRegistryTest {
public void getByIdReturnsSharedSubscription()
throws RegistryHandlerException {
final SharedSubscription sharedSubscription = SharedSubscriptionFixture.INSTANCE
.get();
.get(DataType.GRID);
final ISubscriptionHandler subscriptionHandler = DataDeliveryHandlers
.getSubscriptionHandler();

View file

@ -78,7 +78,8 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Jun 03, 2013 2095 djohnson Move getPointDataSet in from subclass.
* Jul 09, 2013 2106 djohnson Add datadelivery handlers, since they are now dependency injected.
* Sep 17, 2013 2383 bgonzale Added "thrift.stream.maxsize" System property to setup.
* Sept 25, 2013 1797 dhladky separated time from gridded time
* Sep 25, 2013 1797 dhladky separated time from gridded time
* Oct 21, 2013 2292 mpduff Implement multiple data types.
*
* </pre>
*
@ -101,7 +102,7 @@ public abstract class AbstractBandwidthManagerIntTest<T extends Time, C extends
protected ApplicationContext context;
@Autowired
protected EdexBandwidthManager<T,C> bandwidthManager;
protected EdexBandwidthManager<T, C> bandwidthManager;
@Autowired
protected RetrievalManager retrievalManager;
@ -188,7 +189,7 @@ public abstract class AbstractBandwidthManagerIntTest<T extends Time, C extends
*
* @return the subscription
*/
protected SiteSubscription<T,C> createSubscriptionThatFillsUpABucket() {
protected SiteSubscription<T, C> createSubscriptionThatFillsUpABucket() {
return createSubscriptionWithDataSetSizeInBytes(fullBucketSize);
}
@ -197,7 +198,7 @@ public abstract class AbstractBandwidthManagerIntTest<T extends Time, C extends
*
* @return the subscription
*/
protected SiteSubscription<T,C> createSubscriptionThatFillsUpTenBuckets() {
protected SiteSubscription<T, C> createSubscriptionThatFillsUpTenBuckets() {
return createSubscriptionWithDataSetSizeInBytes(fullBucketSize * 10);
}
@ -206,7 +207,7 @@ public abstract class AbstractBandwidthManagerIntTest<T extends Time, C extends
*
* @return the subscription
*/
protected SiteSubscription<T,C> createSubscriptionThatFillsHalfABucket() {
protected SiteSubscription<T, C> createSubscriptionThatFillsHalfABucket() {
return createSubscriptionWithDataSetSizeInBytes(halfBucketSize);
}
@ -215,7 +216,7 @@ public abstract class AbstractBandwidthManagerIntTest<T extends Time, C extends
*
* @return the subscription
*/
protected SiteSubscription<T,C> createSubscriptionThatFillsAThirdOfABucket() {
protected SiteSubscription<T, C> createSubscriptionThatFillsAThirdOfABucket() {
return createSubscriptionWithDataSetSizeInBytes(thirdBucketSizeInBytes);
}
@ -224,14 +225,14 @@ public abstract class AbstractBandwidthManagerIntTest<T extends Time, C extends
*
* @return the subscription
*/
protected SiteSubscription<T,C> createSubscriptionThatFillsUpTwoBuckets() {
protected SiteSubscription<T, C> createSubscriptionThatFillsUpTwoBuckets() {
return createSubscriptionWithDataSetSizeInBytes(fullBucketSize * 2);
}
protected SiteSubscription<T,C> createSubscriptionWithDataSetSizeInBytes(
protected SiteSubscription<T, C> createSubscriptionWithDataSetSizeInBytes(
long bytes) {
SiteSubscription<T,C> subscription = SiteSubscriptionFixture.INSTANCE
.get(subscriptionSeed++);
SiteSubscription<T, C> subscription = SiteSubscriptionFixture.INSTANCE
.get(subscriptionSeed++, DataType.GRID);
subscription.setDataSetSize(BandwidthUtil
.convertBytesToKilobytes(bytes));
subscription.setRoute(getRouteToUseForSubscription());
@ -245,11 +246,12 @@ public abstract class AbstractBandwidthManagerIntTest<T extends Time, C extends
* the retrieval interval
* @return
*/
protected Subscription<T,C> getPointDataSubscription(int retrievalInterval) {
protected Subscription<T, C> getPointDataSubscription(int retrievalInterval) {
final PointTime pointTime = new PointTime();
pointTime.setInterval(retrievalInterval);
Subscription<PointTime,Coverage> subscription = SiteSubscriptionFixture.INSTANCE.get();
Subscription<PointTime, Coverage> subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
subscription.setTime(pointTime);
subscription.setDataSetType(DataType.POINT);
subscription.setLatencyInMinutes(retrievalInterval);

View file

@ -47,6 +47,7 @@ import java.util.concurrent.CountDownLatch;
import org.junit.Test;
import com.raytheon.uf.common.datadelivery.registry.DataDeliveryRegistryObjectTypes;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
import com.raytheon.uf.common.datadelivery.registry.Network;
@ -105,6 +106,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
* Jul 11, 2013 2106 djohnson Use SubscriptionPriority enum.
* Sept 25, 2013 1797 dhladky separated time from gridded time
* Oct 10, 2013 1797 bgonzale Refactored registry Time objects.
* Oct 21, 2013 2292 mpduff Implement multiple data types
*
* </pre>
*
@ -153,7 +155,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
@Test
public void testDataSetMetaDataUpdateSetsSubscriptionRetrievalsToReady()
throws SerializationException, ParseException {
Subscription subscription = SiteSubscriptionFixture.INSTANCE.get();
Subscription subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
bandwidthManager.subscriptionUpdated(subscription);
OpenDapGriddedDataSetMetaData metadata = OpenDapGriddedDataSetMetaDataFixture.INSTANCE
@ -233,7 +236,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
@Test
public void testDataSetMetaDataUpdateSetsCorrectTimeOnSubscription()
throws SerializationException, ParseException {
Subscription subscription = SiteSubscriptionFixture.INSTANCE.get();
Subscription subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
bandwidthManager.subscriptionUpdated(subscription);
OpenDapGriddedDataSetMetaData metadata = OpenDapGriddedDataSetMetaDataFixture.INSTANCE
@ -271,7 +275,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
throws RegistryHandlerException, ParseException,
SerializationException {
// Store the original subscription
Subscription subscription = SiteSubscriptionFixture.INSTANCE.get();
Subscription subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
DataDeliveryHandlers.getSubscriptionHandler().store(subscription);
// The dataset metadata update
@ -309,8 +314,10 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
public void testDailyProductSubscriptionIsSetToReadyStatus()
throws RegistryHandlerException, ParseException {
// Store the original subscription
Subscription subscription = SiteSubscriptionFixture.INSTANCE.get();
((GriddedTime)subscription.getTime()).setCycleTimes(Collections.<Integer> emptyList());
Subscription subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
((GriddedTime) subscription.getTime()).setCycleTimes(Collections
.<Integer> emptyList());
subscription.setLatencyInMinutes(3);
DataDeliveryHandlers.getSubscriptionHandler().store(subscription);
@ -343,7 +350,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
throws RegistryHandlerException, ParseException {
// Store the original subscription
Subscription subscription = SiteSubscriptionFixture.INSTANCE.get();
Subscription subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
subscription.setLatencyInMinutes(5);
DataDeliveryHandlers.getSubscriptionHandler().store(subscription);
@ -378,10 +386,10 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
Subscription subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
List<BandwidthAllocation> unscheduled = bandwidthManager
.schedule(subscription);
@ -425,10 +433,10 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
subscription2.setPriority(SubscriptionPriority.HIGH);
// they conflict for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
List<BandwidthAllocation> unscheduled = bandwidthManager
.schedule(subscription);
@ -463,10 +471,10 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
subscription2.setPriority(SubscriptionPriority.HIGH);
// they conflict for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
bandwidthManager.schedule(subscription);
bandwidthManager.schedule(subscription2);
@ -559,10 +567,10 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
subscription2.setPriority(SubscriptionPriority.HIGH);
// they conflict for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
List<BandwidthAllocation> unscheduled = bandwidthManager
.schedule(subscription);
@ -596,10 +604,10 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
subscription2.setPriority(SubscriptionPriority.HIGH);
// they conflict for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
bandwidthManager.schedule(subscription);
bandwidthManager.schedule(subscription2);
@ -623,7 +631,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
// Subscription starts out too big
Subscription subscription = createSubscriptionThatFillsUpTwoBuckets();
((GriddedTime)subscription.getTime()).setCycleTimes(Arrays.asList(Integer.valueOf(6)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays
.asList(Integer.valueOf(6)));
List<BandwidthAllocation> unscheduled = bandwidthManager
.subscriptionUpdated(subscription);
@ -660,7 +669,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
throws SerializationException {
Subscription subscription = createSubscriptionThatFillsUpTenBuckets();
((GriddedTime)subscription.getTime()).setCycleTimes(Arrays.asList(Integer.valueOf(0)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays
.asList(Integer.valueOf(0)));
subscription.setLatencyInMinutes(0);
int requiredLatency = bandwidthManager
@ -685,7 +695,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
// Subscription starts out too big
Subscription subscription = createSubscriptionThatFillsUpABucket();
((GriddedTime)subscription.getTime()).setCycleTimes(Arrays.asList(Integer.valueOf(0)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays
.asList(Integer.valueOf(0)));
subscription.setLatencyInMinutes(0);
bandwidthManager.subscriptionUpdated(subscription);
@ -724,7 +735,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
throws Exception {
Subscription subscription = createSubscriptionThatFillsUpABucket();
((GriddedTime)subscription.getTime()).setCycleTimes(Arrays.asList(0, 12));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(0,
12));
bandwidthManager.schedule(subscription);
@ -753,7 +765,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
throws Exception {
Subscription subscription = createSubscriptionThatFillsUpABucket();
((GriddedTime)subscription.getTime()).setCycleTimes(Arrays.asList(0, 12));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(0,
12));
bandwidthManager.schedule(subscription);
@ -794,7 +807,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
.getDataSetSize()
/ numberOfSubscriptionsWithSameProviderDataSet);
((GriddedTime)templateSubscription.getTime()).setCycleTimes(Arrays.asList(0, 12));
((GriddedTime) templateSubscription.getTime()).setCycleTimes(Arrays
.asList(0, 12));
int lastKnownNumberOfBandwidthAllocations = 0;
final Subscription[] subscriptions = new Subscription[numberOfSubscriptionsWithSameProviderDataSet];
@ -860,7 +874,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
throws Exception {
Subscription subscription = createSubscriptionThatFillsUpABucket();
((GriddedTime)subscription.getTime()).setCycleTimes(Arrays.asList(0, 12));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(0,
12));
final Network network = subscription.getRoute();
final List<BandwidthAllocation> bandwidthAllocationsOrig = getRetrievalManagerAllocationsForNetwork(network);
@ -892,7 +907,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
throws Exception {
Subscription subscription = createSubscriptionThatFillsUpTwoBuckets();
((GriddedTime)subscription.getTime()).setCycleTimes(Arrays.asList(0, 12));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(0,
12));
subscription.setLatencyInMinutes(0);
final List<BandwidthAllocation> unableToSchedule = bandwidthManager
@ -925,7 +941,8 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
throws Exception {
Subscription subscription = createSubscriptionThatFillsUpTwoBuckets();
((GriddedTime)subscription.getTime()).setCycleTimes(Arrays.asList(0, 12));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(0,
12));
subscription.setLatencyInMinutes(0);
final List<BandwidthAllocation> unableToSchedule = bandwidthManager
@ -969,8 +986,9 @@ public class BandwidthManagerIntTest extends AbstractWfoBandwidthManagerIntTest
private void testSubscriptionCyclesAreAllocatedOncePerCyclePerPlanDay(
List<Integer> cycles) throws SerializationException {
Subscription subscription = SiteSubscriptionFixture.INSTANCE.get();
((GriddedTime)subscription.getTime()).setCycleTimes(cycles);
Subscription subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
((GriddedTime) subscription.getTime()).setCycleTimes(cycles);
bandwidthManager.subscriptionUpdated(subscription);
assertEquals("Incorrect number of bandwidth allocations made!",

View file

@ -49,6 +49,7 @@ import com.raytheon.uf.common.datadelivery.bandwidth.data.TimeWindowData;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscriptionFixture;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
@ -87,12 +88,14 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Jul 11, 2013 2106 djohnson Use SubscriptionPriority enum.
* Jul 18, 2013 1653 mpduff Added test for sub status summary.
* Sept 25, 2013 1797 dhladky separated time from gridded time
* Oct 21, 2013 2292 mpduff Implement multiple data types
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends AbstractWfoBandwidthManagerIntTest<T, C> {
public class BandwidthServiceIntTest<T extends Time, C extends Coverage>
extends AbstractWfoBandwidthManagerIntTest<T, C> {
private static final int ONE_HUNDRED = 100;
@ -216,10 +219,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsHalfABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
@SuppressWarnings("unchecked")
Set<String> unscheduledSubscriptions = service.schedule(Arrays.asList(
@ -235,10 +238,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
@SuppressWarnings("unchecked")
Set<String> unscheduledSubscriptions = service.schedule(Arrays.asList(
@ -254,10 +257,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
Set<String> unscheduledSubscriptions = service.schedule(subscription);
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
@ -275,10 +278,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsHalfABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
@SuppressWarnings("unchecked")
IProposeScheduleResponse response = service.proposeSchedule(Arrays
@ -295,10 +298,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
Subscription<T, C> subscription2 = createSubscriptionThatFillsHalfABucket();
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
@SuppressWarnings("unchecked")
IProposeScheduleResponse response = service.proposeSchedule(Arrays
@ -316,10 +319,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
Subscription<T, C> subscription2 = createSubscriptionThatFillsHalfABucket();
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
@SuppressWarnings("unchecked")
IProposeScheduleResponse response = service.proposeSchedule(Arrays
@ -340,10 +343,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
@SuppressWarnings("unchecked")
Set<String> unscheduledSubscriptions = service.proposeSchedule(
@ -360,10 +363,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
Set<String> unscheduledSubscriptions = service.schedule(subscription);
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
@ -382,10 +385,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
Set<String> unscheduledSubscriptions = service.schedule(subscription);
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
@ -404,10 +407,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpTenBuckets();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
Set<String> unscheduledSubscriptions = service.schedule(subscription);
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
@ -426,8 +429,8 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
public void testProposeScheduleSubscriptionsSecondDoesntFitReturnsRequiredSizeForSubscriptionUpdate() {
Subscription<T, C> subscription = createSubscriptionThatFillsHalfABucket();
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
Set<String> unscheduledSubscriptions = service.schedule(subscription);
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
@ -454,10 +457,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(3), Integer.valueOf(8)));
Set<String> unscheduledSubscriptions = service.schedule(subscription);
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
@ -488,8 +491,9 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
@SuppressWarnings("unchecked")
AdhocSubscription<T, C> subscription = (AdhocSubscription<T, C>) AdhocSubscriptionFixture.INSTANCE
.get();
((GriddedTime)subscription.getTime()).setCycleTimes(Arrays.asList(Integer.valueOf(0)));
.get(DataType.GRID);
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays
.asList(Integer.valueOf(0)));
subscription.setDataSetSize(createSubscriptionThatFillsUpABucket()
.getDataSetSize());
@ -511,10 +515,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime())
.setCycleTimes(Arrays.asList(Integer.valueOf(3)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays
.asList(Integer.valueOf(3)));
service.schedule(subscription);
service.schedule(subscription2);
@ -533,10 +537,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime())
.setCycleTimes(Arrays.asList(Integer.valueOf(3)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays
.asList(Integer.valueOf(3)));
service.schedule(subscription);
service.schedule(subscription2);
@ -545,8 +549,7 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
RetrievalPlan opsnetPlan = retrievalManager.getPlan(Network.OPSNET);
assertEquals("Incorrect number of subscriptions returned!",
opsnetPlan.getBucketMinutes(),
graphData.getBinTimeInMinutes());
opsnetPlan.getBucketMinutes(), graphData.getBinTimeInMinutes());
SortedSet<BandwidthBucketDescription> descs = graphData
.getNetworkBucketMap().get(Network.OPSNET);
long earliestTime = descs.first().getBucketStartTime();
@ -644,10 +647,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
Subscription<T, C> subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime())
.setCycleTimes(Arrays.asList(Integer.valueOf(3)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays
.asList(Integer.valueOf(3)));
service.schedule(subscription);
service.schedule(subscription2);
@ -679,10 +682,10 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
subscription.setPriority(SubscriptionPriority.HIGH);
// subscription2 will not be able to schedule for cycle hour 8
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime)subscription2.getTime())
.setCycleTimes(Arrays.asList(Integer.valueOf(3)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription2.getTime()).setCycleTimes(Arrays
.asList(Integer.valueOf(3)));
service.schedule(subscription);
service.schedule(subscription2);
@ -702,8 +705,8 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
public void testProposeScheduleSubscriptionsReturnsStatusSummary() {
Subscription<T, C> subscription = createSubscriptionThatFillsUpTwoBuckets();
((GriddedTime)subscription.getTime()).setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
((GriddedTime) subscription.getTime()).setCycleTimes(Arrays.asList(
Integer.valueOf(6), Integer.valueOf(8)));
subscription.setLatencyInMinutes(3);
IProposeScheduleResponse response = service
@ -820,7 +823,8 @@ public class BandwidthServiceIntTest<T extends Time, C extends Coverage> extends
* the subscription
*/
private static void verifySubscriptionWasNotAbleToBeFullyScheduled(
Set<String> unscheduledSubscriptions, @SuppressWarnings("rawtypes") Subscription subscription) {
Set<String> unscheduledSubscriptions, @SuppressWarnings("rawtypes")
Subscription subscription) {
assertEquals(
"One and only one subscription should not have been able to fully schedule",
1, unscheduledSubscriptions.size());

View file

@ -34,6 +34,7 @@ import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
* ------------ ---------- ----------- --------------------------
* May 29, 2013 1650 djohnson Initial creation
* Oct 1, 2013 1797 dhladky Updated to work with generic changes
* Oct 21, 2013 2292 mpduff Implement multiple data types
*
* </pre>
*
@ -55,8 +56,8 @@ public abstract class BaseSharedSubscriptionFixture<T extends SharedSubscription
* {@inheritDoc}
*/
@Override
public T getInstance(long seedValue, Random random) {
T subscription = super.getInstance(seedValue, random);
public T getInstance(long seedValue, Random random, DataType dataType) {
T subscription = super.getInstance(seedValue, random, dataType);
subscription.setId(RegistryUtil.getRegistryObjectKey(subscription));

View file

@ -34,6 +34,7 @@ import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
* ------------ ---------- ----------- --------------------------
* Mar 29, 2013 1841 djohnson Initial creation
* Oct 2, 2013 1797 dhladky Updated to work with generics
* Oct 21, 2013 2292 mpduff Implement multiple data types
*
* </pre>
*
@ -48,8 +49,8 @@ public abstract class BaseSiteSubscriptionFixture<M extends SiteSubscription>
* {@inheritDoc}
*/
@Override
public M getInstance(long seedValue, Random random) {
M subscription = super.getInstance(seedValue, random);
public M getInstance(long seedValue, Random random, DataType dataType) {
M subscription = super.getInstance(seedValue, random, dataType);
subscription.setOwner("owner" + random.nextInt());
subscription.setId(RegistryUtil.getRegistryObjectKey(subscription));

View file

@ -25,7 +25,6 @@ import java.util.Random;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.registry.ebxml.RegistryUtil;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.util.AbstractFixture;
/**
* Move in reusable code from {@link SiteSubscriptionFixture}.
@ -43,6 +42,7 @@ import com.raytheon.uf.common.util.AbstractFixture;
* Apr 08, 2013 1826 djohnson Remove delivery options.
* May 15, 2013 1040 mpduff Office Ids are now a list.
* Oct 2 2013 1797 dhladky subscription and time generics
* Oct 21, 2013 2292 mpduff Implement multiple data types
*
* </pre>
*
@ -50,26 +50,53 @@ import com.raytheon.uf.common.util.AbstractFixture;
* @version 1.0
*/
public abstract class BaseSubscriptionFixture<M extends Subscription> extends
AbstractFixture<M> {
public abstract class BaseSubscriptionFixture<M extends Subscription> {
private static long DEFAULT_SEED = 1L;
/**
* {@inheritDoc}
* Retrieve an instance using the default seed value.
*
* @return the instance
*/
@Override
public M getInstance(long seedValue, Random random) {
public final M get(DataType dataType) {
return get(DEFAULT_SEED, dataType);
}
/**
* Retrieve an instance based on the specified seed value.
*
* @param seedValue
* the seed value
* @return the instance based on the seed value
*/
public final M get(long seedValue, DataType dataType) {
Random random = new Random(seedValue);
return getInstance(seedValue, random, dataType);
}
public M getInstance(long seedValue, Random random, DataType dataType) {
M subscription = getSubscription();
subscription.setActive(random.nextBoolean());
subscription.setActivePeriodStart(TimeUtil.newDate());
subscription.setActivePeriodEnd(new Date(subscription
.getActivePeriodStart().getTime() + seedValue));
subscription
.setCoverage(GriddedCoverageFixture.INSTANCE.get(seedValue));
subscription
.setDataSetName(OpenDapGriddedDataSetMetaDataFixture.INSTANCE
.get(seedValue).getDataSetName());
if (dataType == DataType.GRID) {
subscription.setCoverage(GriddedCoverageFixture.INSTANCE
.get(seedValue));
subscription
.setDataSetName(OpenDapGriddedDataSetMetaDataFixture.INSTANCE
.get(seedValue).getDataSetName());
subscription.setDataSetType(DataType.GRID);
subscription.setTime(GriddedTimeFixture.INSTANCE.get(seedValue));
} else if (dataType == DataType.POINT) {
subscription.setDataSetType(DataType.POINT);
subscription.setCoverage(CoverageFixture.INSTANCE.get(seedValue));
subscription.setDataSetName(PointDataSetMetaDataFixture.INSTANCE
.get(seedValue).getDataSetName());
subscription.setTime(PointTimeFixture.INSTANCE.get(seedValue));
}
subscription.setDataSetSize(seedValue);
subscription.setDataSetType(DataType.GRID);
subscription.setDeleted(random.nextBoolean());
subscription.setDescription("description" + random.nextInt());
subscription.setFullDataSet(random.nextBoolean());
@ -85,7 +112,6 @@ public abstract class BaseSubscriptionFixture<M extends Subscription> extends
subscription.setSubscriptionStart(subscription.getActivePeriodStart());
subscription.setSubscriptionEnd(null);
subscription.setSubscriptionId("subscriptionId" + random.nextInt());
subscription.setTime(GriddedTimeFixture.INSTANCE.get(seedValue));
subscription.setUrl("http://someurl/" + random.nextInt());
subscription.setId(RegistryUtil.getRegistryObjectKey(subscription));

View file

@ -0,0 +1,69 @@
/**
* 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;
import java.util.Random;
import org.geotools.geometry.jts.ReferencedEnvelope;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.util.AbstractFixture;
/**
* Fixture for {@link Coverage}s.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 21, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class CoverageFixture extends AbstractFixture<Coverage> {
public static final CoverageFixture INSTANCE = new CoverageFixture();
/**
* Prevent construction.
*/
private CoverageFixture() {
}
/**
* {@inheritDoc}
*/
@Override
public Coverage getInstance(long seedValue, Random random) {
Coverage coverage = new Coverage();
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
coverage.setEnvelope(env);
coverage.setRequestEnvelope(env);
return coverage;
}
}

View file

@ -21,7 +21,6 @@ package com.raytheon.uf.common.datadelivery.registry;
import java.util.Random;
/**
* Fixture for {@link PendingSharedSubscription} objects.
*
@ -32,7 +31,8 @@ import java.util.Random;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 29, 2013 1650 djohnson Initial creation
* oct 2, 2013 1797 dhladky Updated to work with generics
* Oct 2, 2013 1797 dhladky Updated to work with generics
* Oct 21, 2013 2292 mpduff Implement multiple data types
*
* </pre>
*
@ -40,7 +40,8 @@ import java.util.Random;
* @version 1.0
*/
public class PendingSharedSubscriptionFixture extends
public class PendingSharedSubscriptionFixture
extends
BaseSharedSubscriptionFixture<PendingSharedSubscription<Time, Coverage>> {
public static final PendingSharedSubscriptionFixture INSTANCE = new PendingSharedSubscriptionFixture();
@ -55,8 +56,10 @@ public class PendingSharedSubscriptionFixture extends
* {@inheritDoc}
*/
@Override
public PendingSharedSubscription<Time, Coverage> getInstance(long seedValue, Random random) {
PendingSharedSubscription<Time, Coverage> sub = super.getInstance(seedValue, random);
public PendingSharedSubscription<Time, Coverage> getInstance(
long seedValue, Random random, DataType dataType) {
PendingSharedSubscription<Time, Coverage> sub = super.getInstance(
seedValue, random, dataType);
sub.setChangeReqId("change" + seedValue);
return sub;

View file

@ -35,6 +35,7 @@ import com.raytheon.uf.common.util.AbstractFixture;
* ------------ ---------- ----------- --------------------------
* Sep 28, 2012 1187 djohnson Initial creation
* Oct 2, 2013 1797 dhladky Generics
* Oct 21, 2013 2292 mpduff Implement multiple data types
*
* </pre>
*
@ -57,8 +58,10 @@ public class PendingSiteSubscriptionFixture extends
* {@inheritDoc}
*/
@Override
public PendingSiteSubscription<Time, Coverage> getInstance(long seedValue, Random random) {
PendingSiteSubscription<Time, Coverage> sub = super.getInstance(seedValue, random);
public PendingSiteSubscription<Time, Coverage> getInstance(long seedValue,
Random random, DataType dataType) {
PendingSiteSubscription<Time, Coverage> sub = super.getInstance(
seedValue, random, dataType);
sub.setChangeReqId("change" + seedValue);
return sub;

View file

@ -35,6 +35,7 @@ import org.junit.Test;
* Aug 27, 2012 0743 djohnson Initial creation
* Mar 28, 2013 1841 djohnson Subscription is now UserSubscription.
* May 15, 2013 1040 mpduff Changed to handle the list of office ids.
* Oct 21, 2013 2292 mpduff Implement multiple data types
*
* </pre>
*
@ -46,7 +47,8 @@ public class PendingSubscriptionTest {
@Test
public void testCopyConstructorSetsOriginalSubNameAsName() {
SiteSubscription subscription = SiteSubscriptionFixture.INSTANCE.get();
SiteSubscription subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
PendingSiteSubscription pendingSubscription = new PendingSiteSubscription(
subscription, "djohnson");
@ -57,7 +59,8 @@ public class PendingSubscriptionTest {
@Test
public void testCopyConstructorSetsSubscriptionValuesOnPendingSubscription() {
SiteSubscription subscription = SiteSubscriptionFixture.INSTANCE.get();
SiteSubscription subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
PendingSiteSubscription copied = new PendingSiteSubscription(
subscription, "djohnson");

View file

@ -54,6 +54,7 @@ import com.raytheon.uf.common.time.util.TimeUtilTest;
* Jan 11, 2013 1453 djohnson Add test for active period crossing year boundary.
* Mar 28, 2013 1841 djohnson Subscription is now UserSubscription.
* May 15, 2013 1040 mpduff Office Id now a set.
* Oct 21, 2013 2292 mpduff Implement multiple data types
*
* </pre>
*
@ -78,7 +79,8 @@ public class SiteSubscriptionTest {
@Test
public void testCopyConstructorSetsSpecifiedName() throws Exception {
SiteSubscription subscription = SiteSubscriptionFixture.INSTANCE.get();
SiteSubscription subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
Subscription copied = new SiteSubscription(subscription, "newName");
@ -89,7 +91,8 @@ public class SiteSubscriptionTest {
@Test
public void testCopyConstructorSetsValuesFromSourceSubscription()
throws Exception {
SiteSubscription subscription = SiteSubscriptionFixture.INSTANCE.get();
SiteSubscription subscription = SiteSubscriptionFixture.INSTANCE
.get(DataType.GRID);
Subscription copied = new SiteSubscription(subscription, "newName");

View file

@ -39,6 +39,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* Mar 28, 2013 1841 djohnson Subscription is now UserSubscription.
* Apr 08, 2013 1826 djohnson Remove delivery options.
* May 15, 2013 1040 mpduff Office Id now a set.
* Oct 21, 2013 2292 mpduff Implement multiple data types
*
* </pre>
*
@ -94,11 +95,9 @@ public class SubscriptionBuilder {
public SubscriptionBuilder() {
}
/**
* {@inheritDoc}
*/
public SiteSubscription build() {
SiteSubscription subscription = SiteSubscriptionFixture.INSTANCE.get();
SiteSubscription subscription = SiteSubscriptionFixture.INSTANCE
.get(dataType);
subscription.setActive(active);
subscription.setActivePeriodStart(activePeriodStart);
subscription.setActivePeriodEnd(activePeriodEnd);

View file

@ -0,0 +1,247 @@
/**
* 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.service.subscription;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.junit.Test;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
import com.raytheon.uf.common.datadelivery.registry.ParameterFixture;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.edex.datadelivery.service.services.overlap.GridOverlapData;
/**
* GridOverlapData object test class.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 18, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class GridOverlapDataTest {
private static final GridSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ALL = new GridSubscriptionOverlapConfig(
50, 50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ALL);
private static final GridSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ANY = new GridSubscriptionOverlapConfig(
50, 50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ANY);
private static final GridSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_HALF = new GridSubscriptionOverlapConfig(
50, 50, 50, 50, SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
/*
* Duplicate subs
*/
@Test
public void testFiftyPercentMatchAllWithDuplicates() {
SiteSubscription dupeSub1 = getSubscription(1);
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
dupeSub2.getCoverage().setRequestEnvelope(
dupeSub1.getCoverage().getRequestEnvelope());
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
assertTrue("These should be duplicates", od.isDuplicate());
assertTrue("These should overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchAnyWithDuplicates() {
SiteSubscription dupeSub1 = getSubscription(1);
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
dupeSub2.getCoverage().setRequestEnvelope(
dupeSub1.getCoverage().getRequestEnvelope());
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ANY);
assertTrue("These should be duplicates", od.isDuplicate());
assertTrue("These should overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchHalfWithDuplicates() {
SiteSubscription dupeSub1 = getSubscription(1);
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
dupeSub2.getCoverage().setRequestEnvelope(
dupeSub1.getCoverage().getRequestEnvelope());
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_HALF);
assertTrue("These should be duplicates", od.isDuplicate());
assertTrue("These should overlap", od.isOverlapping());
}
/*
* Non matching subs
*/
@Test
public void testFiftyPercentMatchAllWithNoMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
sub2.getParameter().clear();
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
GriddedTime time = new GriddedTime();
time.addCycleTime(0);
List<Integer> indices = new ArrayList<Integer>(1);
indices.add(50);
time.setSelectedTimeIndices(indices);
sub2.setTime(time);
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
assertFalse("These should not be duplicates", od.isDuplicate());
assertFalse("These should not overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchAnyWithNoMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
sub2.getParameter().clear();
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
GriddedTime time = new GriddedTime();
time.addCycleTime(0);
List<Integer> indices = new ArrayList<Integer>(1);
indices.add(50);
time.setSelectedTimeIndices(indices);
sub2.setTime(time);
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
assertFalse("These should not be duplicates", od.isDuplicate());
assertFalse("These should not overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchHalfWithNoMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
sub2.getParameter().clear();
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
GriddedTime time = new GriddedTime();
time.addCycleTime(0);
List<Integer> indices = new ArrayList<Integer>(1);
indices.add(50);
time.setSelectedTimeIndices(indices);
sub2.setTime(time);
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
assertFalse("These should not be duplicates", od.isDuplicate());
assertFalse("These should not overlap", od.isOverlapping());
}
/*
* Half matching subs - match parameter and cycle times
*/
@Test
public void testFiftyPercentMatchAllWithHalfMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
GriddedTime time = new GriddedTime((GriddedTime) sub1.getTime());
List<Integer> indices = new ArrayList<Integer>(1);
indices.add(50);
time.setSelectedTimeIndices(indices);
sub2.setTime(time);
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
assertFalse("These should not be duplicates", od.isDuplicate());
assertFalse("These should not overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchAnyWithHalfMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
GriddedTime time = new GriddedTime((GriddedTime) sub1.getTime());
List<Integer> indices = new ArrayList<Integer>(1);
indices.add(50);
time.setSelectedTimeIndices(indices);
sub2.setTime(time);
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
assertFalse("These should not be duplicates", od.isDuplicate());
assertTrue("These should not overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchHalfWithHalfMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
GriddedTime time = new GriddedTime((GriddedTime) sub1.getTime());
List<Integer> indices = new ArrayList<Integer>(1);
indices.add(50);
time.setSelectedTimeIndices(indices);
sub2.setTime(time);
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
assertFalse("These should not be duplicates", od.isDuplicate());
assertTrue("These should overlap", od.isOverlapping());
}
private SiteSubscription getSubscription(int seed) {
SiteSubscription sub = SiteSubscriptionFixture.INSTANCE.get(seed,
DataType.GRID);
ReferencedEnvelope env = new ReferencedEnvelope(0, 15, 0, 15,
MapUtil.LATLON_PROJECTION);
sub.getCoverage().setRequestEnvelope(env);
return sub;
}
}

View file

@ -1,129 +0,0 @@
/**
* 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.service.subscription;
import static com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy.AT_LEAST_HALF;
import static com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy.MATCH_ALL;
import static com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy.MATCH_ANY;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
/**
* Test {@link GridSubscriptionOverlapMatchStrategy}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 14, 2013 2000 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class GridSubscriptionOverlapMatchStrategyTest {
private static final SubscriptionOverlapConfig MUST_EXCEED_FIFTY_PERCENT = new GridSubscriptionOverlapConfig(
50, 50, 50, 50, null);
@Test
public void matchAnyReturnsTrueIfAnyExceedMaxAllowed() {
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55, 45,
45, 45), is(true));
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45, 55,
45, 45), is(true));
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45, 45,
55, 45), is(true));
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45, 45,
45, 55), is(true));
}
@Test
public void matchAnyReturnsFalseIfNoneExceedMaxAllowed() {
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 50, 50,
50, 50), is(false));
assertThat(
MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 0, 0, 0, 0),
is(false));
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 25, 25,
25, 25), is(false));
}
@Test
public void matchAllReturnsTrueIfAllExceedMaxAllowed() {
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55, 55,
55, 55), is(true));
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 100, 100,
100, 100), is(true));
}
@Test
public void matchAllReturnsFalseIfNotAllExceedMaxAllowed() {
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55, 55,
55, 45), is(false));
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55, 55,
45, 55), is(false));
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55, 45,
55, 55), is(false));
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45, 55,
55, 55), is(false));
}
@Test
public void atLeastHalfReturnsTrueIfAllExceedMaxAllowed() {
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55,
55, 55, 55), is(true));
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 100,
100, 100, 100), is(true));
}
@Test
public void atLeastHalfReturnsTrueIfHalfExceedMaxAllowed() {
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45,
45, 55, 55), is(true));
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55,
55, 45, 45), is(true));
}
@Test
public void atLeastHalfReturnsFalseIfLessThanHalfExceedMaxAllowed() {
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45,
45, 45, 55), is(false));
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45,
45, 55, 45), is(false));
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45,
55, 45, 45), is(false));
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55,
45, 45, 45), is(false));
}
}

View file

@ -1,232 +0,0 @@
/**
* 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.service.subscription;
import static com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy.MATCH_ALL;
import static com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy.MATCH_ANY;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
import com.raytheon.uf.common.localization.exception.LocalizationException;
/**
* Test {@link SubscriptionOverlapService}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 07, 2013 2000 djohnson Initial creation
* Oct 2, 2013 1797 dhladky Some generics
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class GridSubscriptionOverlapServiceTest {
private static final SubscriptionOverlapConfig ANY_MUST_EXCEED_65_PERCENT = new GridSubscriptionOverlapConfig(
65, 65, 65, 65, MATCH_ANY);
private static final SubscriptionOverlapConfig ALL_MUST_EXCEED_65_PERCENT = new GridSubscriptionOverlapConfig(
65, 65, 65, 65, MATCH_ALL);
private final ISubscriptionDuplicateChecker<GriddedTime, GriddedCoverage> duplicateChecker = mock(ISubscriptionDuplicateChecker.class);
private final SubscriptionOverlapService<GriddedTime, GriddedCoverage> service = new SubscriptionOverlapService<GriddedTime, GriddedCoverage>(
duplicateChecker);
private final Subscription<GriddedTime, GriddedCoverage> sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
private final Subscription<GriddedTime, GriddedCoverage> sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
@Before
public void setUp() {
PathManagerFactoryTest.initLocalization();
}
@Test
public void moreParametersInCommonThanAllowedOverlaps() {
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void lessParametersInCommonThanAllowedDoesNotOverlap() {
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(64);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(false));
}
@Test
public void moreForecastHoursInCommonThanAllowedOverlaps() {
when(duplicateChecker.getForecastHourDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void lessForecastHoursInCommonThanAllowedDoesNotOverlap() {
when(duplicateChecker.getForecastHourDuplicationPercent(sub1, sub2))
.thenReturn(64);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(false));
}
@Test
public void moreCyclesInCommonThanAllowedOverlaps() {
when(duplicateChecker.getCycleDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void lessCyclesInCommonThanAllowedDoesNotOverlap() {
when(duplicateChecker.getCycleDuplicationPercent(sub1, sub2))
.thenReturn(64);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(false));
}
@Test
public void moreSpatialInCommonThanAllowedOverlaps()
throws TransformException {
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void lessSpatialInCommonThanAllowedDoesNotOverlap()
throws TransformException {
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(64);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(false));
}
@Test
public void matchesAnyTrueWillConsiderOneExceededValueAsOverlaps()
throws LocalizationException {
service.writeConfig(ANY_MUST_EXCEED_65_PERCENT);
when(duplicateChecker.getCycleDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void matchesAnyFalseWillNotConsiderOneExceededValueAsOverlaps()
throws LocalizationException {
service.writeConfig(ALL_MUST_EXCEED_65_PERCENT);
when(duplicateChecker.getCycleDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(false));
}
@Test
public void matchesAnyTrueWillConsiderAllExceededValuesAsOverlaps()
throws LocalizationException, TransformException {
service.writeConfig(ANY_MUST_EXCEED_65_PERCENT);
when(duplicateChecker.getCycleDuplicationPercent(sub1, sub2))
.thenReturn(66);
when(duplicateChecker.getForecastHourDuplicationPercent(sub1, sub2))
.thenReturn(66);
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(66);
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void matchesAnyFalseWillConsiderAllExceededValuesAsOverlaps()
throws LocalizationException, TransformException {
service.writeConfig(ALL_MUST_EXCEED_65_PERCENT);
when(duplicateChecker.getCycleDuplicationPercent(sub1, sub2))
.thenReturn(66);
when(duplicateChecker.getForecastHourDuplicationPercent(sub1, sub2))
.thenReturn(66);
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(66);
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void whenAllComparisonsReturnOneHundredPercentReturnsDuplicate()
throws LocalizationException, TransformException {
when(duplicateChecker.getCycleDuplicationPercent(sub1, sub2))
.thenReturn(100);
when(duplicateChecker.getForecastHourDuplicationPercent(sub1, sub2))
.thenReturn(100);
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(100);
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(100);
assertThat(service.isOverlapping(sub1, sub2).isDuplicate(), is(true));
}
@Test
public void whenAllComparisonsDontReturnOneHundredPercentReturnsNotDuplicate()
throws LocalizationException, TransformException {
when(duplicateChecker.getCycleDuplicationPercent(sub1, sub2))
.thenReturn(100);
when(duplicateChecker.getForecastHourDuplicationPercent(sub1, sub2))
.thenReturn(100);
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(100);
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(99);
assertThat(service.isOverlapping(sub1, sub2).isDuplicate(), is(false));
}
}

View file

@ -0,0 +1,202 @@
package com.raytheon.uf.common.datadelivery.service.subscription;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.junit.Test;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.ParameterFixture;
import com.raytheon.uf.common.datadelivery.registry.PointTime;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.edex.datadelivery.service.services.overlap.PointOverlapData;
/**
* PointOverlapData object test class.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 18, 2013 2292 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class PointOverlapDataTest {
private static final PointSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ALL = new PointSubscriptionOverlapConfig(
50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ALL);
private static final PointSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ANY = new PointSubscriptionOverlapConfig(
50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ANY);
private static final PointSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_HALF = new PointSubscriptionOverlapConfig(
50, 50, 50, SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
/*
* Duplicate subs
*/
@Test
public void testFiftyPercentMatchAllWithDuplicates() {
SiteSubscription dupeSub1 = getSubscription(1);
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
dupeSub2.getCoverage().setRequestEnvelope(
dupeSub1.getCoverage().getRequestEnvelope());
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
assertTrue("These should be duplicates", od.isDuplicate());
assertTrue("These should overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchAnyWithDuplicates() {
SiteSubscription dupeSub1 = getSubscription(1);
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
dupeSub2.getCoverage().setRequestEnvelope(
dupeSub1.getCoverage().getRequestEnvelope());
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
assertTrue("These should be duplicates", od.isDuplicate());
assertTrue("These should overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchHalfWithDuplicates() {
SiteSubscription dupeSub1 = getSubscription(1);
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
dupeSub2.getCoverage().setRequestEnvelope(
dupeSub1.getCoverage().getRequestEnvelope());
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
assertTrue("These should be duplicates", od.isDuplicate());
assertTrue("These should overlap", od.isOverlapping());
}
/*
* Non matching subs
*/
@Test
public void testFiftyPercentMatchAllWithNoMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
sub2.getParameter().clear();
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
PointTime time = new PointTime();
time.setInterval(100);
sub2.setTime(time);
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
assertFalse("These should not be duplicates", od.isDuplicate());
assertFalse("These should not overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchAnyWithNoMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
sub2.getParameter().clear();
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
PointTime time = new PointTime();
time.setInterval(100);
sub2.setTime(time);
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
assertFalse("These should not be duplicates", od.isDuplicate());
assertFalse("These should not overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchHalfWithNoMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
sub2.getParameter().clear();
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
PointTime time = new PointTime();
time.setInterval(100);
sub2.setTime(time);
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
assertFalse("These should not be duplicates", od.isDuplicate());
assertFalse("These should not overlap", od.isOverlapping());
}
/*
* Half matching subs - match parameter and interval
*/
@Test
public void testFiftyPercentMatchAllWithHalfMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
assertFalse("These should not be duplicates", od.isDuplicate());
assertFalse("These should not overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchAnyWithHalfMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
assertFalse("These should not be duplicates", od.isDuplicate());
assertTrue("These should not overlap", od.isOverlapping());
}
@Test
public void testFiftyPercentMatchHalfWithHalfMatches() {
SiteSubscription sub1 = getSubscription(1);
SiteSubscription sub2 = getSubscription(2);
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
MapUtil.LATLON_PROJECTION);
sub2.getCoverage().setRequestEnvelope(env);
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
assertFalse("These should not be duplicates", od.isDuplicate());
assertTrue("These should overlap", od.isOverlapping());
}
private SiteSubscription getSubscription(int seed) {
SiteSubscription sub = SiteSubscriptionFixture.INSTANCE.get(seed,
DataType.POINT);
ReferencedEnvelope env = new ReferencedEnvelope(0, 15, 0, 15,
MapUtil.LATLON_PROJECTION);
sub.getCoverage().setRequestEnvelope(env);
return sub;
}
}

View file

@ -1,128 +0,0 @@
/**
* 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.service.subscription;
import static com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy.AT_LEAST_HALF;
import static com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy.MATCH_ALL;
import static com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy.MATCH_ANY;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
/**
* Test {@link PointSubscriptionOverlapMatchStrategy}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 14, 2013 2000 djohnson Initial creation
* Sept 24, 2012 2386 dhladky Made point specific
* Sept 25, 2013 1797 dhladky fixed test
*
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class PointSubscriptionOverlapMatchStrategyTest {
private static final SubscriptionOverlapConfig MUST_EXCEED_FIFTY_PERCENT = new PointSubscriptionOverlapConfig(
50, 50, 50, 50, null);
@Test
public void matchAnyReturnsTrueIfAnyExceedMaxAllowed() {
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55, 45,
45, 45), is(true));
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45, 55,
45, 45), is(true));
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45, 45,
45, 55), is(true));
}
@Test
public void matchAnyReturnsFalseIfNoneExceedMaxAllowed() {
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 50, 50,
50, 50), is(false));
assertThat(
MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 0, 0, 0, 0),
is(false));
assertThat(MATCH_ANY.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 25, 25,
25, 25), is(false));
}
@Test
public void matchAllReturnsTrueIfAllExceedMaxAllowed() {
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55, 55,
55, 55), is(true));
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 100, 100,
100, 100), is(true));
}
@Test
public void matchAllReturnsFalseIfNotAllExceedMaxAllowed() {
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55, 55,
55, 45), is(false));
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55, 55,
45, 55), is(false));
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55, 45,
55, 55), is(false));
assertThat(MATCH_ALL.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45, 55,
55, 55), is(false));
}
@Test
public void atLeastHalfReturnsTrueIfAllExceedMaxAllowed() {
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55,
55, 55, 55), is(true));
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 100,
100, 100, 100), is(true));
}
@Test
public void atLeastHalfReturnsTrueIfHalfExceedMaxAllowed() {
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45,
45, 55, 55), is(true));
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55,
55, 45, 45), is(true));
}
@Test
public void atLeastHalfReturnsFalseIfLessThanHalfExceedMaxAllowed() {
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45,
45, 55, 45), is(false));
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 45,
55, 45, 45), is(false));
assertThat(AT_LEAST_HALF.isOverlapping(MUST_EXCEED_FIFTY_PERCENT, 55,
45, 45, 45), is(false));
}
}

View file

@ -1,207 +0,0 @@
/**
* 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.service.subscription;
import static com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy.MATCH_ALL;
import static com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy.MATCH_ANY;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
import com.raytheon.uf.common.localization.exception.LocalizationException;
/**
* Test {@link PointSubscriptionOverlapService}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 07, 2013 2000 djohnson Initial creation
* Sept, 24 2013 2386 dhladky Made point specific
* Sept 25, 2013 1797 dhladky fixed tests
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class PointSubscriptionOverlapServiceTest {
private static final SubscriptionOverlapConfig ANY_MUST_EXCEED_65_PERCENT = new PointSubscriptionOverlapConfig(
65, 65, 65, 65, MATCH_ANY);
private static final SubscriptionOverlapConfig ALL_MUST_EXCEED_65_PERCENT = new PointSubscriptionOverlapConfig(
65, 65, 65, 65, MATCH_ALL);
private final ISubscriptionDuplicateChecker duplicateChecker = mock(ISubscriptionDuplicateChecker.class);
private final SubscriptionOverlapService service = new SubscriptionOverlapService(
duplicateChecker);
private final Subscription sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
private final Subscription sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
@Before
public void setUp() {
PathManagerFactoryTest.initLocalization();
}
@Test
public void moreParametersInCommonThanAllowedOverlaps() {
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void lessParametersInCommonThanAllowedDoesNotOverlap() {
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(64);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(false));
}
@Test
public void moreTimeInCommonThanAllowedOverlaps() {
when(duplicateChecker.getTimeDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void lessTimeInCommonThanAllowedDoesNotOverlap() {
when(duplicateChecker.getTimeDuplicationPercent(sub1, sub2))
.thenReturn(64);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(false));
}
@Test
public void moreSpatialInCommonThanAllowedOverlaps()
throws TransformException {
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void lessSpatialInCommonThanAllowedDoesNotOverlap()
throws TransformException {
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(64);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(false));
}
@Test
public void matchesAnyTrueWillConsiderOneExceededValueAsOverlaps()
throws LocalizationException {
service.writeConfig(ANY_MUST_EXCEED_65_PERCENT);
when(duplicateChecker.getCycleDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void matchesAnyFalseWillNotConsiderOneExceededValueAsOverlaps()
throws LocalizationException {
service.writeConfig(ALL_MUST_EXCEED_65_PERCENT);
when(duplicateChecker.getCycleDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(false));
}
@Test
public void matchesAnyTrueWillConsiderAllExceededValuesAsOverlaps()
throws LocalizationException, TransformException {
service.writeConfig(ANY_MUST_EXCEED_65_PERCENT);
when(duplicateChecker.getTimeDuplicationPercent(sub1, sub2))
.thenReturn(66);
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(66);
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void matchesAnyFalseWillConsiderAllExceededValuesAsOverlaps()
throws LocalizationException, TransformException {
service.writeConfig(ALL_MUST_EXCEED_65_PERCENT);
when(duplicateChecker.getTimeDuplicationPercent(sub1, sub2))
.thenReturn(66);
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(66);
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(66);
assertThat(service.isOverlapping(sub1, sub2).isOverlapping(), is(true));
}
@Test
public void whenAllComparisonsReturnOneHundredPercentReturnsDuplicate()
throws LocalizationException, TransformException {
when(duplicateChecker.getTimeDuplicationPercent(sub1, sub2))
.thenReturn(100);
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(100);
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(100);
assertThat(service.isOverlapping(sub1, sub2).isDuplicate(), is(true));
}
@Test
public void whenAllComparisonsDontReturnOneHundredPercentReturnsNotDuplicate()
throws LocalizationException, TransformException {
when(duplicateChecker.getTimeDuplicationPercent(sub1, sub2))
.thenReturn(100);
when(duplicateChecker.getParameterDuplicationPercent(sub1, sub2))
.thenReturn(100);
when(duplicateChecker.getSpatialDuplicationPercent(sub1, sub2))
.thenReturn(99);
assertThat(service.isOverlapping(sub1, sub2).isDuplicate(), is(false));
}
}

View file

@ -1,237 +0,0 @@
/**
* 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.service.subscription;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.junit.Test;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
import com.raytheon.uf.common.datadelivery.registry.Parameter;
import com.raytheon.uf.common.datadelivery.registry.ParameterFixture;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
/**
* TesT {@link SubscriptionDuplicateChecker}.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 02, 2013 2000 djohnson Initial creation
* Sept 25, 2013 1979 dhladky separated time from gridded time
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class SubscriptionDuplicateCheckerTest {
private static final ISubscriptionDuplicateChecker<GriddedTime, GriddedCoverage> dupeChecker = new SubscriptionDuplicateChecker<GriddedTime, GriddedCoverage>();
@Test
public void returnsPercentOfParametersThatAreTheSame() {
final SiteSubscription<GriddedTime, GriddedCoverage> sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
final SiteSubscription<GriddedTime, GriddedCoverage> sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
sub1.getParameter().clear();
sub1.addParameter(ParameterFixture.INSTANCE.get(1));
sub2.getParameter().clear();
sub2.addParameter((Parameter)sub1.getParameter().iterator().next());
sub2.addParameter(ParameterFixture.INSTANCE.get(2));
assertThat(dupeChecker.getParameterDuplicationPercent(sub1, sub2),
is(50));
assertThat(dupeChecker.getParameterDuplicationPercent(sub2, sub1),
is(100));
}
@SuppressWarnings("unchecked")
@Test
public void returnsZeroPercentOfParametersForNullsOrEmpties() {
final SiteSubscription sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
final SiteSubscription sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
sub1.setParameter(null);
sub2.getParameter().clear();
sub2.addParameter(ParameterFixture.INSTANCE.get(2));
assertThat(dupeChecker.getParameterDuplicationPercent(sub1, sub2),
is(0));
assertThat(dupeChecker.getParameterDuplicationPercent(sub2, sub1),
is(0));
sub1.setParameter(Collections.<Parameter> emptyList());
assertThat(dupeChecker.getParameterDuplicationPercent(sub1, sub2),
is(0));
assertThat(dupeChecker.getParameterDuplicationPercent(sub2, sub1),
is(0));
}
@Test
public void returnsPercentOfForecastHoursThatAreTheSame() {
final SiteSubscription sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
final SiteSubscription sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
final List<Integer> sub1SelectedTimes = Arrays.asList(0, 1);
((GriddedTime)sub1.getTime()).setSelectedTimeIndices(sub1SelectedTimes);
final List<Integer> sub2SelectedTimes = Arrays.asList(0, 3, 4);
((GriddedTime)sub2.getTime()).setSelectedTimeIndices(sub2SelectedTimes);
assertThat(dupeChecker.getTimeDuplicationPercent(sub1, sub2),
is(33));
assertThat(dupeChecker.getTimeDuplicationPercent(sub2, sub1),
is(50));
}
@Test
public void returnsZeroPercentOfForecastHoursForNullsOrEmpties() {
final SiteSubscription<GriddedTime, GriddedCoverage> sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
final SiteSubscription<GriddedTime, GriddedCoverage> sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
((GriddedTime)sub1.getTime()).setSelectedTimeIndices(null);
final List<Integer> sub2SelectedTimes = Arrays.asList(0, 3, 4);
((GriddedTime)sub2.getTime()).setSelectedTimeIndices(sub2SelectedTimes);
assertThat(dupeChecker.getForecastHourDuplicationPercent(sub1, sub2),
is(0));
assertThat(dupeChecker.getForecastHourDuplicationPercent(sub2, sub1),
is(0));
((GriddedTime)sub1.getTime())
.setSelectedTimeIndices(Collections.<Integer> emptyList());
assertThat(dupeChecker.getForecastHourDuplicationPercent(sub1, sub2),
is(0));
assertThat(dupeChecker.getForecastHourDuplicationPercent(sub2, sub1),
is(0));
}
@Test
public void returnsPercentOfCyclesThatAreTheSame() {
final SiteSubscription<GriddedTime, GriddedCoverage> sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
final SiteSubscription<GriddedTime, GriddedCoverage> sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
final List<Integer> sub1CycleTimes = Arrays.asList(0, 6);
((GriddedTime)sub1.getTime()).setCycleTimes(sub1CycleTimes);
final List<Integer> sub2CycleTimes = Arrays.asList(0, 12, 18);
((GriddedTime)sub2.getTime()).setCycleTimes(sub2CycleTimes);
assertThat(dupeChecker.getCycleDuplicationPercent(sub1, sub2),
is(33));
assertThat(dupeChecker.getCycleDuplicationPercent(sub2, sub1),
is(50));
}
@Test
public void returnsZeroPercentOfCyclesForNullsOrEmpties() {
final SiteSubscription<GriddedTime, GriddedCoverage> sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
final SiteSubscription<GriddedTime, GriddedCoverage> sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
((GriddedTime)sub1.getTime()).setCycleTimes(null);
final List<Integer> cycleTimes = Arrays.asList(0, 3, 4);
((GriddedTime)sub2.getTime()).setCycleTimes(cycleTimes);
assertThat(dupeChecker.getCycleDuplicationPercent(sub1, sub2), is(0));
assertThat(dupeChecker.getCycleDuplicationPercent(sub2, sub1), is(0));
((GriddedTime)sub1.getTime()).setCycleTimes(Collections.<Integer> emptyList());
assertThat(dupeChecker.getCycleDuplicationPercent(sub1, sub2), is(0));
assertThat(dupeChecker.getCycleDuplicationPercent(sub2, sub1), is(0));
}
@Test
public void returnsPercentOfSpatialThatIsTheSame()
throws TransformException {
final SiteSubscription<GriddedTime, GriddedCoverage> sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
final SiteSubscription<GriddedTime, GriddedCoverage> sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
ReferencedEnvelope envelope1 = new ReferencedEnvelope(new Envelope(
new Coordinate(-5, 0), new Coordinate(0, 5)),
MapUtil.LATLON_PROJECTION);
// dx = 6, dy = 3, area = 18
ReferencedEnvelope envelope2 = new ReferencedEnvelope(new Envelope(
new Coordinate(-3, 3), new Coordinate(3, 6)),
MapUtil.LATLON_PROJECTION);
// The intersection should have coordinates: (-3, 3) (0, 5)
// dx = 3, dy = 2, area = 6
sub1.getCoverage().setRequestEnvelope(envelope1);
sub2.getCoverage().setRequestEnvelope(envelope2);
// The expected percent overlap: 6 / 18 = .33
assertThat(dupeChecker.getSpatialDuplicationPercent(sub1, sub2), is(33));
}
@Test
public void returnsZeroPercentOfSpatialWhenNoOverlap()
throws TransformException {
final SiteSubscription<GriddedTime, GriddedCoverage> sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
final SiteSubscription<GriddedTime, GriddedCoverage> sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
ReferencedEnvelope envelope1 = new ReferencedEnvelope(new Envelope(
new Coordinate(-5, 0), new Coordinate(0, 5)),
MapUtil.LATLON_PROJECTION);
ReferencedEnvelope envelope2 = new ReferencedEnvelope(new Envelope(
new Coordinate(-10, -20), new Coordinate(-6, -15)),
MapUtil.LATLON_PROJECTION);
sub1.getCoverage().setRequestEnvelope(envelope1);
sub2.getCoverage().setRequestEnvelope(envelope2);
assertThat(dupeChecker.getSpatialDuplicationPercent(sub1, sub2), is(0));
}
@Test
public void returnsZeroPercentOfSpatialForNulls() throws TransformException {
final SiteSubscription<GriddedTime, GriddedCoverage> sub1 = SiteSubscriptionFixture.INSTANCE.get(1);
final SiteSubscription<GriddedTime, GriddedCoverage> sub2 = SiteSubscriptionFixture.INSTANCE.get(2);
sub1.setCoverage(null);
assertThat(dupeChecker.getSpatialDuplicationPercent(sub1, sub2), is(0));
assertThat(dupeChecker.getSpatialDuplicationPercent(sub2, sub1), is(0));
// No envelope set
sub1.setCoverage(new GriddedCoverage());
assertThat(dupeChecker.getSpatialDuplicationPercent(sub1, sub2), is(0));
assertThat(dupeChecker.getSpatialDuplicationPercent(sub2, sub1), is(0));
}
}

View file

@ -42,6 +42,7 @@ import org.junit.Test;
import com.google.common.collect.Lists;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetMetaDataFixture;
@ -75,6 +76,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* ------------ ---------- ----------- --------------------------
* Nov 12, 2012 1286 djohnson Initial creation
* Jun 03, 2013 2038 djohnson Add test getting retrievals by dataset, provider, and status.
* Oct 21, 2013 2292 mpduff Implement multiple data types.
*
* </pre>
*
@ -326,9 +328,9 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
final Calendar now = BandwidthUtil.now();
// Identical except for their identifier fields
BandwidthSubscription entity1 = dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(), now);
SiteSubscriptionFixture.INSTANCE.get(DataType.GRID), now);
BandwidthSubscription entity2 = dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(), now);
SiteSubscriptionFixture.INSTANCE.get(DataType.GRID), now);
assertFalse("The two objects should not have the same id!",
entity1.getId() == entity2.getId());
@ -346,13 +348,13 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
throws SerializationException {
final Calendar now = BandwidthUtil.now();
// Identical except for their base reference times and ids
dao.newBandwidthSubscription(SiteSubscriptionFixture.INSTANCE.get(),
now);
dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(DataType.GRID), now);
final Calendar later = BandwidthUtil.now();
later.add(Calendar.HOUR, 1);
BandwidthSubscription entity2 = dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(), later);
SiteSubscriptionFixture.INSTANCE.get(DataType.GRID), later);
final BandwidthSubscription result = dao.getBandwidthSubscription(
entity2.getRegistryId(), later);
@ -422,8 +424,7 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
.getBandwidthSubscription().getProvider());
assertEquals("Incorrect data set found.",
subscription.getDataSetName(), retrieval
.getBandwidthSubscription()
.getDataSetName());
.getBandwidthSubscription().getDataSetName());
}
}
@ -441,14 +442,11 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
.get(2);
final BandwidthSubscription subDao1 = entity1
.getSubscriptionRetrieval()
.getBandwidthSubscription();
.getSubscriptionRetrieval().getBandwidthSubscription();
final BandwidthSubscription subDao2 = entity2
.getSubscriptionRetrieval()
.getBandwidthSubscription();
.getSubscriptionRetrieval().getBandwidthSubscription();
final BandwidthSubscription subDao3 = entity3
.getSubscriptionRetrieval()
.getBandwidthSubscription();
.getSubscriptionRetrieval().getBandwidthSubscription();
// Give each a unique time
final Calendar one = BandwidthUtil.now();
@ -496,7 +494,8 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
public void testGetSubscriptionsReturnsClones()
throws SerializationException {
BandwidthSubscription entity = dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(), BandwidthUtil.now());
SiteSubscriptionFixture.INSTANCE.get(DataType.GRID),
BandwidthUtil.now());
List<BandwidthSubscription> results = dao.getBandwidthSubscriptions();
assertEquals(1, results.size());
@ -515,15 +514,15 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
three.add(Calendar.HOUR, 1);
// Three entities all the same except for base reference time
dao.newBandwidthSubscription(SiteSubscriptionFixture.INSTANCE.get(),
one);
dao.newBandwidthSubscription(SiteSubscriptionFixture.INSTANCE.get(),
two);
dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(DataType.GRID), one);
dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(DataType.GRID), two);
BandwidthSubscription entity3 = dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(), three);
SiteSubscriptionFixture.INSTANCE.get(DataType.GRID), three);
// One with same base reference time but different provider/dataset
dao.newBandwidthSubscription(SiteSubscriptionFixture.INSTANCE.get(2),
three);
dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(2, DataType.GRID), three);
List<BandwidthSubscription> results = dao.getBandwidthSubscriptions(
entity3.getProvider(), entity3.getDataSetName(), three);
@ -538,7 +537,6 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
assertNotSame(entity3, result);
}
@SuppressWarnings("unchecked")
@Test
public void testQuerySubscriptionRetrievalsBySubscriptionId()
@ -565,8 +563,7 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
final List<SubscriptionRetrieval> results = dao
.querySubscriptionRetrievals(entity2.getSubscriptionRetrieval()
.getBandwidthSubscription()
.getId());
.getBandwidthSubscription().getId());
assertEquals(
"Should have returned one entity for the subscriptionDao id!",
1, results.size());
@ -592,15 +589,11 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
// Still have to persist the actual subscription daos
final BandwidthSubscription subDao1 = entity1
.getSubscriptionRetrieval()
.getBandwidthSubscription();
.getSubscriptionRetrieval().getBandwidthSubscription();
final BandwidthSubscription subDao2 = entity2
.getSubscriptionRetrieval()
.getBandwidthSubscription();
.getSubscriptionRetrieval().getBandwidthSubscription();
final BandwidthSubscription subDao3 = entity3
.getSubscriptionRetrieval()
.getBandwidthSubscription();
.getSubscriptionRetrieval().getBandwidthSubscription();
dao.storeBandwidthSubscriptions(Arrays
.asList(subDao1, subDao2, subDao3));
@ -627,12 +620,12 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
@Test
public void testRemoveSubscriptionDao() throws SerializationException {
final Calendar now = BandwidthUtil.now();
dao.newBandwidthSubscription(SiteSubscriptionFixture.INSTANCE.get(1),
now);
dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(1, DataType.GRID), now);
final BandwidthSubscription entity2 = dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(2), now);
dao.newBandwidthSubscription(SiteSubscriptionFixture.INSTANCE.get(3),
now);
SiteSubscriptionFixture.INSTANCE.get(2, DataType.GRID), now);
dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(3, DataType.GRID), now);
assertEquals("Incorrect number of entities found!", 3, dao
.getBandwidthSubscriptions().size());
@ -696,7 +689,8 @@ public abstract class AbstractBandwidthDaoTest<T extends Time, C extends Coverag
final long estimatedSize = 25L;
BandwidthSubscription entity = dao.newBandwidthSubscription(
SiteSubscriptionFixture.INSTANCE.get(), BandwidthUtil.now());
SiteSubscriptionFixture.INSTANCE.get(DataType.GRID),
BandwidthUtil.now());
entity.setEstimatedSize(estimatedSize);
dao.update(entity);

Some files were not shown because too many files have changed in this diff Show more