Merge branch 'development' into development_on_RHEL6

Former-commit-id: f6d98d6317 [formerly e1969dc2abafe372c0e9a874f464fc5336efd119]
Former-commit-id: 64dd62005b
This commit is contained in:
Greg Armendariz 2013-10-30 14:52:16 -05:00
commit 4fb0e0bd2f
110 changed files with 3057 additions and 588 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Core Plug-in
Bundle-SymbolicName: com.raytheon.uf.viz.core;singleton:=true
Bundle-Version: 1.12.1174.qualifier
Bundle-Version: 1.13.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.core.Activator
Bundle-Vendor: Raytheon
Require-Bundle: org.eclipse.ui,
@ -77,6 +77,7 @@ Export-Package: com.raytheon.uf.viz.core,
com.raytheon.uf.viz.core.notification.observers,
com.raytheon.uf.viz.core.preferences,
com.raytheon.uf.viz.core.procedures,
com.raytheon.uf.viz.core.reflect,
com.raytheon.uf.viz.core.requests,
com.raytheon.uf.viz.core.rsc,
com.raytheon.uf.viz.core.rsc.capabilities,

View file

@ -61,10 +61,10 @@ public class InterpolationContainer implements INumpyable {
/*
* (non-Javadoc)
*
* @see jep.INumpyable#getNumPy()
* @see jep.INumpyable#getNumpy()
*/
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
// todo
return new Object[] { xValues, yValues, zValues };
}

View file

@ -39,6 +39,7 @@ import com.raytheon.uf.viz.datadelivery.bandwidth.ui.GraphDataUtil;
* ------------ ---------- ----------- --------------------------
* Nov 25, 2012 1269 mpduff Initial creation.
* Dec 13, 2012 1269 lvenable Updated to use a graph utility for the graph data.
* Oct 28, 2013 2430 mpduff Removed redraw if already open.
*
* </pre>
*
@ -64,7 +65,6 @@ public class BandwidthScheduleGraphAction extends AbstractHandler {
dlg = new BandwidthUtilizationDlg(shell, gdu);
dlg.open();
} else {
dlg.redrawGraph();
dlg.open();
}

View file

@ -47,6 +47,7 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -61,6 +62,7 @@ import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Slider;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.service.SubscriptionNotificationResponse;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -71,6 +73,8 @@ import com.raytheon.uf.viz.core.notification.NotificationException;
import com.raytheon.uf.viz.core.notification.NotificationMessage;
import com.raytheon.uf.viz.core.notification.jobs.NotificationManagerJob;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.CanvasImages;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphSection;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphType;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.SortBy;
import com.raytheon.uf.viz.datadelivery.common.ui.IDialogClosed;
import com.raytheon.uf.viz.datadelivery.common.ui.SubscriptionViewer;
@ -78,9 +82,10 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
/**
*
* This class contains all of the canvases for graphing data. There are Graph ,
* X Label, Y Label, X Header, and Y Header canvases on the display. The Graph,
* X Label, and Y Label canvases can be zoomed and panned.
* This class contains all of the canvases for graphing data. There are
* Subscription Graph, Bandwidth Graph, X Label, Y Label, X Header, and Y Header
* canvases on the display. The Graph, X Label, and Y Label canvases can be
* zoomed and panned.
*
* <pre>
*
@ -92,7 +97,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
* 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.
*
* Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph.
* </pre>
*
* @author lvenable
@ -105,6 +110,8 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(BandwidthCanvasComp.class);
private final int MISSING = -999;
/** Parent composite */
private final Composite parentComp;
@ -165,12 +172,18 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
/** Counts the minutes until the next full update. */
private int fullUpdateMinuteCount = 0;
/** Vertical line marking the mouse pointer's location */
private int mouseMarker;
/** Bandwidth popup menu */
private Menu bandwidthPopupMenu;
/**
* Constructor.
*
* @param parentComp
* Parent composite.
* @param bgd
* @param graphDataUtil
* Bandwidth graph data object
*/
public BandwidthCanvasComp(Composite parentComp, GraphDataUtil graphDataUtil) {
@ -211,16 +224,28 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
this.setLayout(gl);
this.setLayoutData(gd);
createFillerSpace(2);
createUtilizationHeaderCanvas();
createFillerSpace(1);
createFillerSpace(1);
createUtilizationLabelCanvas();
createUtilizationGraphCanvas();
createFillerSpace(1);
createFillerSpace(2);
createXHeaderCanvas();
createFillerSpace(1);
createYHeaderCanvas();
createYLabelCanvas();
createGraphCanvas();
createVerticalSlider();
createFillerSpace(2);
createXLabelCanvas();
createFillerSpace(1);
createFillerSpace(2);
createHorizontalSlider();
createFillerSpace(1);
@ -315,6 +340,18 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
// Create the y header canvas settings
cs = new CanvasSettings(35, heightWithBuffer, 35, 440, 0, 0);
canvasSettingsMap.put(CanvasImages.Y_HEADER, cs);
// Create the bandwidth utilization header settings
cs = new CanvasSettings(140, 60, 140, 0, 20, 0);
canvasSettingsMap.put(CanvasImages.UTILIZATION_LABEL, cs);
// Create the bandwidth utilization graph settings
cs = new CanvasSettings(740, 60, graphSize.x, 100, xSpaceBuffer, 0);
canvasSettingsMap.put(CanvasImages.UTILIZATION_GRAPH, cs);
// Create the Utilization header canvas settings
cs = new CanvasSettings(740, 40, 740, 40, xSpaceBuffer, 0);
canvasSettingsMap.put(CanvasImages.UTILIZATION_HEADER, cs);
}
/**
@ -365,6 +402,124 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
spaceLbl.setVisible(false);
}
/**
* Create the utilization graph header canvas.
*/
private void createUtilizationHeaderCanvas() {
Canvas canvas = new Canvas(this, SWT.DOUBLE_BUFFERED);
CanvasSettings cs = canvasSettingsMap
.get(CanvasImages.UTILIZATION_HEADER);
GridData gd = new GridData(cs.getCanvasWidth(), cs.getCanvasHeight());
canvas.setLayoutData(gd);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
drawUtilizationHeaderCanvas(e.gc);
}
});
canvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
if (e.button == 1) {
handleUtilizationHeaderMouseEvent(e);
}
}
});
canvasMap.put(CanvasImages.UTILIZATION_HEADER, canvas);
}
/**
* Create the utilization graph's label canvas.
*/
private void createUtilizationLabelCanvas() {
Canvas canvas = new Canvas(this, SWT.DOUBLE_BUFFERED);
CanvasSettings cs = canvasSettingsMap
.get(CanvasImages.UTILIZATION_LABEL);
GridData gd = new GridData(cs.getCanvasWidth(), cs.getCanvasHeight());
canvas.setLayoutData(gd);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
drawUtilizationLabelCanvas(e.gc);
}
});
canvasMap.put(CanvasImages.UTILIZATION_LABEL, canvas);
}
/**
* Create the utilization graph canvas.
*/
private void createUtilizationGraphCanvas() {
Canvas canvas = new Canvas(this, SWT.DOUBLE_BUFFERED);
CanvasSettings cs = canvasSettingsMap
.get(CanvasImages.UTILIZATION_GRAPH);
GridData gd = new GridData(cs.getCanvasWidth(), cs.getCanvasHeight());
canvas.setLayoutData(gd);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
drawUtilizationGraphCanvas(e.gc);
}
});
/*
* Add a mouse track listener to determine when the mouse hovers over
* the canvas.
*/
canvas.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
// Remove mouse vertical line
mouseMarker = MISSING;
canvasMap.get(CanvasImages.GRAPH).redraw();
canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw();
}
});
/*
* Add a mouse move listener to determine when the mouse is moving over
* the canvas.
*/
canvas.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
// If the mouse button is not pressed then set the previous
// mouse x,y coordinates to the current mouse x,y position.
if (!mouseDown) {
previousMousePoint.x = e.x;
previousMousePoint.y = e.y;
mouseMarker = e.x;
canvasMap.get(CanvasImages.GRAPH).redraw();
canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw();
return;
}
mouseMarker = MISSING;
}
});
canvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
if (e.button == 3) {
bandwidthUsedPopupMenu();
}
}
});
canvasMap.put(CanvasImages.UTILIZATION_GRAPH, canvas);
}
/**
* Create the X header canvas.
*/
@ -424,7 +579,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
* Create the graph canvas.
*/
private void createGraphCanvas() {
Canvas graphCanvas = new Canvas(this, SWT.DOUBLE_BUFFERED);
final Canvas graphCanvas = new Canvas(this, SWT.DOUBLE_BUFFERED);
GridData gd = new GridData(graphCanvasSettings.getCanvasWidth(),
graphCanvasSettings.getCanvasHeight());
@ -468,6 +623,14 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
* the canvas.
*/
graphCanvas.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
// Remove mouse vertical line
mouseMarker = MISSING;
canvasMap.get(CanvasImages.GRAPH).redraw();
canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw();
}
@Override
public void mouseHover(MouseEvent e) {
displayToolTipText(e, CanvasImages.GRAPH);
@ -487,6 +650,9 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
if (mouseDown == false) {
previousMousePoint.x = e.x;
previousMousePoint.y = e.y;
mouseMarker = e.x;
canvasMap.get(CanvasImages.GRAPH).redraw();
canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw();
return;
}
@ -523,6 +689,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
canvasMap.get(CanvasImages.GRAPH).redraw();
canvasMap.get(CanvasImages.X_LABEL).redraw();
canvasMap.get(CanvasImages.Y_LABEL).redraw();
canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw();
previousMousePoint.x = e.x;
previousMousePoint.y = e.y;
@ -719,6 +886,47 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
canvasMap.get(CanvasImages.GRAPH).redraw();
canvasMap.get(CanvasImages.X_LABEL).redraw();
canvasMap.get(CanvasImages.UTILIZATION_GRAPH).redraw();
}
private void drawUtilizationHeaderCanvas(GC gc) {
gc.drawImage(imgMap.get(CanvasImages.UTILIZATION_HEADER), 0, 0);
}
private void drawUtilizationLabelCanvas(GC gc) {
gc.drawImage(imgMap.get(CanvasImages.UTILIZATION_LABEL), 0, 0);
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
CanvasSettings cs = canvasSettingsMap
.get(CanvasImages.UTILIZATION_LABEL);
gc.drawLine(0, 0, cs.getCanvasWidth(), 0);
gc.drawLine(0, 0, 0, cs.getCanvasHeight());
gc.drawLine(0, cs.getCanvasHeight() - 1, cs.getCanvasWidth(),
cs.getCanvasHeight() - 1);
gc.drawLine(cs.getCanvasWidth() - 1, 0, cs.getCanvasWidth() - 1,
cs.getCanvasHeight() - 1);
}
private void drawUtilizationGraphCanvas(GC gc) {
gc.drawImage(imgMap.get(CanvasImages.UTILIZATION_GRAPH),
cornerPointOffset.x, 0);
CanvasSettings cs = canvasSettingsMap
.get(CanvasImages.UTILIZATION_GRAPH);
// draw the mouse locator line
if (mouseMarker != MISSING && mouseMarker > cs.getXSpaceBuffer()) {
gc.drawLine(mouseMarker, 0, mouseMarker, cs.getCanvasHeight());
}
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.drawLine(0, 0, cs.getCanvasWidth(), 0);
gc.drawLine(0, 0, 0, cs.getCanvasHeight());
gc.drawLine(0, cs.getCanvasHeight() - 1, cs.getCanvasWidth(),
cs.getCanvasHeight() - 1);
gc.drawLine(cs.getCanvasWidth() - 1, 0, cs.getCanvasWidth() - 1,
cs.getCanvasHeight() - 1);
}
/**
@ -751,6 +959,13 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
gc.drawImage(imgMap.get(CanvasImages.GRAPH), cornerPointOffset.x,
cornerPointOffset.y);
// draw the mouse locator line
if (mouseMarker != MISSING
&& mouseMarker > graphCanvasSettings.getXSpaceBuffer()) {
gc.drawLine(mouseMarker, 0, mouseMarker,
graphCanvasSettings.getCanvasHeight());
}
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.drawLine(0, 0, graphCanvasSettings.getCanvasWidth(), 0);
gc.drawLine(0, 0, 0, graphCanvasSettings.getCanvasHeight());
@ -845,6 +1060,19 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
redrawImage(CanvasImages.GRAPH);
}
/**
* Handle the mouse event on the Utilization header canvas.
*
* @param me
* Mouse Event
*/
private void handleUtilizationHeaderMouseEvent(MouseEvent me) {
imageMgr.performAction(CanvasImages.UTILIZATION_HEADER, new Point(me.x,
me.y));
redrawImage(CanvasImages.UTILIZATION_HEADER);
redrawImage(CanvasImages.UTILIZATION_GRAPH);
}
/**
* Scroll wheel event handler.
*
@ -970,6 +1198,37 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
m.setVisible(true);
}
private void bandwidthUsedPopupMenu() {
if (bandwidthPopupMenu == null) {
bandwidthPopupMenu = new Menu(this.getShell(), SWT.POP_UP);
MenuItem lineMenu = new MenuItem(bandwidthPopupMenu, SWT.RADIO);
lineMenu.setText("Display as Line Graph");
lineMenu.setSelection(true);
lineMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleBandwidthGraphStyleSelection(GraphType.LINE);
}
});
MenuItem barMenu = new MenuItem(bandwidthPopupMenu, SWT.RADIO);
barMenu.setText("Display as Bar Graph");
barMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleBandwidthGraphStyleSelection(GraphType.BAR);
}
});
}
bandwidthPopupMenu.setVisible(true);
}
protected void handleBandwidthGraphStyleSelection(GraphType type) {
imageMgr.setBandwidthGraphType(type);
redrawImage(CanvasImages.UTILIZATION_GRAPH);
}
/**
* Select/Deselect all event handler.
*
@ -1038,7 +1297,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
* @param ci
* The image to redraw
*/
private void redrawImage(CanvasImages ci) {
protected void redrawImage(CanvasImages ci) {
imageMgr.regenerateImage(ci);
imgMap.put(ci, imageMgr.getImage(ci));
canvasMap.get(ci).redraw();
@ -1094,6 +1353,7 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
public void setColorByPriority(boolean colorByPriority) {
imageMgr.setColorByPriority(colorByPriority);
redrawImage(CanvasImages.GRAPH);
redrawImage(CanvasImages.UTILIZATION_GRAPH);
}
/**
@ -1146,8 +1406,10 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
.getTimeInMillis());
redrawImage(CanvasImages.GRAPH);
redrawImage(CanvasImages.X_LABEL);
redrawImage(CanvasImages.UTILIZATION_GRAPH);
canvasMap.get(CanvasImages.GRAPH).redraw();
canvasMap.get(CanvasImages.X_LABEL).redraw();
canvasMap.get(CanvasImages.UTILIZATION_GRAPH);
}
});
@ -1191,4 +1453,50 @@ public class BandwidthCanvasComp extends Composite implements IDialogClosed,
}
});
}
/**
* Set the network for display.
*
* @param network
* The network to display
*/
public void setGraphNetwork(Network network) {
imageMgr.setGraphNetwork(network);
redrawImage(CanvasImages.GRAPH);
redrawImage(CanvasImages.UTILIZATION_GRAPH);
redrawImage(CanvasImages.UTILIZATION_HEADER);
redrawImage(CanvasImages.UTILIZATION_LABEL);
redrawImage(CanvasImages.X_HEADER);
redrawImage(CanvasImages.X_LABEL);
redrawImage(CanvasImages.Y_HEADER);
redrawImage(CanvasImages.Y_LABEL);
}
/**
* Set the bandwidth used threshold values.
*
* @param thresholdValues
* The threshold values
*/
public void setBandwidthThresholdValues(int[] thresholdValues) {
imageMgr.setBandwidthThreholdValues(thresholdValues);
}
/**
* Get the bandwidth used threshold values.
*
* @return thresholdValues The threshold values
*/
public int[] getBandwidthThresholdValues() {
return imageMgr.getBandwidthThreholdValues();
}
/**
* Get the bandwidth threshold colors.
*
* @return Threshold colors
*/
public Map<GraphSection, RGB> getBandwidthThresholdColors() {
return imageMgr.getPercentageColorMap();
}
}

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.viz.datadelivery.bandwidth.ui;
import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import org.eclipse.swt.graphics.Image;
@ -31,7 +32,9 @@ 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.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.viz.core.RGBColors;
/**
* Bandwidth utilization graph image manager.
@ -42,10 +45,11 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPri
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 28, 2012 1269 lvenable Initial creation
* 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 on subscriptions.
* Jan 28, 2013 1529 djohnson Add hasSubscriptionNameChecked().
* Jan 28, 2013 1529 djohnson Add hasSubscriptionNameChecked().
* Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph.
*
* </pre>
*
@ -58,7 +62,7 @@ public class BandwidthImageMgr implements IGraphOptions {
* Image type enumeration.
*/
public enum CanvasImages {
X_HEADER, Y_HEADER, GRAPH, X_LABEL, Y_LABEL;
X_HEADER, Y_HEADER, GRAPH, X_LABEL, Y_LABEL, UTILIZATION_LABEL, UTILIZATION_GRAPH, UTILIZATION_HEADER;
};
/**
@ -80,6 +84,20 @@ public class BandwidthImageMgr implements IGraphOptions {
}
}
/**
* Graph Type
*/
public enum GraphType {
BAR, LINE;
}
/**
* Signifies which section of the graph.
*/
public enum GraphSection {
LOWER, MIDDLE, UPPER;
}
/** Map of CanvasImages type -> image */
private Map<CanvasImages, AbstractCanvasImage> canvasImgMap;
@ -107,9 +125,21 @@ public class BandwidthImageMgr implements IGraphOptions {
/** Sort time in millis */
private long sortTimeMillis;
/** Map of priorities to colors. This hold the changed colors by the user. */
/** Map of priorities to colors. This holds the colors changed by the user. */
private Map<SubscriptionPriority, RGB> priorityColorMap;
/** Map of percentage to colors. This holds the colors changed by the user. */
private Map<GraphSection, RGB> percentageColorMap = new LinkedHashMap<GraphSection, RGB>(
3);
/** The bandwidth graph type */
private GraphType bandwidthGraphType = GraphType.LINE;
/** The network currently displayed in the graph */
private Network network = Network.OPSNET;
private int[] bandwidthThreholdValues = new int[] { 33, 66 };
/**
* Constructor.
*
@ -139,13 +169,17 @@ public class BandwidthImageMgr implements IGraphOptions {
*/
private void init(Composite parentComp, BandwidthGraphData graphData,
Map<CanvasImages, CanvasSettings> canvasSettingsMap) {
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));
percentageColorMap.put(GraphSection.LOWER, new RGB(0, 255, 0));
percentageColorMap.put(GraphSection.MIDDLE,
RGBColors.getRGBColor("yellow"));
percentageColorMap.put(GraphSection.UPPER, new RGB(255, 0, 0));
canvasImgMap = new HashMap<BandwidthImageMgr.CanvasImages, AbstractCanvasImage>();
populateCanvasMap(parentComp, graphData, canvasSettingsMap);
}
@ -188,6 +222,21 @@ public class BandwidthImageMgr implements IGraphOptions {
aci = new YHeaderImage(parentComp, cs, graphData);
canvasImgMap.put(CanvasImages.Y_HEADER, aci);
// utilization header image
cs = canvasSettingsMap.get(CanvasImages.UTILIZATION_HEADER);
aci = new UtilizationHeaderImage(parentComp, cs, this);
canvasImgMap.put(CanvasImages.UTILIZATION_HEADER, aci);
// utilization label image
cs = canvasSettingsMap.get(CanvasImages.UTILIZATION_LABEL);
aci = new UtilizationLabelImage(parentComp, cs, this);
canvasImgMap.put(CanvasImages.UTILIZATION_LABEL, aci);
// utilization graph image
cs = canvasSettingsMap.get(CanvasImages.UTILIZATION_GRAPH);
aci = new UtilizationGraphImage(parentComp, cs, graphData, this);
canvasImgMap.put(CanvasImages.UTILIZATION_GRAPH, aci);
// Regenerate all of the images
for (CanvasImages ci : CanvasImages.values()) {
canvasImgMap.get(ci).regenerateImage();
@ -501,4 +550,87 @@ public class BandwidthImageMgr implements IGraphOptions {
public boolean hasSubscriptionNameChecked() {
return checkMap.containsValue(Boolean.TRUE);
}
/**
* @return the percentageColorMap
*/
public Map<GraphSection, RGB> getPercentageColorMap() {
return percentageColorMap;
}
/**
* @param percentageColorMap
* the percentageColorMap to set
*/
public void setPercentageColorMap(Map<GraphSection, RGB> percentageColorMap) {
this.percentageColorMap = percentageColorMap;
}
/**
* {@inheritDoc}
*/
@Override
public RGB getPercentColor(GraphSection section) {
return this.percentageColorMap.get(section);
}
/**
* {@inheritDoc}
*/
@Override
public void setPercentColor(GraphSection percentString, RGB rgb) {
this.percentageColorMap.put(percentString, rgb);
}
/**
* Set the bandwidth used graph type.
*
* @param type
* The graph type
*/
public void setBandwidthGraphType(GraphType type) {
this.bandwidthGraphType = type;
}
/**
* Get the bandwidth graph type.
*
* @return The Bandwidth graph type
*/
public GraphType getBandwidthGraphType() {
return this.bandwidthGraphType;
}
/**
* Set the network.
*
* @param network
* The network
*/
public void setGraphNetwork(Network network) {
this.network = network;
}
/**
* Get the network.
*
* @return The network
*/
public Network getNetwork() {
return this.network;
}
/**
* @return the bandwidthThreholdValues
*/
public int[] getBandwidthThreholdValues() {
return bandwidthThreholdValues;
}
/**
* @param bandwidthThreholdValues
* the bandwidthThreholdValues to set
*/
public void setBandwidthThreholdValues(int[] bandwidthThreholdValues) {
this.bandwidthThreholdValues = bandwidthThreholdValues;
}
}

View file

@ -0,0 +1,179 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.datadelivery.bandwidth.ui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
import com.raytheon.viz.ui.widgets.TwoValueSliderCanvas;
/**
* Dialog to configure the values for the bandwidth used graph.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 27, 2013 2430 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class BandwidthUsedConfigDlg extends CaveSWTDialogBase {
private TwoValueSliderCanvas slider;
private final int lowerVal;
private final int upperVal;
private final RGB lowerColor;
private final RGB midColor;
private final RGB upperColor;
/**
* Constructor.
*
* @param shell
* The parent shell
* @param lowerVal
* The lower threshold value
* @param upperVal
* The upper threshold value
* @param lowerColor
* The lower threshold color
* @param midColor
* The middle threshold color
* @param upperColor
* The upper threshold color
*/
public BandwidthUsedConfigDlg(Shell shell, int lowerVal, int upperVal,
RGB lowerColor, RGB midColor, RGB upperColor) {
super(shell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK
| CAVE.INDEPENDENT_SHELL);
this.setText("Utilization Threshold");
this.lowerVal = lowerVal;
this.upperVal = upperVal;
this.lowerColor = lowerColor;
this.midColor = midColor;
this.upperColor = upperColor;
}
/**
* {@inheritDoc}
*/
@Override
protected Layout constructShellLayout() {
return new GridLayout(1, false);
}
/**
* {@inheritDoc}
*/
@Override
protected Object constructShellLayoutData() {
return new GridData(SWT.FILL, SWT.DEFAULT, true, false);
}
/**
* {@inheritDoc}
*/
@Override
protected void initializeComponents(Shell shell) {
Group thresholdGroup = new Group(shell, SWT.NONE);
thresholdGroup.setLayout(new GridLayout(1, false));
thresholdGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
true));
thresholdGroup.setText(" Bandwidth Threshold Configuration ");
slider = new TwoValueSliderCanvas(thresholdGroup, 0, 100, 1, lowerVal,
upperVal, lowerColor, midColor, upperColor);
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
GridLayout gl = new GridLayout(2, true);
Composite buttonComp = new Composite(shell, SWT.NONE);
buttonComp.setLayoutData(gd);
buttonComp.setLayout(gl);
gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
gd.widthHint = 70;
Button okBtn = new Button(buttonComp, SWT.PUSH);
okBtn.setText("OK");
okBtn.setLayoutData(gd);
okBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int[] returnVal = new int[2];
returnVal[0] = slider.getLowerValue();
returnVal[1] = slider.getUpperValue();
setReturnValue(returnVal);
close();
}
});
gd = new GridData(SWT.LEFT, SWT.DEFAULT, true, false);
gd.widthHint = 70;
Button cancelBtn = new Button(buttonComp, SWT.PUSH);
cancelBtn.setText("Cancel");
cancelBtn.setLayoutData(gd);
cancelBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setReturnValue(false);
close();
}
});
}
/**
* Get the lower value.
*
* @return The lower value
*/
public int getLowerValue() {
return slider.getLowerValue();
}
/**
* Get the upper value.
*
* @return The upper value
*/
public int getUpperValue() {
return slider.getUpperValue();
}
}

