Merge branch '13.2.1_delivery' into development

Conflicts:
	cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java

Former-commit-id: 12c8d91429 [formerly f207d282bc] [formerly c218786986] [formerly c218786986 [formerly 658bea377b]] [formerly ec56acde81 [formerly c218786986 [formerly 658bea377b] [formerly ec56acde81 [formerly 60b2fd0496097fb1086207cbb01779dbfea877a0]]]]
Former-commit-id: ec56acde81
Former-commit-id: 28ef7b3e5ed69c229148826fc7a07aff84ade484 [formerly 60daaf3ef91fb7f1318c36d98b7b63e339bd5c61] [formerly 73d9455c65 [formerly 6383bf8ed2]]
Former-commit-id: 73d9455c65
Former-commit-id: 41b14f0fa2
This commit is contained in:
Steve Harris 2013-01-31 10:19:14 -06:00
commit 0213e6dfed
72 changed files with 1810 additions and 824 deletions

View file

@ -85,7 +85,7 @@
</mapping>
<mapping key="primaryElevationAngle">
<constraint constraintValue="${elevation1}"
constraintType="IN" />
constraintType="BETWEEN" />
</mapping>
</metadataMap>
</resourceData>
@ -119,7 +119,7 @@
</mapping>
<mapping key="primaryElevationAngle">
<constraint constraintValue="${elevation1}"
constraintType="IN" />
constraintType="BETWEEN" />
</mapping>
</metadataMap>
</resourceData>
@ -173,7 +173,7 @@
</mapping>
<mapping key="primaryElevationAngle">
<constraint constraintValue="${elevation2}"
constraintType="IN" />
constraintType="BETWEEN" />
</mapping>
</metadataMap>
</resourceData>
@ -207,7 +207,7 @@
</mapping>
<mapping key="primaryElevationAngle">
<constraint constraintValue="${elevation2}"
constraintType="IN" />
constraintType="BETWEEN" />
</mapping>
</metadataMap>
</resourceData>
@ -256,7 +256,7 @@
</mapping>
<mapping key="primaryElevationAngle">
<constraint constraintValue="${elevation4}"
constraintType="IN" />
constraintType="BETWEEN" />
</mapping>
</metadataMap>
</resourceData>
@ -290,7 +290,7 @@
</mapping>
<mapping key="primaryElevationAngle">
<constraint constraintValue="${elevation4}"
constraintType="IN" />
constraintType="BETWEEN" />
</mapping>
</metadataMap>
</resourceData>
@ -344,7 +344,7 @@
</mapping>
<mapping key="primaryElevationAngle">
<constraint constraintValue="${elevation3}"
constraintType="IN" />
constraintType="BETWEEN" />
</mapping>
</metadataMap>
</resourceData>
@ -378,7 +378,7 @@
</mapping>
<mapping key="primaryElevationAngle">
<constraint constraintValue="${elevation3}"
constraintType="IN" />
constraintType="BETWEEN" />
</mapping>
</metadataMap>
</resourceData>

View file

@ -110,7 +110,7 @@
<substitute key="stationId" value="72233"/>
</contribute>
<contribute xsi:type="bundleItem" file="bundles/UpperAirRaob.xml"
menuText="Wash-Dulles, VA (KLWX)" id="raobWash-Dulles"
menuText="Wash-Dulles, VA (KIAD)" id="raobWash-Dulles"
editorType="gov.noaa.nws.ncep.ui.nsharp.display.NsharpEditor">
<substitute key="stationId" value="72403"/>
</contribute>

View file

@ -91,6 +91,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
* Nov 6, 2012 1269 lvenable Initial creation.
* Dec 13, 2012 1269 lvenable Fixes and updates.
* Jan 07, 2013 1451 djohnson Use TimeUtil.newGmtCalendar().
* Jan 28, 2013 1529 djohnson Disable menu items if no subscriptions selected.
*
* </pre>
*
@ -886,6 +887,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
MenuItem viewSubs = new MenuItem(m, SWT.NONE);
viewSubs.setText("View Selected Subscriptions...");
viewSubs.setEnabled(imageMgr.hasSubscriptionNameChecked());
viewSubs.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {

View file

@ -20,6 +20,7 @@
package com.raytheon.uf.viz.datadelivery.bandwidth.ui;
import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
@ -30,7 +31,7 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionPriority;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
/**
* Bandwidth utilization graph image manager.
@ -42,7 +43,9 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionP
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 28, 2012 1269 lvenable Initial creation
* Dec 13, 2012 1269 lvenable Fixes and updates.
* Dec 13, 2012 1269 lvenable Fixes and updates.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum on subscriptions.
* Jan 28, 2013 1529 djohnson Add hasSubscriptionNameChecked().
*
* </pre>
*
@ -137,10 +140,11 @@ public class BandwidthImageMgr implements IGraphOptions {
private void init(Composite parentComp, BandwidthGraphData graphData,
Map<CanvasImages, CanvasSettings> canvasSettingsMap) {
priorityColorMap = new HashMap<SubscriptionPriority, RGB>();
for (SubscriptionPriority priority : SubscriptionPriority.values()) {
priorityColorMap.put(priority, priority.getColor());
}
priorityColorMap = new EnumMap<SubscriptionPriority, RGB>(
SubscriptionPriority.class);
priorityColorMap.put(SubscriptionPriority.LOW, new RGB(6, 122, 255));
priorityColorMap.put(SubscriptionPriority.NORMAL, new RGB(0, 255, 0));
priorityColorMap.put(SubscriptionPriority.HIGH, new RGB(255, 0, 0));
canvasImgMap = new HashMap<BandwidthImageMgr.CanvasImages, AbstractCanvasImage>();
populateCanvasMap(parentComp, graphData, canvasSettingsMap);
@ -488,4 +492,13 @@ public class BandwidthImageMgr implements IGraphOptions {
regenerateImage(CanvasImages.X_HEADER);
}
}
/**
* Check whether there is a checked subscription name.
*
* @return true if at least one subscription name is checked
*/
public boolean hasSubscriptionNameChecked() {
return checkMap.containsValue(Boolean.TRUE);
}
}

View file