View file

@ -19,9 +19,12 @@
**/
package com.raytheon.uf.viz.datadelivery.bandwidth.ui;
import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@ -31,7 +34,11 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.CanvasImages;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphSection;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.dialogs.ICloseCallback;
/**
* Bandwidth Utilization Dialog.
@ -44,6 +51,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* ------------ ---------- ----------- --------------------------
* Nov 28, 2012 1269 mpduff Initial creation.
* Dec 13, 2012 1269 lvenable Fixes and updates.
* Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph.
*
* </pre>
*
@ -69,13 +77,19 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog {
private BandwidthCanvasComp canvasComp;
/** Graph data utility class */
private GraphDataUtil graphDataUtil;
private final GraphDataUtil graphDataUtil;
private MenuItem displayOpsNetMI;
private MenuItem displaySbnMI;
/**
* Constructor.
*
* @param parent
* Parent shell
* @param graphDataUtil
* Graph data utility object
*/
public BandwidthUtilizationDlg(Shell parent, GraphDataUtil graphDataUtil) {
super(parent, SWT.DIALOG_TRIM | SWT.MIN, CAVE.DO_NOT_BLOCK
@ -193,6 +207,27 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog {
Menu graphMenu = new Menu(menuBar);
graphMenuItem.setMenu(graphMenu);
displayOpsNetMI = new MenuItem(graphMenu, SWT.RADIO);
displayOpsNetMI.setSelection(true);
displayOpsNetMI.setText("Display for OPSNET");
displayOpsNetMI.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
canvasComp.setGraphNetwork(Network.OPSNET);
}
});
displaySbnMI = new MenuItem(graphMenu, SWT.RADIO);
displaySbnMI.setText("Display for SBN");
displaySbnMI.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
canvasComp.setGraphNetwork(Network.SBN);
}
});
new MenuItem(graphMenu, SWT.SEPARATOR);
liveUpdateMI = new MenuItem(graphMenu, SWT.CHECK);
liveUpdateMI.setText("Live Update");
liveUpdateMI.setSelection(true);
@ -204,7 +239,7 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog {
});
colorByPriorityMI = new MenuItem(graphMenu, SWT.CHECK);
colorByPriorityMI.setText("Color By Priority");
colorByPriorityMI.setText("Color By Priority/Percentage");
colorByPriorityMI.setSelection(true);
colorByPriorityMI.addSelectionListener(new SelectionAdapter() {
@Override
@ -224,7 +259,41 @@ public class BandwidthUtilizationDlg extends CaveSWTDialog {
canvasComp.setShowSubscriptionLines(showSubLinesMI
.getSelection());
}
});
new MenuItem(graphMenu, SWT.SEPARATOR);
MenuItem percentConfigMI = new MenuItem(graphMenu, SWT.NONE);
percentConfigMI.setText("Configure Bandwidth Percent...");
percentConfigMI.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Map<GraphSection, RGB> colors = canvasComp
.getBandwidthThresholdColors();
int[] values = canvasComp.getBandwidthThresholdValues();
BandwidthUsedConfigDlg dlg = new BandwidthUsedConfigDlg(
getShell(), values[0], values[1], colors
.get(GraphSection.LOWER), colors
.get(GraphSection.MIDDLE), colors
.get(GraphSection.UPPER));
dlg.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
if (returnValue instanceof int[]) {
int[] threshValues = (int[]) returnValue;
canvasComp
.setBandwidthThresholdValues(threshValues);
canvasComp
.redrawImage(CanvasImages.UTILIZATION_LABEL);
canvasComp
.redrawImage(CanvasImages.UTILIZATION_HEADER);
canvasComp
.redrawImage(CanvasImages.UTILIZATION_GRAPH);
}
}
});
dlg.open();
}
});
}

View file

@ -52,6 +52,7 @@ import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.SortBy;
* 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.
* Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph.
*
* </pre>
*
@ -106,7 +107,9 @@ public class GraphImage extends AbstractCanvasImage {
*/
@Override
public void disposeResources() {
bgColor.dispose();
if (bgColor != null) {
bgColor.dispose();
}
}
/**
@ -159,7 +162,6 @@ public class GraphImage extends AbstractCanvasImage {
gc.setForeground(display.getSystemColor(SWT.COLOR_GRAY));
if (graphData == null) {
return;
}
@ -193,15 +195,14 @@ public class GraphImage extends AbstractCanvasImage {
}
// Draw the dashed subscription line
gc.setLineStyle(SWT.LINE_DASH);
if (imageMgr.isShowSubscriptionLines()) {
gc.setLineStyle(SWT.LINE_DASH);
gc.setLineWidth(1);
gc.setForeground(display.getSystemColor(SWT.COLOR_GRAY));
gc.drawLine(0, yCoord + 4, cs.getImageWidth(), yCoord + 4);
gc.setLineStyle(SWT.LINE_SOLID);
}
gc.setLineStyle(SWT.LINE_SOLID);
long startTime = 0;
List<TimeWindowData> timeWindows = dataMap.get(subName);
for (TimeWindowData data : timeWindows) {

View file

@ -17,61 +17,71 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.edex.plugin.gfe.smartinit;
import jep.INumpyable;
package com.raytheon.uf.viz.datadelivery.bandwidth.ui;
/**
* TODO Add Description
* Point object for graph points.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 1, 2008 njensen Initial creation
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 24, 2013 2430 mpduff Initial creation
*
* </pre>
*
* @author njensen
* @author mpduff
* @version 1.0
*/
public class FakeTopo implements INumpyable {
public class GraphPoint {
// TODO need real topo databases!
private int x;
private static final int x = 145;
private int y;
private static final int y = 145;
/*
* (non-Javadoc)
/**
* Constructor.
*
* @see jep.INumpyable#getNumPy()
* @param x
* x coordinate
* @param y
* y coordinate
*/
@Override
public Object[] getNumPy() {
return new Object[] { new float[x * y] };
public GraphPoint(int x, int y) {
this.x = x;
this.y = y;
}
/*
* (non-Javadoc)
*
* @see jep.INumpyable#getNumpyX()
/**
* @return the x
*/
@Override
public int getNumpyX() {
public int getX() {
return x;
}
/*
* (non-Javadoc)
*
* @see jep.INumpyable#getNumpyY()
/**
* @param x
* the x to set
*/
@Override
public int getNumpyY() {
public void setX(int x) {
this.x = x;
}
/**
* @return the y
*/
public int getY() {
return y;
}
/**
* @param y
* the y to set
*/
public void setY(int y) {
this.y = y;
}
}

View file

@ -22,9 +22,10 @@ package com.raytheon.uf.viz.datadelivery.bandwidth.ui;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphSection;
/**
* TODO Add Description
* Graph options interface.
*
* <pre>
*
@ -34,6 +35,7 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPri
* ------------ ---------- ----------- --------------------------
* Dec 4, 2012 1269 mpduff Initial creation.
* Dec 13, 2012 1269 lvenable Fixes and updates.
* Oct 28, 2013 2430 mpduff Add % of bandwidth utilized graph.
*
* </pre>
*
@ -109,4 +111,24 @@ public interface IGraphOptions {
* RGB color.
*/
void setPriorityColor(SubscriptionPriority priority, RGB rgb);
/**
* Get the RGB color associated with the specified percentage.
*
* @param percentString
* The percent string
* @return RGB color.
*/
RGB getPercentColor(GraphSection section);
/**
* Set the color associated with the specified percentage.
*
* @param section
* The GraphSection
*
* @param rgb
* RGB color.
*/
void setPercentColor(GraphSection section, RGB rgb);
}

View file

@ -0,0 +1,334 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.datadelivery.bandwidth.ui;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthBucketDescription;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphSection;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphType;
/**
* Percent utilized graph image.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 20, 2013 2430 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class UtilizationGraphImage extends AbstractCanvasImage {
/** Lower percent limit line */
private int lowerLimitLine;
/** Upper percent limit line */
private int upperLimitLine;
private Color nonPriorityColor;
/**
* Constructor.
*
* @param parentComp
* Parent composite
* @param cs
* Canvas settings
* @param graphData
* Graph data
* @param imageMgr
* The BandwidthImageManager
*/
public UtilizationGraphImage(Composite parentComp, CanvasSettings cs,
BandwidthGraphData graphData, BandwidthImageMgr imageMgr) {
super(parentComp, cs, graphData, null);
bgColor = display.getSystemColor(SWT.COLOR_WHITE);
this.imageMgr = imageMgr;
init();
}
/**
* Initialize
*/
private void init() {
millisPerPix = millis48Hrs
/ (cs.getImageWidth() - cs.getXSpaceBuffer() * 2);
bgColor = new Color(display, 230, 230, 230);
nonPriorityColor = new Color(display, new RGB(6, 122, 255));
}
/**
* Draw the vertical time lines.
*
* @param gc
* Graphics Context
*/
private void drawTimeLines(GC gc) {
Calendar cal = TimeUtil.newGmtCalendar();
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
long currentTimeMillis = cal.getTimeInMillis();
long endTimeMillis = currentTimeMillis + millis48Hrs;
cal.set(Calendar.MINUTE, 0);
cal.add(Calendar.HOUR, 1);
long hourInMillis = cal.getTimeInMillis();
// Current time vertical line
gc.setLineWidth(2);
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.drawLine(cs.getXSpaceBuffer(), 0, cs.getXSpaceBuffer(),
cs.getImageHeight());
gc.setLineWidth(1);
// Draw hour lines
while (hourInMillis < endTimeMillis) {
int xCoord = (int) ((hourInMillis - currentTimeMillis) / millisPerPix);
xCoord += cs.getXSpaceBuffer();
// Draw a thicker line at 00Z
if (cal.get(Calendar.HOUR_OF_DAY) == 0) {
gc.setLineWidth(3);
gc.drawLine(xCoord, 0, xCoord, cs.getImageHeight());
gc.setLineWidth(1);
} else {
gc.drawLine(xCoord, 0, xCoord, cs.getImageHeight());
}
cal.add(Calendar.HOUR, 1);
hourInMillis = cal.getTimeInMillis();
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.datadelivery.bandwidth.ui.AbstractCanvasImage#
* disposeResources()
*/
@Override
public void disposeResources() {
if (bgColor != null) {
bgColor.dispose();
}
if (nonPriorityColor != null) {
nonPriorityColor.dispose();
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.datadelivery.bandwidth.ui.AbstractCanvasImage#drawImage
* ()
*/
@Override
public void drawImage() {
GC gc = new GC(image);
gc.setAntialias(SWT.ON);
gc.setBackground(bgColor);
gc.fillRectangle(0, 0, cs.getImageWidth(), cs.getImageHeight());
gc.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
gc.fillRectangle(0, 0, this.cs.getXSpaceBuffer(), cs.getImageHeight());
// Draw vertical time lines
drawTimeLines(gc);
drawPercentLines(gc);
drawData(gc);
}
/**
* Draw the data.
*
* @param gc
*/
private void drawData(GC gc) {
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
Map<Network, SortedSet<BandwidthBucketDescription>> dataMap = this.graphData
.getNetworkBucketMap();
SortedSet<BandwidthBucketDescription> data = dataMap.get(imageMgr
.getNetwork());
if (data == null || data.isEmpty()) {
return;
}
long currentTimeMillis = imageMgr.getCurrentTimeMillis();
int height = cs.getCanvasHeight();
List<GraphPoint> points = new ArrayList<GraphPoint>();
for (BandwidthBucketDescription bucket : data) {
long bucketSize = bucket.getBucketSize();
long startTime = bucket.getBucketStartTime();
long usedBytes = bucket.getUsedBytes();
if (startTime < currentTimeMillis) {
continue;
}
int x = Math.round(((startTime - currentTimeMillis) / millisPerPix)
+ 1 + cs.getXSpaceBuffer());
double percent = usedBytes / (double) bucketSize;
int y = (int) Math.round(height * percent);
y = 60 - y;
GraphPoint point = new GraphPoint(x, y);
points.add(point);
}
if (imageMgr.getBandwidthGraphType() == GraphType.LINE) {
drawLineGraph(points, gc);
} else {
drawBarGraph(points, gc);
}
}
/**
* Draw the bar graph.
*
* @param points
* @param gc
*/
private void drawBarGraph(List<GraphPoint> points, GC gc) {
int height = cs.getCanvasHeight();
if (!imageMgr.isColorByPriority()) {
gc.setBackground(nonPriorityColor);
}
for (GraphPoint point : points) {
if (imageMgr.isColorByPriority()) {
Color c = getColor(point.getY());
gc.setForeground(c);
gc.setBackground(c);
c.dispose();
}
if (height - point.getY() != 0) {
gc.fillRectangle(point.getX() - 1, point.getY() - 1, 3, height
- point.getY());
}
}
}
/**
* Draw the line graph.
*
* @param points
* @param gc
*/
private void drawLineGraph(List<GraphPoint> points, GC gc) {
// Draw the line
GraphPoint prevPoint = points.get(0);
for (int i = 1; i < points.size(); i++) {
GraphPoint p = points.get(i);
gc.setForeground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
gc.drawLine(p.getX(), p.getY(), prevPoint.getX(), prevPoint.getY());
prevPoint = p;
}
// Draw the points
for (GraphPoint p : points) {
int x = p.getX();
int y = p.getY();
Color c = null;
if (imageMgr.isColorByPriority()) {
c = getColor(y);
gc.setForeground(c);
gc.setBackground(c);
c.dispose();
}
gc.drawRectangle(x - 1, (Math.round(y)) - 1, 3, 3);
gc.fillRectangle(x, Math.round(y), 3, 3);
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
}
gc.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
}
/**
* Get the color for the point y.
*
* @param y
* The point
* @return The color for the point
*/
private Color getColor(int y) {
Color c = null;
if (y > lowerLimitLine) {
c = new Color(display, imageMgr.getPercentColor(GraphSection.LOWER));
} else if (y > upperLimitLine) {
c = new Color(display,
imageMgr.getPercentColor(GraphSection.MIDDLE));
} else {
c = new Color(display, imageMgr.getPercentColor(GraphSection.UPPER));
}
return c;
}
/**
* Draw the percent threshold lines.
*
* @param gc
*/
private void drawPercentLines(GC gc) {
int[] threshValues = imageMgr.getBandwidthThreholdValues();
int height = cs.getCanvasHeight();
lowerLimitLine = 60 - ((int) Math.round(height
* (threshValues[0] / 100.0)));
upperLimitLine = 60 - ((int) Math.round(height
* (threshValues[1] / 100.0)));
gc.setLineStyle(SWT.LINE_DASH);
gc.setLineWidth(1);
gc.setForeground(display.getSystemColor(SWT.COLOR_GRAY));
gc.drawLine(cs.getXSpaceBuffer(), lowerLimitLine, cs.getImageWidth(),
lowerLimitLine);
gc.drawLine(cs.getXSpaceBuffer(), upperLimitLine, cs.getImageWidth(),
upperLimitLine);
gc.setLineStyle(SWT.LINE_SOLID);
}
}

View file

@ -0,0 +1,175 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.datadelivery.bandwidth.ui;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Composite;
import com.raytheon.uf.viz.datadelivery.bandwidth.ui.BandwidthImageMgr.GraphSection;
/**
* Utilization header image.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 24, 2013 2430 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class UtilizationHeaderImage extends AbstractCanvasImage {
/** Title text */
private final String TITLE = "Percent of Bandwidth Used";
/** Legend text */
private final String LEGEND = "Legend: ";
/** Percent sign */
private final String PERCENT = "%";
/** Map of Rectangles -> GraphSection */
private final Map<Rectangle, GraphSection> rectPercentMap = new HashMap<Rectangle, GraphSection>();
/**
* Constructor.
*
* @param parentComp
* Parent composite
* @param cs
* Canvas settings
* @param imageMgr
* The image manager
*/
public UtilizationHeaderImage(Composite parentComp, CanvasSettings cs,
BandwidthImageMgr imageMgr) {
super(parentComp, cs, null, imageMgr);
bgColor = display.getSystemColor(SWT.COLOR_WHITE);
}
@Override
public void disposeResources() {
// No-op
}
/**
* {@inheritDoc}
*/
@Override
public void drawImage() {
GC gc = new GC(image);
gc.setAntialias(SWT.ON);
// Fill the background of the image
gc.setBackground(bgColor);
gc.fillRectangle(0, 0, cs.getImageWidth(), cs.getImageHeight());
String titleStr = TITLE + " (" + imageMgr.getNetwork().name() + ")";
Point extent = gc.stringExtent(titleStr);
int yCoord = 5;
int fontHeight = extent.y;
int xCoord = cs.getImageWidth() / 2 - extent.x;
gc.drawText(titleStr, xCoord, yCoord, true);
int legendSpace = 7;
Point legendPt = gc.stringExtent(LEGEND);
xCoord = cs.getXSpaceBuffer() + legendSpace;
yCoord = cs.getCanvasHeight() - fontHeight - 3;
gc.drawText(LEGEND, xCoord, yCoord, true);
xCoord += legendPt.x + legendSpace;
Color c;
Rectangle r;
int[] thresholdValues = imageMgr.getBandwidthThreholdValues();
for (GraphSection section : imageMgr.getPercentageColorMap().keySet()) {
StringBuilder percentString = new StringBuilder("> ");
if (section == GraphSection.MIDDLE) {
percentString.append(thresholdValues[0]).append(PERCENT);
} else if (section == GraphSection.UPPER) {
percentString.append(thresholdValues[1]).append(PERCENT);
} else {
percentString.append("0").append(PERCENT);
}
Point p = gc.stringExtent(percentString.toString());
gc.drawText(percentString.toString(), xCoord, yCoord, true);
c = new Color(display, imageMgr.getPercentageColorMap()
.get(section));
gc.setBackground(c);
xCoord += p.x + 3;
r = new Rectangle(xCoord, yCoord + 4, 10, 10);
gc.fillRectangle(r);
gc.drawRectangle(r);
xCoord += 10 + legendSpace * 3;
c.dispose();
rectPercentMap.put(r, section);
}
gc.dispose();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.datadelivery.bandwidth.ui.AbstractCanvasImage#
* performAction(org.eclipse.swt.graphics.Point)
*/
@Override
public void performAction(Point mousePt) {
for (Rectangle rec : this.rectPercentMap.keySet()) {
if (rec.contains(mousePt)) {
ColorDialog colorDlg = new ColorDialog(display.getActiveShell());
// Set the selected color in the dialog from
// user's selected color
colorDlg.setRGB(imageMgr.getPercentColor(rectPercentMap
.get(rec)));
// Change the title bar text
colorDlg.setText("Select a Color");
// Open the dialog and retrieve the selected color
RGB rgb = colorDlg.open();
if (rgb != null) {
imageMgr.setPercentColor(rectPercentMap.get(rec), rgb);
}
break;
}
}
}
}

View file

@ -0,0 +1,175 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.datadelivery.bandwidth.ui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
/**
* Utilization graph label image.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 20, 2013 2430 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class UtilizationLabelImage extends AbstractCanvasImage {
/**
* Constructor.
*
* @param parentComp
* Parent composite
* @param cs
* Canvas settings
* @param imageMgr
* BandwidthImageMgr
*/
public UtilizationLabelImage(Composite parentComp, CanvasSettings cs,
BandwidthImageMgr imageMgr) {
super(parentComp, cs, null, null);
bgColor = display.getSystemColor(SWT.COLOR_WHITE);
this.imageMgr = imageMgr;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.datadelivery.bandwidth.ui.AbstractCanvasImage#
* disposeResources()
*/
@Override
public void disposeResources() {
// No-op
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.datadelivery.bandwidth.ui.AbstractCanvasImage#drawImage
* ()
*/
@Override
public void drawImage() {
GC gc = new GC(image);
gc.setAntialias(SWT.ON);
// Fill the background of the image
gc.setBackground(bgColor);
gc.fillRectangle(0, 0, cs.getImageWidth(), cs.getImageHeight());
// Get the scale labels/ These are double so the division is floating
// point division
int[] threshValues = imageMgr.getBandwidthThreholdValues();
double lowerValue = threshValues[0];
double upperValue = threshValues[1];
// Draw scale labels
String label1 = lowerValue + "%";
String label2 = upperValue + "%";
Point extent1 = gc.stringExtent(label1);
Point extent2 = gc.stringExtent(label2);
// Draw the label(s)
// y is the lower threshold value, y2 is the upper
double y = cs.getCanvasHeight()
- ((lowerValue / 100) * cs.getCanvasHeight()) - (extent1.y / 2);
int x = cs.getCanvasWidth() - extent1.x - 5;
double y2 = cs.getCanvasHeight()
- ((upperValue / 100) * cs.getCanvasHeight()) - (extent2.y / 2);
int x2 = cs.getCanvasWidth() - extent2.x - 5;
// Align in relation to each other
if (y2 + extent2.y >= y) {
y2 = y - extent2.y + 1;
}
// If off the top of the canvas then move down
if (y2 <= 0) {
y2 = 0;
if (y <= y2 + extent2.y) {
// If overlap then move the other
y = y2 + extent2.y;
}
}
// If off the bottom of the canvas then move up
if (y + extent1.y > cs.getCanvasHeight()) {
y = cs.getCanvasHeight() - extent1.y;
if (y < y2 + extent2.y) {
// if overlap then move the other
y2 = y - extent1.y;
}
}
if (y + extent2.y >= 60) {
y = 60 - extent1.y - 1;
}
gc.drawText(label1, x, (int) y, true);
gc.drawText(label2, x2, (int) y2, true);
gc.dispose();
}
/**
* @return the lowerValue
*/
public int getLowerValue() {
return imageMgr.getBandwidthThreholdValues()[0];
}
/**
* @param lowerValue
* the lowerValue to set
*/
public void setLowerValue(int lowerValue) {
this.imageMgr.getBandwidthThreholdValues()[0] = lowerValue;
}
/**
* @return the upperValue
*/
public int getUpperValue() {
return imageMgr.getBandwidthThreholdValues()[1];
}
/**
* @param upperValue
* the upperValue to set
*/
public void setUpperValue(int upperValue) {
this.imageMgr.getBandwidthThreholdValues()[1] = upperValue;
}
}

View file

@ -46,6 +46,7 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPri
* 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.
* Oct 28, 2013 2430 mpduff Changed labels.
*
* </pre>
*
@ -118,12 +119,13 @@ public class XHeaderImage extends AbstractCanvasImage {
gc.setBackground(bgColor);
gc.fillRectangle(0, 0, cs.getImageWidth(), cs.getImageHeight());
Point extent = gc.stringExtent(xHeaderStr);
int yCoord = 5;
String title = xHeaderStr + " (" + imageMgr.getNetwork().name() + ")";
Point extent = gc.stringExtent(title);
int yCoord = 25;
int fontHeight = extent.y;
int xCoord = cs.getImageWidth() / 2 - extent.x;
gc.drawText(xHeaderStr, xCoord, yCoord, true);
gc.drawText(title, xCoord, yCoord, true);
int legendSpace = 5;
Point priorityPt = gc.stringExtent(priorityStr);

View file

@ -49,6 +49,7 @@ import com.raytheon.uf.viz.derivparam.tree.CubeLevel;
* Jul 8, 2008 njensen Initial creation
* Nov 20, 2009 #3387 jelkins Use derived script's variableId instead of filename
* Nov 21, 2009 #3576 rjpeter Refactored to populate DerivParamDesc.
* Oct 29, 2013 2476 njensen Renamed numeric methods to numpy
* </pre>
*
* @author njensen
@ -214,7 +215,7 @@ public class MasterDerivScript extends PythonInterpreter {
argKey += "_"
+ Integer.toHexString((val.hashCode()));
}
// setNumeric won't work with indexed objects
// setNumpy won't work with indexed objects
evaluateArgument(argKey, val);
jep.eval(argName + ".append(" + argKey + ")");
}
@ -231,7 +232,7 @@ public class MasterDerivScript extends PythonInterpreter {
for (int argIdx = 0; argIdx < valList.length; argIdx++) {
IDataRecord val = valList[argIdx];
jep.eval(argName + ".append(None)");
// setNumeric won't work with indexed objects
// setNumpy won't work with indexed objects
evaluateArgument("__tmp", val);
jep.eval(argName + "[" + argIdx + "] = __tmp");
}
@ -241,10 +242,10 @@ public class MasterDerivScript extends PythonInterpreter {
setDataRecordArg(argName, (IDataRecord) argValue);
} else if (argValue instanceof float[]) {
float[] val = (float[]) argValue;
jep.setNumeric(argName, val, val.length, 1);
jep.setNumpy(argName, val, val.length, 1);
} else if (argValue instanceof int[]) {
int[] val = (int[]) argValue;
jep.setNumeric(argName, val, val.length, 1);
jep.setNumpy(argName, val, val.length, 1);
} else if (argValue instanceof Float) {
jep.set(argName, (argValue));
} else if (argValue instanceof DerivedParameterRequest) {
@ -401,7 +402,7 @@ public class MasterDerivScript extends PythonInterpreter {
if (argValue instanceof FloatDataRecord) {
FloatDataRecord record = (FloatDataRecord) argValue;
if (sizes.length == 2) {
jep.setNumeric(argName, record.getFloatData(), (int) sizes[0],
jep.setNumpy(argName, record.getFloatData(), (int) sizes[0],
(int) sizes[1]);
reshape = false;
} else {
@ -415,7 +416,7 @@ public class MasterDerivScript extends PythonInterpreter {
} else if (argValue instanceof IntegerDataRecord) {
IntegerDataRecord record = (IntegerDataRecord) argValue;
if (sizes.length == 2) {
jep.setNumeric(argName, record.getIntData(), (int) sizes[0],
jep.setNumpy(argName, record.getIntData(), (int) sizes[0],
(int) sizes[1]);
reshape = false;
} else {
@ -424,7 +425,7 @@ public class MasterDerivScript extends PythonInterpreter {
} else if (argValue instanceof ByteDataRecord) {
ByteDataRecord record = (ByteDataRecord) argValue;
if (sizes.length == 2) {
jep.setNumeric(argName, record.getByteData(), (int) sizes[0],
jep.setNumpy(argName, record.getByteData(), (int) sizes[0],
(int) sizes[1]);
reshape = false;
} else {

View file

@ -59,7 +59,7 @@ public class CapeFuncPythonAdapter {
}
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { cape, cin };
}

View file

@ -50,6 +50,7 @@
# so mask can be used with advanced indexing
# (e.g. grid[mask] = value)
# Oct 07, 2013 2424 randerso remove use of pytz
# Oct 29, 2013 2476 njensen Improved getting wx/discrete keys in _getGridResults
#
########################################################################
import types, string, time, sys
@ -463,24 +464,31 @@ class SmartScript(BaseTool.BaseTool):
elif "List" == mode:
xlated = []
for rgrid in result:
xlgrid = rgrid.getGridSlice()
xlgrid = xlgrid.__numpy__
jxlgrid = rgrid.getGridSlice()
xlgrid = jxlgrid.__numpy__
if len(xlgrid) == 1:
xlgrid = xlgrid[0];
elif len(xlgrid) == 2 and isinstance(xlgrid[1], str):
xlgrid[1] = eval(xlgrid[1])
if xlgrid[0].dtype != numpy.int8:
# scalar
xlgrid = xlgrid[0]
else:
# discrete or weather
keys = JUtil.javaObjToPyVal(jxlgrid.getKeyList())
xlgrid.append(keys)
xlated.append(xlgrid)
retVal = xlated
else:
result = result[0];
result = result.getGridSlice()
result = result.__numpy__
slice = result.getGridSlice()
result = slice.__numpy__
if len(result) == 1:
retVal = result[0]
elif len(result) == 2 and isinstance(result[1], str):
retVal = (result[0], eval(result[1]))
else:
retVal = (result[0], result[1])
if result[0].dtype != numpy.int8:
# scalar
result = result[0]
else:
# discrete or weather
keys = JUtil.javaObjToPyVal(slice.getKeyList())
result.append(keys)
retVal = result
if retVal is None or retVal == []:
if noDataError == 1:

View file

@ -17,12 +17,14 @@
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
# further licensing information.
##
import DatabaseID, AbsTime
import DatabaseID, AbsTime, JUtil
from com.raytheon.uf.common.dataplugin.gfe.db.objects import DatabaseID as JavaDatabaseID
from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceID
from com.raytheon.uf.common.dataplugin.gfe.db.objects import ParmID
from numpy import int8
class DBSSWE:
def __init__(self, parm):
self._parm = parm
@ -47,12 +49,17 @@ class DBSSWE:
self._parm.getGridInventory()):
if t == key:
#return g.pyData()
g.populate()
result = g.getGridSlice().__numpy__
g.populate()
slice = g.getGridSlice()
result = slice.__numpy__
if len(result) == 1:
result = result[0]
elif len(result) == 2 and isinstance(result[1], str):
result[1] = eval(result[1])
if result[0].dtype != int8:
# scalar
result = result[0]
else:
# discrete or weather
dkeys = JUtil.javaObjToPyVal(slice.getKeyList())
result.append(dkeys)
return result
return None

View file

@ -840,7 +840,7 @@ public class DiscreteGridData extends AbstractGridData implements INumpyable {
}
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { this.getGrid().getBuffer().array() };
}

View file

@ -817,7 +817,7 @@ public class WeatherGridData extends AbstractGridData implements INumpyable {
}
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { this.getGrid().getBuffer().array() };
}

View file

@ -48,6 +48,7 @@ import com.raytheon.viz.gfe.core.griddata.WeatherGridData;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 12, 2012 dgilling Initial creation
* Oct 29, 2013 2476 njensen Renamed numeric methods to numpy
*
* </pre>
*
@ -117,7 +118,7 @@ public class CalcVcModGridArg implements IVcModuleArgument {
ScalarGridData grid = (ScalarGridData) gd;
Grid2DFloat f = (grid.getScalarSlice()).getScalarGrid();
String name = prefix + "grid";
jep.setNumeric(name, f.getFloats(), f.getXdim(), f.getYdim());
jep.setNumpy(name, f.getFloats(), f.getXdim(), f.getYdim());
jepString.append(name);
jepString.append(", ");
tempGridNames.add(name);
@ -127,9 +128,9 @@ public class CalcVcModGridArg implements IVcModuleArgument {
Grid2DFloat dir = (grid.getVectorSlice()).getDirGrid();
String magName = prefix + "Mag";
String dirName = prefix + "Dir";
jep.setNumeric(magName, mag.getFloats(), mag.getXdim(),
jep.setNumpy(magName, mag.getFloats(), mag.getXdim(),
mag.getYdim());
jep.setNumeric(dirName, dir.getFloats(), dir.getXdim(),
jep.setNumpy(dirName, dir.getFloats(), dir.getXdim(),
dir.getYdim());
jepString.append('(');
jepString.append(magName);
@ -142,7 +143,7 @@ public class CalcVcModGridArg implements IVcModuleArgument {
WeatherGridData grid = (WeatherGridData) gd;
Grid2DByte bytes = grid.getWeatherSlice().getWeatherGrid();
String name = prefix + "grid";
jep.setNumeric(name, bytes.getBytes(), bytes.getXdim(),
jep.setNumpy(name, bytes.getBytes(), bytes.getXdim(),
bytes.getYdim());
jepString.append('(');
jepString.append(name);
@ -159,7 +160,7 @@ public class CalcVcModGridArg implements IVcModuleArgument {
DiscreteGridData grid = (DiscreteGridData) gd;
Grid2DByte bytes = grid.getDiscreteSlice().getDiscreteGrid();
String name = prefix + "grid";
jep.setNumeric(name, bytes.getBytes(), bytes.getXdim(),
jep.setNumpy(name, bytes.getBytes(), bytes.getXdim(),
bytes.getYdim());
jepString.append('(');
jepString.append(name);
@ -175,7 +176,7 @@ public class CalcVcModGridArg implements IVcModuleArgument {
}
String maskName = prefix + "mask";
jep.setNumeric(maskName, mask.getBytes(), mask.getXdim(),
jep.setNumpy(maskName, mask.getBytes(), mask.getXdim(),
mask.getYdim());
jepString.append(maskName);
sb.append(jepString);

View file

@ -69,6 +69,7 @@ import com.raytheon.viz.gfe.core.wxvalue.WxValue;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 20, 2008 njensen Initial creation
* Oct 29, 2013 2476 njensen Renamed numeric methods to numpy
* </pre>
*
* @author njensen
@ -178,7 +179,7 @@ public class SmartToolController extends BaseGfePyController {
if (parmToEdit == null) {
return null;
} else {
return getNumericResult(parmToEdit.getGridInfo().getGridType());
return getNumpyResult(parmToEdit.getGridInfo().getGridType());
}
}
@ -246,7 +247,7 @@ public class SmartToolController extends BaseGfePyController {
* @return the result of the execution in Java format
* @throws JepException
*/
protected Object getNumericResult(GridType type) throws JepException {
protected Object getNumpyResult(GridType type) throws JepException {
Object result = null;
boolean resultFound = (Boolean) jep.getValue(RESULT + " is not None");
@ -308,9 +309,9 @@ public class SmartToolController extends BaseGfePyController {
Grid2DFloat dir = (grid.getVectorSlice()).getDirGrid();
String magName = argName + "Mag";
String dirName = argName + "Dir";
jep.setNumeric(magName, mag.getFloats(), mag.getXdim(),
jep.setNumpy(magName, mag.getFloats(), mag.getXdim(),
mag.getYdim());
jep.setNumeric(dirName, dir.getFloats(), dir.getXdim(),
jep.setNumpy(dirName, dir.getFloats(), dir.getXdim(),
dir.getYdim());
jep.eval(argName + " = [" + magName + ", " + dirName + "]");
jep.eval(magName + " = None");
@ -318,7 +319,7 @@ public class SmartToolController extends BaseGfePyController {
} else if (argValue instanceof ScalarGridData) {
ScalarGridData grid = (ScalarGridData) argValue;
Grid2DFloat f = (grid.getScalarSlice()).getScalarGrid();
jep.setNumeric(argName, f.getFloats(), f.getXdim(), f.getYdim());
jep.setNumpy(argName, f.getFloats(), f.getXdim(), f.getYdim());
} else if (argValue instanceof DiscreteGridData) {
DiscreteGridData grid = (DiscreteGridData) argValue;
jep.set("discreteGridData", grid);

View file

@ -0,0 +1,608 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.ui.widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
/**
* A two value slider widget.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 27, 2013 2430 mpduff Initial version.
*
* </pre>
*/
public class TwoValueSliderCanvas {
/** Parent composite */
private final Composite parentComp;
/** The display */
private final Display display;
/** The lower range color */
private Color lowRangeColor;
/** The middle range color */
private Color midRangeColor;
/** The upper range color */
private Color upperRangeColor;
/*
* Canvas information
*/
private Canvas canvas;
private final int CANVAS_WIDTH = 255;
private final int CANVAS_HEIGHT = 70;
/*
* Bar information.
*/
private final int barBottomYCoord = 45;
private final int barWidth = 200;
private final int barHeight = 10;
private final int barXCoord = 25;
private final int barYCoord = 35;
/*
* Upper arrow, label and values
*/
private Region upperRegion;
private int[] upperPtArray = new int[] { 0, 0 };
private int upperArrowXCoord = 150;
private Rectangle upperLblRect;
private String upperStr;
private final int upperLblYCoord = 1;
private boolean moveUpper = false;
private int upperDisplayVal = 0;
/*
* Lower arrow, label and values
*/
private Region lowerRegion;
private int[] lowerPtArray = new int[] { 0, 0 };
private int lowerArrowXCoord = 50;
private Rectangle lowerLblRect;
private String lowerStr;
private final int lowerLblYCoord = 14;
private boolean moveLower = false;
private int lowerDisplayVal = 0;
/*
* Mouse information.
*/
private Point mousePt;
private boolean mouseDown = false;
/*
* Font/text information
*/
private Font labelFont;
private int textWidth = 0;
private int textHeight = 0;
/*
* Min/Range/Increment information
*/
private int minValue = Integer.MIN_VALUE;
private int rangeValue = Integer.MIN_VALUE;
private int incValue = Integer.MIN_VALUE;
private double incPerPixel = Double.NaN;
private String formatStr;
private int minValLblPixWidth = 0;
private int maxValLblPixWidth = 0;
/**
* Constructor.
*
* @param parentComp
* The parent composite
* @param min
* The minimum value
* @param range
* The range
* @param inc
* The increment
* @param startingLowerVal
* The starting lower value
* @param startingUpperVal
* The starting upper value
*/
public TwoValueSliderCanvas(Composite parentComp, int min, int range,
int inc, int startingLowerVal, int startingUpperVal) {
this(parentComp, min, range, inc, startingLowerVal, startingUpperVal,
null, null, null);
}
/**
* Constructor.
*
* @param parentComp
* The parent composite
* @param min
* The minimum value
* @param range
* The range
* @param inc
* The increment
* @param startingLowerVal
* The starting lower value
* @param startingUpperVal
* The starting upper value
* @param lowerRGB
* Low range RGB color
* @param midRGB
* Mid range RGB color
* @param upperRGB
* High range RGB color
*/
public TwoValueSliderCanvas(Composite parentComp, int min, int range,
int inc, int startingLowerVal, int startingUpperVal, RGB lowerRGB,
RGB midRGB, RGB upperRGB) {
this.parentComp = parentComp;
display = this.parentComp.getDisplay();
setValues(min, range, inc, startingLowerVal, startingUpperVal);
createColors(lowerRGB, midRGB, upperRGB);
calcMinMaxLabelXCoords();
init();
createCanvas();
}
/**
* Create the colors.
*
* @param lowerRGB
* @param midRGB
* @param upperRGB
*/
private void createColors(RGB lowerRGB, RGB midRGB, RGB upperRGB) {
if (lowerRGB == null) {
lowRangeColor = new Color(display, display.getSystemColor(
SWT.COLOR_GREEN).getRGB());
} else {
lowRangeColor = new Color(display, lowerRGB);
}
if (midRGB == null) {
midRangeColor = new Color(display, display.getSystemColor(
SWT.COLOR_YELLOW).getRGB());
} else {
midRangeColor = new Color(display, midRGB);
}
if (upperRGB == null) {
upperRangeColor = new Color(display, display.getSystemColor(
SWT.COLOR_RED).getRGB());
} else {
upperRangeColor = new Color(display, upperRGB);
}
}
/**
* Initialize
*/
private void init() {
upperLblRect = new Rectangle(0, 0, 0, 0);
lowerLblRect = new Rectangle(0, 0, 0, 0);
labelFont = new Font(display, "Monospaced", 10, SWT.BOLD);
mousePt = new Point(0, 0);
upperRegion = new Region(display);
lowerRegion = new Region(display);
makeCalculations();
}
/**
* Create the canvas.
*/
private void createCanvas() {
canvas = new Canvas(parentComp, SWT.DOUBLE_BUFFERED);
GridData gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
gd.heightHint = CANVAS_HEIGHT;
gd.widthHint = CANVAS_WIDTH;
canvas.setSize(CANVAS_WIDTH, CANVAS_HEIGHT);
canvas.setLayoutData(gd);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
drawCanvas(e.gc);
}
});
canvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
if (upperRegion.contains(e.x, e.y) == true
|| upperLblRect.contains(e.x, e.y) == true) {
mousePt.x = e.x;
mousePt.y = e.y;
mouseDown = true;
moveUpper = true;
} else if (lowerRegion.contains(e.x, e.y) == true
|| lowerLblRect.contains(e.x, e.y) == true) {
mousePt.x = e.x;
mousePt.y = e.y;
mouseDown = true;
moveLower = true;
}
}
@Override
public void mouseUp(MouseEvent e) {
mouseDown = false;
moveLower = false;
moveUpper = false;
}
});
canvas.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
handleMouseMove(e);
}
});
canvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
upperRegion.dispose();
lowerRegion.dispose();
labelFont.dispose();
lowRangeColor.dispose();
midRangeColor.dispose();
upperRangeColor.dispose();
}
});
}
/**
* Draw the canvas.
*
* @param gc
*/
private void drawCanvas(GC gc) {
gc.setAntialias(SWT.ON);
gc.setFont(labelFont);
gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.fillRectangle(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
gc.setBackground(lowRangeColor);
gc.fillRectangle(barXCoord, barYCoord, barWidth, barHeight);
gc.setBackground(midRangeColor);
gc.fillRectangle(lowerArrowXCoord, barYCoord, barWidth + 25
- lowerArrowXCoord, barHeight);
gc.setBackground(upperRangeColor);
gc.fillRectangle(upperArrowXCoord, barYCoord, barWidth + 25
- upperArrowXCoord, barHeight);
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.drawRectangle(barXCoord, barYCoord, barWidth, barHeight);
gc.drawString(String.valueOf(minValue) + "%", barXCoord
- (minValLblPixWidth / 2), barYCoord + 10, true);
gc.drawString(String.valueOf(minValue + rangeValue) + "%", barXCoord
+ barWidth - (maxValLblPixWidth / 2), barYCoord + 10, true);
updateLowerArrow(gc);
updateLowerLabel(gc);
updateUpperArrow(gc);
updateUpperLabel(gc);
}
/**
* Update the upper arrow.
*
* @param gc
*/
private void updateUpperArrow(GC gc) {
upperRegion.subtract(upperPtArray);
upperPtArray = new int[] { upperArrowXCoord,
barBottomYCoord - barHeight - 3, upperArrowXCoord + 4,
barBottomYCoord, upperArrowXCoord - 4, barBottomYCoord };
upperRegion.add(upperPtArray);
gc.setBackground(upperRangeColor);
gc.fillPolygon(upperPtArray);
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.drawPolygon(upperPtArray);
}
/**
* Update the lower label.
*
* @param gc
*/
private void updateUpperLabel(GC gc) {
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
upperStr = createDisplayString(upperDisplayVal);
int lblXCoord = (int) (upperArrowXCoord - textWidth
* (double) upperStr.length() / 2.0);
gc.drawString(upperStr + "%", lblXCoord, upperLblYCoord, true);
upperLblRect.x = lblXCoord;
upperLblRect.y = upperLblYCoord;
upperLblRect.width = textWidth * upperStr.length() + textWidth * 2;
upperLblRect.height = textHeight;
}
/**
* Update lower arrow.
*
* @param gc
*/
private void updateLowerArrow(GC gc) {
lowerRegion.subtract(lowerPtArray);
lowerPtArray = new int[] { lowerArrowXCoord,
barBottomYCoord - barHeight - 3, lowerArrowXCoord + 4,
barBottomYCoord, lowerArrowXCoord - 4, barBottomYCoord };
lowerRegion.add(lowerPtArray);
gc.setBackground(midRangeColor);
gc.fillPolygon(lowerPtArray);
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
gc.drawPolygon(lowerPtArray);
}
/**
* Update lower label
*
* @param gc
*/
private void updateLowerLabel(GC gc) {
gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
lowerStr = createDisplayString(lowerDisplayVal);
int lblXCoord = (int) (lowerArrowXCoord - Math.round((double) textWidth
* (double) lowerStr.length() / 2.0));
gc.drawString(lowerStr + "%", lblXCoord, lowerLblYCoord, true);
lowerLblRect.x = lblXCoord;
lowerLblRect.y = lowerLblYCoord;
lowerLblRect.width = textWidth * lowerStr.length() + textWidth * 2;
lowerLblRect.height = textHeight;
}
/**
* Mouse mover handler.
*
* @param e
*/
private void handleMouseMove(MouseEvent e) {
if (mouseDown == false) {
return;
}
if (moveUpper == true) {
int xDiff = e.x - mousePt.x;
upperArrowXCoord += xDiff;
if (upperArrowXCoord > 225) {
upperArrowXCoord = 225;
} else if (upperArrowXCoord < 25) {
upperArrowXCoord = 25;
} else if (upperArrowXCoord < lowerArrowXCoord) {
upperArrowXCoord = lowerArrowXCoord;
}
upperDisplayVal = calcDisplayValue(upperArrowXCoord);
} else if (moveLower == true) {
int xDiff = e.x - mousePt.x;
lowerArrowXCoord += xDiff;
if (lowerArrowXCoord > 225) {
lowerArrowXCoord = 225;
} else if (lowerArrowXCoord < 25) {
lowerArrowXCoord = 25;
} else if (lowerArrowXCoord > upperArrowXCoord) {
lowerArrowXCoord = upperArrowXCoord;
}
lowerDisplayVal = calcDisplayValue(lowerArrowXCoord);
}
mousePt.x = e.x;
mousePt.y = e.y;
canvas.redraw();
}
/**
* Determine text height and width.
*/
private void makeCalculations() {
GC gc = new GC(parentComp);
gc.setFont(labelFont);
textWidth = gc.getFontMetrics().getAverageCharWidth();
textHeight = gc.getFontMetrics().getHeight();
gc.dispose();
}
/**
* Calculate the display value for the provided x coordinate.
*
* @param xCoord
* @return
*/
private int calcDisplayValue(int xCoord) {
double xCoordAsValue = (xCoord - barXCoord) * incPerPixel + minValue;
if (incValue == .25) {
return (int) ((Math.round(xCoordAsValue * 4.00)) / 4.00);
} else if (incValue == .10) {
return (int) ((Math.round(xCoordAsValue * 10.00)) / 10.00);
} else {
return (int) Math.round(xCoordAsValue);
}
}
/**
* Calculate the min/max pixel values.
*/
private void calcMinMaxLabelXCoords() {
GC gc = new GC(parentComp);
gc.setFont(labelFont);
Point ext = gc.stringExtent(String.valueOf(minValue));
minValLblPixWidth = ext.x;
ext = gc.stringExtent(String.valueOf(minValue + rangeValue));
maxValLblPixWidth = ext.x;
gc.dispose();
}
/**
* Create the display string.
*
* @param displVal
* @return
*/
private String createDisplayString(int displVal) {
return String.format(formatStr, displVal);
}
/**
* Calculate the bar value to x coordinate value.
*
* @param val
* @return
*/
private int calcValueToBarXCoord(double val) {
int result = (int) Math.round((val - minValue) / incPerPixel
+ barXCoord);
return result;
}
/**
* Set the values.
*
* @param min
* @param range
* @param inc
* @param startingLowerVal
* @param startingUpperVal
*/
private void setValues(int min, int range, int inc, int startingLowerVal,
int startingUpperVal) {
this.minValue = min;
this.rangeValue = range;
this.incValue = inc;
if (startingUpperVal < startingLowerVal) {
startingUpperVal = startingLowerVal;
}
if (startingLowerVal < min || startingLowerVal > (min + range)) {
startingLowerVal = min;
}
if (startingUpperVal < min || startingUpperVal > (min + range)) {
startingUpperVal = min + range;
}
incPerPixel = this.rangeValue / (double) barWidth;
formatStr = "%d";
upperArrowXCoord = calcValueToBarXCoord(startingUpperVal);
lowerArrowXCoord = calcValueToBarXCoord(startingLowerVal);
upperDisplayVal = calcDisplayValue(upperArrowXCoord);
lowerDisplayVal = calcDisplayValue(lowerArrowXCoord);
}
/**
* Get the upper value.
*
* @return the upper value
*/
public int getUpperValue() {
return upperDisplayVal;
}
/**
* Get the lower value
*
* @return The lower value
*/
public int getLowerValue() {
return lowerDisplayVal;
}
}

Binary file not shown.

View file

@ -17,12 +17,6 @@
<antcall target="deploy.esb-data" />
</then>
</if>
<if>
<equals arg1="${deploy.web}" arg2="true" />
<then>
<antcall target="deploy.esb-web" />
</then>
</if>
</target>
<target name="cleanup">
@ -96,18 +90,6 @@
includes="**/*" type="both" />
</target>
<target name="deploy.esb-web">
<deploy.war
web.project.dir="com.raytheon.edex.uengine"
war.name="uEngineWeb" />
<deploy.war
web.project.dir="gov.noaa.nws.ncep.edex.purgeutil"
war.name="purgeWeb" />
<deploy.war
web.project.dir="com.raytheon.uf.edex.registry.ebxml"
war.name="registryEbxml" />
</target>
<taskdef resource="net/sf/antcontrib/antlib.xml"
classpath="${basedir}/lib/ant/ant-contrib-1.0b3.jar" />
</project>

View file

@ -10,11 +10,9 @@
<macrodef name="deploy.war">
<attribute name="web.project.dir" />
<attribute name="war.name" />
<attribute name="webapps.dir" />
<sequential>
<property name="webapps.dir"
value="${edex.root.directory}/webapps" />
<sequential>
<!-- find the web "project" -->
<var name="project.dir" value="" />
<for list="${basedirectories}" param="directory"
@ -41,13 +39,13 @@
<var name="war.file" value="@{war.name}.war" />
<!-- delete old war file -->
<delete dir="${webapps.dir}/@{war.name}" />
<delete file="${webapps.dir}/${war.file}" />
<mkdir dir="${webapps.dir}" />
<delete dir="@{webapps.dir}/@{war.name}" />
<delete file="@{webapps.dir}/${war.file}" />
<mkdir dir="@{webapps.dir}" />
<!-- build and deploy new war -->
<echo message="Building and deploying war file" />
<war destfile="${webapps.dir}/${war.file}"
<war destfile="@{webapps.dir}/${war.file}"
webxml="${project.dir}/web/WEB-INF/web.xml">
<fileset dir="${project.dir}/web"
excludes="**/WEB-INF/" />
@ -56,9 +54,9 @@
<webinf file="${project.dir}/web/WEB-INF/dwr.xml" />
</war>
<unzip src="${webapps.dir}/${war.file}"
dest="${webapps.dir}/@{war.name}" />
<delete file="${webapps.dir}/${war.file}" />
<unzip src="@{webapps.dir}/${war.file}"
dest="@{webapps.dir}/@{war.name}" />
<delete file="@{webapps.dir}/${war.file}" />
</sequential>
</macrodef>
</project>

View file

@ -1,4 +1,6 @@
<project>
<import file="deploy-web.xml" />
<macrodef name="processPlugins">
<attribute name="includes.file" />
<attribute name="plugin.type" />
@ -101,6 +103,19 @@
</else>
</if>
<!-- determine if the plugin is a web project -->
<if>
<available file="${plugin.base}/web.deploy" type="file" />
<then>
<var file="${plugin.base}/web.deploy" />
<deploy.war
web.project.dir="@{plugin.name}"
war.name="${war.name}"
webapps.dir="${edex.root.directory}/webapps" />
</then>
</if>
<ant antfile="${basedir}/deploy-common/external-rules.xml"
inheritAll="false">
<property name="plugin._directory"

View file

@ -1,4 +1,5 @@
<project name="Build specific targets and properties" default="noDefault">
<import file="${builder}/../deploy-common/deploy-web.xml" />
<!-- =====================================================================
The Following Properties are available in all targets:
@ -28,6 +29,20 @@
<property name="deployment._root"
value="${target.folder}/.." />
</ant>
<!-- determine if plugin is a web project -->
<!-- determine if the plugin is a web project -->
<if>
<available file="${projectLocation}/web.deploy" type="file" />
<then>
<var file="${projectLocation}/web.deploy" />
<basename property="plugin.name" file="${projectLocation}" />
<deploy.war
web.project.dir="${plugin.name}"
war.name="${war.name}"
webapps.dir="${target.folder}/../webapps" />
</then>
</if>
</target>
<!-- ===================================================================== -->

View file

@ -156,6 +156,19 @@
</fileset>
</copy>
<if>
<available file="${build.output.directory}/webapps" type="dir" />
<then>
<mkdir dir="${builder}/postBuild/${edex.root.directory}" />
<copy todir="${builder}/postBuild/${edex.root.directory}"
verbose="true">
<fileset dir="${build.output.directory}">
<include name="webapps/**" />
</fileset>
</copy>
</then>
</if>
<!-- special rule for cots -->
<if>
<not>

View file

@ -9,8 +9,6 @@ wa.to.deploy=
deploy.python=true
# deploy build.edex/esb/data
deploy.data=true
# deploy the web applications
deploy.web=true
# deploy GFESuite
deploy.gfesuite=true
# use esb.overwrite to overwrite files during esb deployment regardless

View file

@ -305,9 +305,16 @@
<exclude>.*datadelivery-ncf.*</exclude>
</mode>
<mode name="sbnSimulator">
<include>.*sbn-simulator.*</include>
<include>.*sbn-simulator-wfo.*</include>
<include>event-common.xml</include>
<include>eventbus-common.xml</include>
<exclude>.*sbn-simulator-ncf.*</exclude>
</mode>
<mode name="centralSbnSimulator">
<include>.*sbn-simulator-ncf.*</include>
<include>event-common.xml</include>
<include>eventbus-common.xml</include>
<exclude>.*sbn-simulator-wfo.*</exclude>
</mode>
<mode name="grib">
<include>grib-decode.xml</include>

View file

@ -4,6 +4,5 @@ esbDir=${install.dir}/../edex
feature=../com.raytheon.edex.feature.uframe/feature.xml
working.dir=edex/tmp/plugins
deploy.web=true
deploy.data=true
svcbudir=${install.dir}/../GFESuite

View file

@ -28,6 +28,7 @@
# 04/04/13 #1787 randerso fix validTime check to work with accumulative parms
# fix logging so you can actually determine why
# a smartInit is not calculating a parameter
# Oct 29, 2013 2476 njensen Improved getting wx/discrete keys when retrieving data
#
##
import string, sys, re, time, types, getopt, fnmatch, LogStream, DatabaseID, JUtil, AbsTime, TimeRange
@ -967,12 +968,16 @@ class Forecaster(GridUtilities):
pytr = TimeRange.encodeJavaTimeRange(tr)
pkeys = TimeRange.javaTimeRangeListToPyList(p.getKeys())
if pytr in pkeys:
slice = p.getItem(tr)
slice = slice.__numpy__
jslice = p.getItem(tr)
slice = jslice.__numpy__
if len(slice) == 1:
slice = slice[0]
elif len(slice) == 2 and type(slice[1]) is str:
exec "slice[1] = " + slice[1]
if slice[0].dtype != int8:
# scalar
slice = slice[0]
else:
# discrete or weather
keys = JUtil.javaObjToPyVal(jslice.getKeyList())
slice.append(keys)
cache[arg] = (slice, pytr)
else:
cache[arg] = (None, time)
@ -1048,11 +1053,16 @@ class Forecaster(GridUtilities):
if type(rval) is not ndarray:
if type(rval) is not tuple:
jrval = rval
rval = rval.__numpy__
if len(rval) == 1:
rval = rval[0]
elif len(rval) == 2 and type(rval[1]) is str:
exec "rval[1] = " + rval[1]
if rval[0].dtype != int8:
# scalar
rval = rval[0]
else:
# discrete or weather
keys = JUtil.javaObjToPyVal(jrval.getKeyList())
rval.append(keys)
cache[we] = (rval, time)
if rval is not None and cache['mtime'][0] is not None and doStore:
parm = self.__getNewWE(we)
@ -1211,9 +1221,13 @@ class IFPIO:
slice = self.getSrcWE(name, 0).getItem(time)
out = slice.__numpy__
if len(out) == 1:
out = out[0]
elif len(out) == 2 and type(out[1]) is str:
exec "out[1] = " + out[1]
if out[0].dtype != int8:
# scalar
out = out[0]
else:
# discrete or weather
keys = JUtil.javaObjToPyVal(slice.getKeyList())
out.append(keys)
else:
out = self._getcube(self.eta, name, time)
return out
@ -1239,12 +1253,16 @@ class IFPIO:
pres = []
for l in lvls:
p = self.getSrcWE(parm + "_" + l, 0)
slice = p.getItem(time)
slice = slice.__numpy__
jslice = p.getItem(time)
slice = jslice.__numpy__
if len(slice) == 1:
slice = slice[0]
elif len(slice) == 2 and type(slice[1]) is str:
exec "slice[1] = " + slice[1]
if slice[0].dtype != int8:
# scalar
slice = slice[0]
else:
# discrete or weather
keys = JUtil.javaObjToPyVal(jslice.getKeyList())
slice.append(keys)
lst.append(slice)
pres.append(int(l[2:]))
if type(lst[0]) == types.TupleType or type(lst[0]) == types.ListType:

View file

@ -36,9 +36,10 @@ import java.util.Map;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20070925 391 jkorman Initial Coding.
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Sep 25, 2007 391 jkorman Initial Coding.
* Oct 29, 2013 2489 bsteffen Add NAVTEX_END_PART
*
* </pre>
*
@ -70,6 +71,9 @@ public class SfcObsPart {
public static final SfcObsPart MAROB_PART = new SfcObsPart("MAROB",true);
public static final SfcObsPart NAVTEX_END_PART = new SfcObsPart("NNNN",
true);
private static final Map<String, SfcObsPart> OBS_TYPE_MAP = new HashMap<String, SfcObsPart>();
static {
OBS_TYPE_MAP.put(AAXX_PART.partValue, AAXX_PART);

View file

@ -31,9 +31,10 @@ import java.util.List;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20070925 391 jkorman Initial Coding.
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Sep 25, 2007 391 jkorman Initial Coding.
* Oct 29, 2013 2489 bsteffen Add checks for NAVTEX_END_PART
*
* </pre>
*
@ -136,6 +137,17 @@ public class SfcObsSubMessage {
// just throw it away.
} else if (SfcObsPart.ME_PART.equals(part)) {
break;
} else if (SfcObsPart.NAVTEX_END_PART.equals(part)) {
/*
* NNNN is an end of message token for some of the sbn
* data(NAVTEX generated data) and it is not a valid
* observation. If NNNN is the only part in the report then
* it will be ignored completely(dataWritten will be false).
* If there is other parts before or after NNNN then it will
* be included in the report.
*/
sb.append(" ");
sb.append(part.getPartValue());
} else {
sb.append(" ");
sb.append(part.getPartValue());

View file

@ -34,11 +34,11 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Oct 19, 2007 391 jkorman Initial Coding.
* Oct 29, 2013 2489 bsteffen Add null check to matchElement.
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20071019 391 jkorman Initial coding.
* </pre>
*
* @author jkorman
@ -166,7 +166,7 @@ public abstract class AbstractSfcObsDecoder implements ISfcObsDecoder {
*/
public static final boolean matchElement(String element, String pattern) {
boolean matches = false;
if (pattern != null) {
if (pattern != null && element != null) {
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(element);
matches = m.find();

View file

@ -0,0 +1 @@
war.name=uEngineWeb

View file

@ -1,13 +1,40 @@
package com.raytheon.uf.common.datadelivery.harvester;
/**
* 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.Arrays;
import java.util.List;
import javax.xml.bind.JAXBException;
import com.raytheon.uf.common.datadelivery.registry.Connection;
import com.raytheon.uf.common.datadelivery.registry.Provider;
import com.raytheon.uf.common.datadelivery.registry.ProviderType;
import com.raytheon.uf.common.datadelivery.registry.Provider.ServiceType;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -22,6 +49,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* ------------ ---------- ----------- --------------------------
* --/--/---- dhladky Initial creation
* Oct 23, 2013 2361 njensen Use JAXBManager for XML
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
*
* </pre>
*
@ -32,9 +60,32 @@ public class HarvesterConfigurationManager {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(HarvesterConfigurationManager.class);
private static final Class<?>[] clazzess = new Class<?>[] {
HarvesterConfig.class, Provider.class, Connection.class,
ProviderType.class, ServiceType.class, Agent.class,
CrawlAgent.class, OGCAgent.class, ConfigLayer.class };
private static final SingleTypeJAXBManager<HarvesterConfig> jaxb = SingleTypeJAXBManager
.createWithoutException(HarvesterConfig.class);
private static JAXBManager jaxb = null;
/**
* marshall and unmarshall harvester objects
*
* @return
*/
private static JAXBManager getJaxb() {
if (jaxb == null) {
try {
jaxb = new JAXBManager(clazzess);
} catch (JAXBException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
return jaxb;
}
/**
* Gets site and base level configs for harvesters
@ -62,13 +113,7 @@ public class HarvesterConfigurationManager {
for (LocalizationFile lf : getLocalizedFiles()) {
try {
config = jaxb.unmarshalFromXmlFile(lf.getFile());
} catch (SerializationException e) {
statusHandler.handle(Priority.ERROR,
"Can't deserialize harvester config at "
+ lf.getFile().getPath(), e);
}
config = getHarvesterFile(lf.getFile());
if (config != null) {
Agent agent = config.getAgent();
@ -93,13 +138,7 @@ public class HarvesterConfigurationManager {
for (LocalizationFile lf : getLocalizedFiles()) {
try {
config = jaxb.unmarshalFromXmlFile(lf.getFile());
} catch (SerializationException e) {
statusHandler.handle(Priority.ERROR,
"Can't deserialize harvester config at "
+ lf.getFile().getPath(), e);
}
config = getHarvesterFile(lf.getFile());
if (config != null) {
Agent agent = config.getAgent();
@ -115,4 +154,42 @@ public class HarvesterConfigurationManager {
return config;
}
/**
* Get this harvester configuration File
*
* @param file
* @return
*/
public static HarvesterConfig getHarvesterFile(File file) {
HarvesterConfig config = null;
try {
config = getJaxb()
.unmarshalFromXmlFile(HarvesterConfig.class, file);
} catch (SerializationException e) {
statusHandler.handle(Priority.ERROR,
"Can't deserialize harvester config at " + file.getPath(),
e);
}
return config;
}
/**
* Writes the harvester config files
*
* @param config
* @param file
*/
public static void setHarvesterFile(HarvesterConfig config, File file) {
try {
getJaxb().marshalToXmlFile(config, file.getAbsolutePath());
} catch (SerializationException e) {
statusHandler.handle(Priority.ERROR,
"Couldn't write Harvester Config file.", e);
}
}
}

View file

@ -131,7 +131,7 @@ public class GridLocation extends PersistableDataObject<String> implements
}
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { data };
}
@ -1048,7 +1048,7 @@ public class GridLocation extends PersistableDataObject<String> implements
System.out.println(gridCoord.x + "," + gridCoord.y + " " + latLon);
PythonNumpyLatLonGrid latLonGrid = gloc.getLatLonGrid();
float[] data = (float[]) latLonGrid.getNumPy()[0];
float[] data = (float[]) latLonGrid.getNumpy()[0];
for (int x = 0; x < gloc.getNx(); x++) {
for (int y = 0; y < gloc.getNy(); y++) {
int idx = 2 * ((x * gloc.ny) + y);

View file

@ -408,7 +408,7 @@ public class Grid2DBoolean implements IGrid2D, Cloneable, INumpyable,
}
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { buffer.array() };
}

View file

@ -414,7 +414,7 @@ public class Grid2DByte implements IGrid2D, Cloneable, INumpyable,
}
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { buffer.array() };
}

View file

@ -425,7 +425,7 @@ public class Grid2DFloat implements IGrid2D, Cloneable, INumpyable,
}
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { buffer.array() };
}

View file

@ -36,7 +36,6 @@ import com.raytheon.uf.common.dataplugin.gfe.discrete.DiscreteKey;
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DBit;
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DByte;
import com.raytheon.uf.common.dataplugin.gfe.grid.IGrid2D;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -58,6 +57,7 @@ import com.raytheon.uf.common.time.TimeRange;
* string
* 08/13/2013 1571 randerso Removed toString to stop it from hanging the
* debugger when trying to display the grid
* 10/29/2013 2476 njensen Updated getNumpy() and added getKeyList()
* </pre>
*
* @author chammack
@ -789,16 +789,8 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
}
@Override
public Object[] getNumPy() {
Object[] numpy = new Object[2];
numpy[0] = getDiscreteGrid().getBuffer().array();
List<String> keyList = new ArrayList<String>();
for (DiscreteKey k : key) {
keyList.add(k.toString());
}
String pyList = PyUtil.listToList(keyList);
numpy[1] = pyList;
return numpy;
public Object[] getNumpy() {
return new Object[] { getDiscreteGrid().getBuffer().array() };
}
@Override
@ -860,4 +852,12 @@ public class DiscreteGridSlice extends AbstractGridSlice implements Cloneable {
diskCache.removeFromCache(cacheId);
}
}
public List<String> getKeyList() {
List<String> list = new ArrayList<String>(key.length);
for (DiscreteKey k : key) {
list.add(k.toString());
}
return list;
}
}

View file

@ -72,10 +72,10 @@ public class PythonWeatherGridSlice extends AbstractGridSlice {
/*
* (non-Javadoc)
*
* @see jep.INumpyable#getNumPy()
* @see jep.INumpyable#getNumpy()
*/
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
Object[] numpy = new Object[2];
numpy[0] = weatherGrid.getBuffer().array();
String pyList = PyUtil.listToList(keys);

View file

@ -937,7 +937,7 @@ public class ScalarGridSlice extends AbstractGridSlice implements
}
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { this.getScalarGrid().getFloats() };
}

View file

@ -1225,7 +1225,7 @@ public class VectorGridSlice extends ScalarGridSlice implements Cloneable,
}
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { this.getMagGrid().getFloats(),
this.getDirGrid().getFloats() };
}

View file

@ -35,7 +35,6 @@ import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DByte;
import com.raytheon.uf.common.dataplugin.gfe.grid.IGrid2D;
import com.raytheon.uf.common.dataplugin.gfe.weather.WeatherKey;
import com.raytheon.uf.common.dataplugin.gfe.weather.WeatherSubKey;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -56,6 +55,7 @@ import com.raytheon.uf.common.time.TimeRange;
* Jan 30, 2013 15719 jdynina Allowed more than 128 char wx string
* Aug 13, 2013 1571 randerso Removed toString to stop it from hanging the
* debugger when trying to display the grid
* Oct 29, 2013 2476 njensen Updated getNumpy() and added getKeyList()
*
* </pre>
*
@ -814,16 +814,8 @@ public class WeatherGridSlice extends AbstractGridSlice {
}
@Override
public Object[] getNumPy() {
Object[] numpy = new Object[2];
numpy[0] = getWeatherGrid().getBuffer().array();
List<String> keyList = new ArrayList<String>();
for (WeatherKey k : keys) {
keyList.add(k.toString());
}
String pyList = PyUtil.listToList(keyList);
numpy[1] = pyList;
return numpy;
public Object[] getNumpy() {
return new Object[] { getWeatherGrid().getBuffer().array() };
}
@Override
@ -884,4 +876,12 @@ public class WeatherGridSlice extends AbstractGridSlice {
diskCache.removeFromCache(cacheId);
}
}
public List<String> getKeyList() {
List<String> list = new ArrayList<String>(keys.length);
for (WeatherKey k : keys) {
list.add(k.toString());
}
return list;
}
}

View file

@ -52,10 +52,10 @@ public class PythonNumpyFloatArray implements INumpyable {
/*
* (non-Javadoc)
*
* @see jep.INumpyable#getNumPy()
* @see jep.INumpyable#getNumpy()
*/
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { messageData };
}

View file

@ -22,7 +22,6 @@ package com.raytheon.uf.common.registry.services.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.xml.bind.JAXBException;
import com.raytheon.uf.common.registry.RegistryException;
import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResponse;
@ -40,6 +39,7 @@ import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResp
* 7/29/2013 2191 bphillip Initial implementation
* 9/20/2013 2385 bphillip Added subscription backup functions
* 10/8/2013 1682 bphillip Added rest functions for use with the query web interface
* 10/23/2013 2385 bphillip restoreSubscriptions throws JAXBException
* </pre>
*
* @author bphillip
@ -111,25 +111,20 @@ public interface IRegistryDataAccessService {
* @param subscriptionName
* The subscription to be backed up
* @return Status message about whether the backup was successful
* @throws JAXBException
* If marshalling/unmarshalling errors are encountered
*/
@GET
@Path(DATA_ACCESS_PATH_PREFIX + "backupSubscription/{subscriptionName}")
public String backupSubscription(
@PathParam("subscriptionName") String subscriptionName)
throws JAXBException;
@PathParam("subscriptionName") String subscriptionName);
/**
* Backs up all subscriptions currently in the registry
*
* @return Status message about whether the backup was successful
* @throws JAXBException
* If marshalling/unmarshalling errors are encountered
*/
@GET
@Path(DATA_ACCESS_PATH_PREFIX + "backupAllSubscriptions/")
public String backupAllSubscriptions() throws JAXBException;
public String backupAllSubscriptions();
/**
* Restores the specified subscription
@ -137,13 +132,11 @@ public interface IRegistryDataAccessService {
* @param subscriptionName
* The name of the subscription to restore
* @return Status message about whether the backup was successful
* @throws JAXBException
*/
@GET
@Path(DATA_ACCESS_PATH_PREFIX + "restoreSubscription/{subscriptionName}")
public String restoreSubscription(
@PathParam("subscriptionName") String subscriptionName)
throws JAXBException;
@PathParam("subscriptionName") String subscriptionName);
/**
* Restores any subscriptions that were previously backed up

View file

@ -23,8 +23,6 @@ import java.util.Iterator;
import java.util.ServiceLoader;
import java.util.concurrent.atomic.AtomicReference;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
* The principal mechanism for representing the outcome of an operation. <BR>
*
@ -103,23 +101,22 @@ public class UFStatus {
protected final String message;
/** handler factory */
private static AtomicReference<IUFStatusHandlerFactory> handlerFactoryRef = createHandlerFactory();
private static AtomicReference<IUFStatusHandlerFactory> handlerFactoryRef = new AtomicReference<IUFStatusHandlerFactory>();
private static final AtomicReference<IUFStatusHandlerFactory> createHandlerFactory() {
static {
ServiceLoader<IUFStatusHandlerFactory> loader = ServiceLoader.load(
IUFStatusHandlerFactory.class,
IUFStatusHandlerFactory.class.getClassLoader());
Iterator<IUFStatusHandlerFactory> handlerIterator = loader.iterator();
IUFStatusHandlerFactory factory = null;
if (handlerIterator.hasNext()) {
factory = handlerIterator.next();
UFStatus.setHandlerFactory(handlerIterator.next());
} else {
factory = new DefaultStatusHandlerFactory();
UFStatus.setHandlerFactory(new DefaultStatusHandlerFactory());
Exception e = new RuntimeException("No "
+ IUFStatusHandlerFactory.class.getName()
+ " found.\nUsing default handler.");
factory.getInstance()
UFStatus.getHandler()
.handle(Priority.CRITICAL,
e.getLocalizedMessage()
+ "\nPlease ignore if you are in a unit test environment\n");
@ -130,7 +127,6 @@ public class UFStatus {
+ IUFStatusHandlerFactory.class.getName()
+ " handlers defined");
}
return new AtomicReference<IUFStatusHandlerFactory>(factory);
}
/**

View file

@ -59,6 +59,7 @@ import java.util.zip.GZIPOutputStream;
* Mar 11, 2013 1645 djohnson Added file modification watcher.
* Mar 14, 2013 1794 djohnson FileUtil.listFiles now returns List.
* May 16, 2013 1966 rferrel Add sizeOfDirectory and listDirFiles method.
* Oct 18, 2013 2267 bgonzale Add listPaths method.
*
* </pre>
*
@ -925,4 +926,37 @@ public class FileUtil {
return size;
}
// TODO Java 1.7 potential code
// /**
// * List files/directories that match a FileFilter.
// *
// * @param directory
// * @param filter
// * @param recurse
// * @return
// * @throws IOException
// */
// public static List<Path> listPaths(File directory,
// DirectoryStream.Filter<? super Path> filter, boolean recurse)
// throws IOException {
// // List of files / directories
// List<Path> files = new LinkedList<Path>();
//
// // Get files / directories in the directory accepted by the filter.
// Path dirPath = FileSystems.getDefault().getPath(
// directory.getAbsolutePath());
// DirectoryStream<Path> stream = null;
// try {
// stream = Files.newDirectoryStream(dirPath, filter);
// for (final Iterator<Path> it = stream.iterator(); it.hasNext();) {
// files.add(it.next());
// }
// } finally {
// if (stream != null) {
// stream.close();
// }
// }
// return files;
// }
}

View file

@ -32,6 +32,7 @@ import java.io.FilenameFilter;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 14, 2013 1794 djohnson Initial creation
* Oct 18, 2013 2267 bgonzale Added Path filters.
*
* </pre>
*
@ -154,7 +155,7 @@ public final class FilenameFilters {
};
/**
* Accepts directories.
* Accepts files.
*/
public static final FilenameFilter ACCEPT_FILES = new FilenameFilter() {
@Override
@ -162,6 +163,38 @@ public final class FilenameFilters {
return new File(dir.getPath(), name).isFile();
}
};
/**
* Accepts files.
*/
public static final FilenameFilter ACCEPT_VISIBLE_FILES = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
File tmp = new File(dir.getPath(), name);
return tmp.isFile() && !tmp.isHidden();
}
};
// TODO Code that can be uncommented after a transition to Java 1.7
// /**
// * Accepts Path directories.
// */
// public static final DirectoryStream.Filter<Path> ACCEPT_PATH_DIRECTORIES
// = new DirectoryStream.Filter<Path>() {
// public boolean accept(Path path) throws IOException {
// return (Files.isDirectory(path));
// }
// };
//
// /**
// * Accepts Path files.
// */
// public static final DirectoryStream.Filter<Path> ACCEPT_PATH_FILES = new
// DirectoryStream.Filter<Path>() {
// public boolean accept(Path path) throws IOException {
// return (Files.isRegularFile(path));
// }
// };
/**
* Returns a {@link FilenameFilter} that matches the specified file

View file

@ -17,3 +17,4 @@ Require-Bundle: com.raytheon.uf.common.datadelivery.bandwidth;bundle-version="1.
com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.edex.core;bundle-version="1.12.1174",
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0"
Import-Package: com.raytheon.edex.site

View file

@ -0,0 +1,30 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="sbnSimulator"
class="com.raytheon.uf.edex.datadelivery.bandwidth.sbn.SbnSimulator" />
<camelContext id="SbnSimulator-context"
xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="errorHandler">
<endpoint id="checkForSbnDataCron"
uri="quartz://datadelivery/sbnSimulator?cron=${sbnSimulator-checkForSbnData.cron}" />
<route id="distributeToSiteDirs">
<from uri="checkForSbnDataCron" />
<doTry>
<pipeline>
<bean ref="sbnSimulator" method="distributeToSiteDirs" />
</pipeline>
<doCatch>
<exception>java.lang.Throwable</exception>
<to
uri="log:SbnSimulator" />
</doCatch>
</doTry>
</route>
</camelContext>
</beans>

View file

@ -24,6 +24,7 @@ import java.io.IOException;
import java.util.List;
import com.google.common.annotations.VisibleForTesting;
import com.raytheon.edex.site.SiteUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.util.FileUtil;
@ -41,6 +42,7 @@ import com.raytheon.uf.edex.core.EDEXUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 14, 2013 1648 djohnson Initial creation
* Oct 18, 2013 2267 bgonzale Added distribution to and check in site specific directories.
*
* </pre>
*
@ -84,14 +86,20 @@ public class SbnSimulator {
private final File directoryToScan;
private final File sitesDirectory;
private final File localSiteDirectory;
private final IFileProcessor fileProcessor;
private String site;
/**
* Private constructor.
*/
public SbnSimulator() {
this(new File(System.getProperty("sbn.retrieval.transfer.directory")),
new CopyFileToManualIngest());
new CopyFileToManualIngest(), SiteUtil.getSite());
}
/**
@ -100,9 +108,13 @@ public class SbnSimulator {
* @param fileProcessor
*/
@VisibleForTesting
SbnSimulator(File scanDirectory, IFileProcessor fileProcessor) {
SbnSimulator(File scanDirectory, IFileProcessor fileProcessor, String site) {
this.fileProcessor = fileProcessor;
this.directoryToScan = scanDirectory;
this.sitesDirectory = new File(directoryToScan, "sbnSimulator");
this.localSiteDirectory = new File(sitesDirectory, site);
this.localSiteDirectory.mkdirs();
this.site = site;
}
/**
@ -111,11 +123,11 @@ public class SbnSimulator {
* @throws IOException
*/
public void checkForSbnData() throws IOException {
final List<File> files = FileUtil.listFiles(directoryToScan,
FilenameFilters.ACCEPT_FILES, false);
final List<File> files = FileUtil.listFiles(localSiteDirectory,
FilenameFilters.ACCEPT_VISIBLE_FILES, false);
statusHandler
.info("Found [" + files.size() + "] files from the SBN...");
statusHandler.info("Found [" + files.size() + "] files for " + site
+ " from the SBN...");
for (File file : files) {
@ -131,4 +143,80 @@ public class SbnSimulator {
}
}
/**
* Distribute to the site directories. Enables all site client registries to
* ingest shared data.
*
* @throws IOException
*/
public void distributeToSiteDirs() throws IOException {
final List<File> undistributedFiles = FileUtil.listFiles(
directoryToScan,
FilenameFilters.ACCEPT_FILES, false);
// get list of site dirs
final List<File> sites = FileUtil.listFiles(sitesDirectory,
FilenameFilters.ACCEPT_DIRECTORIES, false);
statusHandler.info("Found [" + undistributedFiles.size() + "] files to distribute...");
// distribute to site specific directories
for (File file : undistributedFiles) {
statusHandler.info("Distributing file [" + file + "]");
for (File siteDir : sites) {
File dest = new File(siteDir, file.getName().toString());
File hiddenDest = new File(siteDir, "."
+ file.getName().toString());
// move to site sbn directory as hidden
FileUtil.copyFile(file, hiddenDest);
// rename dest to un-hidden
hiddenDest.renameTo(dest);
statusHandler.info("===> to file [" + dest + "]");
}
// delete source file
file.delete();
}
}
// TODO Java 1.7 version of the distributeToSiteDirs() method
// /**
// * Distribute to the site directories. Enables all site client registries
// * to ingest shared data.
// *
// * @throws IOException
// */
// public void distributeToSiteDirs() throws IOException {
// final List<Path> undistributedFiles = FileUtil.listPaths(
// directoryToScan,
// FilenameFilters.ACCEPT_PATH_FILES, false);
// // get list of site dirs
// final List<Path> sites = FileUtil.listPaths(sitesDirectory,
// FilenameFilters.ACCEPT_PATH_DIRECTORIES, false);
//
// statusHandler.info("Found [" + undistributedFiles.size() +
// "] files to distribute...");
//
// // distribute to site specific directories
// for (Path file : undistributedFiles) {
// statusHandler.info("Distributing file [" + file + "]");
// for (Path siteDir : sites) {
// Path dest = FileSystems.getDefault().getPath(
// siteDir.toString(), file.getFileName().toString());
// Path hiddenDest = FileSystems.getDefault()
// .getPath(siteDir.toString(),
// "." + file.getFileName().toString());
//
// // move to site sbn directory as hidden
// java.nio.file.Files.copy(file, hiddenDest,
// StandardCopyOption.REPLACE_EXISTING);
// // rename dest to un-hidden
// java.nio.file.Files.move(hiddenDest, dest,
// StandardCopyOption.ATOMIC_MOVE);
// statusHandler.info("===> to file [" + dest + "]");
// }
// // delete source file
// java.nio.file.Files.delete(file);
// }
// }
}

View file

@ -1,7 +1,8 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
@ -86,5 +87,15 @@
<constructor-arg ref="retrievalAgentNotifier" />
<property name="retrievalPlans" ref="retrievalPlans" />
</bean>
<camelContext id="datadelivery-bandwidth" xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler">
<endpoint id="scheduleBandwidthQueue"
uri="vm://scheduleBandwidth" />
<route id="scheduleSubscription">
<from uri="scheduleBandwidthQueue" />
<bean ref="bandwidthManager" method="schedule"/>
</route>
</camelContext>
</beans>

View file

@ -122,14 +122,15 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException;
* case for no matching dataset metadata for an
* adhoc subscription.
* Sept 25, 2013 1797 dhladky separated time from gridded time
* 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc
* </pre>
*
* @author dhladky
* @version 1.0
*/
public abstract class BandwidthManager<T extends Time, C extends Coverage> extends
AbstractPrivilegedRequestHandler<IBandwidthRequest<T, C>> implements
IBandwidthManager<T, C> {
public abstract class BandwidthManager<T extends Time, C extends Coverage>
extends AbstractPrivilegedRequestHandler<IBandwidthRequest<T, C>>
implements IBandwidthManager<T, C> {
protected static final IUFStatusHandler statusHandler = UFStatus
.getHandler(BandwidthManager.class);
@ -141,7 +142,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
private BandwidthInitializer initializer;
protected final BandwidthDaoUtil<T,C> bandwidthDaoUtil;
protected final BandwidthDaoUtil<T, C> bandwidthDaoUtil;
private final IBandwidthDbInit dbInit;
@ -154,8 +155,9 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
final RetrievalManager retrievalManager;
public BandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao<T, C> bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil<T,C> bandwidthDaoUtil) {
IBandwidthDao<T, C> bandwidthDao,
RetrievalManager retrievalManager,
BandwidthDaoUtil<T, C> bandwidthDaoUtil) {
this.dbInit = dbInit;
this.bandwidthDao = bandwidthDao;
this.retrievalManager = retrievalManager;
@ -244,8 +246,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
return unscheduled;
}
protected List<BandwidthAllocation> schedule(Subscription<T, C> subscription,
BandwidthSubscription dao) {
protected List<BandwidthAllocation> schedule(
Subscription<T, C> subscription, BandwidthSubscription dao) {
Calendar retrievalTime = dao.getBaseReferenceTime();
// Retrieve all the current subscriptions by provider, dataset name and
@ -440,7 +442,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* @return
*/
@Override
public List<BandwidthAllocation> schedule(AdhocSubscription<T, C> subscription) {
public List<BandwidthAllocation> scheduleAdhoc(
AdhocSubscription<T, C> subscription) {
List<BandwidthSubscription> subscriptions = new ArrayList<BandwidthSubscription>();
Calendar now = BandwidthUtil.now();
@ -453,8 +456,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* and time.
*/
AdhocSubscription<T, C> subscriptionUpdated = bandwidthDaoUtil
.setAdhocMostRecentUrlAndTime(
subscription, true);
.setAdhocMostRecentUrlAndTime(subscription, true);
if (subscriptionUpdated != null) {
subscription = subscriptionUpdated;
}
@ -558,7 +560,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* the subscription
* @return the list of unscheduled subscriptions
*/
private List<BandwidthAllocation> handlePoint(Subscription<T, C> subscription) {
private List<BandwidthAllocation> handlePoint(
Subscription<T, C> subscription) {
return schedule(subscription,
((PointTime) subscription.getTime()).getInterval());
}
@ -570,8 +573,10 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* the subscription
* @return the list of unscheduled subscriptions
*/
private List<BandwidthAllocation> handleGridded(Subscription<T, C> subscription) {
final List<Integer> cycles = ((GriddedTime)subscription.getTime()).getCycleTimes();
private List<BandwidthAllocation> handleGridded(
Subscription<T, C> subscription) {
final List<Integer> cycles = ((GriddedTime) subscription.getTime())
.getCycleTimes();
final boolean subscribedToCycles = !CollectionUtil
.isNullOrEmpty(cycles);
final boolean useMostRecentDataSetUpdate = !subscribedToCycles;
@ -599,7 +604,7 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
+ "No adhoc requested.",
subscription.getName()));
} else {
unscheduled = schedule(adhoc);
unscheduled = scheduleAdhoc(adhoc);
}
} else {
statusHandler
@ -614,10 +619,11 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* @return
*/
@Override
public List<BandwidthAllocation> adhocSubscription(AdhocSubscription<T, C> adhoc) {
public List<BandwidthAllocation> adhocSubscription(
AdhocSubscription<T, C> adhoc) {
statusHandler.info("Scheduling adhoc subscription [" + adhoc.getName()
+ "]");
return schedule(adhoc);
return scheduleAdhoc(adhoc);
}
/**
@ -660,7 +666,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* {@inheritDoc}
*/
@Override
public Object handleRequest(IBandwidthRequest<T, C> request) throws Exception {
public Object handleRequest(IBandwidthRequest<T, C> request)
throws Exception {
ITimer timer = TimeUtil.getTimer();
timer.start();
@ -670,7 +677,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
final Network requestNetwork = request.getNetwork();
final int bandwidth = request.getBandwidth();
final List<Subscription<T, C>> subscriptions = request.getSubscriptions();
final List<Subscription<T, C>> subscriptions = request
.getSubscriptions();
final RequestType requestType = request.getRequestType();
switch (requestType) {
case GET_ESTIMATED_COMPLETION:
@ -797,7 +805,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* @throws SerializationException
*/
protected abstract Set<String> scheduleSbnSubscriptions(
List<Subscription<T, C>> subscriptions) throws SerializationException;
List<Subscription<T, C>> subscriptions)
throws SerializationException;
/**
* Proposes scheduling a list of subscriptions.
@ -808,7 +817,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* @throws SerializationException
*/
protected ProposeScheduleResponse proposeScheduleSubscriptions(
List<Subscription<T, C>> subscriptions) throws SerializationException {
List<Subscription<T, C>> subscriptions)
throws SerializationException {
final ProposeScheduleResponse proposeResponse = proposeSchedule(subscriptions);
Set<String> subscriptionsUnscheduled = proposeResponse
.getUnscheduledSubscriptions();
@ -907,7 +917,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* @return the set of subscription names unscheduled
* @throws SerializationException
*/
protected Set<String> scheduleSubscriptions(List<Subscription<T, C>> subscriptions)
protected Set<String> scheduleSubscriptions(
List<Subscription<T, C>> subscriptions)
throws SerializationException {
Set<String> unscheduledSubscriptions = new TreeSet<String>();
@ -993,7 +1004,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* @throws SerializationException
*/
private ProposeScheduleResponse proposeSchedule(
List<Subscription<T, C>> subscriptions) throws SerializationException {
List<Subscription<T, C>> subscriptions)
throws SerializationException {
BandwidthMap copyOfCurrentMap = BandwidthMap
.load(EdexBandwidthContextFactory.getBandwidthMapConfig());
@ -1100,7 +1112,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* @throws SerializationException
*/
@VisibleForTesting
BandwidthManager<T, C> startProposedBandwidthManager(BandwidthMap bandwidthMap) {
BandwidthManager<T, C> startProposedBandwidthManager(
BandwidthMap bandwidthMap) {
InMemoryBandwidthContextFactory
.setInMemoryBandwidthConfigFile(bandwidthMap);
@ -1137,8 +1150,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* @param type
* @return the reference to the bandwidth manager
*/
private BandwidthManager<T, C> startBandwidthManager(final String[] springFiles,
boolean close, String type) {
private BandwidthManager<T, C> startBandwidthManager(
final String[] springFiles, boolean close, String type) {
ITimer timer = TimeUtil.getTimer();
timer.start();
@ -1146,8 +1159,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
try {
ctx = new ClassPathXmlApplicationContext(springFiles,
EDEXUtil.getSpringContext());
final BandwidthManager<T, C> bwManager = ctx.getBean("bandwidthManager",
BandwidthManager.class);
final BandwidthManager<T, C> bwManager = ctx.getBean(
"bandwidthManager", BandwidthManager.class);
try {
bwManager.initializer.executeAfterRegistryInit();
return bwManager;
@ -1218,11 +1231,11 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
/**
* {@inheritDoc}
*/
public List<BandwidthAllocation> copyState(BandwidthManager<T,C> copyFrom) {
public List<BandwidthAllocation> copyState(BandwidthManager<T, C> copyFrom) {
IPerformanceTimer timer = TimeUtil.getPerformanceTimer();
timer.start();
List<BandwidthAllocation> unscheduled = Collections.emptyList();
IBandwidthDao<T,C> fromDao = copyFrom.bandwidthDao;
IBandwidthDao<T, C> fromDao = copyFrom.bandwidthDao;
final boolean proposingBandwidthChange = retrievalManager
.isProposingBandwidthChanges(copyFrom.retrievalManager);
@ -1239,10 +1252,10 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
subscriptionNames.add(subscription.getName());
}
Set<Subscription<T,C>> actualSubscriptions = Sets.newHashSet();
Set<Subscription<T, C>> actualSubscriptions = Sets.newHashSet();
for (String subName : subscriptionNames) {
try {
Subscription<T,C> actualSubscription = DataDeliveryHandlers
Subscription<T, C> actualSubscription = DataDeliveryHandlers
.getSubscriptionHandler().getByName(subName);
actualSubscriptions.add(actualSubscription);
} catch (RegistryHandlerException e) {
@ -1332,7 +1345,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* the subscription
* @return the required dataset size
*/
private long determineRequiredDataSetSize(final Subscription<T, C> subscription) {
private long determineRequiredDataSetSize(
final Subscription<T, C> subscription) {
return determineRequiredValue(subscription,
new FindSubscriptionRequiredDataSetSize());
}
@ -1430,7 +1444,8 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* the subscription
* @return true if able to be cleanly scheduled, false otherwise
*/
private boolean isSchedulableWithoutConflict(final Subscription<T, C> subscription) {
private boolean isSchedulableWithoutConflict(
final Subscription<T, C> subscription) {
BandwidthMap copyOfCurrentMap = BandwidthMap
.load(EdexBandwidthContextFactory.getBandwidthMapConfig());
@ -1455,22 +1470,24 @@ public abstract class BandwidthManager<T extends Time, C extends Coverage> exten
* Provide implementation specific shutdown.
*/
protected abstract void shutdownInternal();
/**
* Special handling for Gridded Times with cycles and time indicies
*
* @param subTime
* @param dataSetMetaDataTime
* @return
*/
protected static Time handleCyclesAndSequences(Time subTime, Time dataSetMetaDataTime) {
protected static Time handleCyclesAndSequences(Time subTime,
Time dataSetMetaDataTime) {
if (subTime instanceof GriddedTime) {
GriddedTime time = (GriddedTime)subTime;
GriddedTime dsmTime = (GriddedTime)dataSetMetaDataTime;
GriddedTime time = (GriddedTime) subTime;
GriddedTime dsmTime = (GriddedTime) dataSetMetaDataTime;
dsmTime.setSelectedTimeIndices(time.getSelectedTimeIndices());
dsmTime.setCycleTimes(time.getCycleTimes());
}
return dataSetMetaDataTime;
}
}

View file

@ -96,13 +96,15 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* Add throws to updatePointDataSetMetaData.
* Oct 1 2013 1797 dhladky Time and GriddedTime separation
* Oct 10, 2013 1797 bgonzale Refactored registry Time objects.
* 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> extends BandwidthManager<T, C> {
public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
extends BandwidthManager<T, C> {
private static final Pattern RAP_PATTERN = Pattern
.compile(".*rap_f\\d\\d$");
@ -135,8 +137,9 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
* @param bandwidthDaoUtil
*/
public EdexBandwidthManager(IBandwidthDbInit dbInit,
IBandwidthDao<T,C> bandwidthDao, RetrievalManager retrievalManager,
BandwidthDaoUtil<T,C> bandwidthDaoUtil,
IBandwidthDao<T, C> bandwidthDao,
RetrievalManager retrievalManager,
BandwidthDaoUtil<T, C> bandwidthDaoUtil,
IDataSetMetaDataHandler dataSetMetaDataHandler,
ISubscriptionHandler subscriptionHandler) {
super(dbInit, bandwidthDao, retrievalManager, bandwidthDaoUtil);
@ -393,11 +396,11 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
GriddedDataSetMetaData dataSetMetaData) throws ParseException {
// Daily/Hourly/Monthly datasets
if (dataSetMetaData.getCycle() == GriddedDataSetMetaData.NO_CYCLE) {
updateDataSetMetaDataWithoutCycle((DataSetMetaData<T>)dataSetMetaData);
updateDataSetMetaDataWithoutCycle((DataSetMetaData<T>) dataSetMetaData);
}
// Regular cycle containing datasets
else {
updateDataSetMetaDataWithCycle((DataSetMetaData<T>)dataSetMetaData);
updateDataSetMetaDataWithCycle((DataSetMetaData<T>) dataSetMetaData);
}
}
@ -465,7 +468,7 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
try {
// Update the retrieval times on the subscription object
// which goes through the retrieval process
final SubscriptionRetrievalAttributes<T,C> subscriptionRetrievalAttributes = bandwidthDao
final SubscriptionRetrievalAttributes<T, C> subscriptionRetrievalAttributes = bandwidthDao
.getSubscriptionRetrievalAttributes(retrieval);
final Subscription<T, C> subscription = subscriptionRetrievalAttributes
.getSubscription();
@ -480,7 +483,8 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
subTime.setRequestStart(earliestRetrievalDataTime);
subTime.setRequestEnd(latestRetrievalDataTime);
subTime.setTimes(time.getTimes());
subscriptionRetrievalAttributes.setSubscription(subscription);
subscriptionRetrievalAttributes
.setSubscription(subscription);
bandwidthDao.update(subscriptionRetrievalAttributes);
@ -533,13 +537,14 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
dataSetMetaData.getUrl()));
// Create an adhoc for each one, and schedule it
for (Subscription<T,C> subscription : subscriptions) {
for (Subscription<T, C> subscription : subscriptions) {
@SuppressWarnings("unchecked")
Subscription<T,C> sub = updateSubscriptionWithDataSetMetaData(
Subscription<T, C> sub = updateSubscriptionWithDataSetMetaData(
subscription, dataSetMetaData);
if (sub instanceof SiteSubscription) {
schedule(new AdhocSubscription<T,C>((SiteSubscription<T,C>) sub));
scheduleAdhoc(new AdhocSubscription<T, C>(
(SiteSubscription<T, C>) sub));
} else {
statusHandler
.warn("Unable to create adhoc queries for shared subscriptions at this point. This functionality should be added in the future...");
@ -583,10 +588,10 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
// SubscriptionRetrieval with the current DataSetMetaData
// URL and time Object
SubscriptionRetrievalAttributes<T,C> attributes = bandwidthDao
SubscriptionRetrievalAttributes<T, C> attributes = bandwidthDao
.getSubscriptionRetrievalAttributes(retrieval);
Subscription<T,C> sub;
Subscription<T, C> sub;
try {
sub = updateSubscriptionWithDataSetMetaData(
attributes.getSubscription(), dataSetMetaData);
@ -608,12 +613,12 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
bandwidthDaoUtil.update(retrieval);
statusHandler
.info(String.format("Updated retrieval [%s] for "
statusHandler.info(String.format(
"Updated retrieval [%s] for "
+ "subscription [%s] to use "
+ "url [%s] and "
+ "base reference time [%s]", retrieval
.getIdentifier(), sub.getName(),
+ "base reference time [%s]",
retrieval.getIdentifier(), sub.getName(),
dataSetMetaData.getUrl(),
BandwidthUtil.format(sub.getTime().getStart())));
}
@ -647,14 +652,14 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
}
}
Set<Subscription<T,C>> subscriptions = new HashSet<Subscription<T,C>>();
Set<Subscription<T, C>> subscriptions = new HashSet<Subscription<T, C>>();
for (SubscriptionRetrieval retrieval : retrievals) {
try {
final SubscriptionRetrievalAttributes<T,C> sra = bandwidthDao
final SubscriptionRetrievalAttributes<T, C> sra = bandwidthDao
.getSubscriptionRetrievalAttributes(retrieval);
if (sra != null) {
@SuppressWarnings("unchecked")
Subscription<T,C> sub = sra.getSubscription();
Subscription<T, C> sub = sra.getSubscription();
if (sub != null) {
subscriptions.add(sub);
}
@ -666,7 +671,7 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
}
}
for (Subscription<T,C> subscription : subscriptions) {
for (Subscription<T, C> subscription : subscriptions) {
subscription.setUnscheduled(true);
subscriptionUpdated(subscription);
}
@ -700,7 +705,7 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage> e
* reinitialize operation.
*/
private void bandwidthMapConfigurationUpdated() {
IBandwidthRequest<T,C> request = new IBandwidthRequest<T,C>();
IBandwidthRequest<T, C> request = new IBandwidthRequest<T, C>();
request.setRequestType(RequestType.REINITIALIZE);
try {

View file

@ -41,6 +41,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.interfaces.ISubscriptionAggre
* ------------ ---------- ----------- --------------------------
* Oct 30, 2012 1286 djohnson Initial creation
* Jul 10, 2013 2106 djohnson Remove EDEX instance specific methods.
* 10/23/2013 2385 bphillip Change schedule method to scheduleAdhoc
*
* </pre>
*
@ -66,7 +67,7 @@ public interface IBandwidthManager<T extends Time, C extends Coverage> {
* @param b
* @return
*/
List<BandwidthAllocation> schedule(AdhocSubscription<T, C> subscription);
List<BandwidthAllocation> scheduleAdhoc(AdhocSubscription<T, C> subscription);
/**
* When a Subscription is updated in the Registry, update the retrieval plan
@ -76,8 +77,8 @@ public interface IBandwidthManager<T extends Time, C extends Coverage> {
* @return
* @throws SerializationException
*/
List<BandwidthAllocation> subscriptionUpdated(Subscription<T, C> subscription)
throws SerializationException;
List<BandwidthAllocation> subscriptionUpdated(
Subscription<T, C> subscription) throws SerializationException;
/**
*

View file

@ -15,6 +15,7 @@ import java.util.Set;
import com.raytheon.uf.common.datadelivery.harvester.Agent;
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
import com.raytheon.uf.common.datadelivery.registry.Collection;
import com.raytheon.uf.common.datadelivery.registry.Provider;
import com.raytheon.uf.common.datadelivery.registry.Utils;
@ -63,6 +64,7 @@ import com.raytheon.uf.edex.registry.ebxml.init.RegistryInitializedListener;
* Feb 05, 2013 1580 mpduff EventBus refactor.
* 3/18/2013 1802 bphillip Modified to insert provider object after database is initialized
* Jun 24, 2013 2106 djohnson Accepts ProviderHandler as a constructor argument.
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
*
* </pre>
*
@ -76,7 +78,7 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(CrawlMetaDataHandler.class);
/** Path to crawler links directory. */
private static final String PROCESSED_DIR = StringUtil.join(new String[] {
"datadelivery", "harvester", "processed" }, File.separatorChar);
@ -97,13 +99,9 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener {
if (files != null) {
for (LocalizationFile file : files) {
try {
HarvesterConfig hc = SerializationUtil
.jaxbUnmarshalFromXmlFile(HarvesterConfig.class,
file.getFile());
HarvesterConfig hc = HarvesterConfigurationManager
.getHarvesterFile(file.getFile());
Agent agent = hc.getAgent();
if (agent != null) {
@ -117,7 +115,7 @@ public class CrawlMetaDataHandler implements RegistryInitializedListener {
hcs.put(hc.getProvider().getName(), hc);
}
}
} catch (SerializationException e1) {
} catch (Exception e1) {
statusHandler.error(
"Serialization Error Reading Crawler Config files",
e1);

View file

@ -12,13 +12,13 @@ import org.quartz.JobExecutionException;
import com.raytheon.uf.common.datadelivery.harvester.Agent;
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -33,6 +33,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* ------------ ---------- ----------- --------------------------
* Oct 4, 2012 1038 dhladky Initial creation
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
*
* </pre>
*
@ -141,11 +142,11 @@ public abstract class CrawlLauncher implements Job {
.getLocalizedFiles();
if (files != null) {
JAXBManager jaxbMan = new JAXBManager(HarvesterConfig.class);
for (LocalizationFile lf : files) {
HarvesterConfig hc = (HarvesterConfig) jaxbMan
.unmarshalFromXmlFile(lf.getFile());
HarvesterConfig hc = HarvesterConfigurationManager
.getHarvesterFile(lf.getFile());
if (hc.getAgent() != null) {
// we only want crawler types for CrawlerMetadata
Agent agent = hc.getAgent();

View file

@ -16,9 +16,8 @@ import com.raytheon.edex.util.Util;
import com.raytheon.uf.common.comm.ProxyConfiguration;
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
import com.raytheon.uf.common.datadelivery.registry.Collection;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -38,6 +37,7 @@ import edu.uci.ics.crawler4j.crawler.CrawlConfig;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 4, 2012 1038 dhladky Initial creation
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
*
* </pre>
*
@ -138,10 +138,9 @@ public abstract class Crawler {
HarvesterConfig hc = null;
try {
hc = SerializationUtil.jaxbUnmarshalFromXmlFile(
HarvesterConfig.class, configFile);
} catch (SerializationException e1) {
e1.printStackTrace();
hc = HarvesterConfigurationManager.getHarvesterFile(configFile);
} catch (Exception e1) {
statusHandler.handle(Priority.ERROR, e1.getLocalizedMessage(), e1);
}
return hc;

View file

@ -34,6 +34,7 @@ import java.util.regex.Pattern;
import com.google.common.annotations.VisibleForTesting;
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
import com.raytheon.uf.common.datadelivery.harvester.ProtoCollection;
import com.raytheon.uf.common.datadelivery.registry.Collection;
import com.raytheon.uf.common.datadelivery.registry.Provider;
@ -43,7 +44,6 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
import com.raytheon.uf.common.serialization.ExceptionWrapper;
import com.raytheon.uf.common.serialization.SerializableExceptionWrapper;
import com.raytheon.uf.common.serialization.SerializationException;
@ -73,6 +73,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.ProviderCollectionLinkStore;
* Aug 06, 2012 1022 djohnson Add shutdown(), write out millis with filename to prevent overwriting.
* Sep 10, 2012 1154 djohnson Use JAXB instead of thrift, allowing introspection of links, return files in ascending order.
* Mar 14, 2013 1794 djohnson Consolidate common FilenameFilter implementations.
* * Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
*
* </pre>
*
@ -373,18 +374,15 @@ class FileCommunicationStrategy implements CommunicationStrategy {
File file = lf.getFile();
try {
SerializationUtil.jaxbMarshalToXmlFile(hconfig,
file.getAbsolutePath());
HarvesterConfigurationManager.setHarvesterFile(hconfig, file);
lf.save();
} catch (SerializationException e) {
} catch (Exception e) {
statusHandler
.error("Unable to recreate the "
+ provider
+ "-harvester.xml configuration! Save of new collections failed",
e);
} catch (LocalizationOpFailedException e) {
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
}
}
}
/**

View file

@ -6,13 +6,13 @@ import java.util.List;
import com.raytheon.uf.common.datadelivery.harvester.Agent;
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -29,6 +29,7 @@ import com.raytheon.uf.edex.datadelivery.harvester.cron.HarvesterJobController;
* Mar 14, 2012 00357 dhladky Initial creation
* Jun 12, 2012 00609 djohnson Update path to crawl script.
* Aug 06, 2012 01022 djohnson Launch the crawler in the same JVM.
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
*
* </pre>
*
@ -78,9 +79,9 @@ public class MainSequenceCrawlLauncher extends CrawlLauncher {
// if many, start many
for (LocalizationFile lf : getLocalizedFiles()) {
HarvesterConfig hc = SerializationUtil
.jaxbUnmarshalFromXmlFile(HarvesterConfig.class,
lf.getFile());
HarvesterConfig hc = HarvesterConfigurationManager
.getHarvesterFile(lf.getFile());
if (hc.getProvider().getName().equals(providerName)) {
if (hc.getAgent() != null) {
// we only want crawler types for CrawlerMetadata

View file

@ -6,13 +6,13 @@ import java.util.List;
import com.raytheon.uf.common.datadelivery.harvester.Agent;
import com.raytheon.uf.common.datadelivery.harvester.CrawlAgent;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -28,6 +28,7 @@ import com.raytheon.uf.edex.datadelivery.harvester.cron.HarvesterJobController;
* ------------ ---------- ----------- --------------------------
* Oct 4, 2012 1038 dhladky Initial creation
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Oct 28, 2013 2361 dhladky Fixed up JAXBManager.
*
* </pre>
*
@ -76,9 +77,7 @@ public class SeedCrawlLauncher extends CrawlLauncher {
// if many, start many
for (LocalizationFile lf : getLocalizedFiles()) {
HarvesterConfig hc = (HarvesterConfig) new JAXBManager(
HarvesterConfig.class).unmarshalFromXmlFile(
lf.getFile());
HarvesterConfig hc = HarvesterConfigurationManager.getHarvesterFile(lf.getFile());
if (hc.getProvider().getName().equals(providerName)) {
if (hc.getAgent() != null) {

View file

@ -52,6 +52,7 @@ import com.raytheon.uf.edex.database.purge.PurgeRuleSet;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 11, 2013 2460 dhladky Initial creation
* Oct 23, 2013 2469 dhladky Refined the time check and accommodation for lack of purge rules.
*
* </pre>
*
@ -63,6 +64,8 @@ public class AdhocSubscriptionCleaner {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(AdhocSubscriptionCleaner.class);
private static final String DEFAULT_RULE = "00-12:00:00";
public AdhocSubscriptionCleaner() {
@ -150,17 +153,29 @@ public class AdhocSubscriptionCleaner {
if (purgeRuleSet != null) {
List<PurgeRule> rules = purgeRuleSet.getRules();
// if no rules exist, create a default, 12 hours
if (rules.isEmpty()) {
rules = new ArrayList<PurgeRule>();
PurgeRule rule = new PurgeRule();
rule.setPeriod(DEFAULT_RULE);
rules.add(rule);
}
// Go over all of the purge rules for each sub
for (PurgeRule rule: rules) {
// use current system date/time
long timeCheck = TimeUtil.newDate().getTime();
Date expireDate = new Date(timeCheck + rule.getPeriodInMillis());
// check rule against creation time of this sub
if (adhoc.getTime().getEnd().before(expireDate)) {
if (!subsToDelete.contains(adhoc)) {
subsToDelete.add(adhoc);
for (PurgeRule rule : rules) {
// use a valid rule
if (rule.getPeriodInMillis() != 0) {
// use current system date/time
Date compareTime = TimeUtil.newDate();
Date expireDate = new Date(adhoc.getTime()
.getStart().getTime()
+ rule.getPeriodInMillis());
if (expireDate.before(compareTime)) {
if (!subsToDelete.contains(adhoc)) {
subsToDelete.add(adhoc);
break;
}
}
}
}

View file

@ -46,10 +46,10 @@ public class PythonNumpyByteArray implements INumpyable {
/*
* (non-Javadoc)
*
* @see jep.INumpyable#getNumPy()
* @see jep.INumpyable#getNumpy()
*/
@Override
public Object[] getNumPy() {
public Object[] getNumpy() {
return new Object[] { messageData };
}

View file

@ -34,7 +34,8 @@ Require-Bundle: com.raytheon.uf.common.registry.schemas.ebxml;bundle-version="1.
com.raytheon.uf.common.datadelivery.request;bundle-version="1.0.0",
javax.mail;bundle-version="1.0.0",
org.apache.commons.validator;bundle-version="1.2.0",
com.sun.xml.bind;bundle-version="1.0.0"
com.sun.xml.bind;bundle-version="1.0.0",
org.reflections;bundle-version="0.9.9"
Export-Package: com.raytheon.uf.edex.registry.ebxml.acp,
com.raytheon.uf.edex.registry.ebxml.dao,
com.raytheon.uf.edex.registry.ebxml.exception,

View file

@ -21,12 +21,14 @@ package com.raytheon.uf.edex.registry.ebxml.services.rest;
import java.io.File;
import java.util.List;
import java.util.Set;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.xml.bind.JAXB;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlRootElement;
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
@ -40,21 +42,29 @@ import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SubscriptionType;
import org.reflections.Reflections;
import org.reflections.scanners.TypeAnnotationsScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.springframework.transaction.annotation.Transactional;
import com.raytheon.uf.common.registry.RegistryException;
import com.raytheon.uf.common.registry.services.rest.IRegistryDataAccessService;
import com.raytheon.uf.common.registry.services.rest.response.RestCollectionResponse;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.util.CollectionUtil;
import com.raytheon.uf.common.util.StringUtil;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.core.EdexException;
import com.raytheon.uf.edex.registry.ebxml.dao.QueryDefinitionDao;
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
/**
*
* Implementation of the registry data access service interface
* Implementation of the registry data access service interface <br>
* TODO: This class really needs to be moved to a data delivery specific plugin
*
* <pre>
*
@ -66,6 +76,7 @@ import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectDao;
* 9/20/2013 2385 bphillip Added subscription backup functions
* 10/2/2013 2385 bphillip Fixed subscription backup queries
* 10/8/2013 1682 bphillip Added query queries
* 10/23/2013 2385 bphillip Restored subscriptions are now scheduled in the bandwidth manager
* </pre>
*
* @author bphillip
@ -91,6 +102,8 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
+ "where obj.objectType like '%SiteSubscription' "
+ "OR obj.objectType like '%SharedSubscription' order by obj.id asc";
private static final JAXBManager subscriptionJaxbManager = initJaxbManager();
/** Data access object for registry objects */
private RegistryObjectDao registryObjectDao;
@ -234,8 +247,7 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
@GET
@Path(DATA_ACCESS_PATH_PREFIX + "backupSubscription/{subscriptionName}")
public String backupSubscription(
@PathParam("subscriptionName") String subscriptionName)
throws JAXBException {
@PathParam("subscriptionName") String subscriptionName) {
StringBuilder response = new StringBuilder();
List<RegistryObjectType> result = registryObjectDao.executeHQLQuery(
GET_SINGLE_SUBSCRIPTIONS_QUERY, "id", subscriptionName);
@ -277,7 +289,7 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
@Override
@GET
@Path(DATA_ACCESS_PATH_PREFIX + "backupAllSubscriptions/")
public String backupAllSubscriptions() throws JAXBException {
public String backupAllSubscriptions() {
StringBuilder response = new StringBuilder();
List<RegistryObjectType> subs = registryObjectDao
.executeHQLQuery(GET_SUBSCRIPTIONS_QUERY);
@ -300,16 +312,32 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
@GET
@Path(DATA_ACCESS_PATH_PREFIX + "restoreSubscription/{subscriptionName}")
public String restoreSubscription(
@PathParam("subscriptionName") String subscriptionName)
throws JAXBException {
@PathParam("subscriptionName") String subscriptionName) {
StringBuilder response = new StringBuilder();
File subscriptionFile = new File(SUBSCRIPTION_BACKUP_DIR
+ File.separator + subscriptionName);
if (subscriptionFile.exists()) {
SubmitObjectsRequest submitRequest = JAXB.unmarshal(
subscriptionFile, SubmitObjectsRequest.class);
String subscriptionXML = submitRequest.getRegistryObjects().get(0)
.getSlotByName("content").getSlotValue().getValue();
try {
Object subObj = subscriptionJaxbManager
.unmarshalFromXml(subscriptionXML);
EDEXUtil.getMessageProducer().sendSync("scheduleSubscription",
subObj);
lcm.submitObjects(submitRequest);
subscriptionFile.delete();
response.append(
"Subscription successfully restored from file [")
.append(subscriptionFile).append("]<br>");
} catch (EdexException e1) {
statusHandler.error("Error submitting subscription", e1);
response.append("Subscription from file [")
.append(subscriptionFile)
.append("] failed to be restored: ")
.append(e1.getLocalizedMessage()).append("<br>");
} catch (MsgRegistryException e) {
response.append("Error restoring subscription from file [")
.append(subscriptionFile).append("] ")
@ -317,10 +345,13 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
statusHandler.error("Error restoring subscription from file ["
+ subscriptionFile + "]", e);
return response.toString();
} catch (JAXBException e) {
response.append("Error restoring subscription from file [")
.append(subscriptionFile).append("] ")
.append(e.getMessage()).append("<br>");
statusHandler.error("Error restoring subscription from file ["
+ subscriptionFile + "]", e);
}
subscriptionFile.delete();
response.append("Subscription successfully restored from file [")
.append(subscriptionFile).append("]<br>");
} else {
response.append("No backup file exists for subscription[")
.append(subscriptionName).append("]<br>");
@ -345,18 +376,7 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
response.append("No subscriptions found to restore<br>");
} else {
for (File subscription : filesToRestore) {
try {
response.append(restoreSubscription(subscription
.getName()));
} catch (JAXBException e) {
statusHandler.error("Error restoring subscription ["
+ subscription + "]", e);
response.append("Error restoring subscription [")
.append(subscription).append("] ")
.append(e.getMessage()).append("<br>");
continue;
}
response.append(restoreSubscription(subscription.getName()));
}
}
} else {
@ -394,6 +414,28 @@ public class RegistryDataAccessService implements IRegistryDataAccessService {
return response.toString();
}
/**
* Initializes the JAXBManager for datadelivery classes.
*
* @return JAXBManager for datadelivery classes
*/
private static JAXBManager initJaxbManager() {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.addUrls(ClasspathHelper
.forPackage("com.raytheon.uf.common.datadelivery.registry"));
cb.setScanners(new TypeAnnotationsScanner());
Reflections reflecs = cb.build();
Set<Class<?>> classes = reflecs
.getTypesAnnotatedWith(XmlRootElement.class);
try {
return new JAXBManager(
classes.toArray(new Class<?>[classes.size()]));
} catch (JAXBException e) {
throw new RuntimeException(
"Error initializing subscription jaxb Manager!", e);
}
}
public void setRegistryObjectDao(RegistryObjectDao registryObjectDao) {
this.registryObjectDao = registryObjectDao;
}

View file

@ -0,0 +1 @@
war.name=registryEbxml

View file

@ -20,13 +20,14 @@
package jep;
/**
* TODO Add Description
* Interface representing a Java object that can be transformed into a numpy
* array.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 4, 2008 njensen Initial creation
* Apr 4, 2008 njensen Initial creation
*
* </pre>
*
@ -39,14 +40,21 @@ public interface INumpyable {
/**
* Gets an Object[] representation of the object to transform into numpy.
* Each index in the Object[] should be another array of the primitive type,
* e.g. {float[], float[]}
* e.g. {float[], float[]}. The result in python will then be a python
* list, e.g. [numpy.ndarray(dtype=float32), numpy.ndarray(dtype=float32)].
*
* @return
*/
public Object[] getNumPy();
public Object[] getNumpy();
/**
* Gets the x dimension of the arrays returned by getNumpy().
*/
public int getNumpyX();
/**
* Gets the y dimension of hte arrays returned by getNumpy().
*/
public int getNumpyY();
}

View file

@ -821,7 +821,7 @@ public final class Jep {
throws JepException;
// added by njensen
public void setNumeric(String name, float[] v, int nx, int ny) throws JepException {
public void setNumpy(String name, float[] v, int nx, int ny) throws JepException {
if(this.closed)
throw new JepException("Jep has been closed.");
isValidThread();
@ -832,7 +832,7 @@ public final class Jep {
private native void setNumeric(long tstate, String name, float[] v, int nx, int ny)
throws JepException;
// end of added by njensen
public void setNumeric(String name, int[] v, int nx, int ny) throws JepException {
public void setNumpy(String name, int[] v, int nx, int ny) throws JepException {
if(this.closed)
throw new JepException("Jep has been closed.");
isValidThread();
@ -843,7 +843,7 @@ public final class Jep {
private native void setNumeric(long tstate, String name, int[] v, int nx, int ny)
throws JepException;
public void setNumeric(String name, byte[] v, int nx, int ny) throws JepException {
public void setNumpy(String name, byte[] v, int nx, int ny) throws JepException {
if(this.closed)
throw new JepException("Jep has been closed.");
isValidThread();

View file

@ -86,17 +86,11 @@ static jmethodID objectGetClass = 0;
static jmethodID classGetMethods = 0;
static jmethodID classGetFields = 0;
// all following static variables added by njensen
static jmethodID xMethod = 0;
static jmethodID yMethod = 0;
static jmethodID getMethod = 0;
static jmethodID getNumpyMethod = 0;
// added by njensen
static jclass floatarrayclass = NULL;
static jclass bytearrayclass = NULL;
static jclass intarrayclass = NULL;
static jclass stringclass = NULL;
// added by njensen
static jmethodID classGetName = 0;
static PyObject* classnamePyJMethodsDict = NULL;
@ -739,35 +733,35 @@ static PyObject* pyjobject_getattr(PyJobject_Object *obj,
// added by njensen
static PyObject* pyjobject_numpy(PyJobject_Object *obj) {
int i=0;
/* updated by bkowal */
npy_intp *dims = NULL;
jfloat *dataFloat = NULL;
jbyte *dataByte = NULL;
jint *dataInt = NULL;
const char *message = NULL;
jobjectArray objarray = NULL;
PyObject *resultList = NULL;
jint xsize = 0;
jint ysize = 0;
jsize listSize =0;
int i=0;
/* updated by bkowal */
npy_intp *dims = NULL;
jobjectArray objarray = NULL;
PyObject *resultList = NULL;
jint xsize = 0;
jint ysize = 0;
jsize listSize =0;
JNIEnv *env = pyembed_get_env();
JNIEnv *env = pyembed_get_env();
// methods are forever but classes are fleeting
jclass numpyable = (*env)->FindClass(env, "jep/INumpyable");
if((*env)->IsInstanceOf(env, obj->object, numpyable))
{
xMethod = (*env)->GetMethodID(env, numpyable, "getNumpyX", "()I");
if(xMethod == NULL)
xMethod = (*env)->GetMethodID(env, numpyable, "getNumpyX", "()I");
xsize = (jint) (*env)->CallIntMethod(env, obj->object, xMethod);
yMethod = (*env)->GetMethodID(env, numpyable, "getNumpyY", "()I");
if(yMethod == NULL)
yMethod = (*env)->GetMethodID(env, numpyable, "getNumpyY", "()I");
ysize = (jint) (*env)->CallIntMethod(env, obj->object, yMethod);
dims = malloc(2 * sizeof(npy_intp));
dims[0] = ysize;
dims[1] = xsize;
getMethod = (*env)->GetMethodID(env, numpyable, "getNumPy", "()[Ljava/lang/Object;");
objarray = (jobjectArray) (*env)->CallObjectMethod(env, obj->object, getMethod);
if(getNumpyMethod == NULL)
getNumpyMethod = (*env)->GetMethodID(env, numpyable, "getNumpy", "()[Ljava/lang/Object;");
objarray = (jobjectArray) (*env)->CallObjectMethod(env, obj->object, getNumpyMethod);
if(process_java_exception(env) || !objarray)
{
Py_INCREF(Py_None);
@ -775,59 +769,19 @@ static PyObject* pyjobject_numpy(PyJobject_Object *obj) {
}
listSize = (*env)->GetArrayLength(env, objarray);
initNumpy();
resultList = PyList_New(listSize);
if(floatarrayclass == NULL)
floatarrayclass = (*env)->FindClass(env, "[F");
if(bytearrayclass == NULL)
bytearrayclass = (*env)->FindClass(env, "[B");
if(intarrayclass == NULL)
intarrayclass = (*env)->FindClass(env, "[I");
if(stringclass == NULL)
stringclass = (*env)->FindClass(env, "java/lang/String");
resultList = PyList_New(listSize);
for(i=0; i < listSize; i=i+1)
{
PyObject *pyjob;
PyObject *pyjob = NULL;
jobject jo = (*env)->GetObjectArrayElement(env, objarray, i);
if((*env)->IsInstanceOf(env, jo, floatarrayclass))
pyjob = javaToNumpyArray(env, jo, dims);
if(pyjob == NULL)
{
pyjob = PyArray_SimpleNew(2, dims, NPY_FLOAT32);
dataFloat = (*env)->GetFloatArrayElements(env, jo, 0);
memcpy(((PyArrayObject *)pyjob)->data,
dataFloat, ysize * xsize * sizeof(float));
(*env)->ReleaseFloatArrayElements(env, jo, dataFloat, 0);
}
else if((*env)->IsInstanceOf(env, jo, bytearrayclass))
{
pyjob = PyArray_SimpleNew(2, dims, NPY_BYTE);
dataByte = (*env)->GetByteArrayElements(env, jo, 0);
memcpy(((PyArrayObject *)pyjob)->data,
dataByte, ysize * xsize * 1);
(*env)->ReleaseByteArrayElements(env, jo, dataByte, 0);
}
else if((*env)->IsInstanceOf(env, jo, intarrayclass))
{
pyjob = PyArray_SimpleNew(2, dims, NPY_INT32);
dataInt = (*env)->GetIntArrayElements(env, jo, 0);
memcpy(((PyArrayObject *)pyjob)->data,
dataInt, ysize * xsize * sizeof(int));
(*env)->ReleaseIntArrayElements(env, jo, dataInt, 0);
}
else if((*env)->IsInstanceOf(env, jo, stringclass))
{
message = jstring2char(env, jo);
pyjob = PyString_FromString(message);
release_utf_char(env, jo, message);
}
else
{
Py_INCREF(Py_None);
pyjob = Py_None;
}
PyErr_Format(PyExc_TypeError, "Cannot transform INumpyable.getNumpy()[%i] java object to numpy array", i);
free(dims);
Py_DECREF(resultList);
return NULL;
}
PyList_SetItem(resultList, i, pyjob);
(*env)->DeleteLocalRef(env, jo);
}
@ -837,20 +791,11 @@ static PyObject* pyjobject_numpy(PyJobject_Object *obj) {
}
else
{
Py_INCREF(Py_None);
return Py_None;
PyErr_Format(PyExc_TypeError, "Object does not implement INumpyable and therefore cannot be transformed to numpy array");
return NULL;
}
}
// added by njensen
static void initNumpy(void)
{
if (!numpyInit)
{
import_array();
numpyInit = 1;
}
}
// set attribute v for object.
// uses obj->attr dictionary for storage.

View file

@ -69,7 +69,6 @@ int pyjobject_check(PyObject *obj);
//added by njensen
static PyObject* pyjobject_numpy(PyJobject_Object *obj);
static void initNumpy(void);
static int numpyInit = 0;
#endif // ndef pyjobject

View file

@ -95,6 +95,7 @@ jclass JBOOLEAN_ARRAY_TYPE = NULL;
jclass JDOUBLE_ARRAY_TYPE = NULL;
jclass JFLOAT_ARRAY_TYPE = NULL;
jclass JBYTE_ARRAY_TYPE = NULL;
jclass JSHORT_ARRAY_TYPE = NULL;
// cached methodids
jmethodID objectToString = 0;
@ -905,6 +906,15 @@ int cache_primitive_classes(JNIEnv *env) {
(*env)->DeleteLocalRef(env, clazz);
}
if(JSHORT_ARRAY_TYPE == NULL) {
clazz = (*env)->FindClass(env, "[S");
if((*env)->ExceptionOccurred(env))
return 0;
JSHORT_ARRAY_TYPE = (*env)->NewGlobalRef(env, clazz);
(*env)->DeleteLocalRef(env, clazz);
}
return 1;
}
@ -985,6 +995,11 @@ void unref_cache_primitive_classes(JNIEnv *env) {
(*env)->DeleteGlobalRef(env, JDOUBLE_ARRAY_TYPE);
JDOUBLE_ARRAY_TYPE = NULL;
}
if(JSHORT_ARRAY_TYPE != NULL) {
(*env)->DeleteGlobalRef(env, JSHORT_ARRAY_TYPE);
JSHORT_ARRAY_TYPE = NULL;
}
}
@ -1402,7 +1417,7 @@ jvalue convert_pynumpyarg_jvalue(JNIEnv *env,
arr = NULL;
if(param != Py_None && !pyjarray_check(param)) {
initUtil();
initNumpy();
if(PyArray_Check(param))
{
@ -1580,7 +1595,7 @@ jvalue convert_pyarg_jvalue(JNIEnv *env,
}
else {
//added by njensen
initUtil();
initNumpy();
if(PyArray_Check(param))
{
ret.l = numpyToJavaArray(env, param, NULL);
@ -1723,7 +1738,7 @@ jarray numpyToJavaArray(JNIEnv* env, PyObject *param, jclass desiredType)
PyArrayObject *pa = NULL;
int minDim = 0;
int maxDim = 0;
initUtil();
initNumpy();
sz = PyArray_Size(param);
if(desiredType == NULL)
@ -1732,6 +1747,8 @@ jarray numpyToJavaArray(JNIEnv* env, PyObject *param, jclass desiredType)
desiredType = JBOOLEAN_ARRAY_TYPE;
else if(((PyArrayObject *) param)->descr->type_num == NPY_BYTE)
desiredType = JBYTE_ARRAY_TYPE;
else if(((PyArrayObject *) param)->descr->type_num == NPY_INT16)
desiredType = JSHORT_ARRAY_TYPE;
else if(((PyArrayObject *) param)->descr->type_num == NPY_INT32)
desiredType = JINT_ARRAY_TYPE;
else if(((PyArrayObject *) param)->descr->type_num == NPY_INT64)
@ -1762,6 +1779,15 @@ jarray numpyToJavaArray(JNIEnv* env, PyObject *param, jclass desiredType)
pa = (PyArrayObject *) nvalue;
(*env)->SetByteArrayRegion(env, arr, 0, sz, (const jbyte *)pa->data);
}
else if((*env)->IsSameObject(env, desiredType, JSHORT_ARRAY_TYPE)
&& (((PyArrayObject *) param)->descr->type_num == NPY_INT16))
{
arr = (*env)->NewShortArray(env, sz);
nobj = PyArray_ContiguousFromObject(param, NPY_INT16, minDim, maxDim);
nvalue = (PyObject *)PyArray_Cast((PyArrayObject *)nobj, NPY_INT16);
pa = (PyArrayObject *) nvalue;
(*env)->SetShortArrayRegion(env, arr, 0, sz, (const jshort *)pa->data);
}
else if((*env)->IsSameObject(env, desiredType, JINT_ARRAY_TYPE)
&& (((PyArrayObject *) param)->descr->type_num == NPY_INT32))
{
@ -1808,6 +1834,75 @@ jarray numpyToJavaArray(JNIEnv* env, PyObject *param, jclass desiredType)
return arr;
}
// added by njensen
PyObject* javaToNumpyArray(JNIEnv* env, jobject jo, npy_intp *dims)
{
PyObject *pyjob = NULL;
int ysize, xsize;
ysize = dims[0];
xsize = dims[1];
initNumpy();
if((*env)->IsInstanceOf(env, jo, JBOOLEAN_ARRAY_TYPE))
{
jboolean *dataBool = NULL;
pyjob = PyArray_SimpleNew(2, dims, NPY_BOOL);
dataBool = (*env)->GetBooleanArrayElements(env, jo, 0);
memcpy(((PyArrayObject *)pyjob)->data, dataBool, ysize * xsize * 1);
(*env)->ReleaseBooleanArrayElements(env, jo, dataBool, 0);
}
else if((*env)->IsInstanceOf(env, jo, JBYTE_ARRAY_TYPE))
{
jbyte *dataByte = NULL;
pyjob = PyArray_SimpleNew(2, dims, NPY_BYTE);
dataByte = (*env)->GetByteArrayElements(env, jo, 0);
memcpy(((PyArrayObject *)pyjob)->data, dataByte, ysize * xsize * 1);
(*env)->ReleaseByteArrayElements(env, jo, dataByte, 0);
}
else if((*env)->IsInstanceOf(env, jo, JSHORT_ARRAY_TYPE))
{
jshort *dataShort = NULL;
pyjob = PyArray_SimpleNew(2, dims, NPY_INT16);
dataShort = (*env)->GetShortArrayElements(env, jo, 0);
memcpy(((PyArrayObject *)pyjob)->data, dataShort, ysize * xsize * 2);
(*env)->ReleaseShortArrayElements(env, jo, dataShort, 0);
}
else if((*env)->IsInstanceOf(env, jo, JINT_ARRAY_TYPE))
{
jint *dataInt = NULL;
pyjob = PyArray_SimpleNew(2, dims, NPY_INT32);
dataInt = (*env)->GetIntArrayElements(env, jo, 0);
memcpy(((PyArrayObject *)pyjob)->data, dataInt, ysize * xsize * 4);
(*env)->ReleaseIntArrayElements(env, jo, dataInt, 0);
}
else if((*env)->IsInstanceOf(env, jo, JLONG_ARRAY_TYPE))
{
jlong *dataLong = NULL;
pyjob = PyArray_SimpleNew(2, dims, NPY_INT64);
dataLong = (*env)->GetLongArrayElements(env, jo, 0);
memcpy(((PyArrayObject *)pyjob)->data, dataLong, ysize * xsize * 8);
(*env)->ReleaseLongArrayElements(env, jo, dataLong, 0);
}
else if((*env)->IsInstanceOf(env, jo, JFLOAT_ARRAY_TYPE))
{
jfloat *dataFloat = NULL;
pyjob = PyArray_SimpleNew(2, dims, NPY_FLOAT32);
dataFloat = (*env)->GetFloatArrayElements(env, jo, 0);
memcpy(((PyArrayObject *)pyjob)->data, dataFloat, ysize * xsize * 4);
(*env)->ReleaseFloatArrayElements(env, jo, dataFloat, 0);
}
else if((*env)->IsInstanceOf(env, jo, JDOUBLE_ARRAY_TYPE))
{
jdouble *dataDouble = NULL;
pyjob = PyArray_SimpleNew(2, dims, NPY_FLOAT64);
dataDouble = (*env)->GetDoubleArrayElements(env, jo, 0);
memcpy(((PyArrayObject *)pyjob)->data, dataDouble, ysize * xsize * 8);
(*env)->ReleaseDoubleArrayElements(env, jo, dataDouble, 0);
}
return pyjob;
}
// added by njensen, code from brockwoo
jarray pylistToJStringList(JNIEnv* env, PyObject* plist)
{
@ -1827,12 +1922,12 @@ jarray pylistToJStringList(JNIEnv* env, PyObject* plist)
}
// added by njensen
static void initUtil(void)
static void initNumpy(void)
{
if (!utilInit)
if (!numpyInited)
{
import_array();
utilInit = 1;
numpyInited = 1;
}
}

View file

@ -37,6 +37,9 @@
#endif
#include <Python.h>
// added by njensen
#include "numpy/arrayobject.h"
#ifndef _Included_util
#define _Included_util
@ -106,11 +109,12 @@ int process_py_exception(JNIEnv*, int);
// added by njensen
char *PyTraceback_AsString(PyObject*);
static void initUtil(void);
static int utilInit = 0;
static void initNumpy(void);
static int numpyInited = 0;
jstring javaStacktrace_tostring(JNIEnv*, jthrowable);
jarray numpyToJavaArray(JNIEnv*, PyObject*, jclass);
jarray pylistToJStringList(JNIEnv*, PyObject*);
PyObject* javaToNumpyArray(JNIEnv*, jobject, npy_intp*);
// convert java exception to pyerr.
// true (1) if an exception was processed.

View file

@ -0,0 +1 @@
war.name=purgeWeb

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.ui.nctextui.rsc.NctextuiResourceData

View file

@ -1,23 +1,4 @@
gov.noaa.nws.ncep.ui.nsharp.NsharpConfigStore
gov.noaa.nws.ncep.ui.nsharp.NsharpLineProperty
gov.noaa.nws.ncep.ui.nsharp.NsharpGraphProperty
gov.noaa.nws.ncep.ui.nsharp.NsharpDataPageProperty
gov.noaa.nws.ncep.ui.nsharp.display.NsharpSkewTPaneDisplay
gov.noaa.nws.ncep.ui.nsharp.display.NsharpInsetPaneDisplay
gov.noaa.nws.ncep.ui.nsharp.display.NsharpDataPaneDisplay
gov.noaa.nws.ncep.ui.nsharp.display.NsharpHodoPaneDisplay
gov.noaa.nws.ncep.ui.nsharp.display.NsharpTimeStnPaneDisplay
gov.noaa.nws.ncep.ui.nsharp.display.NsharpWitoPaneDisplay
gov.noaa.nws.ncep.ui.nsharp.display.NsharpSpcGraphsPaneDisplay
gov.noaa.nws.ncep.ui.nsharp.display.NsharpAbstractPaneDescriptor
gov.noaa.nws.ncep.ui.nsharp.display.NsharpHodoPaneDescriptor
gov.noaa.nws.ncep.ui.nsharp.display.NsharpSkewTPaneDescriptor
gov.noaa.nws.ncep.ui.nsharp.display.NsharpSpcGraphsPaneDescriptor
gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpDataPaneResourceData
gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpHodoPaneResourceData
gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpInsetPaneResourceData
gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpSkewTPaneResourceData
gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpSpcGraphsPaneResourceData
gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpTimeStnPaneResourceData
gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpWitoPaneResourceData
gov.noaa.nws.ncep.ui.nsharp.display.map.NsharpMapResourceData
gov.noaa.nws.ncep.ui.nsharp.NsharpDataPageProperty

View file

@ -1,6 +0,0 @@
gov.noaa.nws.ncep.viz.overlays.resources.LatLonOverlayResourceData
gov.noaa.nws.ncep.viz.overlays.resources.ScaleOverlayResourceData
gov.noaa.nws.ncep.viz.overlays.resources.DbOverlayResourceData
gov.noaa.nws.ncep.viz.overlays.resources.PgenStaticOverlayResourceData
gov.noaa.nws.ncep.viz.overlays.resources.PointOverlayResourceData
gov.noaa.nws.ncep.viz.overlays.resources.OverlayResourceGroupData

View file

@ -10,6 +10,7 @@ Require-Bundle: org.apache.batik;bundle-version="1.6.0",
org.eclipse.ui,
org.eclipse.core.runtime,
com.raytheon.viz.core,
com.raytheon.uf.viz.core,
com.raytheon.viz.ui,
javax.measure;bundle-version="1.0.0",
org.apache.commons.lang,

View file

@ -1,8 +1,3 @@
gov.noaa.nws.ncep.viz.resources.time_match.NCTimeMatcher
gov.noaa.nws.ncep.viz.resources.manager.NcMapRBD
gov.noaa.nws.ncep.viz.resources.manager.NTransRBD
gov.noaa.nws.ncep.viz.resources.manager.SolarRBD
gov.noaa.nws.ncep.viz.resources.manager.ResourceDefinition
gov.noaa.nws.ncep.viz.resources.manager.ResourceDefinitionFilters
gov.noaa.nws.ncep.viz.resources.manager.AttrSetGroup
gov.noaa.nws.ncep.viz.resources.colorBar.ColorBarResourceData
gov.noaa.nws.ncep.viz.resources.manager.AttrSetGroup

View file

@ -1,7 +1,5 @@
package gov.noaa.nws.ncep.viz.resources.manager;
import gov.noaa.nws.ncep.viz.common.area.PredefinedArea;
import gov.noaa.nws.ncep.viz.common.area.PredefinedAreaFactory;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsDescriptor;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsPaneManager;
import gov.noaa.nws.ncep.viz.common.display.INatlCntrsRenderableDisplay;
@ -21,6 +19,7 @@ import gov.noaa.nws.ncep.viz.ui.display.NcPaneLayout;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import javax.xml.bind.JAXBException;
@ -32,14 +31,16 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.serialization.jaxb.JAXBClassLocator;
import com.raytheon.uf.common.serialization.jaxb.JaxbDummyObject;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.VariableSubstitutionUtil;
import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.reflect.SubClassLocator;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.viz.ui.editor.AbstractEditor;
@ -62,7 +63,8 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
* 11/25/12 #630 Greg Hull getDefaultRBD()
* 02/22/10 #972 Greg Hull created from old RbdBundle
* 05/14/13 #862 Greg Hull implement INatlCntrsPaneManager
*
* 10/29/13 #2491 bsteffen Use custom JAXB context instead of SerializationUtil.
*
* </pre>
*
* @author ghull
@ -71,7 +73,9 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public abstract class AbstractRBD<T extends AbstractRenderableDisplay>
implements INatlCntrsPaneManager, ISerializableObject, Comparable<AbstractRBD<?>> {
implements INatlCntrsPaneManager, Comparable<AbstractRBD<?>> {
private static JAXBManager jaxb;
@XmlElement
protected NcDisplayType displayType = NcDisplayType.NMAP_DISPLAY;
@ -259,7 +263,7 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay>
File tempRbdFile = File.createTempFile("tempRBD-", ".xml");
SerializationUtil.jaxbMarshalToXmlFile( rbdBndl,
getJaxbManager().marshalToXmlFile(rbdBndl,
tempRbdFile.getAbsolutePath() );
AbstractRBD<?> clonedRbd = getRbd( tempRbdFile );
@ -289,6 +293,8 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay>
} catch (SerializationException e) {
throw new VizException( e );
} catch (JAXBException e) {
throw new VizException(e);
} catch (VizException e) {
throw new VizException("Error loading rbd "+rbdBndl.rbdName+" :"+e.getMessage() );
} catch (IOException e) { // from createTempFile
@ -396,7 +402,7 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay>
public String toXML() throws VizException {
try {
return SerializationUtil.marshalToXml(this);
return getJaxbManager().marshalToXml(this);
} catch (JAXBException e) {
throw new VizException(e);
}
@ -588,7 +594,7 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay>
String substStr = VariableSubstitutionUtil.processVariables(
bundleStr, variables);
Object xmlObj = SerializationUtil.unmarshalFromXml(substStr);
Object xmlObj = getJaxbManager().unmarshalFromXml(substStr);
if (!(xmlObj instanceof AbstractRBD)) {
System.out.println("Unmarshalled rbd file is not a valid RBD?");
return null;
@ -660,6 +666,36 @@ public abstract class AbstractRBD<T extends AbstractRenderableDisplay>
}
}
/**
* Builds and returns a JAXB manager which has the ability to
* marshal/unmarshall all AbstractRBD types.
*
* @return a JAXBManager to use for marshalling/unmarshalling RBDs.
* @throws JAXBException
* if there are illegal JAXB annotations.
*/
public static synchronized JAXBManager getJaxbManager()
throws JAXBException {
if (jaxb == null) {
SubClassLocator locator = new SubClassLocator();
Collection<Class<?>> classes = JAXBClassLocator.getJAXBClasses(
locator, AbstractRBD.class);
locator.save();
Class<?>[] jaxbClasses = new Class<?>[classes.size() + 1];
classes.toArray(jaxbClasses);
/*
* Add JaxbDummyObject at the begining so properties are loaded
* correctly
*/
jaxbClasses[jaxbClasses.length - 1] = jaxbClasses[0];
jaxbClasses[0] = JaxbDummyObject.class;
jaxb = new JAXBManager(jaxbClasses);
}
return jaxb;
}
public NCTimeMatcher getTimeMatcher() {
if (timeMatcher == null) {
timeMatcher = (NCTimeMatcher) displays[0].getDescriptor()

View file

@ -6,26 +6,20 @@ import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsRequestableResourceData;
import gov.noaa.nws.ncep.viz.resources.AbstractNatlCntrsResourceData;
import gov.noaa.nws.ncep.viz.resources.INatlCntrsResourceData;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.viz.core.VariableSubstitutionUtil;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.procedures.Bundle;
import com.raytheon.uf.viz.core.rsc.ResourceGroup;
import com.raytheon.uf.viz.core.rsc.ResourceList;
/**
* Class used by the content providers for Resources and Overlays. This stores the
* instantiated Resource Bundle Templates first with the default attributes and
* additionally stores later changes to the attributes.
* Class used by the content providers for Resources and Overlays. This stores
* the instantiated Resource Bundle Templates first with the default attributes
* and additionally stores later changes to the attributes.
*
* <pre>
* SOFTWARE HISTORY
@ -43,10 +37,11 @@ import com.raytheon.uf.viz.core.rsc.ResourceList;
* 08/23/10 #273 Greg Hull isVisible()
* 11/17/11 #518 Greg Hull set dfltFrameTimes (GDATTIM)
* 02/10/13 #972 Greg Hull getSupportedDisplayTypes
*
* 10/29/13 #2491 bsteffen Use AbstratRBD JAXBManager instead of SerializationUtil.
*
* </pre>
*
* @author
* @author
* @version 1
*/
@ -187,7 +182,7 @@ public class ResourceFactory {
ResourceList bndl_rscs = null;
Object rg = SerializationUtil.unmarshalFromXml(substStr);
Object rg = AbstractRBD.getJaxbManager().unmarshalFromXml(substStr);
if( !(rg instanceof ResourceGroup) ) {
throw new VizException("Resource Bundle template has unexpected class. (not ResourceGroup)");

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.airmet.rsc.AirmetResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.atcf.rsc.AtcfResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.convsigmet.rsc.ConvSigmetResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.ffg.rsc.FFGResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.hrcn.rsc.HrcnResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.idft.rsc.IDFTResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.intlsig.rsc.IntlSigmetResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.lightning.rsc.LightningResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.mosaic.rsc.MosaicResourceData

View file

@ -1,3 +1 @@
gov.noaa.nws.ncep.viz.rsc.ncgrid.rsc.NcgridResourceData
gov.noaa.nws.ncep.viz.rsc.ncgrid.rsc.NcEnsembleResourceData
gov.noaa.nws.ncep.edex.common.dataRecords.NcFloatDataRecord

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.ncradar.rsc.RadarResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.ncscat.rsc.NcscatResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.nonconvsigmet.rsc.NonConvSigmetResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.pgen.rsc.PgenDisplayResourceData

View file

@ -1 +0,0 @@
gov.noaa.nws.ncep.viz.rsc.satellite.rsc.SatelliteResourceData

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