@ -34,9 +34,9 @@ import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
import com.raytheon.uf.common.datadelivery.bandwidth.data.TimeWindowData;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.SortBy;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionPriority;
/**
* The graph image class.
@ -51,6 +51,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionP
* Dec 13, 2012 1269 lvenable Fixes and updates.
* Jan 07, 2013 1451 djohnson Use TimeUtil.newGmtCalendar().
* Jan 04, 2013 1420 mpduff Change default priority to normal priority.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum, remove incorrect use of ordinal values.
*
* </pre>
*
@ -171,20 +172,17 @@ public class GraphImage extends AbstractCanvasImage {
for (String subName : subscriptionList) {
if (imageMgr.isColorByPriority()) {
if (graphData.getPriority(subName) == SubscriptionPriority.NORMAL
.ordinal()) {
if (graphData.getPriority(subName) == SubscriptionPriority.NORMAL) {
c = new Color(
display,
imageMgr.getPriorityColor(SubscriptionPriority.NORMAL));
gc.setBackground(c);
} else if (graphData.getPriority(subName) == SubscriptionPriority.HIGH
.ordinal()) {
} else if (graphData.getPriority(subName) == SubscriptionPriority.HIGH) {
c = new Color(
display,
imageMgr.getPriorityColor(SubscriptionPriority.HIGH));
gc.setBackground(c);
} else if (graphData.getPriority(subName) == SubscriptionPriority.LOW
.ordinal()) {
} else if (graphData.getPriority(subName) == SubscriptionPriority.LOW) {
c = new Color(display,
imageMgr.getPriorityColor(SubscriptionPriority.LOW));
gc.setBackground(c);

View file

@ -21,7 +21,7 @@ package com.raytheon.uf.viz.datadelivery.bandwidth.ui;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionPriority;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
/**
* TODO Add Description

View file

@ -32,7 +32,7 @@ import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionPriority;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
/**
* Header image for X axis.
@ -45,6 +45,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionP
* ------------ ---------- ----------- --------------------------
* Nov 28, 2012 1269 lvenable Initial creation.
* Dec 13, 2012 1269 lvenable Fixes and updates.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
*
* </pre>
*
@ -75,7 +76,7 @@ public class XHeaderImage extends AbstractCanvasImage {
private final String sortBy = "Sort by: ";
/** Map of rectangles and subscription priorities. */
private Map<Rectangle, SubscriptionPriority> rectPriMap;
private final Map<Rectangle, SubscriptionPriority> rectPriMap;
/**
* Constructor.

View file

@ -20,6 +20,8 @@
package com.raytheon.uf.viz.datadelivery.common.ui;
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.Combo;
@ -28,7 +30,7 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionPriority;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
/**
* This is the priority group information composite. This class is intended to
@ -43,6 +45,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionP
* Jun 27, 2012 702 jpiatt Initial creation.
* Aug 21, 2012 712 mpduff Default to Default, and allow for setting the combo box.
* Jan 04, 2013 1420 mpduff Add latency.
* Jan 25, 2013 1528 djohnson Use priority enum instead of raw integers.
*
* </pre>
*
@ -60,7 +63,7 @@ public class PriorityComp extends Composite {
private final int latency;
/** The priority value */
private final int priority;
private SubscriptionPriority priority;
/**
* Constructor.
@ -70,10 +73,11 @@ public class PriorityComp extends Composite {
* @param latency
* @param priority
*/
public PriorityComp(Composite parent, int latency, int priority) {
public PriorityComp(Composite parent, int latency,
SubscriptionPriority priority) {
super(parent, SWT.NONE);
this.latency = latency;
this.priority = priority - 1;
this.priority = priority;
init();
}
@ -127,9 +131,16 @@ public class PriorityComp extends Composite {
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
priorityCombo = new Combo(priorityComp, SWT.READ_ONLY);
priorityCombo.setItems(priorities);
priorityCombo.select(this.priority);
priorityCombo.setLayoutData(gd);
priorityCombo.setToolTipText("Select a priority");
priorityCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
priority = SubscriptionPriority.fromPriorityName(priorityCombo
.getItem(priorityCombo.getSelectionIndex()));
}
});
setPriority(priority);
Composite latencyComp = new Composite(subPriorityGroup, SWT.NONE);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -153,8 +164,8 @@ public class PriorityComp extends Composite {
*
* @return priority
*/
public int getPriorityIndex() {
return priorityCombo.getSelectionIndex();
public SubscriptionPriority getPriority() {
return priority;
}
/**
@ -162,10 +173,9 @@ public class PriorityComp extends Composite {
*
* @param index
*/
public void setPriorityIndex(int index) {
if (index <= priorityCombo.getItemCount()) {
priorityCombo.select(index);
}
public void setPriority(SubscriptionPriority priority) {
priorityCombo.select(priorityCombo.indexOf(priority.getPriorityName()));
this.priority = priority;
}
/**

View file

@ -39,6 +39,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.datadelivery.registry.ebxml.DataSetQuery;
import com.raytheon.uf.viz.datadelivery.common.ui.ActivePeriodComp;
import com.raytheon.uf.viz.datadelivery.common.ui.DeliveryOptionsComp;
@ -79,6 +80,7 @@ import com.raytheon.viz.ui.presenter.components.ComboBoxConf;
* Dec 13, 2012 1391 bgonzale Added cancel/ok selection status.
* Jan 02, 2013 1441 djohnson Add isGroupSelected().
* Jan 04, 2013 1420 mpduff Add latency.
* Jan 25, 2013 1528 djohnson Use priority enum instead of raw integers.
*
* </pre>
*
@ -195,7 +197,8 @@ public class CreateSubscriptionDlg extends CaveSWTDialog implements
// Get latency value
SystemRuleManager ruleManager = SystemRuleManager.getInstance();
int latency = ruleManager.getLatency(this.subscription, cycleTimes);
int priority = ruleManager.getPriority(this.subscription, cycleTimes);
SubscriptionPriority priority = ruleManager.getPriority(
this.subscription, cycleTimes);
priorityComp = new PriorityComp(mainComp, latency, priority);
this.createCycleGroup();
@ -517,16 +520,16 @@ public class CreateSubscriptionDlg extends CaveSWTDialog implements
* {@inheritDoc}
*/
@Override
public int getPriority() {
return priorityComp.getPriorityIndex();
public SubscriptionPriority getPriority() {
return priorityComp.getPriority();
}
/**
* {@inheritDoc}
*/
@Override
public void setPriority(int i) {
priorityComp.setPriorityIndex(i);
public void setPriority(SubscriptionPriority priority) {
priorityComp.setPriority(priority);
}
/**
@ -842,14 +845,6 @@ public class CreateSubscriptionDlg extends CaveSWTDialog implements
this.subscription = subscription;
}
/**
* {@inheritDoc}
*/
@Override
public int getPriorityValue() {
return priorityComp.getPriorityIndex();
}
/**
* {@inheritDoc}
*/

View file

@ -46,6 +46,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
* Aug 10, 2012 1002 mpduff Change dataset size from int to long.
* Aug 21, 2012 712 mpduff Make priorities display as 1, 2, 3.
* Oct 2, 2012 1103 jpiatt Remove unused methods, update enum, code clean up.
* Jan 25, 2012 1528 djohnson Priorities no longer need incrementing for display.
* </pre>
*
* @author mpduff
@ -67,7 +68,7 @@ public class SubscriptionManagerRowData implements ITableData<SubscriptionManage
private boolean active = false;
/** Subscription priority of fulfillment. */
private int priority = 2;
private int priority;
/** Subscription description. */
private String description = null;
@ -493,7 +494,7 @@ public class SubscriptionManagerRowData implements ITableData<SubscriptionManage
this.setName(subscription.getName());
this.setOwner(subscription.getOwner());
this.setPriority(subscription.getPriority() + 1);
this.setPriority(subscription.getPriority().getPriorityValue());
this.setSubscriptionStart(subscription.getSubscriptionStart());
this.setSubscriptionEnd(subscription.getSubscriptionEnd());
this.setActive(subscription.isActive());

View file

@ -71,6 +71,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
* Dec 18, 2012 1443 bgonzale Open force apply prompt pop-up on the UI thread.
* Dec 20, 2012 1413 bgonzale Added new pending approve and denied request and responses.
* Jan 04, 2013 1441 djohnson Separated out notification methods into their own service.
* Jan 28, 2013 1530 djohnson Reset unscheduled flag with each update.
*
* </pre>
*
@ -358,6 +359,7 @@ public class SubscriptionService implements ISubscriptionService {
final ServiceInteraction action = new ServiceInteraction() {
@Override
public String call() throws RegistryHandlerException {
subscription.setUnscheduled(false);
DataDeliveryHandlers.getSubscriptionHandler().update(
subscription);
return successMessage;
@ -380,6 +382,7 @@ public class SubscriptionService implements ISubscriptionService {
@Override
public String call() throws RegistryHandlerException {
for (Subscription sub : subs) {
sub.setUnscheduled(false);
DataDeliveryHandlers.getSubscriptionHandler().update(sub);
}
return successMessage;
@ -439,6 +442,7 @@ public class SubscriptionService implements ISubscriptionService {
subscription).isAuthorized();
try {
if (authorized) {
subscription.setUnscheduled(false);
DataDeliveryHandlers.getSubscriptionHandler()
.update(subscription);
} else {

View file

@ -100,6 +100,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
* Dec 03, 2012 1279 mpduff Add ability to populate from a list of subscription names.
* Dec 12, 2012 1391 bgonzale Added a job for subscription retrieves.
* Jan 07, 2013 1437 bgonzale Added sort column direction updates.
* Jan 28, 2013 1529 djohnson Disable menu items if no subscriptions are selected.
*
* </pre>
*
@ -120,7 +121,7 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
* Subscription action callback that is called when there is a table
* selection.
*/
private ISubscriptionAction subActionCallback;
private final ISubscriptionAction subActionCallback;
/** TableDataManager object. */
private TableDataManager<SubscriptionManagerRowData> subManagerData;
@ -756,11 +757,14 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
popupMenu.dispose();
}
final boolean menuItemsEnabled = table.getSelectionIndices().length > 0;
// Detail popup menu
popupMenu = new Menu(table);
MenuItem item1 = new MenuItem(popupMenu, SWT.PUSH);
item1.setText("Details... ");
item1.addSelectionListener(new SelectionAdapter() {
MenuItem detailsItem = new MenuItem(popupMenu, SWT.PUSH);
detailsItem.setText("Details... ");
detailsItem.setEnabled(menuItemsEnabled);
detailsItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleDetails();
@ -770,6 +774,7 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
if (subType == SubscriptionType.MANAGER) {
MenuItem editItem = new MenuItem(popupMenu, SWT.PUSH);
editItem.setText("Edit...");
editItem.setEnabled(menuItemsEnabled);
editItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@ -780,6 +785,7 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
// Add the selected row to a subscription group
MenuItem groupItem = new MenuItem(popupMenu, SWT.PUSH);
groupItem.setText("Add to Group...");
groupItem.setEnabled(menuItemsEnabled);
groupItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {

View file

@ -52,6 +52,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Jul 25, 2012 955 djohnson Use List instead of ArrayList.
* Sep 24, 2012 1157 mpduff Use InitialPendingSubsription.
* Dec 10, 2012 1259 bsteffen Switch Data Delivery from LatLon to referenced envelopes.
* Jan 25, 2013 1528 djohnson Compare priorities as primitive ints.
*
* </pre>
*
@ -115,7 +116,7 @@ public class SubscriptionDiff {
getMap();
if (!(sub.getPriority().equals(pendingSub.getPriority()))) {
if (sub.getPriority() != pendingSub.getPriority()) {
diffMap.put("priority", true);
}

View file

@ -44,6 +44,7 @@ import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSet;
import com.raytheon.uf.common.datadelivery.registry.PendingSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.datadelivery.registry.Utils.SubscriptionStatus;
import com.raytheon.uf.common.datadelivery.registry.handlers.IPendingSubscriptionHandler;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
@ -102,6 +103,7 @@ import com.raytheon.viz.ui.presenter.components.WidgetConf;
* Jan 11, 2013 1453 djohnson Sets cycle times on construction.
* Jan 14, 2013 1286 djohnson Check that message to display is not null or empty, and
* only send notification of subscription creation on OK status.
* Jan 25, 2013 1528 djohnson Use priority enum instead of raw integers, default to existing priority on edit.
* </pre>
*
* @author mpduff
@ -373,6 +375,10 @@ public class CreateSubscriptionDlgPresenter {
view.setActiveEndDateBtnEnabled(false);
}
if (!create) {
view.setPriority(subscription.getPriority());
}
List<Integer> cycleTimes = subscription.getTime().getCycleTimes();
if (cycleTimes != null) {
List<String> cycleStrings = new ArrayList<String>();
@ -504,8 +510,8 @@ public class CreateSubscriptionDlgPresenter {
}
// priority
int priorityInd = view.getPriority();
subscription.setPriority(priorityInd);
SubscriptionPriority priority = view.getPriority();
subscription.setPriority(priority);
subscription.setOfficeID(LocalizationManager.getInstance()
.getCurrentSite());

View file

@ -84,6 +84,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
* Jan 04, 2013 1299 djohnson Add logging of invalid forecast hour information if it occurs again.
* Jan 04, 2013 1420 mpduff Pass cycles in for rules.
* Jan 18, 2013 1414 bsteffen Add ensemble tab.
* Jan 28, 2013 1533 djohnson Update the calculated dataset size after loading subset xml.
*
* </pre>
*
@ -200,6 +201,7 @@ public class GriddedSubsetManagerDlg
if (ensembleTab != null) {
ensembleTab.loadFromSubsetXML(subsetXml);
}
updateDataSize();
}
/*

View file

@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.viz.datadelivery.common.ui.PriorityComp;
import com.raytheon.uf.viz.datadelivery.subscription.subset.presenter.IGriddedTimingSelectionDlgView;
import com.raytheon.uf.viz.datadelivery.system.SystemRuleManager;
@ -55,6 +56,7 @@ import com.raytheon.viz.ui.presenter.components.ListConf;
* Oct 11, 2012 1263 jpiatt Modified for cancel button
* Nov 20, 2012 1286 djohnson Implement displayYesNoPopup.
* Jan 04, 2013 1420 mpduff Add Priority Composite.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
*
* </pre>
*
@ -137,7 +139,8 @@ public class GriddedTimingSelectionDlg extends CaveSWTDialog implements
// Get latency value
SystemRuleManager ruleManager = SystemRuleManager.getInstance();
int latency = ruleManager.getLatency(this.subscription, cycleTimes);
int priority = ruleManager.getPriority(this.subscription, cycleTimes);
SubscriptionPriority priority = ruleManager
.getPriority(this.subscription, cycleTimes);
priorityComp = new PriorityComp(shell, latency, priority);
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
@ -337,7 +340,7 @@ public class GriddedTimingSelectionDlg extends CaveSWTDialog implements
* {@inheritDoc}
*/
@Override
public int getPriority() {
return priorityComp.getPriorityIndex();
public SubscriptionPriority getPriority() {
return priorityComp.getPriority();
}
}

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.viz.datadelivery.subscription.subset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -51,6 +52,7 @@ import com.raytheon.uf.common.datadelivery.registry.DataSet;
import com.raytheon.uf.common.datadelivery.registry.DataType;
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSet;
import com.raytheon.uf.common.datadelivery.registry.Levels;
import com.raytheon.uf.common.datadelivery.registry.Parameter;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
@ -123,6 +125,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
* Jan 02, 2012 1345 djohnson Use gui thread task executor.
* Jan 04, 2012 1420 mpduff Pass the subscription in to the GriddedTimingSelectionDlg.
* Jan 10, 2013 1444 mpduff Fix the loading of saved subsets from the saved subset tab.
* Jan 28, 2013 1530 djohnson Break out long method chaining into local variables for debugging.
* </pre>
*
* @author mpduff
@ -562,7 +565,6 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
sub.setOfficeID(LocalizationManager.getInstance().getCurrentSite());
if (create) {
sub.setOwner(LocalizationManager.getInstance().getCurrentUser());
sub.setPriority(1);
} else {
sub.setOwner(this.subscription.getOwner());
sub.setGroupName(this.subscription.getGroupName());
@ -908,8 +910,11 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
// Data providers have parameters with multiple level types
// containing multiple levels
if (levelType.getId() == 100) {
for (int index : p.getLevels().getSelectedLevelIndices()) {
v.addLevel(String.valueOf(p.getLevels().getLevel()
final Levels levels = p.getLevels();
final List<Integer> selectedLevelIndices = levels
.getSelectedLevelIndices();
for (int index : selectedLevelIndices) {
v.addLevel(String.valueOf(levels.getLevel()
.get(index)));
}
}

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.uf.viz.datadelivery.subscription.subset.presenter;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.viz.ui.presenter.IPresenterView;
import com.raytheon.viz.ui.presenter.components.ButtonConf;
import com.raytheon.viz.ui.presenter.components.CheckBoxConf;
@ -119,9 +120,9 @@ public interface IGriddedTimingSelectionDlgView extends IPresenterView {
int getLatency();
/**
* Get the priority value.
* Get the priority.
*
* @return priority value
* @return priority
*/
int getPriority();
SubscriptionPriority getPriority();
}

View file

@ -26,6 +26,7 @@ import java.util.Set;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.viz.ui.presenter.IPresenterView;
import com.raytheon.viz.ui.presenter.components.ButtonConf;
import com.raytheon.viz.ui.presenter.components.CheckBoxConf;
@ -44,6 +45,7 @@ import com.raytheon.viz.ui.presenter.components.ComboBoxConf;
* Dec 13, 2012 1391 bgonzale Added status methods.
* Jan 02, 2013 1441 djohnson Add isGroupSelected.
* Jan 04, 2013 1420 mpduff Added getters for latency and priority.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
*
* </pre>
*
@ -210,14 +212,14 @@ public interface ICreateSubscriptionDlgView extends IPresenterView {
*
* @return
*/
int getPriority();
SubscriptionPriority getPriority();
/**
* Set the priority selection
*
* @param i
* @param subscriptionPriority
*/
void setPriority(int i);
void setPriority(SubscriptionPriority subscriptionPriority);
/**
* Open the dialog
@ -406,13 +408,6 @@ public interface ICreateSubscriptionDlgView extends IPresenterView {
*/
int getLatencyValue();
/**
* Get the priority value.
*
* @return
*/
int getPriorityValue();
/**
* Set Subscription.
*

View file

@ -24,6 +24,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
/**
* Priority rule xml object.
*
@ -34,6 +36,7 @@ import javax.xml.bind.annotation.XmlRootElement;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 19, 2012 1420 mpduff Initial creation.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
*
* </pre>
*
@ -44,20 +47,20 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class PriorityRuleXML extends RuleXML {
@XmlElement(name = "priority")
private Integer priority;
private SubscriptionPriority priority;
/**
* @param priority
* the priority to set
*/
public void setPriority(Integer priority) {
public void setPriority(SubscriptionPriority priority) {
this.priority = priority;
}
/**
* @return the priority
*/
public Integer getPriority() {
public SubscriptionPriority getPriority() {
return priority;
}
}

View file

@ -36,6 +36,7 @@ import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.units.DataSizeUnit;
@ -44,7 +45,6 @@ import com.raytheon.uf.viz.datadelivery.subscription.xml.OperatorAdapter;
import com.raytheon.uf.viz.datadelivery.subscription.xml.PriorityRuleXML;
import com.raytheon.uf.viz.datadelivery.subscription.xml.RuleXML;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryGUIUtils.SubscriptionPriority;
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
import com.raytheon.uf.viz.datadelivery.utils.NameOperationItems;
import com.raytheon.uf.viz.datadelivery.utils.TypeOperationItems;
@ -69,6 +69,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* rules are only for future subscriptions.
* Jan 14, 2013 1286 djohnson Rule operators are now used as objects.
* Jan 17, 2013 1357 mpduff Moved DataSizeUnit.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
*
* </pre>
*
@ -543,17 +544,17 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
}
if (PRIORITY_TYPE.equals(ruleType)) {
Integer priority = ((PriorityRuleXML) ruleXml).getPriority();
SubscriptionPriority priority = ((PriorityRuleXML) ruleXml)
.getPriority();
int o = 0;
SubscriptionPriority[] priorityOptions = SubscriptionPriority
.values();
for (SubscriptionPriority item : priorityOptions) {
if (priority == item.getPriorityValue()) {
priorityCombo.select(o);
if (priority == item) {
priorityCombo.select(priorityCombo.indexOf(priority
.getPriorityName()));
break;
}
o++;
}
} else {
Integer latency = ((LatencyRuleXML) ruleXml).getLatency();
@ -732,12 +733,11 @@ public class CreateEditRuleDlg extends CaveSWTDialog {
if (PRIORITY_TYPE.equals(ruleType)) {
PriorityRuleXML rule = new PriorityRuleXML();
priorityVal = SubscriptionPriority.valueOf(priorityCombo.getText()
.toUpperCase());
priorityVal = SubscriptionPriority.fromPriorityName(priorityCombo
.getText());
for (SubscriptionPriority pri : SubscriptionPriority.values()) {
if (pri.equals(priorityVal)) {
priority = pri.getPriorityValue();
(rule).setPriority(priority);
rule.setPriority(pri);
break;
}
}

View file

@ -32,6 +32,7 @@ import javax.xml.bind.Unmarshaller;
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthService;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.localization.FileUpdatedMessage;
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
import com.raytheon.uf.common.localization.IPathManager;
@ -66,6 +67,7 @@ import com.raytheon.uf.viz.datadelivery.utils.TypeOperationItems;
* Sep 17, 2012 730 jpiatt Initial creation.
* Oct 23, 2012 1286 djohnson Hook into bandwidth management.
* Jan 04, 2013 1420 mpduff Move rules into a single file.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
*
* </pre>
*
@ -498,22 +500,23 @@ public class SystemRuleManager {
* @param cycleTimes
* @return
*/
public int getPriority(Subscription sub, Set<Integer> cycleTimes) {
public SubscriptionPriority getPriority(Subscription sub,
Set<Integer> cycleTimes) {
PriorityRulesXML rulesXml = this.getPriorityRules(false);
int priority = 3;
boolean found = false;
SubscriptionPriority priority = null;
for (PriorityRuleXML rule : rulesXml.getRules()) {
if (rule.matches(sub, cycleTimes)) {
if (rule.getPriority() < priority) {
if (priority == null
|| rule.getPriority().getPriorityValue() < priority
.getPriorityValue()) {
priority = rule.getPriority();
found = true;
}
}
}
// Default to normal priority
if (!found) {
priority = 2;
if (priority == null) {
priority = SubscriptionPriority.NORMAL;
}
return priority;

View file

@ -25,10 +25,7 @@ import java.util.Date;
import java.util.TimeZone;
import java.util.regex.Pattern;
import javax.xml.bind.annotation.XmlEnumValue;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
@ -55,6 +52,7 @@ import com.raytheon.uf.viz.core.VizApp;
* Dec 17, 2012 1435 mpduff Fix ThreadLocal implementation.
* Dec 18, 2012 1439 mpduff Change Regex to match invalid chars.
* Jan 04, 2013 1420 mpduff Change default priority to normal priority.
* Jan 25, 2013 1528 djohnson Subscription priority has moved up in the world to the Subscription class.
*
* </pre>
*
@ -108,67 +106,6 @@ public class DataDeliveryGUIUtils {
/** Name Required Message */
public static final String NAME_REQUIRED_MESSAGE = "Name required.\nA Subscription Name must be entered.";
/** Enumeration to use for subscription priorities */
public static enum SubscriptionPriority {
/** High Priority */
@XmlEnumValue("High")
HIGH("High", 1, new RGB(255, 0, 0)),
/** Default Priority */
@XmlEnumValue("Normal")
NORMAL("Normal", 2, new RGB(0, 255, 0)),
/** Low Priority */
@XmlEnumValue("Low")
LOW("Low", 3, new RGB(6, 122, 255));
/** Priority Setting */
private final String priorityName;
/** Numeric Value of the priority */
private Integer priorityValue;
/** Priority color for ui */
private RGB color;
private SubscriptionPriority(String priorityName,
Integer priorityValue, RGB color) {
this.priorityName = priorityName;
this.priorityValue = priorityValue;
this.color = color;
}
/**
* Get column name.
*
* @return Priority Name
*/
public String getPriorityName() {
return priorityName;
}
/**
* Get the integer value of the priority
*
* @return The integer value of the priority.
*/
public Integer getPriorityValue() {
return priorityValue;
}
@Override
public String toString() {
return priorityName;
}
/**
* Get the color.
*
* @return the color
*/
public RGB getColor() {
return color;
}
}
/**
* Constructor.
*/

View file

@ -453,7 +453,8 @@ public class DataDeliveryUtils {
.append(newline);
fmtStr.append("Provider : ").append(sub.getProvider()).append(newline);
fmtStr.append("Office ID: ").append(sub.getOfficeID()).append(newline);
fmtStr.append("Priority : ").append(sub.getPriority()).append(newline);
fmtStr.append("Priority : ")
.append(sub.getPriority().getPriorityValue()).append(newline);
fmtStr.append("Coverage: ").append(newline);
final Coverage coverage = sub.getCoverage();

View file

@ -58,7 +58,6 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import com.google.common.base.Strings;
import com.raytheon.uf.common.stats.data.DataPoint;
import com.raytheon.uf.common.stats.data.GraphData;
import com.raytheon.uf.common.stats.data.StatsData;
@ -83,6 +82,7 @@ import com.raytheon.uf.viz.stats.display.ScaleManager;
* ------------ ---------- ----------- --------------------------
* Oct 03, 2012 728 mpduff Initial creation.
* Jan 17, 2013 1357 mpduff Added mouse listeners.
* Jan 29, 2013 1523 mpduff Fix for count units.
*
* </pre>
*
@ -676,11 +676,10 @@ public class StatsDisplayCanvas extends Canvas {
String unit = graphData.getDisplayUnit();
StringBuilder yAxisLabel = new StringBuilder(graphTitle);
if (!Strings.isNullOrEmpty(unit) && !unit.equalsIgnoreCase(COUNT)
&& !view.equals(DataView.COUNT)) {
yAxisLabel.append(" (").append(unit).append(")");
} else if (view.equals(DataView.COUNT)) {
if (isCount(unit)) {
yAxisLabel.append(" Counts");
} else {
yAxisLabel.append(" (").append(unit).append(")");
}
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
@ -700,6 +699,10 @@ public class StatsDisplayCanvas extends Canvas {
t.dispose();
}
private boolean isCount(String unit) {
return view.equals(DataView.COUNT) || COUNT.equalsIgnoreCase(unit);
}
/**
* Draw the data on the canvas.
*

View file

@ -20,6 +20,8 @@
package com.raytheon.viz.gfe.actions;
import java.util.Map;
import com.raytheon.viz.gfe.Activator;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
@ -29,9 +31,8 @@ import org.eclipse.jface.resource.ImageDescriptor;
import com.raytheon.viz.gfe.core.msgs.Message;
import com.raytheon.viz.gfe.core.msgs.ShowISCGridsMsg;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.menus.UIElement;
/**
* Action to show the ISC grids
@ -44,44 +45,47 @@ import org.eclipse.swt.widgets.ToolItem;
* ------------ ---------- ----------- --------------------------
* 07/20/09 1995 bphillip Initial release
* 12/06/12 DR 15574 jzeng Change the image of
* the icon when it is activated
* 01/11/13 DR 15574 jzeng delete all fields to local variables
* the icon when it is activated
* 01/11/13 DR 15574 jzeng Change all fields to local variables
* 01/16/13 DR 15722 jzeng/randerson override updateElement()
* </pre>
*
* @author bphillip
* @version 1
*/
public class ShowISCGridsAction extends AbstractHandler {
public class ShowISCGridsAction extends AbstractHandler implements
IElementUpdater {
@Override
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
boolean current = Message.inquireLastMessage(ShowISCGridsMsg.class).show();
if (arg0.getTrigger() instanceof Event) {
Event e = (Event) arg0.getTrigger();
if ( e.widget instanceof ToolItem) {
ToolItem ti = (ToolItem) e.widget;
if (ti != null ){
ImageDescriptor id;
if (!current){
id = Activator.imageDescriptorFromPlugin(
Activator.PLUGIN_ID, "icons/isc1.gif" );
} else {
id = Activator.imageDescriptorFromPlugin(
Activator.PLUGIN_ID, "icons/isc0.gif" );
}
if (id != null){
Image img = id.createImage();
ti.setImage(img);
img.dispose();
}
}
}
}
boolean current = Message.inquireLastMessage(ShowISCGridsMsg.class)
.show();
new ShowISCGridsMsg(!current).send();
return null;
}
@Override
public void updateElement(UIElement element,
@SuppressWarnings("rawtypes") Map parameters) {
boolean current = Message.inquireLastMessage(ShowISCGridsMsg.class)
.show();
ImageDescriptor id;
if (current) {
id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
"icons/isc1.gif");
} else {
id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
"icons/isc0.gif");
}
if (id != null) {
element.setIcon(id);
}
}
}

View file

@ -19,6 +19,9 @@
**/
package com.raytheon.viz.gfe.core.msgs;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
/**
* TODO Add Description
*
@ -26,9 +29,12 @@ package com.raytheon.viz.gfe.core.msgs;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 30, 2011 randerso Initial creation
* Date Ticket# Engineer Description
* ------------ ---------- ---------------- --------------------------
* 03/30/11 randerso Initial creation
* 01/16/13 DR15722 jzeng/randerso override send() to
* force the UI to update the button
* whenever the message is sent.
*
* </pre>
*
@ -50,4 +56,15 @@ public class ShowISCGridsMsg extends Message {
public boolean show() {
return showIscGrids;
}
@Override
public void send() {
super.send();
ICommandService service = (ICommandService) PlatformUI.getWorkbench()
.getService(ICommandService.class);
service.refreshElements("com.raytheon.viz.gfe.actions.showISCGrids",
null);
}
}

View file

@ -623,6 +623,7 @@ public class DbParm extends Parm {
success &= allSaved;
}
// if any pending saves
if (sgr.size() > 0) {
if (doSave(sgr)) {
@ -632,13 +633,7 @@ public class DbParm extends Parm {
} else {
success = false;
}
}
// if any pending saves
if (sgr.size() > 0) {
if (!doSave(sgr)) {
success = false;
}
pendingUnlocks.clear();
}
if (success) {

View file

@ -23,6 +23,46 @@
id="${icao}fourPanel">
<contribute xsi:type="titleItem" titleText="------ Z/V ------"
id="${icao}Terminal4panelZV" />
<contribute xsi:type="bundleItem"
file="bundles/DefaultRadarFourPanelBlendedBestRes.xml" menuText="${elev1} ${elev2} ${elev6} ${elev8}"
id="${icao}${elev1}${elev2}${elev6}${elev8}Terminal4panelZV"
suppressErrors="${suppressErrors3}">
<substitute key="icao" value="${icao}" />
<substitute key="product1" value="180" />
<substitute key="product2" value="181" />
<substitute key="product3" value="" />
<substitute key="product4" value="" />
<substitute key="mode1" value="" />
<substitute key="product5" value="182" />
<substitute key="product6" value="183" />
<substitute key="product7" value="" />
<substitute key="product8" value="" />
<substitute key="mode2" value="" />
<substitute key="elevation1" value="${elev1}--${elev1}" />
<substitute key="elevation2" value="${elev2}--${elev2}" />
<substitute key="elevation3" value="${elev6}--${elev6}" />
<substitute key="elevation4" value="${elev8}--${elev8}" />
</contribute>
<contribute xsi:type="bundleItem"
file="bundles/DefaultRadarFourPanelBlendedBestRes.xml" menuText="${elev1} ${elev3} ${elev5} ${elev6}"
id="${icao}${elev1}${elev3}${elev5}${elev6}Terminal4panelZV"
suppressErrors="${suppressErrors3}">
<substitute key="icao" value="${icao}" />
<substitute key="product1" value="180" />
<substitute key="product2" value="181" />
<substitute key="product3" value="" />
<substitute key="product4" value="" />
<substitute key="mode1" value="" />
<substitute key="product5" value="182" />
<substitute key="product6" value="183" />
<substitute key="product7" value="" />
<substitute key="product8" value="" />
<substitute key="mode2" value="" />
<substitute key="elevation1" value="${elev1}--${elev1}" />
<substitute key="elevation2" value="${elev3}--${elev3}" />
<substitute key="elevation3" value="${elev5}--${elev5}" />
<substitute key="elevation4" value="${elev6}--${elev6}" />
</contribute>
<contribute xsi:type="bundleItem"
file="bundles/DefaultRadarFourPanelBlendedBestRes.xml" menuText="${elev1} ${elev2} ${elev3} ${elev4}"
id="${icao}${elev1}${elev2}${elev3}${elev4}Terminal4panelZV"
@ -38,14 +78,94 @@
<substitute key="product7" value="" />
<substitute key="product8" value="" />
<substitute key="mode2" value="" />
<substitute key="elevation1" value="${elev1}" />
<substitute key="elevation2" value="${elev2}" />
<substitute key="elevation3" value="${elev3}" />
<substitute key="elevation4" value="${elev4}" />
</contribute>
<substitute key="elevation1" value="${elev1}--${elev1}" />
<substitute key="elevation2" value="${elev2}--${elev2}" />
<substitute key="elevation3" value="${elev3}--${elev3}" />
<substitute key="elevation4" value="${elev4}--${elev4}" />
</contribute>
<contribute xsi:type="bundleItem"
file="bundles/DefaultRadarFourPanelBlendedBestRes.xml" menuText="${elev3} ${elev7} ${elev8} ${elev9}"
id="${icao}${elev3}${elev7}${elev8}${elev9}Terminal4panelZV"
suppressErrors="${suppressErrors3}">
<substitute key="icao" value="${icao}" />
<substitute key="product1" value="180" />
<substitute key="product2" value="181" />
<substitute key="product3" value="" />
<substitute key="product4" value="" />
<substitute key="mode1" value="" />
<substitute key="product5" value="182" />
<substitute key="product6" value="183" />
<substitute key="product7" value="" />
<substitute key="product8" value="" />
<substitute key="mode2" value="" />
<substitute key="elevation1" value="${elev3}--${elev3}" />
<substitute key="elevation2" value="${elev7}--${elev7}" />
<substitute key="elevation3" value="${elev8}--${elev8}" />
<substitute key="elevation4" value="${elev9}--${elev9}" />
</contribute>
<contribute xsi:type="bundleItem"
file="bundles/DefaultRadarFourPanelBlendedBestRes.xml" menuText="${elev8} ${elev9} ${elev10} ${elev12}"
id="${icao}${elev8}${elev9}${elev10}${elev12}Terminal4panelZV"
suppressErrors="${suppressErrors3}">
<substitute key="icao" value="${icao}" />
<substitute key="product1" value="180" />
<substitute key="product2" value="181" />
<substitute key="product3" value="" />
<substitute key="product4" value="" />
<substitute key="mode1" value="" />
<substitute key="product5" value="182" />
<substitute key="product6" value="183" />
<substitute key="product7" value="" />
<substitute key="product8" value="" />
<substitute key="mode2" value="" />
<substitute key="elevation1" value="${elev8}--${elev8}" />
<substitute key="elevation2" value="${elev9}--${elev9}" />
<substitute key="elevation3" value="${elev10}--${elev10}" />
<substitute key="elevation4" value="${elev12}--${elev12}" />
</contribute>
<contribute xsi:type="separator" id="below${icao}Terminal4panelZSRM8" />
<contribute xsi:type="titleItem" titleText="------ Z/SRM8 ------"
id="${icao}Terminal4panelZSRM8" />
<contribute xsi:type="bundleItem"
file="bundles/DefaultRadarFourPanelBlendedBestRes.xml" menuText="${elev1} ${elev2} ${elev6} ${elev8}"
id="${icao}${elev1}${elev2}${elev6}${elev8}Terminal4panelZSRM8"
suppressErrors="${suppressErrors3}">
<substitute key="icao" value="${icao}" />
<substitute key="product1" value="180" />
<substitute key="product2" value="181" />
<substitute key="product3" value="" />
<substitute key="product4" value="" />
<substitute key="mode1" value="" />
<substitute key="product5" value="182" />
<substitute key="product6" value="" />
<substitute key="product7" value="" />
<substitute key="product8" value="" />
<substitute key="mode2" value="SRM8" />
<substitute key="elevation1" value="${elev1}--${elev1}" />
<substitute key="elevation2" value="${elev2}--${elev2}" />
<substitute key="elevation3" value="${elev6}--${elev6}" />
<substitute key="elevation4" value="${elev8}--${elev8}" />
</contribute>
<contribute xsi:type="bundleItem"
file="bundles/DefaultRadarFourPanelBlendedBestRes.xml" menuText="${elev1} ${elev3} ${elev5} ${elev6}"
id="${icao}${elev1}${elev3}${elev5}${elev6}Terminal4panelZSRM8"
suppressErrors="${suppressErrors3}">
<substitute key="icao" value="${icao}" />
<substitute key="product1" value="180" />
<substitute key="product2" value="181" />
<substitute key="product3" value="" />
<substitute key="product4" value="" />
<substitute key="mode1" value="" />
<substitute key="product5" value="182" />
<substitute key="product6" value="" />
<substitute key="product7" value="" />
<substitute key="product8" value="" />
<substitute key="mode2" value="SRM8" />
<substitute key="elevation1" value="${elev1}--${elev1}" />
<substitute key="elevation2" value="${elev3}--${elev3}" />
<substitute key="elevation3" value="${elev5}--${elev5}" />
<substitute key="elevation4" value="${elev6}--${elev6}" />
</contribute>
<contribute xsi:type="bundleItem"
file="bundles/DefaultRadarFourPanelBlendedBestRes.xml" menuText="${elev1} ${elev2} ${elev3} ${elev4}"
id="${icao}${elev1}${elev2}${elev3}${elev4}Terminal4panelZSRM8"
@ -60,11 +180,51 @@
<substitute key="product6" value="" />
<substitute key="product7" value="" />
<substitute key="product8" value="" />
<substitute key="mode2" value="SRM8" />
<substitute key="elevation1" value="${elev1}--${elev1}" />
<substitute key="elevation2" value="${elev2}--${elev2}" />
<substitute key="elevation3" value="${elev3}--${elev3}" />
<substitute key="elevation4" value="${elev4}--${elev4}" />
</contribute>
<contribute xsi:type="bundleItem"
file="bundles/DefaultRadarFourPanelBlendedBestRes.xml" menuText="${elev3} ${elev7} ${elev8} ${elev9}"
id="${icao}${elev3}${elev7}${elev8}${elev9}Terminal4panelZSRM8"
suppressErrors="${suppressErrors3}">
<substitute key="icao" value="${icao}" />
<substitute key="product1" value="180" />
<substitute key="product2" value="181" />
<substitute key="product3" value="" />
<substitute key="product4" value="" />
<substitute key="mode1" value="" />
<substitute key="product5" value="182" />
<substitute key="product6" value="" />
<substitute key="product7" value="" />
<substitute key="product8" value="" />
<substitute key="mode2" value="SRM8" />
<substitute key="elevation1" value="${elev1}" />
<substitute key="elevation2" value="${elev2}" />
<substitute key="elevation3" value="${elev3}" />
<substitute key="elevation4" value="${elev4}" />
</contribute>
<substitute key="elevation1" value="${elev3}--${elev3}" />
<substitute key="elevation2" value="${elev7}--${elev7}" />
<substitute key="elevation3" value="${elev8}--${elev8}" />
<substitute key="elevation4" value="${elev9}--${elev9}" />
</contribute>
<contribute xsi:type="bundleItem"
file="bundles/DefaultRadarFourPanelBlendedBestRes.xml" menuText="${elev8} ${elev9} ${elev10} ${elev12}"
id="${icao}${elev8}${elev9}${elev10}${elev12}Terminal4panelZSRM8"
suppressErrors="${suppressErrors3}">
<substitute key="icao" value="${icao}" />
<substitute key="product1" value="180" />
<substitute key="product2" value="181" />
<substitute key="product3" value="" />
<substitute key="product4" value="" />
<substitute key="mode1" value="" />
<substitute key="product5" value="182" />
<substitute key="product6" value="" />
<substitute key="product7" value="" />
<substitute key="product8" value="" />
<substitute key="mode2" value="SRM8" />
<substitute key="elevation1" value="${elev8}--${elev8}" />
<substitute key="elevation2" value="${elev9}--${elev9}" />
<substitute key="elevation3" value="${elev10}--${elev10}" />
<substitute key="elevation4" value="${elev12}--${elev12}" />
</contribute>
</contribute>
</menuTemplate>

View file

@ -60,8 +60,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* uses the font.
* Feb 03, 2012 14317 mhuang Make alarm display window wider
* Sep 6, 2012 13365 rferrel Accumulate and Display fix.
* Sep 25, 2012 1196 lvenable Dialog refactor for AlarmDisplayWindow. Added DO_NOT_BLOCK.
* Dec 31, 2012 15651 mgamazaychikov Added an argument to re-factored PrintDisplay.print
* Sep 25, 2012 1196 lvenable Dialog refactor for AlarmDisplayWindow.Added DO_NOT_BLOCK.
*
* </pre>
*
@ -199,7 +198,7 @@ public class AlarmDisplayWindow extends CaveSWTDialog {
}
PrintDisplay.print(lines.toString(), text.getFont()
.getFontData()[0], -1, UFStatus
.getFontData()[0], UFStatus
.getHandler(AlarmDisplayWindow.class));
}
});
@ -208,7 +207,7 @@ public class AlarmDisplayWindow extends CaveSWTDialog {
@Override
public void widgetSelected(SelectionEvent event) {
PrintDisplay.print(text.getText(),
text.getFont().getFontData()[0], -1,
text.getFont().getFontData()[0],
UFStatus.getHandler(AlarmDisplayWindow.class));
}
});

View file

@ -309,8 +309,7 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox;
* 28Nov2012 14842 M.Gamazaychikov Re-wrote processPopup method
* 13Dec2012 1353 rferrel Change to make edit cancel message not
* dispaly the red had kill job message.
* 31Dec2012 15651 M.Gamazaychikov Added an argument to re-factored PrintDisplay.print
* 10JAN2012 15704 M.Gamazaychikov Added setting userKeyPressed to false in verifyText method.
* 10JAN2012 15704 M.Gamazaychikov Added setting userKeyPressed to false in verifyText method
* 22JAN2013 1496 rferrel Query for loading products no longer on the UI thread.
* </pre>
*
@ -4443,8 +4442,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
*/
private void printAllText() {
FontData fontData = textEditor.getFont().getFontData()[0];
PrintDisplay.print(textEditor.getText(), fontData, charWrapCol,
statusHandler);
PrintDisplay.print(textEditor.getText(), fontData, statusHandler);
}
/**
@ -4467,8 +4465,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
String tmpText = textEditor.getText();
Point point = textEditor.getSelection();
FontData fontData = textEditor.getFont().getFontData()[0];
PrintDisplay.print(textEditor.getSelectionText(), fontData,
charWrapCol, statusHandler);
PrintDisplay.print(textEditor.getSelectionText(), fontData,
statusHandler);
textEditor.setText(tmpText);
textEditor.setSelection(point);
}

View file

@ -43,7 +43,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Sep 15, 2011 10557 rferrel Initial creation
* Jul 17, 2012 14274 rferrel Now use eclipse Printer instead of awt.
* Text is printed using same font as the GUI
* Dec 31, 2012 15651 mgamazaychikov Added setFont method to scale font for printing
* Dec 31, 2012 15651 M Gamazaychikov Added setFont method to scale font for printing
*
* </pre>
*
@ -53,7 +53,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
public class PrintDisplay {
public static void print(final String printedText, final FontData fontData,
int aLineWidth, IUFStatusHandler statusHandler) {
IUFStatusHandler statusHandler) {
PrinterData data = Printer.getDefaultPrinterData();
if (data == null) {
statusHandler.handle(Priority.PROBLEM,
@ -67,11 +67,9 @@ public class PrintDisplay {
}
final Printer printer = new Printer(data);
PrintDisplay pd = new PrintDisplay(printer, printedText, fontData, aLineWidth);
PrintDisplay pd = new PrintDisplay(printer, printedText, fontData);
pd.printJob();
}
private int lineWidth;
private Printer printer;
@ -105,16 +103,10 @@ public class PrintDisplay {
int end;
private PrintDisplay(Printer printer, String text, FontData fontData, int aWidth) {
private PrintDisplay(Printer printer, String text, FontData fontData) {
this.printer = printer;
this.textToPrint = text;
this.printerFontData = fontData;
if (aWidth == -1) {
this.lineWidth = 69;
}
else {
this.lineWidth = aWidth;
}
}
private void printJob() {
@ -128,6 +120,19 @@ public class PrintDisplay {
}
protected void setFont() {
/*
* get the max number of characters in a line of text
* and add a length of tab
*/
String [] textLines = textToPrint.split("[\n]");
int maxChar = textLines[0].length();
for ( int counter=1; counter<textLines.length; counter++){
if (textLines[counter].length() > maxChar){
maxChar = textLines[counter].length();
}
}
maxChar = maxChar + 4;
/*
* get the original font size and set the gc font.
*/
@ -138,8 +143,8 @@ public class PrintDisplay {
/*
* Create a buffer for computing line width in pixels.
*/
StringBuilder aBuffer = new StringBuilder(lineWidth);
for (int i = 0; i < lineWidth; i++) {
StringBuilder aBuffer = new StringBuilder(maxChar);
for (int i = 0; i < maxChar; i++) {
aBuffer.append(' ');
}
/*

View file

@ -136,6 +136,20 @@ public abstract class AbstractVizPerspectiveManager implements
@Override
public void partDeactivated(IWorkbenchPart part) {
// update editor on last selected modal tool
if (part instanceof IEditorPart
&& part instanceof IDisplayPaneContainer) {
AbstractVizPerspectiveManager mgr = VizPerspectiveListener
.getCurrentPerspectiveManager();
if (mgr != null) {
for (AbstractModalTool tool : mgr.getToolManager()
.getSelectedModalTools()) {
if (tool.getCurrentEditor() == part) {
tool.deactivate();
}
}
}
}
}
@Override
@ -362,12 +376,6 @@ public abstract class AbstractVizPerspectiveManager implements
page.hideEditor(ref);
}
for (AbstractModalTool tool : toolManager.getSelectedModalTools()) {
if (tool != null) {
tool.deactivate();
}
}
deactivateDialogs();
deactivateContexts();
removeFromStatusLine();

View file

@ -156,6 +156,7 @@ public abstract class AbstractModalTool extends AbstractTool {
this.setEnabled(false);
if (editor != null) {
deactivateTool();
editor = null;
}
}

View file

@ -15,6 +15,7 @@ import org.geotools.referencing.GeodeticCalculator;
import com.raytheon.uf.common.dataplugin.warning.config.PathcastConfiguration;
import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration;
import com.raytheon.uf.common.dataplugin.warning.gis.PreparedGeometryCollection;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.geospatial.SpatialQueryResult;
import com.raytheon.uf.viz.core.exception.VizException;
@ -26,7 +27,6 @@ import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
/**
*
@ -146,7 +146,7 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
boolean userDirections = Boolean.valueOf(String.valueOf(attributes
.get(useDirectionField)));
if (userDirections) {
PreparedGeometry prepGeom = PreparedGeometryFactory.prepare(geom);
PreparedGeometry prepGeom = new PreparedGeometryCollection(geom);
if (prepGeom.intersects(searchArea) && !prepGeom.within(searchArea)) {
Geometry intersection = searchArea.intersection(geom);
partOfArea = GisUtil.asStringList(calculateLocationPortion(

View file

@ -50,6 +50,7 @@ import com.raytheon.viz.warngen.gui.WarngenLayer;
import com.raytheon.viz.warngen.suppress.SuppressMap;
import com.raytheon.viz.warngen.util.Abbreviation;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
/**
* Area
@ -176,6 +177,7 @@ public class Area {
GeodeticCalculator gc = new GeodeticCalculator();
for (GeospatialData regionFeature : countyMap.values()) {
Geometry regionGeom = regionFeature.geometry;
PreparedGeometry preparedRegionGeom = regionFeature.prepGeom;
AffectedAreas area = new AffectedAreas();
area.name = regionFeature.attributes.get(areaField).toString();
area.fips = regionFeature.attributes.get(fipsField).toString();
@ -237,7 +239,7 @@ public class Area {
if (ptFeatures != null) {
List<String> pointList = new ArrayList<String>();
for (SpatialQueryResult ptRslt : ptFeatures) {
if (regionGeom.contains(ptRslt.geometry)) {
if (preparedRegionGeom.contains(ptRslt.geometry)) {
pointList.add(String.valueOf(ptRslt.attributes
.get(pointField)));
}
@ -331,7 +333,7 @@ public class Area {
}
return retVal;
}
public static List<String> converFeAreaToPartList(String feArea) {
final List<String> partList = new ArrayList<String>();
if (feArea == null) {

View file

@ -29,6 +29,7 @@ import java.util.List;
import org.geotools.referencing.GeodeticCalculator;
import com.raytheon.uf.common.dataplugin.warning.util.GeometryUtil;
import com.raytheon.viz.warngen.suppress.SuppressMap;
import com.vividsolutions.jts.algorithm.CGAlgorithms;
import com.vividsolutions.jts.geom.Coordinate;
@ -37,7 +38,6 @@ import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.MultiPolygon;
import com.vividsolutions.jts.geom.Polygon;
/**
@ -206,27 +206,21 @@ public class GisUtil {
yDirection = Direction.SOUTH;
}
List<Geometry> geoms = new ArrayList<Geometry>(geom.getNumGeometries());
GeometryUtil.buildGeometryList(geoms, geom);
boolean isExtreme = false;
Coordinate[] coords;
if (geom instanceof Polygon) {
LineString lineString = ((Polygon) geom).getExteriorRing();
coords = lineString.getCoordinates();
isExtreme = isExtreme(coords, point,
(extremaThresholdX + extremaThresholdY) / 2.0);
} else if (geom instanceof MultiPolygon) {
int geoms = ((MultiPolygon) geom).getNumGeometries();
for (int i = 0; i < geoms; i++) {
LineString lineString = ((Polygon) ((MultiPolygon) geom)
.getGeometryN(i)).getExteriorRing();
coords = lineString.getCoordinates();
if (isExtreme(coords, point,
for (Geometry g : geoms) {
if (g instanceof Polygon) {
LineString lineString = ((Polygon) g).getExteriorRing();
if (isExtreme(lineString.getCoordinates(), point,
(extremaThresholdX + extremaThresholdY) / 2.0)) {
isExtreme = true;
break;
}
}
}
EnumSet<Direction> retVal = EnumSet.noneOf(Direction.class);
if (xDirection != null && !suppressType.equals(SuppressMap.EAST_WEST)

View file

@ -30,6 +30,7 @@ import org.geotools.referencing.operation.DefaultMathTransformFactory;
import org.opengis.metadata.spatial.PixelOrientation;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.dataplugin.warning.gis.PreparedGeometryCollection;
import com.raytheon.uf.common.dataplugin.warning.util.GeometryUtil;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.exception.VizException;
@ -44,7 +45,6 @@ import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineSegment;
import com.vividsolutions.jts.geom.Polygon;
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
/**
* Utility for polygon operations
@ -57,7 +57,7 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
* ------------ ---------- ----------- --------------------------
* Dec 1, 2010 mschenke Initial creation
* 12/06/2012 DR 15559 Qinglu Lin Added round() methods.
*
*
* </pre>
*
* @author mschenke
@ -850,7 +850,7 @@ public class PolygonUtil {
List<PreparedGeometry> prepped = new ArrayList<PreparedGeometry>(
geomList.size());
for (Geometry g : geomList) {
prepped.add(PreparedGeometryFactory.prepare(g));
prepped.add(new PreparedGeometryCollection(g));
}
GeometryFactory gf = warningArea.getFactory();
@ -931,56 +931,54 @@ public class PolygonUtil {
}
}
}
public static void truncate(List<Coordinate >coordinates, int decimalPlaces) {
public static void truncate(List<Coordinate> coordinates, int decimalPlaces) {
for (Coordinate coordinate : coordinates) {
truncate(coordinate, decimalPlaces);
}
}
public static void truncate(Coordinate[] coordinates, int decimalPlaces) {
for (Coordinate coordinate : coordinates) {
truncate(coordinate, decimalPlaces);
}
}
public static void truncate(Coordinate coordinate, int decimalPlaces) {
double x = coordinate.x * Math.pow(10, decimalPlaces);
double y = coordinate.y * Math.pow(10, decimalPlaces);
x = x >= 0 ? Math.floor(x) : Math.ceil(x);
y = y >= 0 ? Math.floor(y) : Math.ceil(y);
coordinate.x = x / Math.pow(10, decimalPlaces);
coordinate.y = y / Math.pow(10, decimalPlaces);
}
public static void round(List<Coordinate >coordinates, int decimalPlaces) {
public static void round(List<Coordinate> coordinates, int decimalPlaces) {
for (Coordinate coordinate : coordinates) {
round(coordinate, decimalPlaces);
}
}
public static void round(Coordinate[] coordinates, int decimalPlaces) {
for (Coordinate coordinate : coordinates) {
round(coordinate, decimalPlaces);
}
}
/**
* round()
* Rounding coordinates, instead of truncating them.
*
* History
* 12/06/2012 DR 15559 Qinglu Lin Created.
* round() Rounding coordinates, instead of truncating them.
*
* History 12/06/2012 DR 15559 Qinglu Lin Created.
*/
public static void round(Coordinate coordinate, int decimalPlaces) {
double x = coordinate.x * Math.pow(10, decimalPlaces);
double y = coordinate.y * Math.pow(10, decimalPlaces);
x = Math.round(x);
y = Math.round(y);
coordinate.x = x / Math.pow(10, decimalPlaces);
coordinate.y = y / Math.pow(10, decimalPlaces);
}

View file

@ -24,13 +24,13 @@ import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Matcher;
@ -40,10 +40,15 @@ import javax.measure.converter.UnitConverter;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.PlatformUI;
import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.GeodeticCalculator;
@ -60,6 +65,7 @@ import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialData;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialFactory;
import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialMetadata;
import com.raytheon.uf.common.dataplugin.warning.gis.PreparedGeometryCollection;
import com.raytheon.uf.common.dataplugin.warning.util.CountyUserData;
import com.raytheon.uf.common.dataplugin.warning.util.GeometryUtil;
import com.raytheon.uf.common.geospatial.DestinationGeodeticCalculator;
@ -118,7 +124,6 @@ import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;
import com.vividsolutions.jts.geom.TopologyException;
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKTReader;
@ -152,8 +157,8 @@ import com.vividsolutions.jts.io.WKTReader;
* 12/13/2012 DR 15559 Qinglu Lin Added code to call WarngenUIState's adjustPolygon().
* 12/17/2012 DR 15571 Qinglu Lin For hydro products,futurePoints is null. Resolved an issue caused by trying to get
* Coordinate[] from futurePoints.
* 12/18/2012 DR 15571 Qinglu Lin Resolved coordinate issue in TML line caused by clicking Restart button.
*
* 12/18/2012 DR 15571 Qinglu Lin Resolved coordinate issue in TML line caused by clicking Restart button.
*
* </pre>
*
* @author mschenke
@ -181,6 +186,60 @@ public class WarngenLayer extends AbstractStormTrackResource {
int nx, ny;
}
private class CustomMaps extends Job {
private Set<String> customMaps = new HashSet<String>();
private Set<String> mapsToLoad;
private MapManager manager;
public CustomMaps() {
super("Loading WarnGen Maps");
manager = MapManager.getInstance(descriptor);
}
@Override
protected IStatus run(IProgressMonitor monitor) {
boolean done = false;
while (!done) {
Set<String> toLoad = null;
synchronized (this) {
if (mapsToLoad != null) {
toLoad = mapsToLoad;
mapsToLoad = null;
}
}
if (toLoad != null) {
for (String loaded : customMaps) {
manager.unloadMap(loaded);
}
for (String load : toLoad) {
manager.loadMapByName(load);
}
issueRefresh();
}
done = mapsToLoad == null;
}
return Status.OK_STATUS;
}
public void loadCustomMaps(Collection<String> maps) {
synchronized (this) {
mapsToLoad = new HashSet<String>(maps);
}
schedule();
}
public void clearMaps() {
loadCustomMaps(new HashSet<String>());
}
}
private static Map<String, GeospatialDataList> siteMap = new HashMap<String, GeospatialDataList>();
private static Map<String, Geometry> timezoneMap = new HashMap<String, Geometry>();
@ -220,7 +279,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
private boolean boxEditable = true;
private Map<MapDescriptor, Set<String>> loadedCustomMaps;
private CustomMaps customMaps;
protected Mode lastMode = null;
@ -260,7 +319,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
super(resourceData, loadProperties, descriptor);
displayState.displayType = DisplayType.POINT;
getCapability(ColorableCapability.class).setColor(WHITE);
loadedCustomMaps = new HashMap<MapDescriptor, Set<String>>();
customMaps = new CustomMaps();
try {
dialogConfig = DialogConfiguration
@ -385,13 +444,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
@Override
protected void disposeInternal() {
for (Entry<MapDescriptor, Set<String>> entry : loadedCustomMaps
.entrySet()) {
for (String map : entry.getValue()) {
MapManager.getInstance(entry.getKey()).unloadMap(map);
}
}
loadedCustomMaps.clear();
customMaps.clearMaps();
super.disposeInternal();
@ -432,7 +485,6 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
super.initInternal(target);
VizApp.runSync(new Runnable() {
@Override
public void run() {
createDialog();
@ -493,17 +545,17 @@ public class WarngenLayer extends AbstractStormTrackResource {
displayState.geomChanged = false;
}
if (warningAction == null || warningAction == WarningAction.NEW) {
// Initialize box
if (((configuration.isTrackEnabled() == false || configuration
.getPathcastConfig() == null) && this.displayState.displayType != DisplayType.POLY)
|| frameCount == 1) {
createSquare();
resetInitialFrame();
} else {
redrawBoxFromTrack();
}
// Initialize box
if (((configuration.isTrackEnabled() == false || configuration
.getPathcastConfig() == null) && this.displayState.displayType != DisplayType.POLY)
|| frameCount == 1) {
createSquare();
resetInitialFrame();
} else {
redrawBoxFromTrack();
}
} else {
redrawBoxFromTrack();
redrawBoxFromTrack();
}
}
@ -746,7 +798,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
local);
gd.attributes.put(
GeospatialDataList.LOCAL_PREP_GEOM,
PreparedGeometryFactory.prepare(local));
new PreparedGeometryCollection(local));
locals.add(local);
}
@ -825,43 +877,11 @@ public class WarngenLayer extends AbstractStormTrackResource {
String areaSource = config.getGeospatialConfig().getAreaSource();
geoData = siteMap.get(areaSource + "." + site);
}// end synchronize
loadCustomMaps(descriptor, config);
this.configuration = config;
System.out.println("Time to init warngen config: "
+ (System.currentTimeMillis() - t0));
}
customMaps.loadCustomMaps(Arrays.asList(config.getMaps()));
protected void loadCustomMaps(MapDescriptor descriptor,
WarngenConfiguration config) {
if (config == null || descriptor == null) {
return;
}
long t1 = System.currentTimeMillis();
MapManager mapManager = MapManager.getInstance(descriptor);
List<String> maps = Arrays.asList(config.getMaps());
Set<String> loadedCustomMaps = this.loadedCustomMaps.get(descriptor);
if (loadedCustomMaps == null) {
loadedCustomMaps = new HashSet<String>();
this.loadedCustomMaps.put(descriptor, loadedCustomMaps);
}
Iterator<String> it = loadedCustomMaps.iterator();
while (it.hasNext()) {
String map = it.next();
if (!maps.contains(map)) {
it.remove();
mapManager.unloadMap(map);
}
}
for (String map : maps) {
if (!loadedCustomMaps.contains(map)) {
if (!mapManager.isMapLoaded(map)) {
mapManager.loadMapByName(map);
loadedCustomMaps.add(map);
}
}
}
System.out.println("Time to load custom maps: "
+ (System.currentTimeMillis() - t1));
this.configuration = config;
System.out.println("Total time to init warngen config = "
+ (System.currentTimeMillis() - t0) + "ms");
}
public GeospatialData[] getGeodataFeatures(String key) {
@ -1103,30 +1123,17 @@ public class WarngenLayer extends AbstractStormTrackResource {
dialog = new WarngenDialog(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell(), this);
dialog.open();
addDialogDisposeListener(descriptor);
} else {
showDialog(true);
}
}
public void addDialogDisposeListener(final MapDescriptor descriptor) {
if (dialog != null) {
dialog.getShell().addDisposeListener(new DisposeListener() {
dialog.addListener(SWT.Dispose, new Listener() {
@Override
public void widgetDisposed(DisposeEvent e) {
public void handleEvent(Event event) {
descriptor.getResourceList().removeRsc(WarngenLayer.this);
}
});
} else {
showDialog(true);
}
}
@Override
public void setDescriptor(MapDescriptor descriptor) {
super.setDescriptor(descriptor);
addDialogDisposeListener(descriptor);
loadCustomMaps(descriptor, configuration);
}
/**
* Show the WarnGen dialog and move it to the front.
*/
@ -1611,15 +1618,15 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (hatched != null) {
// DR 15559
Coordinate[] coords = hatched.getCoordinates();
PolygonUtil.round(coords, 2);
state.adjustPolygon(coords);
GeometryFactory gf = new GeometryFactory();
LinearRing lr = gf.createLinearRing(coords);
state.setWarningPolygon(gf.createPolygon(lr, null));
updateWarnedAreas(true, true);
issueRefresh();
// End of DR 15559
state.snappedToArea = true;
PolygonUtil.round(coords, 2);
state.adjustPolygon(coords);
GeometryFactory gf = new GeometryFactory();
LinearRing lr = gf.createLinearRing(coords);
state.setWarningPolygon(gf.createPolygon(lr, null));
updateWarnedAreas(true, true);
issueRefresh();
// End of DR 15559
state.snappedToArea = true;
}
System.out.println("Time to createWarningPolygon: "
+ (System.currentTimeMillis() - t0) + "ms");
@ -1838,16 +1845,20 @@ public class WarngenLayer extends AbstractStormTrackResource {
Coordinate[] cc = null;
switch (stormTrackState.displayType) {
case POINT:
cc = new Coordinate[] { stormTrackState.futurePoints == null ? stormTrackState.dragMePoint
.getCoordinate() : stormTrackState.futurePoints[0].coord };
if (warningAction == null || warningAction == WarningAction.NEW || warningAction == WarningAction.CON
|| warningAction == WarningAction.CAN) {
Coordinate coord = new Coordinate(stormTrackState.dragMePoint.getCoordinate());
DataTime currentDataTime = new DataTime(SimulatedTime.getSystemTime().getTime());
if (stormTrackState.compuateCurrentStormCenter(coord,currentDataTime))
cc = new Coordinate[] {coord};
}
break;
cc = new Coordinate[] { stormTrackState.futurePoints == null ? stormTrackState.dragMePoint
.getCoordinate() : stormTrackState.futurePoints[0].coord };
if (warningAction == null || warningAction == WarningAction.NEW
|| warningAction == WarningAction.CON
|| warningAction == WarningAction.CAN) {
Coordinate coord = new Coordinate(
stormTrackState.dragMePoint.getCoordinate());
DataTime currentDataTime = new DataTime(SimulatedTime
.getSystemTime().getTime());
if (stormTrackState.compuateCurrentStormCenter(coord,
currentDataTime))
cc = new Coordinate[] { coord };
}
break;
case POLY:
Coordinate[] polyPoints = stormTrackState.dragMeLine
.getCoordinates();
@ -2357,8 +2368,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
+ e.getLocalizedMessage(), e);
}
}
public void setWarningAction(WarningAction warningAction) {
this.warningAction = warningAction;
this.warningAction = warningAction;
}
}

View file

@ -20,6 +20,7 @@
package com.raytheon.viz.warngen.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
@ -37,8 +38,10 @@ import com.raytheon.uf.common.dataplugin.warning.UGCZone;
import com.raytheon.uf.common.dataplugin.warning.WarningRecord;
import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
import com.raytheon.uf.common.dataplugin.warning.util.AnnotationUtil;
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
import com.raytheon.uf.common.site.SiteMap;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -46,10 +49,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.SimulatedTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.viz.core.alerts.AlertMessage;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
import com.raytheon.uf.viz.core.catalog.ScriptCreator;
import com.raytheon.uf.viz.core.comm.Connector;
import com.raytheon.uf.viz.core.rsc.ResourceType;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.alerts.IAlertObserver;
import com.raytheon.viz.alerts.observers.ProductAlertObserver;
import com.raytheon.viz.core.mode.CAVEMode;
@ -187,7 +188,8 @@ public class CurrentWarnings {
* @param phenSigs
* @return
*/
public List<AbstractWarningRecord> getCorrectableWarnings(AbstractWarningRecord warnRec) {
public List<AbstractWarningRecord> getCorrectableWarnings(
AbstractWarningRecord warnRec) {
List<AbstractWarningRecord> rval = new ArrayList<AbstractWarningRecord>();
Calendar current = Calendar.getInstance();
Calendar end = Calendar.getInstance();
@ -197,24 +199,28 @@ public class CurrentWarnings {
for (AbstractWarningRecord warning : records) {
String phensig = warning.getPhensig();
String etn = warning.getEtn();
if (warnRec.getPhensig().equals(phensig) && warnRec.getEtn().equals(etn)) {
WarningAction action = WarningAction.valueOf(warning.getAct());
if (warnRec.getPhensig().equals(phensig)
&& warnRec.getEtn().equals(etn)) {
WarningAction action = WarningAction.valueOf(warning
.getAct());
end.setTime(warning.getStartTime().getTime());
end.add(Calendar.MINUTE, 10);
TimeRange t = new TimeRange(warning.getStartTime().getTime(),
end.getTime());
if ((action == WarningAction.NEW || action == WarningAction.CON || action == WarningAction.EXT)
TimeRange t = new TimeRange(warning.getStartTime()
.getTime(), end.getTime());
if ((action == WarningAction.NEW
|| action == WarningAction.CON || action == WarningAction.EXT)
&& t.contains(current.getTime())) {
rval.add(warning);
} else if (action == WarningAction.CAN || action == WarningAction.EXP) {
} else if (action == WarningAction.CAN
|| action == WarningAction.EXP) {
rval.clear();
return rval;
}
}
}
}
return rval;
}
@ -253,7 +259,7 @@ public class CurrentWarnings {
for (AbstractWarningRecord warning : warnings) {
if (getAction(warning.getAct()) == WarningAction.CON) {
if (rval != null) {
//rval.setAct("CON");
// rval.setAct("CON");
rval.setGeometry(warning.getGeometry());
rval.setCountyheader(warning.getCountyheader());
rval.setUgczones(warning.getUgczones());
@ -421,7 +427,10 @@ public class CurrentWarnings {
Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
constraints.put("officeid", new RequestConstraint(officeId));
long t0 = System.currentTimeMillis();
List<AbstractWarningRecord> warnings = requestRecords(constraints);
System.out.println("Time to request CurrentWarnings records: "
+ (System.currentTimeMillis() - t0) + "ms");
processRecords(warnings);
}
@ -472,6 +481,10 @@ public class CurrentWarnings {
}
}
if (dataURIs.size() == 0) {
return;
}
Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
RequestConstraint constraint = new RequestConstraint(null,
ConstraintType.IN);
@ -534,25 +547,16 @@ public class CurrentWarnings {
private static List<AbstractWarningRecord> requestRecords(
Map<String, RequestConstraint> constraints) {
List<AbstractWarningRecord> newRecords = new ArrayList<AbstractWarningRecord>();
Object[] resp;
LayerProperty lp = new LayerProperty();
try {
String tableName = AnnotationUtil.getTableName(getWarningClass());
constraints.put("pluginName", new RequestConstraint(tableName));
lp.setDesiredProduct(ResourceType.PLAN_VIEW);
lp.setEntryQueryParameters(constraints, false);
lp.setNumberOfImages(9999);
String script = ScriptCreator.createScript(lp);
if (script != null) {
resp = Connector.getInstance().connect(script, null, 60000);
for (int i = 0; i < resp.length; i++) {
newRecords.add((AbstractWarningRecord) resp[i]);
}
}
} catch (Exception e) {
DbQueryRequest request = new DbQueryRequest();
request.setConstraints(constraints);
request.setEntityClass(getWarningClass());
DbQueryResponse response = (DbQueryResponse) ThriftClient
.sendRequest(request);
newRecords.addAll(Arrays.asList(response
.getEntityObjects(AbstractWarningRecord.class)));
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, "Error retreiving warnings",
e);
}

View file

@ -22,8 +22,8 @@ package com.raytheon.viz.warnings.rsc;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
@ -33,14 +33,10 @@ import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.SimulatedTime;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.viz.core.rsc.jts.JTSCompiler;
@ -70,132 +66,38 @@ import com.vividsolutions.jts.geom.Geometry;
public class WarningsResource extends AbstractWWAResource {
protected static class RepaintHeartbeat extends TimerTask {
protected static class RefreshTimerTask extends TimerTask {
private final HashSet<AbstractVizResource<?, ?>> resourceSet = new HashSet<AbstractVizResource<?, ?>>();
private boolean cancelled = false;
public RepaintHeartbeat() {
}
/**
* copy resources from old task, just in case some were added after it
* should have been replaced (threads are fun)
**/
public void copyResourceSet(RepaintHeartbeat oldTask) {
// copy resources, in case one was added after a cancel
Set<AbstractVizResource<?, ?>> oldResourceSet = oldTask
.getResourceSet();
synchronized (oldResourceSet) {
for (AbstractVizResource<?, ?> rsc : oldResourceSet) {
this.addResource(rsc);
}
}
}
public Set<AbstractVizResource<?, ?>> getResourceSet() {
return resourceSet;
}
private final Set<WarningsResource> resourceSet = new HashSet<WarningsResource>();
@Override
public void run() {
// get the unique displays from all the added resources
ArrayList<IRenderableDisplay> displaysToRefresh = new ArrayList<IRenderableDisplay>(
1);
List<WarningsResource> rscs;
synchronized (resourceSet) {
for (AbstractVizResource<?, ?> rsc : resourceSet) {
try {
IRenderableDisplay disp = rsc.getDescriptor()
.getRenderableDisplay();
if (!displaysToRefresh.contains(disp)) {
displaysToRefresh.add(disp);
}
} catch (Exception e) {
statusHandler
.handle(Priority.PROBLEM,
"Encountered error during Warnings Heartbeat, continuing with other Warnings ",
e);
}
}
rscs = new ArrayList<WarningsResource>(resourceSet);
}
// create an array with final modifier
final IRenderableDisplay[] refreshList = displaysToRefresh
.toArray(new IRenderableDisplay[displaysToRefresh.size()]);
// execute refersh in UI thread
VizApp.runAsync(new Runnable() {
@Override
public void run() {
for (IRenderableDisplay disp : refreshList) {
disp.refresh();
}
}
});
// cancel the task if there are no more resources
boolean cancel = false;
synchronized (resourceSet) {
if (resourceSet.size() < 1) {
cancel = true;
}
}
if (cancel) {
doCancel();
for (WarningsResource rsc : rscs) {
rsc.issueRefresh();
}
}
public void addResource(AbstractVizResource<?, ?> rsc) {
// if task has no resources then it needs to be started when the
// first is added
boolean start = false;
public void addResource(WarningsResource rsc) {
synchronized (resourceSet) {
// if this is the first resource added to an empty set start the
// timer
if (resourceSet.size() < 1) {
start = true;
}
resourceSet.add(rsc);
}
if (start) {
WarningsResource.scheduleHeartBeat();
}
}
public void removeResource(AbstractVizResource<?, ?> rsc) {
public void removeResource(WarningsResource rsc) {
synchronized (resourceSet) {
resourceSet.remove(rsc);
// cancel the task if there are no more resources
if (resourceSet.size() < 1) {
doCancel();
}
}
}
private void doCancel() {
synchronized (heartBeatChangeLock) {
if (cancelled == false) {
cancelled = true;
heartBeatTimer.cancel();
heartBeatTask = new RepaintHeartbeat();
heartBeatTimer = new Timer();
heartBeatTask.copyResourceSet(this);
}
}
}
}
/** lock when changing heartBeatTask **/
protected static final Object heartBeatChangeLock = new Object();
protected static RefreshTimerTask refreshTask;
protected static RepaintHeartbeat heartBeatTask = null;
protected static Timer heartBeatTimer = null;
protected static Timer refreshTimer;
/**
* Constructor
@ -207,14 +109,13 @@ public class WarningsResource extends AbstractWWAResource {
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
DataTime earliest = this.descriptor.getFramesInfo().getFrameTimes()[0];
requestData(earliest);
synchronized (heartBeatChangeLock) {
if (heartBeatTask == null) {
heartBeatTask = new RepaintHeartbeat();
}
heartBeatTask.addResource(this);
FramesInfo info = descriptor.getFramesInfo();
DataTime[] times = info.getFrameTimes();
if (times != null && times.length > 0) {
// Request data for "earliest" time
requestData(times[0]);
}
scheduleRefreshTask(this);
}
/*
@ -224,9 +125,7 @@ public class WarningsResource extends AbstractWWAResource {
*/
@Override
protected void disposeInternal() {
synchronized (heartBeatChangeLock) {
heartBeatTask.removeResource(this);
}
cancelRefreshTask(this);
for (WarningEntry entry : entryMap.values()) {
if (entry.shadedShape != null) {
entry.shadedShape.dispose();
@ -404,43 +303,45 @@ public class WarningsResource extends AbstractWWAResource {
}
/**
* Cancel the heart beat timer task
*
* @param resource
*/
protected static void cancelRefreshTask(WarningsResource resource) {
synchronized (RefreshTimerTask.class) {
if (refreshTask != null) {
refreshTask.removeResource(resource);
if (refreshTask.resourceSet.isEmpty()) {
refreshTimer.cancel();
refreshTimer = null;
refreshTask = null;
}
}
}
}
/**
* schedule the heart beat for the next minute
*/
protected static void scheduleHeartBeat() {
// get simulated time
Date currentTime = SimulatedTime.getSystemTime().getTime();
// get a calendar
Calendar now = Calendar.getInstance();
// set calendar time to simulated time
now.setTime(currentTime);
// add one to the minutes field
now.add(Calendar.MINUTE, 1);
// reset second and milisecond to 0
now.set(Calendar.SECOND, 0);
now.set(Calendar.MILLISECOND, 0);
// schedule task to fire every minute
synchronized (heartBeatChangeLock) {
try {
if (heartBeatTimer == null) {
heartBeatTimer = new Timer();
}
// schedule on the minute every minute
heartBeatTimer.schedule(heartBeatTask, now.getTime(),
1 * 60 * 1000);
} catch (Exception e) {
try {
heartBeatTimer.cancel();
} catch (Exception e2) {
// ignore, we just want to make sure the timer is cancelled
} finally {
// create a new task if there was an error when scheduling
heartBeatTask = new RepaintHeartbeat();
heartBeatTimer = new Timer();
}
statusHandler.handle(Priority.SIGNIFICANT,
"Error scheduling warnings heart beat ", e);
protected static void scheduleRefreshTask(WarningsResource resource) {
synchronized (RefreshTimerTask.class) {
if (refreshTask == null) {
refreshTimer = new Timer(true);
refreshTask = new RefreshTimerTask();
// get a calendar
Calendar now = Calendar.getInstance();
// add one to the minutes field
now.add(Calendar.MINUTE, 1);
// reset second and milisecond to 0
now.set(Calendar.SECOND, 0);
now.set(Calendar.MILLISECOND, 0);
refreshTimer.scheduleAtFixedRate(refreshTask, now.getTime(),
60 * 1000);
}
refreshTask.addResource(resource);
}
}

View file

@ -192,6 +192,9 @@ public class WatchesResource extends AbstractWWAResource {
JTSCompiler jtsCompiler = new JTSCompiler(ss, null,
this.descriptor, PointStyle.CROSS);
jtsCompiler.handle(geo, color);
if (record.getPhen() == null) {
return;
}
ss.setFillPattern(FillPatterns.getGLPattern(record.getPhen()
.equals("TO") ? "VERTICAL" : "HORIZONTAL"));
ss.compile();

View file

@ -605,7 +605,7 @@ HRAP = ('HRAP', POLAR_STEREOGRAPHIC,
(-119.036, 23.097), (-75.945396, 53.480095),
(0.0, 0.0), 0.0, 0.0, (1, 1), (801, 881), 0.0, 0.0, -105.0)
NDFD_Oceanic_10K = ('NDFD Oceanic 10km', MERCATOR,
NDFD_Oceanic_10K = ('NDFD_Oceanic_10km', MERCATOR,
(-230.094, -30.4192), (10.71, 67.03),
(0.0, 0.0), 0.0, 0.0, (1, 1), (2517, 1289), 0.0, -109.962, 0.0)

View file

@ -164,7 +164,7 @@ public class GfeScriptExecutor {
}
String fileContents = getFileContents(xmlFileName);
Pattern pat = Pattern.compile("<site>([A-Z]{3})</site>");
Pattern pat = Pattern.compile("<site>(.*?)</site>");
Matcher matcher = pat.matcher(fileContents);
while (matcher.find()) {

View file

@ -334,4 +334,5 @@ com.raytheon.uf.common.dataplugin.shef.tables.YuniqueId
com.raytheon.uf.common.dataplugin.shef.tables.Zoneinfo
com.raytheon.uf.common.dataplugin.shef.tables.ZoneinfoId
com.raytheon.uf.common.dataplugin.shef.tables.Zonenum
com.raytheon.uf.common.dataplugin.shef.tables.ZonenumId
com.raytheon.uf.common.dataplugin.shef.tables.ZonenumId
com.raytheon.edex.transform.shef.MetarToShefFilter

View file

@ -28,7 +28,7 @@
</bean>
<bean id="metarToShefFilter"
class="com.raytheon.uf.edex.decodertools.core.filterimpl.PluginDataObjectFilter">
class="com.raytheon.edex.transform.shef.MetarToShefFilter">
<constructor-arg type="java.lang.String" value="metarToShefFilter.xml" />
<constructor-arg type="java.lang.String" value="SITE" />
</bean>
@ -133,7 +133,7 @@
<pipeline>
<split streaming="true">
<method bean="metarToShef" method="iterate" />
<bean ref="metarToShef" method="transform" />
<bean ref="metarToShef" method="transformMetar" />
<to
uri="jms-generic:queue:Ingest.ShefStaged?destinationResolver=#qpidDurableResolver" />
</split>

View file

@ -483,7 +483,7 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
/**
* Create, or recreate and validate the shef archive directory.
*/
private void configureArchiveDir() {
protected void configureArchiveDir() {
archiveEnabled = AppsDefaults.getInstance().getBoolean(OPT_ARC_ENABLE,
false);
String arcDir = AppsDefaults.getInstance().getToken(OPT_SHEF_ARC_DIR);

View file

@ -0,0 +1,286 @@
/**
* 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.edex.transform.shef;
import static com.raytheon.uf.common.localization.LocalizationContext.LocalizationType.EDEX_STATIC;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.ohd.AppsDefaults;
//import com.raytheon.edex.transform.shef.MetarToShefTransformer;
import com.raytheon.uf.edex.decodertools.core.filterimpl.AbstractFilterElement;
import com.raytheon.uf.edex.decodertools.core.filterimpl.AbstractObsFilter;
import com.raytheon.uf.edex.decodertools.core.filterimpl.PluginDataObjectFilter;
/**
* Use information in metarToShefFilter.xml, MetarToShefFilter filters out
* the metar messages before send the message to MetarToShefTransformer to
* encode to a SHEF message.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ---------- ------- -------- --------------------------
* 1/10/2013 15497 wkwock Initial creation
*
* </pre>
*
* @author wkwock
* @version 1.0
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class MetarToShefFilter {
@XmlElement
@DynamicSerializeElement
protected List<MetarToShefRun> metarToShefRun = new ArrayList<MetarToShefRun>();
private static final String ERROR_1_FMT = "Could not create {%s} context for file \"%s\"";
private static final String ERROR_2_FMT = "File %s does not exist";
private static final String METAR_CFG = "metar.cfg";
public static final String FILTERS_DIR = "plugin-filters";
private String metarToShefOptions = AppsDefaults.getInstance().getToken("metar2shef_options");
private Log logger = LogFactory.getLog(getClass());
private String filterConfigFile = null;
public MetarToShefFilter() {
}
public MetarToShefFilter(String configFile, String localContext) {
filterConfigFile = configFile;
try {
File filterDir = null;
IPathManager manager = PathManagerFactory.getPathManager();
if(manager != null) {
LocalizationContext context = manager.getContext(EDEX_STATIC, LocalizationLevel.valueOf(localContext));
if(context != null) {
filterDir = manager.getFile(context, FILTERS_DIR);
if (filterDir.exists()) {
File srcFile = new File(filterDir, filterConfigFile);
byte[] data = new byte[(int) srcFile.length()];
InputStream stream = getInputStream(srcFile);
try {
stream.read(data);
stream.close();
Object obj = SerializationUtil
.unmarshalFromXml(new String(data));
if (obj instanceof PluginDataObjectFilter){
logger.info("Found "+filterConfigFile+" is PluginDataObjectFilter");
PluginDataObjectFilter pdof=(PluginDataObjectFilter) obj;
MetarToShefRun mtsr= new MetarToShefRun();
mtsr.setConfigFileName(METAR_CFG);
mtsr.setMetarToShefOptions(metarToShefOptions);
mtsr.setFilterElements(pdof.getFilterElements());
mtsr.setFilterName(pdof.getFilterName());
this.metarToShefRun.add(mtsr);
}else if (obj instanceof MetarToShefFilter) {
MetarToShefFilter filter = (MetarToShefFilter) obj;
this.metarToShefRun=filter.metarToShefRun;
logger.info("Found "+filterConfigFile+" is MetarToShefFilter");
}else {
logger.error("Found "+filterConfigFile+" is "+obj.getClass().getCanonicalName());
createDummyFilter();
}
} catch (IOException e) {
logger.error("Unable to read filter config", e);
} catch (JAXBException e) {
logger.error("Unable to unmarshall filter config", e);
}
} else {
logger.error(String.format(ERROR_2_FMT,filterDir.getPath()));
createDummyFilter();
}
} else {
logger.error(String.format(ERROR_1_FMT, localContext,configFile));
createDummyFilter();
}
} else {
// Could not create PathManager
}
} catch (Exception e) {
logger.error(
"Error creating filter.", e);
createDummyFilter();
}
for (MetarToShefRun mtsr: metarToShefRun){
logger.info("Filter name = " + mtsr.getFilterName()+" with config file: "+mtsr.getConfigFileName());
}
}
private PluginDataObject[] filterARun(PluginDataObject[] reports, List<AbstractFilterElement> filterElements) {
int reportCount = 0;
if (reports != null) {
for (int i = 0; i < reports.length; i++) {
PluginDataObject r = null;
boolean keep = true;
for (AbstractFilterElement element : filterElements) {
r = element.filter(reports[i]);
// Only allow keep to be set to true. Once true it stays that way.
if(AbstractObsFilter.INCLUDE_TYPE.equals(element.getFilterType())) {
// Did the filter pass?
if(r == null) {
// If we fail an element, exit now.
keep = false;
break;
}
} else if(AbstractObsFilter.EXCLUDE_TYPE.equals(element.getFilterType())) {
if(r != null) {
// There was a match, so we want to remove this item.
keep = false;
// And there's no reason for further checks.
break;
}
}
}
if (keep) {
reportCount++;
} else {
reports[i] = null;
}
}
}
if (reportCount == 0) {
reports = new PluginDataObject[0];
} else {
PluginDataObject[] newReports = new PluginDataObject[reportCount];
int i = 0;
// Copy in the reports that passed filtering.
for (PluginDataObject report : reports) {
if (report != null) {
newReports[i++] = report;
}
}
reports = newReports;
}
return reports;
}
/**
* Apply the list of filters against given input data.
*
*/
// @Override
public PluginDataObject[] filter(PluginDataObject[] reports) {
PluginDataObject[] resultRpt=null;
for (MetarToShefRun mtsr : metarToShefRun) {
PluginDataObject[] tmpRprts = reports.clone();
resultRpt=filterARun(tmpRprts,mtsr.getFilterElements());
if (resultRpt!=null && resultRpt.length>=1) {
logger.info("Report matchs in filter "+mtsr.getFilterName());
MetarToShefTransformer.setCfgNOption(mtsr.getConfigFileName(),mtsr.getMetarToShefOptions());
break ;
}
}
return resultRpt;
}
private void createDummyFilter() {
MetarToShefRun mtsr= new MetarToShefRun();
mtsr.setConfigFileName(METAR_CFG);
mtsr.setMetarToShefOptions(metarToShefOptions);
// Add a dummy element.
AbstractFilterElement dummy = new AbstractFilterElement() {
@Override
public PluginDataObject filter(PluginDataObject report) {
return report;
}
};
dummy.setFilterType(AbstractObsFilter.INCLUDE_TYPE);
mtsr.getFilterElements().set(0, dummy);
mtsr.setFilterName("Created Pass-All filter");
this.metarToShefRun.add(mtsr);
}
/**
*
* @param file
* @return
*/
private static FileInputStream getInputStream(File file) {
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return fis;
}
public void addMetarToShefRun(MetarToShefRun element) {
metarToShefRun.add(element);
}
/**
*
* @return
*/
public List<MetarToShefRun> getMetarToShefRun() {
return metarToShefRun;
}
/**
*
* @param elements
*/
public void setMetarToShefRun(List<MetarToShefRun> elements) {
metarToShefRun = elements;
}
}

View file

@ -0,0 +1,150 @@
package com.raytheon.edex.transform.shef;
/**
* 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.
**/
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.edex.decodertools.core.filterimpl.AbstractFilterElement;
/**
* MetarToShefRun is for the metarToShefRun tag in Metar2ShefFilter tag
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ---------- ------- -------- --------------------------
* 1/10/2013 15497 wkwock Initial creation
*
* </pre>
*
* @author wkwock
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class MetarToShefRun implements ISerializableObject{
public static final String INCLUDE_TYPE = "INCLUDE";
public static final String EXCLUDE_TYPE = "EXCLUDE";
@XmlElement
@DynamicSerializeElement
private String configFileName;
@XmlElement
@DynamicSerializeElement
private String metarToShefOptions;
@XmlElement
@DynamicSerializeElement
protected List<AbstractFilterElement> filterElements = new ArrayList<AbstractFilterElement>();
@XmlElement
@DynamicSerializeElement
private String filterName;
/**
*
* @param filterFile
*/
void createFilter(File filterFile) {
}
/**
*
* @return
*/
public String getConfigFileName() {
return configFileName;
}
/**
*
* @param name
*/
public void setConfigFileName(String name) {
configFileName = name;
}
/**
*
* @return
*/
public String getMetarToShefOptions() {
return metarToShefOptions;
}
/**
*
* @param name
*/
public void setMetarToShefOptions(String name) {
metarToShefOptions = name;
}
/**
*
*/
public void addFilterElement(AbstractFilterElement element) {
filterElements.add(element);
}
/**
*
* @return
*/
public List<AbstractFilterElement> getFilterElements() {
return filterElements;
}
/**
*
* @param elements
*/
public void setFilterElements(List<AbstractFilterElement> elements) {
filterElements = elements;
}
/**
*
* @return
*/
public String getFilterName() {
return filterName;
}
/**
*
* @param name
*/
public void setFilterName(String name) {
filterName = name;
}
}

View file

@ -80,6 +80,10 @@ public class MetarToShefTransformer extends
private static final int P1_MIN = 50;
private static final int P2_MAX = 5;
private static String cfgFileName="metar.cfg";
private static String cmdLnOptions="";
private static boolean refreshOptions=true;
/**
* Construct an instance of this transformer.
* @param cmdLine Command line options that may be used if these
@ -411,4 +415,24 @@ public class MetarToShefTransformer extends
}
return sb;
}
}
public final byte[] transformMetar(MetarRecord report, Headers headers)
throws TransformerException {
if (refreshOptions) {
logger.info("Metar to SHEF now use config file: "+cfgFileName+" with options:"+cmdLnOptions);
options.setCfgFileName(cfgFileName);
options.updateCommandLine(cmdLnOptions);
options.updateOptions();
refreshOptions=false;
}
configureArchiveDir();
return transformReport(report, headers);
}
public static void setCfgNOption (String cfg, String options){
cfgFileName=cfg;
cmdLnOptions=options;
refreshOptions=true;
}
}

View file

@ -179,6 +179,7 @@ public class ObsToSHEFOptions {
public static final String OPT_NO_HR_TRACE = "optNoHourTrace";
private String cfgFileName=null;
// private static class PCReset {
//
// private final String stationId;
@ -408,7 +409,11 @@ public class ObsToSHEFOptions {
initOptions();
parseCommandLine(cmdLine);
if (useLocalized) {
readConfig(METAR_CFG, optConfigContext);
if (cfgFileName==null){
readConfig(METAR_CFG, optConfigContext);
} else {
readConfig(cfgFileName, optConfigContext);
}
updateTime = System.currentTimeMillis();
}
localized = useLocalized;
@ -843,7 +848,11 @@ public class ObsToSHEFOptions {
long cTime = System.currentTimeMillis() - updateTime;
if (cTime > UPDATE_DELTA) {
if (loaded && localized) {
readConfig(METAR_CFG, optConfigContext);
if (cfgFileName==null) {
readConfig(METAR_CFG, optConfigContext);
} else {
readConfig(cfgFileName, optConfigContext);
}
updateTime = System.currentTimeMillis();
}
}
@ -874,7 +883,11 @@ public class ObsToSHEFOptions {
if (SITE_CONTEXT.equals(optConfigContext)) {
// Retry from a base context.
optConfigContext = BASE_CONTEXT;
readConfig(METAR_CFG, optConfigContext);
if (cfgFileName==null) {
readConfig(METAR_CFG, optConfigContext);
}else{
readConfig(cfgFileName, optConfigContext);
}
}
}
} else {
@ -973,6 +986,10 @@ public class ObsToSHEFOptions {
loaded = true;
}
public void setCfgFileName(String fileName) {
cfgFileName=fileName;
}
public String toString() {
StringBuilder sb = new StringBuilder();

View file

@ -27,23 +27,25 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* Response object for the GraphDataRequest.
*
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 25, 2012 1269 lvenable Initial creation.
* Dec 06, 2012 1397 djohnson Add dynamic serialize class annotation.
*
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
*
* </pre>
*
*
* @author lvenable
* @version 1.0
*/
@ -55,7 +57,7 @@ public class BandwidthGraphData {
/** Subscription Name -> Subscription Priority */
@DynamicSerializeElement
private Map<String, Integer> priorityMap;
private Map<String, SubscriptionPriority> priorityMap;
/** Bin duration in minutes */
@DynamicSerializeElement
@ -81,7 +83,7 @@ public class BandwidthGraphData {
public BandwidthGraphData(int binTimeMins) {
this.binTimeInMins = binTimeMins;
dataMap = new HashMap<String, List<TimeWindowData>>();
priorityMap = new HashMap<String, Integer>();
priorityMap = new HashMap<String, SubscriptionPriority>();
}
/**
@ -102,7 +104,7 @@ public class BandwidthGraphData {
/**
* @return the priorityMap
*/
public Map<String, Integer> getPriorityMap() {
public Map<String, SubscriptionPriority> getPriorityMap() {
return priorityMap;
}
@ -110,7 +112,7 @@ public class BandwidthGraphData {
* @param priorityMap
* the priorityMap to set
*/
public void setPriorityMap(Map<String, Integer> priorityMap) {
public void setPriorityMap(Map<String, SubscriptionPriority> priorityMap) {
this.priorityMap = priorityMap;
}
@ -145,7 +147,8 @@ public class BandwidthGraphData {
* @param priority
* @param dataArray
*/
public void addGraphDataArray(String subscriptionName, int priority,
public void addGraphDataArray(String subscriptionName,
SubscriptionPriority priority,
List<TimeWindowData> dataArray) {
dataMap.put(subscriptionName, dataArray);
priorityMap.put(subscriptionName, priority);
@ -206,14 +209,15 @@ public class BandwidthGraphData {
* The subscription name.
* @return The priority number.
*/
public int getPriority(String subscriptionName) {
public SubscriptionPriority getPriority(String subscriptionName) {
if (priorityMap.containsKey(subscriptionName)) {
return priorityMap.get(subscriptionName);
}
// This should never occur. A low priority number is being return rather
// than a null.
return 99;
// This should never occur.
throw new IllegalArgumentException(
"Unable to find a priority for subscription ["
+ subscriptionName + "]");
}
/**

View file

@ -31,6 +31,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Code clean up.
* Set 06, 2012 1121 mpduff Added a unique key.
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Jan 24, 2013 1527 dhladky Changed 0DEG to FRZ
*
* </pre>
*
@ -110,7 +111,7 @@ public class DataLevelType implements ISerializableObject, Serializable {
"Cloud Level", 110), SIGL("sigma", "Sigma Level", 111), PVL(
"pv", "PV Level", 111), CTL("top", "Top Level", 112), MSL(
"mean", "Mean Sea Level", 113), EA("entire",
"Entire Atmosphere (As Single Layer)", 114), ODEG("0c",
"Entire Atmosphere (As Single Layer)", 114), FRZ("0c",
"0c isotherm", 115), LCY("low", "Low Cloud Bottom Level", 116), MCY(
"middle", "Middle Cloud Level", 117), HCY("high",
"High Cloud Level", 118), PBL("planetary",
@ -175,11 +176,8 @@ public class DataLevelType implements ISerializableObject, Serializable {
break;
}
}
// special case since enums can't start with integers
if (rval == LevelType.ODEG) {
return "0DEG";
} else if (rval == LevelType.U || rval == LevelType.V) {
if (rval == LevelType.U || rval == LevelType.V) {
return LevelType.MAXW.toString();
}

View file

@ -25,6 +25,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Feb 08, 2011 191 dhladky Initial creation
* Jul 24, 2012 955 djohnson Use List instead of ArrayList.
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Jan 28, 2013 1530 djohnson Never return null for selected level indices.
* </pre>
*
* @author dhladky
@ -67,7 +68,7 @@ public class Levels implements ISerializableObject, Serializable {
@XmlElements({ @XmlElement(name = "selectedLevelIndices", type = Integer.class) })
@DynamicSerializeElement
private List<Integer> selectedLevelIndices;
private List<Integer> selectedLevelIndices = new ArrayList<Integer>();
/**
* Copy constructor

View file

@ -11,6 +11,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
@ -50,6 +52,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* Nov 20, 2012 1286 djohnson Add unscheduled.
* Dec 12, 2012 1433 bgonzale Refactored Subscription copy ctor into two ctors.
* Jan 03, 2013 1441 djohnson Default to no group.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
*
* </pre>
*
@ -66,6 +69,73 @@ import com.raytheon.uf.common.time.util.TimeUtil;
Subscription.DATA_SET_SLOT, Subscription.OWNER_SLOT })
public class Subscription implements ISerializableObject, Serializable {
/** Enumeration to use for subscription priorities */
@XmlEnum
public static enum SubscriptionPriority {
/** High Priority */
@XmlEnumValue("High")
HIGH("High", 1),
/** Default Priority */
@XmlEnumValue("Normal")
NORMAL("Normal", 2),
/** Low Priority */
@XmlEnumValue("Low")
LOW("Low", 3);
/** Priority Setting */
private final String priorityName;
/** Numeric Value of the priority */
private int priorityValue;
private SubscriptionPriority(String priorityName, Integer priorityValue) {
this.priorityName = priorityName;
this.priorityValue = priorityValue;
}
/**
* Get column name.
*
* @return Priority Name
*/
public String getPriorityName() {
return priorityName;
}
/**
* Get the integer value of the priority
*
* @return The integer value of the priority.
*/
public int getPriorityValue() {
return priorityValue;
}
@Override
public String toString() {
return priorityName;
}
/**
* Retrieve the {@link SubscriptionPriority} by its string
* representation.
*
* @param string
* the string representation
* @return the {@link SubscriptionPriority}
*/
public static SubscriptionPriority fromPriorityName(String string) {
for (SubscriptionPriority potential : SubscriptionPriority.values()) {
if (potential.getPriorityName().equals(string)) {
return potential;
}
}
throw new IllegalArgumentException(
"Unable to find priority with priority name [" + string
+ "]");
}
}
private static final long serialVersionUID = -6422673887457060034L;
/** Dataset Name slot */
@ -133,6 +203,7 @@ public class Subscription implements ISerializableObject, Serializable {
this.setDataSetType(sub.getDataSetType());
this.setRoute(sub.getRoute());
this.setLatencyInMinutes(sub.getLatencyInMinutes());
this.setEnsemble(sub.getEnsemble());
}
@XmlAttribute
@ -166,7 +237,7 @@ public class Subscription implements ISerializableObject, Serializable {
@XmlAttribute
@DynamicSerializeElement
private Integer priority;
private SubscriptionPriority priority = SubscriptionPriority.NORMAL;
@XmlAttribute
@DynamicSerializeElement
@ -363,7 +434,7 @@ public class Subscription implements ISerializableObject, Serializable {
*
* @return subscription name
*/
public Integer getPriority() {
public SubscriptionPriority getPriority() {
return priority;
}
@ -373,7 +444,7 @@ public class Subscription implements ISerializableObject, Serializable {
* @param priority
* priority
*/
public void setPriority(Integer priority) {
public void setPriority(SubscriptionPriority priority) {
this.priority = priority;
}

View file

@ -44,6 +44,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
/**
@ -61,7 +62,7 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
* Apr 11, 2012 #14691 Qinglu Lin For marine warnings, getFeAreaField() returns null.
* So, do not add the returned value of getFeAreaField()
* to areaFields.
* Jan 9, 2013 15600 Qinglu Lin Execute "timezones = myTimeZones;" even if timezones != null.
* Jan 9, 2013 15600 Qinglu Lin Execute "timezones = myTimeZones;" even if timezones != null.
*
* </pre>
*
@ -87,13 +88,12 @@ public class GeospatialFactory {
boolean generate = true;
if (lastRunTime != null) {
System.out.println("Loading areas from disk");
// load from disk
try {
long t0 = System.currentTimeMillis();
dataSet = loadAreaGeoData(site, lastRunTime);
System.out.println("Loading areas from disk took "
+ (System.currentTimeMillis() - t0));
+ (System.currentTimeMillis() - t0) + "ms");
} catch (Exception e) {
statusHandler.handle(Priority.WARN,
"Failed to load area geometry files from disk", e);
@ -119,7 +119,7 @@ public class GeospatialFactory {
GeospatialData[] parentAreas = dataSet.getParentAreas();
GeospatialData[] myTimeZones = dataSet.getTimezones();
if (myTimeZones != null && myTimeZones.length > 0) {
timezones = myTimeZones;
timezones = myTimeZones;
for (GeospatialData tz : myTimeZones) {
tz.prepGeom = PreparedGeometryFactory.prepare(tz.geometry);
@ -138,7 +138,6 @@ public class GeospatialFactory {
list.add(data);
}
GeospatialData[] uniqueAreas = new GeospatialData[uniqueAreasMap.size()];
int index = 0;
for (String key : uniqueAreasMap.keySet()) {
@ -148,34 +147,15 @@ public class GeospatialFactory {
// if multiple areas share a common fips ID, the smaller areas will
// have to merge will the largest area
if (list.size() > 1) {
double maxArea = -1;
for (GeospatialData item : list) {
double area = item.getGeometry().getArea();
if (area > maxArea) {
data = item;
maxArea = area;
}
}
// collect all individual geometries that are not a part
// of the maxArea
// collect all individual geometries
List<Geometry> geometries = new ArrayList<Geometry>();
for (GeospatialData item : list) {
if (data != item) {
GeometryUtil.buildGeometryList(geometries,
item.geometry);
}
}
for (int i = 0; i < geometries.size(); i++) {
// convexHull will remove any side location conflicts
// convexHull the geometries individually because they are
// usually not next to each other.
// data.geometry = data.geometry.union(geometries.get(i)
// .convexHull());
data.geometry = data.geometry.union(geometries.get(i)
.convexHull());
GeometryUtil.buildGeometryList(geometries, item.geometry);
}
// Create multi geometry out of combined areas
data.geometry = new GeometryFactory()
.createGeometryCollection(geometries
.toArray(new Geometry[0]));
}
uniqueAreas[index] = data;
index++;
@ -204,7 +184,7 @@ public class GeospatialFactory {
// Prepare the geometries
for (GeospatialData data : areas) {
data.prepGeom = PreparedGeometryFactory.prepare(data.geometry);
data.prepGeom = new PreparedGeometryCollection(data.geometry);
}
return areas;

View file

@ -0,0 +1,246 @@
/**
* 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.dataplugin.warning.gis;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
/**
* {@link PreparedGeometry} implementation that can handle
* {@link GeometryCollection} objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 28, 2013 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class PreparedGeometryCollection implements PreparedGeometry {
private Geometry geometry;
private PreparedGeometry[] prepared;
public PreparedGeometryCollection(Geometry geometry) {
this.geometry = geometry;
int numGeoms = geometry.getNumGeometries();
if (geometry.getClass() == GeometryCollection.class) {
prepared = new PreparedGeometry[numGeoms];
for (int i = 0; i < numGeoms; ++i) {
prepared[i] = PreparedGeometryFactory.prepare(geometry
.getGeometryN(i));
}
} else {
prepared = new PreparedGeometry[] { PreparedGeometryFactory
.prepare(geometry) };
}
}
/*
* (non-Javadoc)
*
* @see com.vividsolutions.jts.geom.prep.PreparedGeometry#getGeometry()
*/
@Override
public Geometry getGeometry() {
return geometry;
}
/*
* (non-Javadoc)
*
* @see
* com.vividsolutions.jts.geom.prep.PreparedGeometry#contains(com.vividsolutions
* .jts.geom.Geometry)
*/
@Override
public boolean contains(Geometry geom) {
for (PreparedGeometry pg : prepared) {
if (pg.contains(geom)) {
return true;
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see
* com.vividsolutions.jts.geom.prep.PreparedGeometry#containsProperly(com
* .vividsolutions.jts.geom.Geometry)
*/
@Override
public boolean containsProperly(Geometry geom) {
for (PreparedGeometry pg : prepared) {
if (pg.containsProperly(geom)) {
return true;
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see com.vividsolutions.jts.geom.prep.PreparedGeometry#coveredBy(com.
* vividsolutions.jts.geom.Geometry)
*/
@Override
public boolean coveredBy(Geometry geom) {
boolean coveredBy = true;
for (PreparedGeometry pg : prepared) {
if (pg.coveredBy(geom) == false) {
coveredBy = false;
break;
}
}
return coveredBy;
}
/*
* (non-Javadoc)
*
* @see
* com.vividsolutions.jts.geom.prep.PreparedGeometry#covers(com.vividsolutions
* .jts.geom.Geometry)
*/
@Override
public boolean covers(Geometry geom) {
throw new UnsupportedOperationException(
"PreparedGeometryCollection does not support PreparedGeometry.covers");
}
/*
* (non-Javadoc)
*
* @see
* com.vividsolutions.jts.geom.prep.PreparedGeometry#crosses(com.vividsolutions
* .jts.geom.Geometry)
*/
@Override
public boolean crosses(Geometry geom) {
for (PreparedGeometry pg : prepared) {
if (pg.crosses(geom)) {
return true;
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see
* com.vividsolutions.jts.geom.prep.PreparedGeometry#disjoint(com.vividsolutions
* .jts.geom.Geometry)
*/
@Override
public boolean disjoint(Geometry geom) {
boolean disjoint = true;
for (PreparedGeometry pg : prepared) {
if (pg.disjoint(geom) == false) {
disjoint = false;
break;
}
}
return disjoint;
}
/*
* (non-Javadoc)
*
* @see com.vividsolutions.jts.geom.prep.PreparedGeometry#intersects(com.
* vividsolutions.jts.geom.Geometry)
*/
@Override
public boolean intersects(Geometry geom) {
for (PreparedGeometry pg : prepared) {
if (pg.intersects(geom)) {
return true;
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see
* com.vividsolutions.jts.geom.prep.PreparedGeometry#overlaps(com.vividsolutions
* .jts.geom.Geometry)
*/
@Override
public boolean overlaps(Geometry geom) {
for (PreparedGeometry pg : prepared) {
if (pg.overlaps(geom)) {
return true;
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see
* com.vividsolutions.jts.geom.prep.PreparedGeometry#touches(com.vividsolutions
* .jts.geom.Geometry)
*/
@Override
public boolean touches(Geometry geom) {
for (PreparedGeometry pg : prepared) {
if (pg.touches(geom)) {
return true;
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see
* com.vividsolutions.jts.geom.prep.PreparedGeometry#within(com.vividsolutions
* .jts.geom.Geometry)
*/
@Override
public boolean within(Geometry geom) {
boolean within = true;
for (PreparedGeometry pg : prepared) {
if (pg.within(geom) == false) {
within = false;
break;
}
}
return within;
}
}

View file

@ -1,24 +1,38 @@
package com.raytheon.uf.common.dataplugin.warning.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.Polygon;
import com.vividsolutions.jts.geom.TopologyException;
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
import com.vividsolutions.jts.operation.overlay.snap.GeometrySnapper;
import com.vividsolutions.jts.operation.polygonize.Polygonizer;
/**
*
* Performs common geometry operations taking geometry collections into
* account for counties. Makes certain assumptions about these geometries that
* only apply to warngen
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 15, 2010 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class GeometryUtil {
private static final String SEPARATOR = "_";
@ -41,7 +55,7 @@ public class GeometryUtil {
}
for (int i = 0; i < list1.size(); ++i) {
if (list1.get(i).buffer(0).equals(list2.get(i).buffer(0)) == false) {
if (list1.get(i).equals(list2.get(i)) == false) {
return false;
}
}
@ -190,12 +204,15 @@ public class GeometryUtil {
}
if ((g1Name == null || g2Name == null || g2Name
.startsWith(prefix))) {
Geometry section = g1.intersection(g2);
if (section.isEmpty() == false) {
section = section.buffer(0);
setUserData(section, (CountyUserData) g2.getUserData());
section.setUserData(g2.getUserData());
intersections.add(section);
if (g1.isValid() && g2.isValid()) {
Geometry section = g1.intersection(g2);
if (section.isEmpty() == false) {
section = section.buffer(0);
setUserData(section,
(CountyUserData) g2.getUserData());
section.setUserData(g2.getUserData());
intersections.add(section);
}
}
}
}
@ -209,64 +226,31 @@ public class GeometryUtil {
intersection(g1.getGeometryN(i), pg, intersections);
}
} else {
Geometry g2 = pg.getGeometry();
String g1Name = toString(g1.getUserData());
String g2Name = toString(g2.getUserData());
String prefix = null;
if (g1Name != null && g2Name != null) {
prefix = getPrefix(g1Name);
}
if (g1Name == null || g2Name == null || g2Name.startsWith(prefix)) {
if (pg.intersects(g1)) {
Geometry section = null;
try {
section = g1.intersection(g2);
} catch (TopologyException e) {
// This exception is due to g2 having interior
// intersections
section = clean(g1).intersection(g2.buffer(0));
}
if (section != null) {
setUserData(section, (CountyUserData) g2.getUserData());
section.setUserData(g2.getUserData());
intersections.add(section);
if (pg.intersects(g1)) {
Geometry g2 = pg.getGeometry();
List<Geometry> sections = new ArrayList<Geometry>();
for (int n = 0; n < g2.getNumGeometries(); n++) {
Geometry section = g1.intersection(g2.getGeometryN(n));
if (section.isEmpty() == false) {
sections.add(section);
}
}
Geometry section = null;
if (sections.size() == 1) {
section = sections.get(0);
} else if (sections.size() > 0) {
section = new GeometryFactory()
.createGeometryCollection(sections
.toArray(new Geometry[0]));
}
if (section != null && section.isEmpty() == false) {
setUserData(section, (CountyUserData) g2.getUserData());
intersections.add(section);
}
}
}
}
/**
* Returns a geometry from the noded line strings of g.
*
* @param g
* geometry to be cleaned up
* @return
*/
private static Geometry clean(Geometry g) {
Coordinate[] coords = g.getCoordinates();
// create a line string
GeometryFactory gf = new GeometryFactory();
LineString ls = gf.createLineString(coords);
// node the line string (insert vertices where lines cross)
com.vividsolutions.jts.geom.Point pt = gf.createPoint(ls
.getCoordinate());
Geometry nodedLines = ls.union(pt);
// create the polygon(s) from the noded line
Polygonizer polygonizer = new Polygonizer();
polygonizer.add(nodedLines);
Collection<Polygon> polygons = polygonizer.getPolygons();
g = gf.createMultiPolygon(
polygons.toArray(new Polygon[polygons.size()])).buffer(0);
return g;
}
/**
* Get the difference between the 2 geometries
*

View file

@ -19,6 +19,8 @@
**/
package com.raytheon.uf.common.dataquery.responses;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -47,15 +49,31 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
@DynamicSerialize
public class DbQueryResponse implements ISerializableObject {
public static final String ENTITY_RESULT_KEY = null;
@DynamicSerializeElement
private List<Map<String, Object>> results;
public List<Map<String, Object>> getResults() {
return results;
return results == null ? new ArrayList<Map<String, Object>>() : results;
}
public void setResults(List<Map<String, Object>> results) {
this.results = results;
}
public int getNumResults() {
return getResults().size();
}
@SuppressWarnings("unchecked")
public <T> T[] getEntityObjects(Class<T> entityType) {
List<Map<String, Object>> results = getResults();
T[] entities = (T[]) Array.newInstance(entityType, results.size());
int i = 0;
for (Map<String, Object> result : results) {
entities[i++] = entityType.cast(result.get(ENTITY_RESULT_KEY));
}
return entities;
}
}

View file

@ -31,6 +31,11 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
import com.raytheon.uf.common.datadelivery.bandwidth.data.TimeWindowData;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
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.common.time.util.TimeUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionDao;
@ -50,7 +55,8 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan.Bandw
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 6, 2012 1397 djohnson Initial creation
* Dec 06, 2012 1397 djohnson Initial creation
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
*
* </pre>
*
@ -59,6 +65,8 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan.Bandw
*/
class BandwidthGraphDataAdapter {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(BandwidthGraphDataAdapter.class);
private final RetrievalManager retrievalManager;
@ -88,7 +96,7 @@ class BandwidthGraphDataAdapter {
.getBucketMinutes());
Map<String, List<TimeWindowData>> dataMap = new HashMap<String, List<TimeWindowData>>();
Map<String, Integer> priorityMap = new HashMap<String, Integer>();
Map<String, SubscriptionPriority> priorityMap = new HashMap<String, SubscriptionPriority>();
Map<Long, SubscriptionRetrieval> retrievals = new HashMap<Long, SubscriptionRetrieval>();
Multimap<Long, BandwidthReservation> reservations = ArrayListMultimap
@ -133,7 +141,16 @@ class BandwidthGraphDataAdapter {
final SubscriptionRetrieval value = entry.getValue();
SubscriptionDao dao = value.getSubscriptionDao();
final String subName = dao.getName();
priorityMap.put(subName, Integer.valueOf((int) dao.getPriority()));
try {
priorityMap.put(subName, dao.getSubscription().getPriority());
} catch (SerializationException e) {
statusHandler
.handle(Priority.PROBLEM,
"Unable to get access to the actual subscription for ["
+ subName + "], skipping...",
e);
continue;
}
List<TimeWindowData> timeWindows = dataMap.get(subName);

View file

@ -96,7 +96,9 @@ import com.raytheon.uf.edex.event.EventBus;
* Dec 06, 2012 1397 djohnson Add ability to get bandwidth graph data.
* Dec 11, 2012 1403 djohnson Adhoc subscriptions no longer go to the registry.
* Dec 12, 2012 1286 djohnson Remove shutdown hook and finalize().
*
* Jan 25, 2013 1528 djohnson Compare priorities as primitive ints.
* Jan 28, 2013 1530 djohnson Unschedule all allocations for a subscription that does not fully schedule.
* Jan 30, 2013 1501 djohnson Fix broken calculations for determining required latency.
* </pre>
*
* @author dhladky
@ -567,9 +569,45 @@ abstract class BandwidthManager extends
.getCycleTimes());
List<BandwidthAllocation> unscheduled = schedule(subscription, cycles);
unscheduleSubscriptionsForAllocations(unscheduled);
return unscheduled;
}
/**
* Unschedules all subscriptions the allocations are associated to.
*
* @param unscheduled
* the unscheduled allocations
*/
private void unscheduleSubscriptionsForAllocations(
List<BandwidthAllocation> unscheduled) {
Set<Subscription> subscriptionsToUnschedule = Sets.newHashSet();
for (BandwidthAllocation unscheduledAllocation : unscheduled) {
if (unscheduledAllocation instanceof SubscriptionRetrieval) {
SubscriptionRetrieval retrieval = (SubscriptionRetrieval) unscheduledAllocation;
try {
subscriptionsToUnschedule.add(retrieval.getSubscription());
} catch (SerializationException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to deserialize a subscription", e);
continue;
}
}
}
for (Subscription sub : subscriptionsToUnschedule) {
sub.setUnscheduled(true);
try {
subscriptionUpdated(sub);
} catch (SerializationException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to deserialize a subscription", e);
continue;
}
}
}
/**
* {@inheritDoc}
*
@ -658,7 +696,8 @@ abstract class BandwidthManager extends
// If BandwidthManager does not know about the subscription, and
// it's active, attempt to add it..
if (subscriptionDaos.isEmpty() && subscription.isActive()) {
if (subscriptionDaos.isEmpty() && subscription.isActive()
&& !subscription.isUnscheduled()) {
final boolean subscribedToCycles = !subscription.getTime()
.getCycleTimes().isEmpty();
final boolean useMostRecentDataSetUpdate = !subscribedToCycles;
@ -687,8 +726,8 @@ abstract class BandwidthManager extends
unscheduled = schedule(adhoc);
}
return unscheduled;
} else if (!subscription.isActive()) {
// See if the subscription was inactivated..
} else if (!subscription.isActive() || subscription.isUnscheduled()) {
// See if the subscription was inactivated or unscheduled..
// Need to remove BandwidthReservations for this
// subscription.
return remove(subscriptionDaos, true);
@ -796,7 +835,7 @@ abstract class BandwidthManager extends
boolean requiresReschedule = (old.getDataSetSize() != subscription
.getDataSetSize())
// Priority is different
|| (!old.getPriority().equals(subscription.getPriority()))
|| (old.getPriority() != subscription.getPriority())
// Latency is different
|| (!(old.getLatencyInMinutes() == subscription
.getLatencyInMinutes()));
@ -1121,8 +1160,7 @@ abstract class BandwidthManager extends
* @return the graph data
*/
private BandwidthGraphData getBandwidthGraphData() {
return new BandwidthGraphDataAdapter(retrievalManager)
.get();
return new BandwidthGraphDataAdapter(retrievalManager).get();
}
/**
@ -1505,95 +1543,86 @@ abstract class BandwidthManager extends
* @return the required latency, in minutes
*/
@VisibleForTesting
int determineRequiredLatency(Subscription subscription) {
int determineRequiredLatency(final Subscription subscription) {
ITimer timer = TimeUtil.getTimer();
timer.start();
try {
final Subscription clone = BandwidthUtil.cheapClone(
Subscription.class, subscription);
if (clone.getLatencyInMinutes() < 1) {
clone.setLatencyInMinutes(1);
}
boolean foundLatency = false;
int latency = clone.getLatencyInMinutes();
int previousLatency = latency;
do {
// Double the latency until we have two values we can binary
// search between...
previousLatency = latency;
latency *= 2;
clone.setLatencyInMinutes(latency);
foundLatency = isSchedulableWithoutConflict(clone);
} while (!foundLatency);
SortedSet<Integer> possibleLatencies = new TreeSet<Integer>();
for (int i = previousLatency; i < (latency + 1); i++) {
possibleLatencies.add(Integer.valueOf(i));
}
IBinarySearchResponse<Integer> response = AlgorithmUtil
.binarySearch(possibleLatencies, new Comparable<Integer>() {
@Override
public int compareTo(Integer valueToCheck) {
clone.setLatencyInMinutes(valueToCheck);
boolean latencyWouldWork = isSchedulableWithoutConflict(clone);
// Check if one value less would not work, if so
// then this is the required latency, otherwise keep
// searching
if (latencyWouldWork) {
clone.setLatencyInMinutes(clone
.getLatencyInMinutes() - 1);
return (isSchedulableWithoutConflict(clone)) ? 1
: 0;
} else {
// Still too low, stuff would be unscheduled
return -1;
}
}
});
final Integer binarySearchedLatency = response.getItem();
if (binarySearchedLatency != null) {
latency = binarySearchedLatency.intValue();
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
statusHandler
.debug(String
.format("Found required latency of [%s] in [%s] iterations",
binarySearchedLatency,
response.getIterations()));
}
} else {
statusHandler
.warn(String
.format("Unable to find the required latency with a binary search, using required latency [%s]",
latency));
}
timer.stop();
int bufferRoomInMinutes = retrievalManager.getPlan(
subscription.getRoute()).getBucketMinutes();
final String logMsg = String
.format("Determined required latency of [%s] in [%s] ms. Adding buffer room of [%s] minutes",
latency, timer.getElapsedTime(),
bufferRoomInMinutes);
statusHandler.info(logMsg);
latency += bufferRoomInMinutes;
return latency;
} catch (SerializationException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to serialize a Subscription", e);
return -1;
boolean foundLatency = false;
int latency = subscription.getLatencyInMinutes();
if (latency < 1) {
latency = 1;
}
int previousLatency = latency;
do {
// Double the latency until we have two values we can binary
// search between...
previousLatency = latency;
latency *= 2;
Subscription clone = new Subscription(subscription);
clone.setLatencyInMinutes(latency);
foundLatency = isSchedulableWithoutConflict(clone);
} while (!foundLatency);
SortedSet<Integer> possibleLatencies = new TreeSet<Integer>();
for (int i = previousLatency; i < (latency + 1); i++) {
possibleLatencies.add(Integer.valueOf(i));
}
IBinarySearchResponse<Integer> response = AlgorithmUtil.binarySearch(
possibleLatencies, new Comparable<Integer>() {
@Override
public int compareTo(Integer valueToCheck) {
Subscription clone = new Subscription(subscription);
clone.setLatencyInMinutes(valueToCheck);
boolean latencyWouldWork = isSchedulableWithoutConflict(clone);
// Check if one value less would not work, if so
// then this is the required latency, otherwise keep
// searching
if (latencyWouldWork) {
clone.setLatencyInMinutes(clone
.getLatencyInMinutes() - 1);
return (isSchedulableWithoutConflict(clone)) ? 1
: 0;
} else {
// Still too low, stuff would be unscheduled
return -1;
}
}
});
final Integer binarySearchedLatency = response.getItem();
if (binarySearchedLatency != null) {
latency = binarySearchedLatency.intValue();
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
statusHandler.debug(String.format(
"Found required latency of [%s] in [%s] iterations",
binarySearchedLatency, response.getIterations()));
}
} else {
statusHandler
.warn(String
.format("Unable to find the required latency with a binary search, using required latency [%s]",
latency));
}
timer.stop();
int bufferRoomInMinutes = retrievalManager.getPlan(
subscription.getRoute()).getBucketMinutes();
final String logMsg = String
.format("Determined required latency of [%s] in [%s] ms. Adding buffer room of [%s] minutes",
latency, timer.getElapsedTime(), bufferRoomInMinutes);
statusHandler.info(logMsg);
latency += bufferRoomInMinutes;
return latency;
}
/**

View file

@ -298,4 +298,16 @@ public class BandwidthAllocation implements IPersistableDataObject<Long>,
return sb.toString();
}
/**
* Check whether this allocation is higher priority than another.
*
* @param other
* the other
* @return true if this allocation is higher priority than the other one
*/
public boolean isHigherPriorityThan(BandwidthAllocation other) {
// A lower priority value means it's higher priority
return this.getPriority() < other.getPriority();
}
}

View file

@ -28,7 +28,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Aug 27, 2012 726 jspinks Initial release.
* Oct 17, 2012 0726 djohnson If unable to find a bucket with floorKey, use ceilingKey.
* Oct 26, 2012 1286 djohnson Return list of unscheduled allocations.
*
* Jan 25, 2013 1528 djohnson Lower priority requests should not be able to unschedule higher priority requests.
* </pre>
*
* @version 1.0
@ -180,7 +180,10 @@ public class PriorityRetrievalScheduler implements IRetrievalScheduler {
for (BandwidthBucket bucket : window) {
for (BandwidthAllocation o : bucket.getRequests()) {
long estimatedSizeInBytes = o.getEstimatedSizeInBytes();
if (request.getPriority() > o.getPriority()) {
// This was bad... we just about released giving lower
// priority requests the ability to unschedule higher priority
// requests....
if (request.isHigherPriorityThan(o)) {
total += estimatedSizeInBytes;
lowerPriorityRequests.add(o);
}

View file

@ -207,7 +207,7 @@ public class BandwidthUtil {
// will have to revisit when other data type are introduced.
// perhaps minute of the day?
dao.setCycle(baseReferenceTime.get(Calendar.HOUR_OF_DAY));
dao.setPriority(subscription.getPriority());
dao.setPriority(subscription.getPriority().getPriorityValue());
dao.setRegistryId(subscription.getId());
return dao;
}

View file

@ -90,6 +90,7 @@ import dods.dap.DAS;
* Dec 10, 2012 1259 bsteffen Switch Data Delivery from LatLon to referenced envelopes.
* Jan 08, 2013 dhladky Performance enhancements, specific model fixes.
* Jan 18, 2013 1513 dhladky Level look up improvements.
* Jan 24, 2013 1527 dhladky Changed 0DEG to FRZ
*
* </pre>
*
@ -419,7 +420,6 @@ class OpenDAPMetaDataParser extends MetaDataParser {
parm.setLevels(getLevels(type, collectionName, gdsmd, dz,
levMin, levMax));
parm.addLevelType(type);
parameters.put(name, parm);
} catch (Exception le) {
@ -494,6 +494,11 @@ class OpenDAPMetaDataParser extends MetaDataParser {
type.addLayer(new Double(10).doubleValue());
type.setUnit(serviceConfig.getConstantValue("METER"));
}
// FRZ freezing level, catches one's with on the end of the param name
// hgt0c etc
else if (param.getProviderName().endsWith(LevelType.FRZ.getLevelType())) {
type = new DataLevelType(LevelType.FRZ);
}
// Really special cases presented by NOMADS data sets
if (type == null) {
@ -573,8 +578,8 @@ class OpenDAPMetaDataParser extends MetaDataParser {
type = new DataLevelType(LevelType.MSL);
} else if (w1.equals(LevelType.EA.getLevelType())) {
type = new DataLevelType(LevelType.EA);
} else if (w1.equals(LevelType.ODEG.getLevelType())) {
type = new DataLevelType(LevelType.ODEG);
} else if (w1.equals(LevelType.FRZ.getLevelType())) {
type = new DataLevelType(LevelType.FRZ);
} else if (w1.equals(LevelType.LCY.getLevelType())) {
type = new DataLevelType(LevelType.LCY);
} else if (w1.equals(LevelType.MCY.getLevelType())) {

View file

@ -30,6 +30,7 @@
# 06/16/10 njensen Initial Creation.
# 05/03/11 9134 njensen Optimized for pointdata
# 10/09/12 rjpeter Optimized __getGroup for retrievals
# 01/17/13 DR 15294 D. Friedman Clear out data in response
#
#
#
@ -94,6 +95,9 @@ class H5pyDataStore(IDataStore.IDataStore):
except:
logger.warn("Exception occurred on file " + fn + ":" + IDataStore._exc())
exc.append(IDataStore._exc())
# Clear out data so we don't send the whole thing back to the client.
# NOTE: This assumes pypies no longer needs the data
r.putDataObject(None)
failRecs.append(r)
if ss:

View file

@ -5,7 +5,7 @@
Name: awips2-ldm
Summary: AWIPS II LDM Distribution
Version: 6.8.1
Release: 28
Release: 29
Group: AWIPSII
BuildRoot: /tmp
URL: N/A

View file

@ -151,7 +151,15 @@ public abstract class AbstractBandwidthManagerIntTest {
*/
protected Subscription createSubscriptionThatFillsUpABucket() {
return createSubscriptionWithDataSetSizeInBytes(fullBucketSize);
}
/**
* Create a subscription the fills up ten buckets.
*
* @return the subscription
*/
protected Subscription createSubscriptionThatFillsUpTenBuckets() {
return createSubscriptionWithDataSetSizeInBytes(fullBucketSize * 10);
}
/**

View file

@ -19,8 +19,11 @@
**/
package com.raytheon.uf.edex.datadelivery.bandwidth;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.text.ParseException;
@ -47,6 +50,7 @@ import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetMetaDat
import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetMetaDataFixture;
import com.raytheon.uf.common.datadelivery.registry.ParameterFixture;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionFixture;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
@ -81,6 +85,9 @@ import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
* Oct 12, 2012 0726 djohnson Initial creation
* Oct 23, 2012 1286 djohnson Create reusable abstract int test.
* Dec 11, 2012 1286 djohnson Add test verifying fulfilled retrievals won't cause NPEs when the subscription is updated.
* Jan 25, 2013 1528 djohnson Compare priorities as primitive ints.
* Jan 28, 2013 1530 djohnson Test that all allocations are unscheduled for subscription that doesn't fully schedule.
* Jan 30, 2013 1501 djohnson Fix broken calculations for determining required latency.
*
* </pre>
*
@ -313,7 +320,7 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
Subscription subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will have higher priority
subscription2.setPriority(subscription.getPriority() + 1);
subscription2.setPriority(SubscriptionPriority.HIGH);
// they conflict for cycle hour 8
subscription.getTime().setCycleTimes(
@ -335,16 +342,45 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
BandwidthAllocation unscheduledAllocation = iter.next();
assertEquals(
"The first subscription with lower priority should have been the one unscheduled.",
subscription.getPriority().intValue(),
subscription.getPriority().getPriorityValue(),
unscheduledAllocation.getPriority(), 0.0);
unscheduledAllocation = iter.next();
assertEquals(
"The first subscription with lower priority should have been the one unscheduled.",
subscription.getPriority().intValue(),
subscription.getPriority().getPriorityValue(),
unscheduledAllocation.getPriority(), 0.0);
}
@Test
public void unscheduledSubscriptionUnschedulesAllAllocations() {
String unscheduledSubDataSetName = "willBeUnscheduled";
Subscription subscription = createSubscriptionThatFillsUpABucket();
subscription.setDataSetName(unscheduledSubDataSetName);
Subscription subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will have higher priority
subscription2.setPriority(SubscriptionPriority.HIGH);
// they conflict for cycle hour 8
subscription.getTime().setCycleTimes(
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
subscription2.getTime().setCycleTimes(
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
bandwidthManager.schedule(subscription);
bandwidthManager.schedule(subscription2);
final List<SubscriptionRetrieval> subscriptionRetrievals = bandwidthDao
.getSubscriptionRetrievals(subscription.getProvider(),
unscheduledSubDataSetName);
for (SubscriptionRetrieval subscriptionRetrieval : subscriptionRetrievals) {
assertThat(subscriptionRetrieval.getStatus(),
is(equalTo(RetrievalStatus.UNSCHEDULED)));
}
}
@Test
public void testScheduleSubscriptionWithHigherPrioritySetsOtherAllocationsToUnscheduled() {
@ -352,7 +388,7 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
Subscription subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will have higher priority
subscription2.setPriority(subscription.getPriority() + 1);
subscription2.setPriority(SubscriptionPriority.HIGH);
// they conflict for cycle hour 8
subscription.getTime().setCycleTimes(
@ -389,7 +425,7 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
Subscription subscription2 = createSubscriptionThatFillsUpABucket();
// subscription2 will have higher priority
subscription2.setPriority(subscription.getPriority() + 1);
subscription2.setPriority(SubscriptionPriority.HIGH);
// they conflict for cycle hour 8
subscription.getTime().setCycleTimes(
@ -419,8 +455,6 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
// Subscription starts out too big
Subscription subscription = createSubscriptionThatFillsUpTwoBuckets();
// they conflict for cycle hour 8
subscription.getTime().setCycleTimes(Arrays.asList(Integer.valueOf(6)));
List<BandwidthAllocation> unscheduled = bandwidthManager
@ -432,6 +466,7 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
// Hey look, this subscription will fit now!
subscription.setDataSetSize(subscription.getDataSetSize() / 2);
subscription.setUnscheduled(false);
unscheduled = bandwidthManager.subscriptionUpdated(subscription);
@ -456,15 +491,14 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
public void testDetermineRequiredLatencyReturnsNecessaryLatency()
throws SerializationException {
// Subscription starts out too big
Subscription subscription = createSubscriptionThatFillsUpTwoBuckets();
Subscription subscription = createSubscriptionThatFillsUpTenBuckets();
subscription.getTime().setCycleTimes(Arrays.asList(Integer.valueOf(0)));
subscription.setLatencyInMinutes(0);
int requiredLatency = bandwidthManager
.determineRequiredLatency(subscription);
assertEquals("The required latency was calculated incorrectly", 6,
assertEquals("The required latency was calculated incorrectly", 30,
requiredLatency);
}
@ -712,7 +746,7 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
final List<BandwidthAllocation> bandwidthAllocations = bandwidthDao
.getBandwidthAllocations(subscription.getRoute());
assertEquals("Incorrect number of allocations found.", 4,
assertEquals("Incorrect number of allocations found.", 0,
bandwidthAllocations.size());
sendDeletedSubscriptionEvent(subscription);
@ -745,7 +779,7 @@ public class BandwidthManagerIntTest extends AbstractBandwidthManagerIntTest {
final List<SubscriptionDao> subscriptionDaos = bandwidthDao
.getSubscriptionDao(subscription);
assertEquals("Incorrect number of subscription daos found.", 4,
assertEquals("Incorrect number of subscription daos found.", 0,
subscriptionDaos.size());
sendDeletedSubscriptionEvent(subscription);

View file

@ -47,6 +47,7 @@ import com.raytheon.uf.common.datadelivery.registry.AdhocSubscription;
import com.raytheon.uf.common.datadelivery.registry.AdhocSubscriptionFixture;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
@ -425,7 +426,7 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
Subscription subscription = createSubscriptionThatFillsUpTwoBuckets();
subscription.setLatencyInMinutes(6);
subscription.setPriority(2);
subscription.setPriority(SubscriptionPriority.HIGH);
// Reserves a full bucket at 19700103 18:03:00 which fragments the
// subscription to 19700103 18:00:00 and 18:06:00
@ -538,9 +539,9 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
// Two subscriptions that will fill up a bucket exactly
Subscription subscription = createSubscriptionThatFillsUpABucket();
subscription.setPriority(2);
subscription.setPriority(SubscriptionPriority.NORMAL);
Subscription subscription2 = createSubscriptionThatFillsUpABucket();
subscription.setPriority(4);
subscription.setPriority(SubscriptionPriority.HIGH);
// subscription2 will not be able to schedule for cycle hour 8
subscription.getTime().setCycleTimes(
@ -552,7 +553,8 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
service.schedule(subscription2);
BandwidthGraphData graphData = service.getBandwidthGraphData();
final Map<String, Integer> priorityMap = graphData.getPriorityMap();
final Map<String, SubscriptionPriority> priorityMap = graphData
.getPriorityMap();
assertThat(priorityMap.get(subscription.getName()),
is(equalTo(subscription.getPriority())));

View file

@ -23,6 +23,7 @@ import java.util.Date;
import java.util.Random;
import com.google.common.collect.Lists;
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;
@ -79,7 +80,7 @@ public abstract class BaseSubscriptionFixture<T extends Subscription> extends
subscription.setParameter(Lists.<Parameter> newArrayList());
// Same priority for all, individual tests needing to test specific
// priorities should set it manually anyway
subscription.setPriority(1);
subscription.setPriority(SubscriptionPriority.NORMAL);
subscription.setProvider(ProviderFixture.INSTANCE.get(seedValue)
.getName());
subscription.setSubscriptionStart(subscription.getActivePeriodStart());

View file

@ -21,6 +21,7 @@ package com.raytheon.uf.common.datadelivery.registry;
import java.util.Date;
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;
@ -73,7 +74,7 @@ public class SubscriptionBuilder {
private String owner = "your_user";
private int priority = 1;
private SubscriptionPriority priority = SubscriptionPriority.NORMAL;
private Date subscriptionStart = TimeUtil.newDate();
@ -256,7 +257,7 @@ public class SubscriptionBuilder {
* @param priority
* the priority to set
*/
public SubscriptionBuilder withPriority(int priority) {
public SubscriptionBuilder withPriority(SubscriptionPriority priority) {
this.priority = priority;
return this;
}