diff --git a/cave/build/static/common/cave/etc/aviation/python/CCFPMonitor.py b/cave/build/static/common/cave/etc/aviation/python/CCFPMonitor.py index 84231494ed..dcdc42b0cb 100644 --- a/cave/build/static/common/cave/etc/aviation/python/CCFPMonitor.py +++ b/cave/build/static/common/cave/etc/aviation/python/CCFPMonitor.py @@ -60,9 +60,6 @@ # Status: TEST # Title: AvnFPS: tpo indicator not monitoring properly # -# Date Ticket# Engineer Description -# ------------- ---------- ----------- -------------------------- -# Feb. 21, 2013 15834 zhao Modified for CCFP 8hr data # import logging, time import Avn, AvnLib, Globals, MonitorP @@ -71,10 +68,10 @@ import CCFPData _Logger = logging.getLogger(__name__) _Code = { \ - 'tops': {1: '400+ ', 2: '350-390', 3: '300-340', 4: '250-290'}, \ - 'gwth': {1: '+ ', 2: 'NC', 3: '- '}, \ + 'tops': {1: '370+ ', 2: '310-370', 3: '250-310'}, \ + 'gwth': {1: '++', 2: '+ ', 3: 'NC', 4: '- '}, \ 'conf': {1: 'HIGH', 3: 'LOW'}, \ - 'cvrg': {1: '75-100%', 2: ' 40-74%', 3: ' 25-39%'}, \ + 'cvrg': {1: '75-100%', 2: ' 50-74%', 3: ' 25-49%'}, \ } ############################################################################## @@ -85,7 +82,7 @@ class Monitor(MonitorP.Monitor): def __makeData(self, data): # 6 hour forecast tstart = (time.time()//3600.0 + 1) * 3600.0 - tend = tstart + 9*3600.0 - 10.0 + tend = tstart + 7*3600.0 - 10.0 seq = [{'time': t} for t in Avn.frange(tstart, tend, 3600.0)] fcst, text = {}, [] try: diff --git a/cave/build/static/common/cave/etc/menus/upperair/baseAviation.xml b/cave/build/static/common/cave/etc/menus/upperair/baseAviation.xml index a6ac6b05ab..b99b8e6866 100644 --- a/cave/build/static/common/cave/etc/menus/upperair/baseAviation.xml +++ b/cave/build/static/common/cave/etc/menus/upperair/baseAviation.xml @@ -25,9 +25,7 @@ menuText="Convective SIGMET" id="ConvSigmet"> /convsigmet/% - - /bufrncwf/% - + diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/data/IColorMapDataRetrievalCallback.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/data/IColorMapDataRetrievalCallback.java index 627e10044c..2442d4a9cb 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/data/IColorMapDataRetrievalCallback.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/data/IColorMapDataRetrievalCallback.java @@ -36,6 +36,8 @@ import com.raytheon.uf.viz.core.exception.VizException; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Nov 17, 2011 mschenke Initial creation + * Mar 21, 2013 1806 bsteffen Add ColorMapData constructor that + * creates buffer from the dataType. * * * @@ -45,6 +47,40 @@ import com.raytheon.uf.viz.core.exception.VizException; public interface IColorMapDataRetrievalCallback { + /** + * @param dataType + * @param dataBounds + */ + public ColorMapData(ColorMapDataType dataType, int[] dimensions) { + this.buffer = getBuffer(dataType, dimensions); + this.dimensions = dimensions; + this.dataType = dataType; + } + + } + + private static Buffer getBuffer(ColorMapDataType dataType, + int[] dimensions) { + int size = 1; + for (int i : dimensions) { + size *= i; + } + switch (dataType) { + case BYTE: + case SIGNED_BYTE: + return ByteBuffer.allocate(size); + case SHORT: + case UNSIGNED_SHORT: + return ShortBuffer.allocate(size); + case FLOAT: + return FloatBuffer.allocate(size); + case INT: + return IntBuffer.allocate(size); + default: + throw new RuntimeException("Could not find Buffer for " + + dataType); + } + /** * Get the ColorMapData. IMPORTANT NOTE: This method should retrieve the * ColorMapData from wherever it lives. ColorMapData objects should not be diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java index 7f6fe5963f..8e44c4333d 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java @@ -116,7 +116,9 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Feb 10, 2013 1584 mpduff Add performance logging. * Feb 28, 2013 1729 dhladky Adjusted the way in which the dialog load thread rejoins the main GUI thread. * Mar 01, 2013 13228 gzhang Adding field rowName for VGB in County + * Mar 24, 2013 1818 mpduff Fixed Attributes dialog on multiple opens, needed an isDisposed check. * + * * @author lvenable * @version 1.0 */ @@ -255,8 +257,9 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements private FFMPTableDataLoader dataRetrieveThread = null; private boolean groupLabelFlag = true; - - private String rowName="";// DR 13228 + + private String rowName = "";// DR 13228 + /** * Statistics load event. */ @@ -1084,7 +1087,8 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements // Loop over enum from config singleton to create menu items for (ThreshColNames colName : ThreshColNames.values()) { - if (ffmpConfig.isColorCell(colName) && (colName != ThreshColNames.GUID)) {// DR 14907 + if (ffmpConfig.isColorCell(colName) + && (colName != ThreshColNames.GUID)) {// DR 14907 // only add a menu item if colorCell is true MenuItem mi = new MenuItem(popupMenu, SWT.NONE); mi.setText(colName.name()); @@ -1304,7 +1308,7 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements } private void displayAttributesDlg() { - if (attributeDlg == null) { + if (attributeDlg == null || attributeDlg.isDisposed()) { attrData = ffmpTable.getVisibleColumns(); attributeDlg = new AttributesDlg(shell, resource, attrData, this); } @@ -1770,7 +1774,7 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements || allOnlySmallBasinsMI.getSelection()) { groupLbl.setText(name); } - rowName=name;// DR 13228 + rowName = name;// DR 13228 shell.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_WAIT)); fireScreenRecenterEvent(pfaf, 1); } @@ -2089,7 +2093,6 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements public void updateLoadingLabel(FFMPLoaderStatus status) { this.loadStatus = status; - if (dataLoadComp == null) { return; } @@ -2192,7 +2195,7 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements if (!this.isDisposed()) { - VizApp.runAsync(new Runnable() { + VizApp.runAsync(new Runnable() { @Override public void run() { processUpdate(fupdateData); @@ -2243,9 +2246,9 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements groupLbl.setText(""); } } - + // DR 13228 - public String getRowName(){ - return this.rowName; + public String getRowName() { + return this.rowName; } } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TrendGraphDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TrendGraphDlg.java index 52757b080c..e7b378f013 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TrendGraphDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TrendGraphDlg.java @@ -35,10 +35,25 @@ import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; import com.raytheon.uf.viz.monitor.scan.TrendGraphData; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; -public class TrendGraphDlg extends CaveSWTDialog //implements ICommonDialogAction -{ +/** + * Scan/DMD Trend Graph Dialog. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 21, 2013   1812        mpduff   Redraw now updates with new data.
+ * 
+ * 
+ * + * @author lvenable + * @version 1.0 + */ +public class TrendGraphDlg extends CaveSWTDialog { - private ScanTables scanTable; + private final ScanTables scanTable; private Combo identCbo; @@ -50,24 +65,34 @@ public class TrendGraphDlg extends CaveSWTDialog //implements ICommonDialogActio private TrendGraphCanvas trendGraphCanvas; - private ITrendGraphUpdate updateCallback; + private final ITrendGraphUpdate updateCallback; - private IRequestTrendGraphData requestDataCallback; + private final IRequestTrendGraphData requestDataCallback; -// private LinkedHashMap dataMap; - private TrendGraphData trendGraphData; - private String[] identArray; + private final String[] identArray; - private Integer vcp; + private final Integer vcp; + /** + * Constructor. + * + * @param parentShell + * @param scanTable + * @param ident + * @param attrName + * @param updateCallback + * @param requestDataCallback + * @param identArray + * @param vcp + */ public TrendGraphDlg(Shell parentShell, ScanTables scanTable, String ident, String attrName, ITrendGraphUpdate updateCallback, IRequestTrendGraphData requestDataCallback, String[] identArray, - Integer vcp) - { - super(parentShell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK | CAVE.INDEPENDENT_SHELL); + Integer vcp) { + super(parentShell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK + | CAVE.INDEPENDENT_SHELL); setText(scanTable.name() + " Trend Graph"); this.scanTable = scanTable; @@ -76,7 +101,7 @@ public class TrendGraphDlg extends CaveSWTDialog //implements ICommonDialogActio this.updateCallback = updateCallback; this.requestDataCallback = requestDataCallback; this.identArray = identArray; - this.vcp=vcp; + this.vcp = vcp; } @Override @@ -92,7 +117,7 @@ public class TrendGraphDlg extends CaveSWTDialog //implements ICommonDialogActio protected void initializeComponents(Shell shell) { trendGraphData = requestDataCallback.requestTrendGraphData(scanTable, attrName, ident); - + createTopControls(); createGraphCanvas(); } @@ -135,8 +160,8 @@ public class TrendGraphDlg extends CaveSWTDialog //implements ICommonDialogActio private void createGraphCanvas() { trendGraphCanvas = new TrendGraphCanvas(shell, trendGraphData, - requestDataCallback.getCurrentDate(), scanTable, - attrName,vcp,requestDataCallback,ident); + requestDataCallback.getCurrentDate(), scanTable, attrName, vcp, + requestDataCallback, ident); } private void populateIdentCombo() { @@ -165,8 +190,8 @@ public class TrendGraphDlg extends CaveSWTDialog //implements ICommonDialogActio trendGraphData = requestDataCallback.requestTrendGraphData(scanTable, attrName, ident); - trendGraphCanvas.updateAttribute(attrName, trendGraphData, requestDataCallback - .getCurrentDate()); + trendGraphCanvas.updateAttribute(attrName, trendGraphData, + requestDataCallback.getCurrentDate()); trendGraphCanvas.setIndent(ident); } @@ -177,31 +202,33 @@ public class TrendGraphDlg extends CaveSWTDialog //implements ICommonDialogActio trendGraphData = requestDataCallback.requestTrendGraphData(scanTable, attrName, ident); - trendGraphCanvas.updateAttribute(attrName, trendGraphData, requestDataCallback - .getCurrentDate()); + trendGraphCanvas.updateAttribute(attrName, trendGraphData, + requestDataCallback.getCurrentDate()); } - + /** - * Update the trend graph data so the latest data can be displayed. + * Update the trend graph data so the latest data can be displayed. + * * @return true if item is to be disposed */ - public boolean updateTrendGraph() - { + public boolean updateTrendGraph() { trendGraphData = requestDataCallback.requestTrendGraphData(scanTable, attrName, ident); - trendGraphCanvas.updateAttribute(attrName, trendGraphData, requestDataCallback - .getCurrentDate()); - + trendGraphCanvas.updateAttribute(attrName, trendGraphData, + requestDataCallback.getCurrentDate()); + if (requestDataCallback.cellValid(this.ident) == false) { return true; } - + return false; } - - public void redrawTrendGraph() - { - trendGraphCanvas.redrawCanvas(); + + /** + * Redraw the graphs with updated data. + */ + public void redrawTrendGraph() { + updateTrendGraph(); } public void displayDialog() { @@ -211,24 +238,12 @@ public class TrendGraphDlg extends CaveSWTDialog //implements ICommonDialogActio public boolean dialogIsDisposed() { return shell.isDisposed(); } - + /** * Overriding the dispose method to notify that the trend graph is closing. */ @Override - protected void disposed() - { + protected void disposed() { this.updateCallback.trendGraphClosing(this); } - -// @Override -// public void closeDialog() { -// this.updateCallback.trendGraphClosing(this); -// shell.dispose(); -// } -// -// @Override -// public boolean isDisposed() { -// return shell.isDisposed(); -// } } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TrendSetsGraphDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TrendSetsGraphDlg.java index 804cfa6781..756a727a95 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TrendSetsGraphDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/TrendSetsGraphDlg.java @@ -40,11 +40,25 @@ import com.raytheon.uf.common.monitor.scan.config.TrendSetConfigMgr; import com.raytheon.uf.viz.monitor.scan.TrendGraphData; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; -public class TrendSetsGraphDlg extends CaveSWTDialog // implements - // ICommonDialogAction -{ +/** + * Scan/DMD Trend Sets Graph Dialog. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 21, 2013   1812        mpduff   Redraw now updates with new data.
+ * 
+ * 
+ * + * @author lvenable + * @version 1.0 + */ +public class TrendSetsGraphDlg extends CaveSWTDialog { - private ScanTables scanTable; + private final ScanTables scanTable; private Combo identCbo; @@ -56,15 +70,15 @@ public class TrendSetsGraphDlg extends CaveSWTDialog // implements private TrendSetConfigMgr trendCfgMgr; - private ITrendSetsGraphUpdate updateCallback; + private final ITrendSetsGraphUpdate updateCallback; - private IRequestTrendGraphData requestDataCallback; + private final IRequestTrendGraphData requestDataCallback; // private LinkedHashMap dataMap; private LinkedHashMap trendSetData; - private String[] identArray; + private final String[] identArray; private String[] attrArray; @@ -72,14 +86,27 @@ public class TrendSetsGraphDlg extends CaveSWTDialog // implements private HashMap canvasMap; - private Integer vcp; + private final Integer vcp; + /** + * Constructor. + * + * @param parentShell + * @param scanTable + * @param ident + * @param trendSetName + * @param updateCallback + * @param requestDataCallback + * @param identArray + * @param vcp + */ public TrendSetsGraphDlg(Shell parentShell, ScanTables scanTable, String ident, String trendSetName, ITrendSetsGraphUpdate updateCallback, IRequestTrendGraphData requestDataCallback, String[] identArray, Integer vcp) { - super(parentShell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK | CAVE.INDEPENDENT_SHELL); + super(parentShell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK + | CAVE.INDEPENDENT_SHELL); setText(scanTable.name() + " Trend Graph"); this.scanTable = scanTable; @@ -153,7 +180,6 @@ public class TrendSetsGraphDlg extends CaveSWTDialog // implements @Override public void widgetSelected(SelectionEvent e) { shell.dispose(); - // closeDialog(); } }); } @@ -223,11 +249,10 @@ public class TrendSetsGraphDlg extends CaveSWTDialog // implements trendSetData.clear(); // Loop through all of the attributes and call update and store the data - // map for - // each attribute + // map for each attribute for (String attr : attrArray) { - TrendGraphData tgd = requestDataCallback - .requestTrendGraphData(scanTable, attr, ident); + TrendGraphData tgd = requestDataCallback.requestTrendGraphData( + scanTable, attr, ident); trendSetData.put(attr, tgd); // Call the update call back so the table can manage this dialog. @@ -252,8 +277,8 @@ public class TrendSetsGraphDlg extends CaveSWTDialog // implements for (String attr : attrArray) { System.out.println("Change trend set - attr = " + attr); - TrendGraphData tgd = requestDataCallback - .requestTrendGraphData(scanTable, attr, ident); + TrendGraphData tgd = requestDataCallback.requestTrendGraphData( + scanTable, attr, ident); trendSetData.put(attr, tgd); } @@ -272,36 +297,35 @@ public class TrendSetsGraphDlg extends CaveSWTDialog // implements * @return true if item is to be disposed */ public boolean updateTrendSetsGraph() { - trendSetData.clear(); - // Loop through all of the attributes and call update and store the data - // map for - // each attribute - for (String attr : attrArray) { - TrendGraphData tgd = requestDataCallback - .requestTrendGraphData(scanTable, attr, ident); - trendSetData.put(attr, tgd); - - // Call the update call back so the table can manage this dialog. - this.updateCallback.trendSetGraphChanged(ident, trendSetName, this); - - // Update the canvas with the new data - canvasMap.get(attr).updateAttribute(attr, tgd, - requestDataCallback.getCurrentDate()); - } - - if (requestDataCallback.cellValid(this.ident) == false) { - return true; - } - - return false; + trendSetData.clear(); + // Loop through all of the attributes and call update and store the data + // map for + // each attribute + for (String attr : attrArray) { + TrendGraphData tgd = requestDataCallback.requestTrendGraphData( + scanTable, attr, ident); + trendSetData.put(attr, tgd); + + // Call the update call back so the table can manage this dialog. + this.updateCallback.trendSetGraphChanged(ident, trendSetName, this); + + // Update the canvas with the new data + canvasMap.get(attr).updateAttribute(attr, tgd, + requestDataCallback.getCurrentDate()); + } + + if (requestDataCallback.cellValid(this.ident) == false) { + return true; + } + + return false; } + /** + * Redraw the graphs with updated data. + */ public void redrawTrendGraph() { - for (String key : canvasMap.keySet()) { - if (canvasMap.get(key) != null) { - canvasMap.get(key).redrawCanvas(); - } - } + updateTrendSetsGraph(); } public void displayDialog() { @@ -319,15 +343,4 @@ public class TrendSetsGraphDlg extends CaveSWTDialog // implements protected void disposed() { this.updateCallback.trendSetGraphClosing(this); } - - // @Override - // public void closeDialog() { - // this.updateCallback.trendSetGraphClosing(this); - // shell.dispose(); - // } - // - // @Override - // public boolean isDisposed() { - // return shell.isDisposed(); - // } } diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/dataformat/GLColorMapDataFormatFactory.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/dataformat/GLColorMapDataFormatFactory.java index 730bbbbfdc..95338f75b5 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/dataformat/GLColorMapDataFormatFactory.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/dataformat/GLColorMapDataFormatFactory.java @@ -20,6 +20,7 @@ package com.raytheon.viz.core.gl.dataformat; import com.raytheon.uf.common.colormap.image.ColorMapData; +import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapDataType; /** * Factory class for getting GLColorMapDataFormat objects given the ColorMapData @@ -32,6 +33,8 @@ import com.raytheon.uf.common.colormap.image.ColorMapData; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Nov 21, 2011 mschenke Initial creation + * Mar 21, 2013 1806 bsteffen Update GL mosaicing to use dynamic data + * format for offscreen textures. * * * @@ -43,8 +46,13 @@ public class GLColorMapDataFormatFactory { public static AbstractGLColorMapDataFormat getGLColorMapDataFormat( ColorMapData colorMapData) { + return getGLColorMapDataFormat(colorMapData.getDataType()); + } + + public static AbstractGLColorMapDataFormat getGLColorMapDataFormat( + ColorMapDataType colorMapDataType) { AbstractGLColorMapDataFormat dataFormat = null; - switch (colorMapData.getDataType()) { + switch (colorMapDataType) { case BYTE: { dataFormat = new GLByteDataFormat(); break; diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/GLOffscreenRenderingExtension.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/GLOffscreenRenderingExtension.java index 8054bc862d..fcbf47f0af 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/GLOffscreenRenderingExtension.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/GLOffscreenRenderingExtension.java @@ -33,6 +33,7 @@ import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IView; import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback; +import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapDataType; import com.raytheon.uf.viz.core.data.IRenderedImageCallback; import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension; @@ -41,6 +42,7 @@ import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.viz.core.gl.IGLTarget; import com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat; import com.raytheon.viz.core.gl.dataformat.GLByteDataFormat; +import com.raytheon.viz.core.gl.dataformat.GLColorMapDataFormatFactory; import com.raytheon.viz.core.gl.dataformat.IGLColorMapDataFormatProvider; import com.raytheon.viz.core.gl.images.AbstractGLImage; import com.raytheon.viz.core.gl.images.GLColormappedImage; @@ -61,6 +63,8 @@ import com.raytheon.viz.core.gl.internal.ext.GLColormappedImageExtension; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 10, 2012 bsteffen Initial creation + * Mar 21, 2013 1806 bsteffen Update GL mosaicing to use dynamic data + * format for offscreen textures. * * * @@ -175,51 +179,37 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension } public GLColormappedImage constructOffscreenImage( - Class dataType, int[] dimensions) - throws VizException { + ColorMapDataType dataType, int[] dimensions) throws VizException { return constructOffscreenImage(dataType, dimensions, null); } public GLColormappedImage constructOffscreenImage( - Class dataType, final int[] dimensions, + final ColorMapDataType dataType, final int[] dimensions, ColorMapParameters parameters) throws VizException { - int width = dimensions[0]; - int height = dimensions[1]; - // Need to add support for multiple buffer types - Buffer imageBuffer = null; - if (dataType.isAssignableFrom(ByteBuffer.class)) { - int pixels = 3; - if (supportsLuminance) { - pixels = 1; - } - byte[] buf = new byte[width * height * pixels]; - imageBuffer = ByteBuffer.wrap(buf); - } + GLColormappedImageExtension cmapExt = target + .getExtension(GLColormappedImageExtension.class); + if (!supportsLuminance) { + return cmapExt.initializeRaster(new NoLuminanceDataCallback( + dimensions, dataType), parameters); + } else { + GLColormappedImage image = cmapExt.initializeRaster( + new IColorMapDataRetrievalCallback() { - if (imageBuffer != null) { - GLColormappedImage image = null; - final Buffer buffer = imageBuffer; - GLColormappedImageExtension cmapExt = target - .getExtension(GLColormappedImageExtension.class); - if (supportsLuminance) { - image = cmapExt.initializeRaster( - new IColorMapDataRetrievalCallback() { - - @Override - public ColorMapData getColorMapData() - throws VizException { - return new ColorMapData(buffer, dimensions); - } - }, parameters); - } else { - image = cmapExt.initializeRaster(new GLOffscreenDataCallback( - buffer, dimensions), parameters); - } + @Override + public ColorMapData getColorMapData() + throws VizException { + return new ColorMapData(dataType, dimensions); + } + }, parameters); if (!checkedLuminance) { checkedLuminance = true; try { renderOffscreen(image); } catch (VizException e) { + // Log this so it is easy to see in the console logs. + new VizException( + "Graphics card does not support luminance textures.", + e).printStackTrace(System.out); // assume we don't support luminance supportsLuminance = false; // Reconstruct image @@ -230,84 +220,76 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension } } return image; - } else { - return null; } } - private static final class GLOffscreenDataCallback implements - IColorMapDataRetrievalCallback, IGLColorMapDataFormatProvider { + private static final class NoLuminanceDataFormat extends GLByteDataFormat { - private Buffer dataBuffer; + // Used to get the original min/max which makes signed bytes work and + // theoretically will give better looking results for other integer data + // types. + private final ColorMapDataType originalType; + + private NoLuminanceDataFormat(ColorMapDataType originalType) { + this.originalType = originalType; + } + + @Override + public int getTextureInternalFormat() { + return GL.GL_RGB8; + } + + @Override + public int getTextureFormat() { + return GL.GL_RGB; + } + + @Override + public int getValuesPerPixel() { + return 3; + } + + @Override + public double getDataFormatMin() { + return getOriginalGLColorMapDataFormat().getDataFormatMin(); + } + + @Override + public double getDataFormatMax() { + return getOriginalGLColorMapDataFormat().getDataFormatMax(); + } + + private AbstractGLColorMapDataFormat getOriginalGLColorMapDataFormat() { + return GLColorMapDataFormatFactory + .getGLColorMapDataFormat(originalType); + } + + } + + private static final class NoLuminanceDataCallback implements + IColorMapDataRetrievalCallback, IGLColorMapDataFormatProvider { private int[] dimensions; - private GLOffscreenDataCallback(Buffer dataBuffer, int[] dimensions) { - this.dataBuffer = dataBuffer; + private final ColorMapDataType originalType; + + private NoLuminanceDataCallback(int[] dimensions, + ColorMapDataType type) { this.dimensions = dimensions; + this.originalType = type; } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.core.gl.dataprep.IGLColorMapDataRetrievalCallback - * #getGLColorMapData - * (com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback - * .ColorMapData) - */ @Override public AbstractGLColorMapDataFormat getGLColorMapDataFormat( ColorMapData colorMapData) { - return new GLByteDataFormat() { - - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.core.gl.dataprep.GLByteDataFormat# - * getTextureInternalFormat() - */ - @Override - public int getTextureInternalFormat() { - return GL.GL_RGB8; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.core.gl.dataprep.AbstractGLColorMapDataFormat - * #getTextureFormat() - */ - @Override - public int getTextureFormat() { - return GL.GL_RGB; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.core.gl.dataprep.AbstractGLColorMapDataFormat - * #getPointsPerPixel() - */ - @Override - public int getValuesPerPixel() { - return 3; - } - - }; + return new NoLuminanceDataFormat(originalType); } - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback# - * getColorMapData() - */ @Override public ColorMapData getColorMapData() throws VizException { - return new ColorMapData(dataBuffer, dimensions); + Buffer buffer = ByteBuffer.allocate(dimensions[0] * dimensions[1] + * 3); + return new ColorMapData(buffer, dimensions, originalType); } } diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLCMTextureData.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLCMTextureData.java index 37a9ff8ff3..9d568a2b9e 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLCMTextureData.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLCMTextureData.java @@ -28,6 +28,7 @@ import javax.media.opengl.glu.GLU; import com.raytheon.uf.common.colormap.image.ColorMapData; import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback; +import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapDataType; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.viz.core.gl.GLContextBridge; import com.raytheon.viz.core.gl.dataformat.GLColorMapData; @@ -49,6 +50,8 @@ import com.raytheon.viz.core.gl.objects.GLTextureObject; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Aug 2, 2011 bsteffen Initial creation + * Mar 21, 2013 1806 bsteffen Update GL mosaicing to use dynamic data + * format for offscreen textures. * * * @@ -271,4 +274,8 @@ public class GLCMTextureData implements IImageCacheable { return 0; } + public ColorMapDataType getColorMapDataType() { + return data.getDataType(); + } + } diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLColormappedImage.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLColormappedImage.java index 970c9191dc..0dcc8d9976 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLColormappedImage.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/images/GLColormappedImage.java @@ -23,6 +23,7 @@ import javax.media.opengl.GL; import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback; +import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapDataType; import com.raytheon.uf.viz.core.drawables.IColormappedImage; import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension; import com.raytheon.uf.viz.core.exception.VizException; @@ -39,6 +40,8 @@ import com.sun.opengl.util.texture.TextureCoords; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 27, 2009 mschenke Initial creation + * Mar 21, 2013 1806 bsteffen Update GL mosaicing to use dynamic data + * format for offscreen textures. * * * @@ -109,6 +112,10 @@ public class GLColormappedImage extends AbstractGLImage implements return data.getTextureType(); } + public ColorMapDataType getColorMapDataType() { + return data.getColorMapDataType(); + } + /** * Return the texture's format * diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImage.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImage.java index 9651a9020b..45a3a0dd84 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImage.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImage.java @@ -38,6 +38,8 @@ import com.raytheon.viz.core.gl.images.GLDelegateImage; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 16, 2011 mschenke Initial creation + * Mar 21, 2013 1806 bsteffen Update GL mosaicing to use dynamic data + * format for offscreen textures. * * * @@ -165,4 +167,9 @@ public class GLMosaicImage extends GLDelegateImage return image.getValue(x, y); } + public void setWrappedImage(GLColormappedImage wrappedImage) { + this.image.dispose(); + this.image = wrappedImage; + } + } diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImageExtension.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImageExtension.java index c5db747010..697365f8b3 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImageExtension.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/ext/mosaic/GLMosaicImageExtension.java @@ -19,15 +19,15 @@ **/ package com.raytheon.viz.core.gl.internal.ext.mosaic; -import java.nio.ByteBuffer; - import javax.media.opengl.GL; import com.raytheon.uf.common.colormap.prefs.ColorMapParameters; import com.raytheon.uf.viz.core.DrawableImage; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.PixelCoverage; +import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapDataType; import com.raytheon.uf.viz.core.drawables.IImage; +import com.raytheon.uf.viz.core.drawables.IImage.Status; import com.raytheon.uf.viz.core.drawables.ImagingSupport; import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.ext.IMosaicImageExtension; @@ -36,6 +36,7 @@ import com.raytheon.viz.core.gl.ext.GLOffscreenRenderingExtension; import com.raytheon.viz.core.gl.glsl.AbstractGLSLImagingExtension; import com.raytheon.viz.core.gl.glsl.GLShaderProgram; import com.raytheon.viz.core.gl.images.AbstractGLImage; +import com.raytheon.viz.core.gl.images.GLColormappedImage; /** * Extension used for rendering radar mosaic images @@ -47,6 +48,8 @@ import com.raytheon.viz.core.gl.images.AbstractGLImage; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 16, 2011 mschenke Initial creation + * Mar 21, 2013 1806 bsteffen Update GL mosaicing to use dynamic data + * format for offscreen textures. * * * @@ -57,13 +60,14 @@ import com.raytheon.viz.core.gl.images.AbstractGLImage; public class GLMosaicImageExtension extends AbstractGLSLImagingExtension implements IMosaicImageExtension { - private AbstractGLImage writeToImage; + private GLColormappedImage writeToImage; public GLMosaicImage initializeRaster(int[] imageBounds, IExtent imageExtent, ColorMapParameters params) throws VizException { + // Since byte is the most common type of mosaic start with a byte image. It might switch later if needed. return new GLMosaicImage(target.getExtension( GLOffscreenRenderingExtension.class).constructOffscreenImage( - ByteBuffer.class, imageBounds, params), imageBounds, + ColorMapDataType.BYTE, imageBounds, params), imageBounds, imageExtent, this.getClass()); } @@ -93,7 +97,7 @@ public class GLMosaicImageExtension extends AbstractGLSLImagingExtension if (image instanceof GLMosaicImage) { GLMosaicImage mosaicImage = (GLMosaicImage) image; if (mosaicImage.isRepaint()) { - writeToImage = mosaicImage.getWrappedImage(); + writeToImage = getWriteToImage(mosaicImage); GLOffscreenRenderingExtension extension = target .getExtension(GLOffscreenRenderingExtension.class); try { @@ -134,6 +138,38 @@ public class GLMosaicImageExtension extends AbstractGLSLImagingExtension } } + private GLColormappedImage getWriteToImage(GLMosaicImage mosaicImage) + throws VizException { + ColorMapDataType neededType = null; + for (DrawableImage di : mosaicImage.getImagesToMosaic()) { + IImage image = di.getImage(); + if (image.getStatus() != Status.LOADED) { + continue; + } + if (image instanceof GLColormappedImage) { + GLColormappedImage colorMapImage = (GLColormappedImage) image; + ColorMapDataType type = colorMapImage.getColorMapDataType(); + if (neededType == null) { + neededType = type; + } else if (neededType != type) { + // Mosaicing images of different types? + // No Idea how to handle this + return mosaicImage.getWrappedImage(); + } + } + } + GLColormappedImage writeTo = mosaicImage.getWrappedImage(); + if (neededType != null && neededType != writeTo.getColorMapDataType()) { + GLOffscreenRenderingExtension offscreenExt = target + .getExtension(GLOffscreenRenderingExtension.class); + int[] dimensions = { writeTo.getWidth(), writeTo.getHeight() }; + writeTo = offscreenExt.constructOffscreenImage(neededType, + dimensions, writeTo.getColorMapParameters()); + mosaicImage.setWrappedImage(writeTo); + } + return writeTo; + } + /* * (non-Javadoc) * diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ServiceBackupComponent.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ServiceBackupComponent.java index d81c2aeed3..efa8e7f9bf 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ServiceBackupComponent.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ServiceBackupComponent.java @@ -19,9 +19,6 @@ **/ package com.raytheon.viz.gfe; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - import com.raytheon.viz.gfe.dialogs.sbu.ServiceBackupDlg; import com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent; @@ -36,6 +33,8 @@ import com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent; * ------------ ---------- ----------- -------------------------- * Aug 12, 2011 bphillip Initial creation * Oct 26, 2012 1287 rferrel Change to force blocking of ServiceBackupDlg. + * Mar 21, 2013 1447 dgilling Fix dialog construction so this dialog + * is created as a top-level shell. * * * @@ -54,8 +53,7 @@ public class ServiceBackupComponent extends AbstractCAVEComponent { */ @Override protected void startInternal(String componentName) throws Exception { - ServiceBackupDlg svcBuDlg = new ServiceBackupDlg(new Shell( - Display.getCurrent())); + ServiceBackupDlg svcBuDlg = new ServiceBackupDlg(null); svcBuDlg.setBlockOnOpen(true); svcBuDlg.open(); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/StoreTransmitDlg.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/StoreTransmitDlg.java index 98174d46bc..d764d43ecd 100755 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/StoreTransmitDlg.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/StoreTransmitDlg.java @@ -65,6 +65,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 28May2010 2187 cjeanbap Added StdTextProductFactory * functionality. * 09 NOV 2012 1298 rferrel Changes for non-blocking dialog. + * 08Mar2013 15564 mgamazaychikov Set the awipsWanPil based on productText data * * * @author lvenable @@ -387,7 +388,15 @@ public class StoreTransmitDlg extends CaveSWTDialog implements } else { req = new OUPRequest(); OfficialUserProduct oup = new OfficialUserProduct(); - String awipsWanPil = productIdTF.getText(); + /* + * DR15564 - set the awipsWanPil based on productText data + */ + String[] splitLines = productText.split("\n"); + String[] firstLine = splitLines[0].split(" "); + String[] secondLine = splitLines[1].split(" "); + String cccc = firstLine[1]; + String productNnnidXxxid = secondLine[0]; + String awipsWanPil = cccc + productNnnidXxxid; oup.setAwipsWanPil(awipsWanPil); oup.setProductText(productText); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/QueryOptionsDlg.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/QueryOptionsDlg.java index 23e8322a9a..c1eb5d1a88 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/QueryOptionsDlg.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/QueryOptionsDlg.java @@ -31,7 +31,7 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; /** - * TODO Add Description + * Asks the user if they want to import digital data and/or start GFE. * *
  * 
@@ -39,7 +39,9 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
  * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Aug 4, 2011            randerso     Initial creation
+ * Aug 04, 2011            randerso     Initial creation
+ * Mar 20, 2013   1447     dgilling     Implement changes from A1 DR 21404,
+ *                                      make default selections match A1.
  * 
  * 
* @@ -54,9 +56,11 @@ public class QueryOptionsDlg extends CaveJFACEDialog { private boolean importGrids; private boolean startGfe; - + + private boolean trMode; + private Button importGridsBtn; - + private Button startGfeBtn; /** @@ -96,23 +100,37 @@ public class QueryOptionsDlg extends CaveJFACEDialog { if (doImCon) { importGridsBtn = new Button(top, SWT.CHECK); importGridsBtn.setText("Import Digital Forecast"); + importGridsBtn.setSelection(true); importGridsBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { importGrids = importGridsBtn.getSelection(); } }); - importGridsBtn.getSelection(); + importGrids = importGridsBtn.getSelection(); + + final Button trModeBtn = new Button(top, SWT.CHECK); + trModeBtn.setText("Troubleshooting Mode (no ISC/VTEC AT sharing)"); + trModeBtn.setSelection(false); + trModeBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + trMode = trModeBtn.getSelection(); + } + }); + trMode = trModeBtn.getSelection(); } startGfeBtn = new Button(top, SWT.CHECK); startGfeBtn.setText("Start GFE"); + startGfeBtn.setSelection(true); startGfeBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { startGfe = startGfeBtn.getSelection(); } }); + startGfe = startGfeBtn.getSelection(); return top; } @@ -124,4 +142,8 @@ public class QueryOptionsDlg extends CaveJFACEDialog { public boolean startGFE() { return this.startGfe; } + + public boolean trMode() { + return this.trMode; + } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/ServiceBackupDlg.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/ServiceBackupDlg.java index 4f03ab588e..6bad0dedca 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/ServiceBackupDlg.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/ServiceBackupDlg.java @@ -19,7 +19,6 @@ **/ package com.raytheon.viz.gfe.dialogs.sbu; -import java.io.IOException; import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; @@ -39,6 +38,7 @@ import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -57,7 +57,6 @@ import com.raytheon.uf.common.site.requests.GetActiveSitesRequest; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; -import com.raytheon.uf.common.util.RunProcess; import com.raytheon.uf.viz.core.RGBColors; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.auth.UserController; @@ -87,10 +86,12 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Aug 4, 2011 randerso Initial creation - * Sep 19,2011 10955 rferrel Use RunProcess - * Oct 25, 2012 1287 rferrel Code clean up for non-blocking dialog. - * Nov 15,2012 15614 jdynina Added check for national center + * Aug 04, 2011 randerso Initial creation + * Sep 19, 2011 10955 rferrel Use RunProcess + * Oct 25, 2012 1287 rferrel Code clean up for non-blocking dialog. + * Nov 15, 2012 15614 jdynina Added check for national center + * Mar 20, 2013 1447 dgilling Port troubleshooting mode changes + * from A1 DR 21404, some code cleanup. * * * @@ -156,7 +157,7 @@ public class ServiceBackupDlg extends CaveJFACEDialog { private Job updateJob; private boolean authorized; - + private boolean nationalCenter; private SVCBU_OP currentOperation = SVCBU_OP.no_backup; @@ -342,15 +343,11 @@ public class ServiceBackupDlg extends CaveJFACEDialog { helpItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - try { - // DR#10955 - RunProcess - .getRunProcess() - .exec("/usr/bin/firefox http://" - + getServiceBackupServer() - + ":8080/uEngineWeb/GfeServiceBackup/help/svcbu_help.html"); - } catch (IOException e1) { - statusHandler.error("Unable to open Help page!", e1); + final String url = "http://" + + getServiceBackupServer() + + ":8080/uEngineWeb/GfeServiceBackup/help/svcbu_help.html"; + if (!Program.launch(url)) { + statusHandler.error("Unable to open Help page: " + url); } } }); @@ -360,15 +357,12 @@ public class ServiceBackupDlg extends CaveJFACEDialog { instructionsItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - try { - // DR#10955 - RunProcess - .getRunProcess() - .exec("/usr/bin/firefox http://" - + getServiceBackupServer() - + ":8080/uEngineWeb/GfeServiceBackup/help/svcbu_instructions.html"); - } catch (IOException e1) { - statusHandler.error("Unable to open Help page!", e1); + final String url = "http://" + + getServiceBackupServer() + + ":8080/uEngineWeb/GfeServiceBackup/help/svcbu_instructions.html"; + if (!Program.launch(url)) { + statusHandler.error("Unable to open Instructions page: " + + url); } } }); @@ -378,15 +372,11 @@ public class ServiceBackupDlg extends CaveJFACEDialog { faqItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - try { - // DR#10955 - RunProcess - .getRunProcess() - .exec("/usr/bin/firefox http://" - + getServiceBackupServer() - + ":8080/uEngineWeb/GfeServiceBackup/help/svcbu_faq.html"); - } catch (IOException e1) { - statusHandler.error("Unable to open Help page!", e1); + final String url = "http://" + + getServiceBackupServer() + + ":8080/uEngineWeb/GfeServiceBackup/help/svcbu_faq.html"; + if (!Program.launch(url)) { + statusHandler.error("Unable to open FAQ page: " + url); } } }); @@ -493,7 +483,7 @@ public class ServiceBackupDlg extends CaveJFACEDialog { jobManager.addJob(new SvcbuDeactivateSiteJob(failedSite, this.site)); jobManager.addJob(new SvcbuImportConfJob(site, failedSite, - progress)); + false, progress)); jobManager.addJob(new SvcbuActivateSiteJob(failedSite, this.site)); jobManager.addJob(new SvcbuStartGfeJob(failedSite, this.site)); @@ -544,11 +534,12 @@ public class ServiceBackupDlg extends CaveJFACEDialog { if (dlg.open() == Window.OK) { boolean importGrids = dlg.importGrids(); boolean startGFE = dlg.startGFE(); + boolean trMode = dlg.trMode(); String failedSite = getFailedSite(); jobManager.addJob(new SvcbuDeactivateSiteJob(failedSite, this.site)); jobManager.addJob(new SvcbuImportConfJob(site, failedSite, - progress)); + trMode, progress)); jobManager.addJob(new SvcbuActivateSiteJob(failedSite, this.site)); if (importGrids) { @@ -1191,8 +1182,8 @@ public class ServiceBackupDlg extends CaveJFACEDialog { doExGrids.setEnabled(true); doExGrids.setText("Export " + this.site + "'s Digital Forecast to the Central Server"); - updateBanner("YOU ARE NOT IN BACKUP MODE", getShell().getParent() - .getFont(), black, gray); + updateBanner("YOU ARE NOT IN BACKUP MODE", getShell().getFont(), + black, gray); currentOperation = SVCBU_OP.no_backup; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/jobs/SvcbuImportConfJob.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/jobs/SvcbuImportConfJob.java index 46adf650ee..895a576fdd 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/jobs/SvcbuImportConfJob.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/sbu/jobs/SvcbuImportConfJob.java @@ -49,7 +49,9 @@ import com.raytheon.viz.gfe.dialogs.sbu.ServiceBackupDlg; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Aug 5, 2011 bphillip Initial creation + * Aug 05, 2011 bphillip Initial creation + * Mar 20, 2013 1447 dgilling Add support for service backup + * troubleshooting mode from A1. * * * @@ -62,6 +64,8 @@ public class SvcbuImportConfJob extends ServiceBackupJob implements private String failedSite; + private boolean trMode; + private ProgressDlg progress; private boolean complete; @@ -70,21 +74,19 @@ public class SvcbuImportConfJob extends ServiceBackupJob implements private String errorMsg; - /** - * @param name - */ public SvcbuImportConfJob(String primarySite, String failedSite, - ProgressDlg progress) { + boolean trMode, ProgressDlg progress) { super("Import Configuration: " + failedSite, primarySite); this.failedSite = failedSite; this.progress = progress; + this.trMode = trMode; NotificationManagerJob.addObserver(ServiceBackupDlg.NOTIFY_TOPIC, this); } @Override public void run() { ImportConfRequest request = new ImportConfRequest(primarySite, - failedSite); + failedSite, trMode); try { VizApp.runAsync(new Runnable() { @@ -158,7 +160,7 @@ public class SvcbuImportConfJob extends ServiceBackupJob implements + failedSite, e); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, - "SERVICE BACKUP: "+e.getLocalizedMessage()); + "SERVICE BACKUP: " + e.getLocalizedMessage()); } finally { NotificationManagerJob.removeObserver( ServiceBackupDlg.NOTIFY_TOPIC, this); diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureController.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureController.java index 595911f39e..8a85e02f96 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureController.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureController.java @@ -52,6 +52,7 @@ import com.raytheon.viz.gfe.core.DataManager; * Nov 5, 2008 njensen Initial creation * Jan 8, 2013 1486 dgilling Support changes to BaseGfePyController. * 02/12/2013 #1597 randerso Added logging to support GFE Performance metrics + * Mar 7, 2013 15717 jzeng Change CAVE_STATIC to COMMON_STATIC * * * @@ -76,7 +77,7 @@ public class ProcedureController extends BaseGfePyController { super(filePath, anIncludePath, classLoader, dataManager, "Procedure"); LocalizationContext baseCtx = PathManagerFactory.getPathManager() - .getContext(LocalizationType.CAVE_STATIC, + .getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.BASE); proceduresDir = GfePyIncludeUtil.getProceduresLF(baseCtx); diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java index 1095891aed..30e2a0b8bc 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDataManager.java @@ -53,7 +53,7 @@ import com.raytheon.viz.hydrocommon.util.DbUtils; /** * Class for managing database query calls. TimeSeriesDataManager.java - * + * *
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
@@ -70,1332 +70,1344 @@ import com.raytheon.viz.hydrocommon.util.DbUtils;
  * July 25 2011 10082      djingtao    modify edit()
  * May  30 2012 14967      wkwock      overload insertRejectedData method
  * Feb  22 2013 14676      lbousaidi   check when producttime is null
+ * Mar 25, 2013  1781      mpduff      Constrain time series table query with a start time.
  * 
- * + * * @author dhladky * @version 1.0 */ public class TimeSeriesDataManager extends HydroDataManager { - private static final String TIME_SERIES_DATA_QUERY = "select lid,obstime,lid,product_id from latestobsvalue"; - - private final String INGEST_FILTER_QUERY = "select lid,pe,ts,extremum,dur from ingestfilter where lid=':lid' and ingest = 'T' order by pe asc,ts_rank asc,ts asc,dur asc,extremum asc"; - - private final String SHEF_PE_QUERY = "select name||' '|| eng_unit from shefpe where pe=':pe'"; - - private static final String SHEF_PE_GENERIC_UNITS = "Generic Units"; - - private static TimeSeriesDataManager manager = null; - - private Map stationData; - - private boolean sortChanged = false; - - private static SimpleDateFormat dateFormat; - - /** - * Map holding the location id and display class. - */ - private Map stnDisplayMap = null; - - static { - dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - } - - /** - * private constructor - */ - private TimeSeriesDataManager() { - } - - /** - * Get an instance of this singleton object - * - * @return instance of this class - */ - public static synchronized TimeSeriesDataManager getInstance() { - if (manager == null) { - manager = new TimeSeriesDataManager(); - } - return manager; - } - - /** - * Get TimeSeriesData from the DB - * - * @return Object[] - */ - public Object[] getTimeSeriesData() { - List data; - - try { - data = DirectDbQuery.executeQuery(TIME_SERIES_DATA_QUERY, - HydroConstants.IHFS, QueryLanguage.SQL); - if (data != null) { - return data.get(0); - } - } catch (VizException e) { - - } - return null; - } - - /** - * Get TimeSeriesStationData from the DB - * - * @return map - */ - public Map getTimeSeriesStationData() { - return getTimeSeriesStationData(false); - } - - /** - * Get the station list data sorted by lid. - * - * @param sortByName - * boolean - * @return map - */ - public Map getTimeSeriesStationData(boolean sortByName) { - boolean stnDisplayMapSet = true; - - StringBuilder sql = new StringBuilder("Select "); - sql.append("distinct location.lid, ingestfilter.pe, "); - sql.append("upper(location.name) as uppername, stnclass.disp_Class "); - sql.append("from ingestfilter, location, stnclass "); - sql.append("where ingest='T' and location.lid = stnclass.lid "); - sql.append("and location.lid=ingestfilter.lid "); - - if (sortByName) { - sql.append("order by uppername asc"); - } else { - sql.append("order by lid asc"); - } - - // if the sort changed then requery for the data - if (sortChanged != sortByName) { - sortChanged = true; - } - - if (stnDisplayMap == null) { - stnDisplayMap = new HashMap(); - stnDisplayMapSet = false; - } - - if ((stationData == null) || sortChanged) { - stationData = new LinkedHashMap(); - - List data; - try { - data = DirectDbQuery.executeQuery(sql.toString(), - HydroConstants.IHFS, QueryLanguage.SQL); - for (Object[] rowData : data) { - if (rowData[2] == null) { - rowData[2] = ""; - } - stationData.put((String) rowData[0], (String) rowData[2]); - if (!stnDisplayMapSet) { - stnDisplayMap.put((String) rowData[0], - (String) rowData[3]); - } - } - } catch (VizException e) { - e.printStackTrace(); - } - } - - return stationData; - } - - /** - * Get the site's PE data for graphical display - * - * @param lid - * The lid to query for - * @return ArrayList of Object[] of data - * @throws VizException - */ - public List getSitePEData(String lid) throws VizException { - return DirectDbQuery.executeQuery( - INGEST_FILTER_QUERY.replace(":lid", lid), HydroConstants.IHFS, - QueryLanguage.SQL); - } - - /** - * Get the site's PE data for tabular display - * - * @param lid - * The lid to query for - * @return List of SiteInfo objects - * @throws VizException - */ - public List getTabularPEData(String lid) throws VizException { - StringBuilder sql = new StringBuilder("select "); - sql.append("lid, pe, dur, ts, extremum from Ingestfilter "); - sql.append("where lid = '" + lid + "' and ingest = 'T' "); - sql.append("order by pe, dur, ts, extremum asc"); - - ArrayList results = (ArrayList) DirectDbQuery - .executeQuery(sql.toString(), HydroConstants.IHFS, - QueryLanguage.SQL); - - ArrayList returnData = new ArrayList(); - for (int i = 0; i < results.size(); i++) { - Object[] oa = results.get(i); - SiteInfo si = new SiteInfo(); - si.setLid((String) oa[0]); - si.setPe((String) oa[1]); - si.setDur((Integer) oa[2]); - si.setTs((String) oa[3]); - si.setExt((String) oa[4]); - returnData.add(si); - } - - return returnData; - } - - /** - * Checks the record count in the Location and Stnclass tables. - * - * @return true if same count, otherwise false - * @throws VizException - */ - public boolean checkLidCount() throws VizException { - /* Set up a location query */ - String locationTable = "locview"; - String stnClassTable = "stnclass"; - - StringBuilder errMessage = null; - errMessage = new StringBuilder( - "Error querying the Location table, no data returned"); - - /* Execute the location query */ - long locationCount = recordCount(locationTable, ""); - if (locationCount <= 0) { - throw new VizException(errMessage.toString()); - } - errMessage.setLength(0); - - errMessage.setLength(0); - errMessage - .append("Error querying the Stnclass table, no data returned"); - - /* Execute the Stnclass query */ - long stnClassCount = recordCount(stnClassTable, ""); - - if (stnClassCount <= 0) { - throw new VizException(errMessage.toString()); - } - - if (stnClassCount == locationCount) { - return true; - } - - return false; - } - - /** - * Get the shef pe data from IHFS. - * - * @param pe - * The PE value - * @return The units of the data - * @throws VizException - */ - public String getShefPE(String pe) throws VizException { - - List data = DirectDbQuery.executeQuery( - SHEF_PE_QUERY.replace(":pe", pe), HydroConstants.IHFS, - QueryLanguage.SQL); - if ((data != null) && (data.size() > 0)) { - Object[] sa = data.get(0); - return (String) sa[0]; - - } - return SHEF_PE_GENERIC_UNITS; - } - - /** - * Query the table. - * - * @param tablename - * The table to query - * @param lid - * The location id - * @param pe - * The physical element - * @param ts - * The type source - * @param startTime - * The start time - * @param endTime - * The end time - * @return The List of Object[] data - * @throws VizException - * @throws ClassNotFoundException - */ - public ArrayList getGraphData(String tablename, String lid, - String pe, String ts, String dur, String extremum, Date startTime, Date endTime) - throws VizException, ClassNotFoundException { - - StringBuilder graphQuery = new StringBuilder( - "select lid,obstime,value,product_id from "); - graphQuery.append(tablename + " where lid = '" + lid + "' and pe = '" - + pe + "' " + "and dur = '" + dur + "' "); - graphQuery.append("and ts = '" + ts + "' and extremum = '" + extremum.toUpperCase() + "' and obstime "); - graphQuery.append("between '" - + HydroConstants.DATE_FORMAT.format(startTime) + "' "); - graphQuery.append("and '" + HydroConstants.DATE_FORMAT.format(endTime) - + "' "); - graphQuery.append("order by obstime asc"); - - return (ArrayList) DirectDbQuery.executeQuery( - graphQuery.toString(), HydroConstants.IHFS, QueryLanguage.SQL); - } - - /** - * Query the Riverstat table for the flood/action stage/flow. - * - * @param lid - * The Location Id - * @return The list of flood stage values - * @throws VizException - */ - public List getFloodStage(String lid) throws VizException { - /* Query the floodCat table for the flood stage data */ - String floodQuerySql = "select lid,fs,fq,wstg,action_Flow from riverstat where lid = '" - + lid + "'"; - return DirectDbQuery.executeQuery(floodQuerySql, HydroConstants.IHFS, - QueryLanguage.SQL); - } - - /** - * Query the floodcat table for the flood stage. - * - * @param lid - * The Location Id - * @return The flood stage value as a String - */ - public List getFloodCategories(String lid) throws VizException { - String floodQuerySql = "select " + HydroConstants.LID + "," - + HydroConstants.MINOR_STAGE + "," - + HydroConstants.MODERATE_STAGE + "," - + HydroConstants.MAJOR_STAGE + "," + HydroConstants.MINOR_FLOW - + "," + HydroConstants.MODERATE_FLOW + "," - + HydroConstants.MAJOR_FLOW + " from floodcat where lid = '" - + lid + "'"; - return DirectDbQuery.executeQuery(floodQuerySql, HydroConstants.IHFS, - QueryLanguage.SQL); - } - - /** - * Get the Station name and river name. - * - * @param lid - * Location Id of the station - * @return List of Object[] containing the data - * @throws VizException - */ - public String[] getStnRiverName(String lid) throws VizException { - StringBuilder sql = new StringBuilder("select "); - sql.append("name "); - sql.append("from location "); - sql.append(" where lid = '" + lid + "'"); - - ArrayList result1 = (ArrayList) DirectDbQuery - .executeQuery(sql.toString(), HydroConstants.IHFS, - QueryLanguage.SQL); - - sql.setLength(0); - sql.append("select stream from riverstat where lid = '" + lid + "'"); - - ArrayList result2 = (ArrayList) DirectDbQuery - .executeQuery(sql.toString(), HydroConstants.IHFS, - QueryLanguage.SQL); - - ArrayList sa = new ArrayList(); - - if ((result1 != null) && (result1.size() > 0)) { - sa.add((String) result1.get(0)[0]); - } else { - sa.add(HydroConstants.UNDEFINED); - } - - if ((result2 != null) && (result2.size() > 0)) { - sa.add((String) result2.get(0)[0]); - } else { - sa.add(HydroConstants.UNDEFINED); - } - - return sa.toArray(new String[sa.size()]); - } - - /** - * Gets a unique list of basis times. - * - * @param table - * The table to query - * @param lid - * The lid to query on - * @param pe - * The pe to query on - * @param dur - * The duration to query on - * @param ts - * The type source to query on - * @param ext - * The extremum to query on - * @param begin - * The beginning time - * @param end - * The ending time - * @return List of Object arrays - * @throws VizException - * @throws ClassNotFoundException - */ - public List getUniqueList(String table, String lid, String pe, - int dur, String ts, String ext, Date begin, Date end) - throws VizException, ClassNotFoundException { - StringBuilder sql = new StringBuilder("select "); - sql.append("distinct(basistime) from " + table + " "); - sql.append("where lid = '" + lid + "' and ts = '" + ts + "' and "); - sql.append("dur = '" + dur + "' and extremum = '" + ext + "' and "); - sql.append("validtime > '" + dateFormat.format(begin) + "' and "); - sql.append("validtime < '" + dateFormat.format(end) + "' "); - sql.append("order by basistime desc"); - - return DirectDbQuery.executeQuery(sql.toString(), HydroConstants.IHFS, - QueryLanguage.SQL); - } - - /** - * Query for the data records - * - * @param tablename - * The table to query - * @param lid - * The lid to query on - * @param pe - * The pe to query on - * @param ts - * The type source to query on - * @param dur - * The duration to query on - * @param ext - * The extremum to query on - * @param startTime - * The start time of the data - * @param endTime - * The end time of the data - * @param basisTime - * The forecast basis time, null if not forecast data - * @param forecastData - * true if forecast data - * @return ArrayList of TabularData - * @throws VizException - * @throws ClassNotFoundException - */ - public ArrayList getTabularData(String tablename, String lid, - String pe, String ts, String dur, String ext, Date startTime, - Date endTime, String basisTime, boolean forecastData) - throws VizException, ClassNotFoundException { - StringBuilder sql = new StringBuilder("select "); - - if (forecastData) { - sql.append("lid, validtime, value, revision, shef_qual_code, "); - sql.append("quality_code, product_id, producttime, postingtime, "); - sql.append("basistime, probability "); - sql.append("from " + tablename); - sql.append(" where lid = '" + lid + "'"); - sql.append(" and pe = '" + pe + "'"); - sql.append(" and ts = '" + ts + "'"); - sql.append(" and dur = " + dur); - sql.append(" and extremum = '" + ext + "'"); - sql.append(" and validtime > '" + dateFormat.format(startTime) - + "'"); - sql.append(" and validtime < '" + dateFormat.format(endTime) + "'"); - sql.append(" and basistime = '" + basisTime + "'"); - sql.append(" order by validtime desc"); - } else { - sql.append("lid, obstime, value, revision, shef_qual_code, "); - sql.append("quality_code, product_id, producttime, postingtime "); - sql.append("from " + tablename); - sql.append(" where lid = '" + lid + "'"); - sql.append(" and pe = '" + pe + "'"); - sql.append(" and ts = '" + ts + "'"); - sql.append(" and dur = " + dur); - sql.append(" and extremum = '" + ext + "'"); - sql.append(" and obstime < '" + dateFormat.format(endTime) + "'"); - sql.append(" order by obstime desc"); - } - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql.toString()); - } - - ArrayList tabularData = new ArrayList(); - ArrayList results = (ArrayList) DirectDbQuery - .executeQuery(sql.toString(), HydroConstants.IHFS, - QueryLanguage.SQL); - - for (int i = 0; i < results.size(); i++) { - Object[] oa = results.get(i); - TabularData td = new TabularData(); - td.setLid((String) oa[0]); - td.setObsTime((Date) oa[1]); - td.setValue((Double) oa[2]); - td.setRevision((Integer) oa[3]); - td.setShefQualCode((String) oa[4]); - td.setQualityCode((Integer) oa[5]); - td.setProductId((String) oa[6]); - td.setProductTime((Date) oa[7]); - td.setPostingTime((Date) oa[8]); - if (forecastData) { - td.setValidTime((Date) oa[9]); - td.setProbability((Float) oa[10]); - } - tabularData.add(td); - } - - return tabularData; - } - - /** - * Get the record count of the table. - * - * @param table - * The table to query - * @param where - * The where statement - * @return Number of rows in the table, or -1 if error - * @throws VizException - */ - public long recordCount(String table, String where) throws VizException { - if ((table == null) || table.equals("")) { - return -1; - } - - String sql = "select count(*) from " + table + where; - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); - } - - List results = DirectDbQuery.executeQuery(sql.toString(), - HydroConstants.IHFS, QueryLanguage.SQL); - - if ((results == null) || (results.get(0) == null)) { - return -1; - } - - return (Long) results.get(0)[0]; - } - - /** - * Delete the record. - * - * @param tablename - * The tablename to query - * @param where - * The where statement - * @throws VizException - */ - public void deleteRecord(String tablename, String where) - throws VizException { - String sql = "delete from " + tablename + " " + where; - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); - } - DirectDbQuery.executeStatement(sql, HydroConstants.IHFS, - QueryLanguage.SQL); - } - - /** - * Delete a list of items. - * - * @param queryList - * list of queries - * @throws VizException - */ - public void deleteRecords(ArrayList queryList) throws VizException { - StringBuilder sb = new StringBuilder(); - for (String query : queryList) { - sb.append(query); - } - - DirectDbQuery.executeStatement(sb.toString(), HydroConstants.IHFS, - QueryLanguage.SQL); - } - - /** - * Add a data record. - * - * @param tablename - * The tablename to query - * @param dr - * The data record to add - * @return int - * @throws VizException - */ - public int addDataRecord(String tablename, DataRecord dr) - throws VizException { - StringBuilder sb = new StringBuilder(); - Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); - if (tablename.startsWith("Fcst") || tablename.startsWith("fcst") - || tablename.startsWith("Contingency")) { - sb.append("insert into " + tablename - + "(lid, pe, dur, ts, extremum, "); - sb.append("probability, validtime, basistime, value, quality_code, "); - sb.append("shef_qual_code, revision, product_id, producttime, postingtime) "); - sb.append("values ('" + dr.getLid() + "', '" - + dr.getPe().toUpperCase() + "', "); - sb.append(dr.getDur() + ", '" + dr.getTs().toUpperCase() + "', '"); - sb.append(dr.getExt().toUpperCase() + "', -1, "); - Date d; - if (dr.getObsTime() instanceof Timestamp) { - d = timestampToDate((Timestamp) dr.getObsTime()); - sb.append("'" + dateFormat.format(d) + "', '"); - } else { - sb.append("'" + dateFormat.format(dr.getObsTime()) + "', '"); - } - sb.append(dr.getBasisTime() + "', " + dr.getValue() + ", "); - sb.append(dr.getQualityCode() + ", '" + dr.getShefQualCode() - + "', "); - sb.append(dr.getRevision() + ", '" + dr.getProductId() + "', "); - if (dr.getObsTime() instanceof Timestamp) { - d = timestampToDate((Timestamp) dr.getProductTime()); - sb.append("'" + dateFormat.format(d) + "', '"); - } else { - sb.append("'" + dateFormat.format(dr.getProductTime()) + "', '"); - } - sb.append(dateFormat.format(now) + "')"); - - } else { - sb.append("insert into " + tablename - + "(lid, pe, dur, ts, extremum, "); - sb.append("obstime, postingtime, value, quality_code, shef_qual_code, productTime, "); - sb.append("revision, product_Id) "); - sb.append("values ('" + dr.getLid() + "', '" - + dr.getPe().toUpperCase() + "', "); - sb.append(dr.getDur() + ", '" + dr.getTs().toUpperCase() + "', '"); - sb.append(dr.getExt().toUpperCase() + "', "); - Date d; - if (dr.getObsTime() instanceof Timestamp) { - d = timestampToDate((Timestamp) dr.getObsTime()); - sb.append("'" + dateFormat.format(d) + "', '"); - } else { - sb.append("'" + dateFormat.format(dr.getObsTime()) + "', '"); - } - - sb.append(dateFormat.format(now) + "', "); - - sb.append(dr.getValue() + ", "); - sb.append(dr.getQualityCode() + ", '"); - sb.append(dr.getShefQualCode() + "', '"); - sb.append(dr.getProductTime() + "', "); - sb.append("0, '" + dr.getProductId() + "')"); - } - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sb.toString()); - } - - return DirectDbQuery.executeStatement(sb.toString(), - HydroConstants.IHFS, QueryLanguage.SQL); - } - - /** - * Update sql. - * - * @param sql - * The sql string - * @return int - * @throws VizException - */ - public int update(String sql) throws VizException { - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); - } - - return DirectDbQuery.executeStatement(sql, HydroConstants.IHFS, - QueryLanguage.SQL); - } - - /** - * Insert rejected data record. - * - * @param dr - * The data record - * @return int - * @throws VizException - */ - public int insertRejectedData(DataRecord dr) throws VizException { - Rejecteddata rd = new Rejecteddata(); - RejecteddataId rdid = new RejecteddataId(); - Date d = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); - - /* set basistime to obstime for observed data */ - if (dr.getBasisTime() != null) { - try { - rdid.setBasistime(HydroConstants.DATE_FORMAT.parse(dr - .getBasisTime())); - } catch (ParseException e) { - rdid.setBasistime(dr.getObsTime()); - } - } else { - rdid.setBasistime(dr.getObsTime()); - } - - rdid.setDur((short) dr.getDur()); - rdid.setExtremum(dr.getExt()); - rdid.setLid(dr.getLid()); - rdid.setPe(dr.getPe()); - - /* set postingtime to current time */ - rdid.setPostingtime(d); - - rdid.setProbability(-1); - rdid.setTs(dr.getTs()); - rdid.setValidtime(dr.getValidTime()); - rd.setId(rdid); - - rd.setProductId(dr.getProductId()); - rd.setProducttime(dr.getProductTime()); - rd.setQualityCode((int) dr.getQualityCode()); - - /* set reject_type to M for Manual */ - rd.setRejectType("M"); - - rd.setRevision((short) dr.getRevision()); - rd.setShefQualCode(dr.getShefQualCode()); - rd.setUserid(LocalizationManager.getInstance().getCurrentUser()); - rd.setValue(dr.getValue()); - - /* set validtime for observed data */ - if (rdid.getValidtime() == null) { - rdid.setValidtime(dr.getObsTime()); - } - - return DirectDbQuery.saveOrUpdate(rd, HydroConstants.IHFS); - } - - /** - * Insert a list of items into the rejected table - * - * @param recordList - * List of DataRecord objects - * @return - * @throws VizException - */ - public int insertRejectedData(ArrayList recordList) - throws VizException { - StringBuilder sb = new StringBuilder(); - - Date d = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); - for (DataRecord dr : recordList) { - sb.append("insert into rejecteddata(lid, pe, dur, ts, extremum, "); - sb.append("probability, validtime, basistime, postingtime, value, "); - sb.append("revision, shef_qual_code, product_id, producttime, quality_code, "); - sb.append("reject_type, userid) VALUES("); - - sb.append("'" + dr.getLid() + "', "); - sb.append("'" + dr.getPe() + "', "); - sb.append(dr.getDur() + ", "); - sb.append("'" + dr.getTs() + "', "); - sb.append("'" + dr.getExt() + "', "); - sb.append(-1 + ", "); - - /* set validtime for observed data */ - if (dr.getValidTime() != null) { - sb.append("'" - + HydroConstants.DATE_FORMAT.format(dr.getValidTime()) - + "', "); - } else { - sb.append("'" - + (HydroConstants.DATE_FORMAT.format(dr.getObsTime())) - + "', "); - } - - if (dr.getBasisTime() != null) { - try { - sb.append("'" - + (HydroConstants.DATE_FORMAT.parse(dr - .getBasisTime())) + "', "); - } catch (ParseException e) { - sb.append("'" - + (HydroConstants.DATE_FORMAT.format(dr - .getObsTime())) + "', "); - } - } else { - sb.append("'" - + (HydroConstants.DATE_FORMAT.format(dr.getObsTime())) - + "', "); - } - - sb.append("'" + HydroConstants.DATE_FORMAT.format(d) + "', "); - sb.append(dr.getValue() + ", "); - sb.append(dr.getRevision() + ", "); - sb.append("'" + dr.getShefQualCode() + "', "); - sb.append("'" + dr.getProductId() + "', "); - sb.append("'" - + HydroConstants.DATE_FORMAT.format(dr.getProductTime()) - + "', "); - sb.append(dr.getQualityCode() + ", "); - sb.append("'M', "); - sb.append("'" + LocalizationManager.getInstance().getCurrentUser() - + "');"); - } - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sb.toString()); - } - - return DirectDbQuery.executeStatement(sb.toString(), - HydroConstants.IHFS, QueryLanguage.SQL); - } - - private Object getDataFromDB (ForecastData dr, String field) { - StringBuilder sql = new StringBuilder("select "+field+" from "); - String tablename = DbUtils.getTableName(dr.getPe(), dr.getTs()); - sql.append(tablename + " where "); - sql.append("lid = '" + dr.getLid() + "' "); - sql.append("and pe = '" + dr.getPe().toUpperCase() + "' "); - sql.append("and dur =" +dr.getDur()+" "); - sql.append("and ts = '"+dr.getTs().toUpperCase()+"' "); - sql.append("and extremum = '" +dr.getExtremum().toUpperCase()+"' "); - if (dr.getTs().toUpperCase().startsWith("F") || dr.getTs().toUpperCase().startsWith("C")){ - sql.append("and validtime = '"+dr.getValidTime()+"' "); - sql.append("and basistime = '"+dr.getBasisTime()+"';"); - }else {//obs data - sql.append("and obstime = '"+dr.getObsTime()+"';"); - } - List sqlResult; - try { - sqlResult = (DirectDbQuery.executeQuery(sql.toString(), HydroConstants.IHFS, QueryLanguage.SQL)); - if (sqlResult !=null && sqlResult.size()>0 && sqlResult.get(0)[0]!=null) { + private static final String TIME_SERIES_DATA_QUERY = "select lid,obstime,lid,product_id from latestobsvalue"; + + private final String INGEST_FILTER_QUERY = "select lid,pe,ts,extremum,dur from ingestfilter where lid=':lid' and ingest = 'T' order by pe asc,ts_rank asc,ts asc,dur asc,extremum asc"; + + private final String SHEF_PE_QUERY = "select name||' '|| eng_unit from shefpe where pe=':pe'"; + + private static final String SHEF_PE_GENERIC_UNITS = "Generic Units"; + + private static TimeSeriesDataManager manager = null; + + private Map stationData; + + private boolean sortChanged = false; + + private static SimpleDateFormat dateFormat; + + /** + * Map holding the location id and display class. + */ + private Map stnDisplayMap = null; + + static { + dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + } + + /** + * private constructor + */ + private TimeSeriesDataManager() { + } + + /** + * Get an instance of this singleton object + * + * @return instance of this class + */ + public static synchronized TimeSeriesDataManager getInstance() { + if (manager == null) { + manager = new TimeSeriesDataManager(); + } + return manager; + } + + /** + * Get TimeSeriesData from the DB + * + * @return Object[] + */ + public Object[] getTimeSeriesData() { + List data; + + try { + data = DirectDbQuery.executeQuery(TIME_SERIES_DATA_QUERY, + HydroConstants.IHFS, QueryLanguage.SQL); + if (data != null) { + return data.get(0); + } + } catch (VizException e) { + + } + return null; + } + + /** + * Get TimeSeriesStationData from the DB + * + * @return map + */ + public Map getTimeSeriesStationData() { + return getTimeSeriesStationData(false); + } + + /** + * Get the station list data sorted by lid. + * + * @param sortByName + * boolean + * @return map + */ + public Map getTimeSeriesStationData(boolean sortByName) { + boolean stnDisplayMapSet = true; + + StringBuilder sql = new StringBuilder("Select "); + sql.append("distinct location.lid, ingestfilter.pe, "); + sql.append("upper(location.name) as uppername, stnclass.disp_Class "); + sql.append("from ingestfilter, location, stnclass "); + sql.append("where ingest='T' and location.lid = stnclass.lid "); + sql.append("and location.lid=ingestfilter.lid "); + + if (sortByName) { + sql.append("order by uppername asc"); + } else { + sql.append("order by lid asc"); + } + + // if the sort changed then requery for the data + if (sortChanged != sortByName) { + sortChanged = true; + } + + if (stnDisplayMap == null) { + stnDisplayMap = new HashMap(); + stnDisplayMapSet = false; + } + + if ((stationData == null) || sortChanged) { + stationData = new LinkedHashMap(); + + List data; + try { + data = DirectDbQuery.executeQuery(sql.toString(), + HydroConstants.IHFS, QueryLanguage.SQL); + for (Object[] rowData : data) { + if (rowData[2] == null) { + rowData[2] = ""; + } + stationData.put((String) rowData[0], (String) rowData[2]); + if (!stnDisplayMapSet) { + stnDisplayMap.put((String) rowData[0], + (String) rowData[3]); + } + } + } catch (VizException e) { + e.printStackTrace(); + } + } + + return stationData; + } + + /** + * Get the site's PE data for graphical display + * + * @param lid + * The lid to query for + * @return ArrayList of Object[] of data + * @throws VizException + */ + public List getSitePEData(String lid) throws VizException { + return DirectDbQuery.executeQuery( + INGEST_FILTER_QUERY.replace(":lid", lid), HydroConstants.IHFS, + QueryLanguage.SQL); + } + + /** + * Get the site's PE data for tabular display + * + * @param lid + * The lid to query for + * @return List of SiteInfo objects + * @throws VizException + */ + public List getTabularPEData(String lid) throws VizException { + StringBuilder sql = new StringBuilder("select "); + sql.append("lid, pe, dur, ts, extremum from Ingestfilter "); + sql.append("where lid = '").append(lid).append("' and ingest = 'T' "); + sql.append("order by pe, dur, ts, extremum asc"); + + ArrayList results = (ArrayList) DirectDbQuery + .executeQuery(sql.toString(), HydroConstants.IHFS, + QueryLanguage.SQL); + + ArrayList returnData = new ArrayList(); + for (int i = 0; i < results.size(); i++) { + Object[] oa = results.get(i); + SiteInfo si = new SiteInfo(); + si.setLid((String) oa[0]); + si.setPe((String) oa[1]); + si.setDur((Integer) oa[2]); + si.setTs((String) oa[3]); + si.setExt((String) oa[4]); + returnData.add(si); + } + + return returnData; + } + + /** + * Checks the record count in the Location and Stnclass tables. + * + * @return true if same count, otherwise false + * @throws VizException + */ + public boolean checkLidCount() throws VizException { + /* Set up a location query */ + String locationTable = "locview"; + String stnClassTable = "stnclass"; + + StringBuilder errMessage = null; + errMessage = new StringBuilder( + "Error querying the Location table, no data returned"); + + /* Execute the location query */ + long locationCount = recordCount(locationTable, ""); + if (locationCount <= 0) { + throw new VizException(errMessage.toString()); + } + errMessage.setLength(0); + + errMessage.setLength(0); + errMessage + .append("Error querying the Stnclass table, no data returned"); + + /* Execute the Stnclass query */ + long stnClassCount = recordCount(stnClassTable, ""); + + if (stnClassCount <= 0) { + throw new VizException(errMessage.toString()); + } + + if (stnClassCount == locationCount) { + return true; + } + + return false; + } + + /** + * Get the shef pe data from IHFS. + * + * @param pe + * The PE value + * @return The units of the data + * @throws VizException + */ + public String getShefPE(String pe) throws VizException { + + List data = DirectDbQuery.executeQuery( + SHEF_PE_QUERY.replace(":pe", pe), HydroConstants.IHFS, + QueryLanguage.SQL); + if ((data != null) && (data.size() > 0)) { + Object[] sa = data.get(0); + return (String) sa[0]; + + } + return SHEF_PE_GENERIC_UNITS; + } + + /** + * Query the table. + * + * @param tablename + * The table to query + * @param lid + * The location id + * @param pe + * The physical element + * @param ts + * The type source + * @param startTime + * The start time + * @param endTime + * The end time + * @return The List of Object[] data + * @throws VizException + * @throws ClassNotFoundException + */ + public ArrayList getGraphData(String tablename, String lid, + String pe, String ts, String dur, String extremum, Date startTime, + Date endTime) throws VizException, ClassNotFoundException { + + StringBuilder graphQuery = new StringBuilder( + "select lid,obstime,value,product_id from "); + graphQuery.append(tablename + " where lid = '" + lid + "' and pe = '" + + pe + "' " + "and dur = '" + dur + "' "); + graphQuery.append("and ts = '" + ts + "' and extremum = '" + + extremum.toUpperCase() + "' and obstime "); + graphQuery.append("between '" + + HydroConstants.DATE_FORMAT.format(startTime) + "' "); + graphQuery.append("and '" + HydroConstants.DATE_FORMAT.format(endTime) + + "' "); + graphQuery.append("order by obstime asc"); + + return (ArrayList) DirectDbQuery.executeQuery( + graphQuery.toString(), HydroConstants.IHFS, QueryLanguage.SQL); + } + + /** + * Query the Riverstat table for the flood/action stage/flow. + * + * @param lid + * The Location Id + * @return The list of flood stage values + * @throws VizException + */ + public List getFloodStage(String lid) throws VizException { + /* Query the floodCat table for the flood stage data */ + String floodQuerySql = "select lid,fs,fq,wstg,action_Flow from riverstat where lid = '" + + lid + "'"; + return DirectDbQuery.executeQuery(floodQuerySql, HydroConstants.IHFS, + QueryLanguage.SQL); + } + + /** + * Query the floodcat table for the flood stage. + * + * @param lid + * The Location Id + * @return The flood stage value as a String + */ + public List getFloodCategories(String lid) throws VizException { + String floodQuerySql = "select " + HydroConstants.LID + "," + + HydroConstants.MINOR_STAGE + "," + + HydroConstants.MODERATE_STAGE + "," + + HydroConstants.MAJOR_STAGE + "," + HydroConstants.MINOR_FLOW + + "," + HydroConstants.MODERATE_FLOW + "," + + HydroConstants.MAJOR_FLOW + " from floodcat where lid = '" + + lid + "'"; + return DirectDbQuery.executeQuery(floodQuerySql, HydroConstants.IHFS, + QueryLanguage.SQL); + } + + /** + * Get the Station name and river name. + * + * @param lid + * Location Id of the station + * @return List of Object[] containing the data + * @throws VizException + */ + public String[] getStnRiverName(String lid) throws VizException { + StringBuilder sql = new StringBuilder("select "); + sql.append("name "); + sql.append("from location "); + sql.append(" where lid = '" + lid + "'"); + + ArrayList result1 = (ArrayList) DirectDbQuery + .executeQuery(sql.toString(), HydroConstants.IHFS, + QueryLanguage.SQL); + + sql.setLength(0); + sql.append("select stream from riverstat where lid = '" + lid + "'"); + + ArrayList result2 = (ArrayList) DirectDbQuery + .executeQuery(sql.toString(), HydroConstants.IHFS, + QueryLanguage.SQL); + + ArrayList sa = new ArrayList(); + + if ((result1 != null) && (result1.size() > 0)) { + sa.add((String) result1.get(0)[0]); + } else { + sa.add(HydroConstants.UNDEFINED); + } + + if ((result2 != null) && (result2.size() > 0)) { + sa.add((String) result2.get(0)[0]); + } else { + sa.add(HydroConstants.UNDEFINED); + } + + return sa.toArray(new String[sa.size()]); + } + + /** + * Gets a unique list of basis times. + * + * @param table + * The table to query + * @param lid + * The lid to query on + * @param pe + * The pe to query on + * @param dur + * The duration to query on + * @param ts + * The type source to query on + * @param ext + * The extremum to query on + * @param begin + * The beginning time + * @param end + * The ending time + * @return List of Object arrays + * @throws VizException + * @throws ClassNotFoundException + */ + public List getUniqueList(String table, String lid, String pe, + int dur, String ts, String ext, Date begin, Date end) + throws VizException, ClassNotFoundException { + StringBuilder sql = new StringBuilder("select "); + sql.append("distinct(basistime) from " + table + " "); + sql.append("where lid = '" + lid + "' and ts = '" + ts + "' and "); + sql.append("dur = '" + dur + "' and extremum = '" + ext + "' and "); + sql.append("validtime > '" + dateFormat.format(begin) + "' and "); + sql.append("validtime < '" + dateFormat.format(end) + "' "); + sql.append("order by basistime desc"); + + return DirectDbQuery.executeQuery(sql.toString(), HydroConstants.IHFS, + QueryLanguage.SQL); + } + + /** + * Query for the data records + * + * @param tablename + * The table to query + * @param lid + * The lid to query on + * @param pe + * The pe to query on + * @param ts + * The type source to query on + * @param dur + * The duration to query on + * @param ext + * The extremum to query on + * @param startTime + * The start time of the data + * @param endTime + * The end time of the data + * @param basisTime + * The forecast basis time, null if not forecast data + * @param forecastData + * true if forecast data + * @return ArrayList of TabularData + * @throws VizException + * @throws ClassNotFoundException + */ + public ArrayList getTabularData(String tablename, String lid, + String pe, String ts, String dur, String ext, Date startTime, + Date endTime, String basisTime, boolean forecastData) + throws VizException, ClassNotFoundException { + StringBuilder sql = new StringBuilder("select "); + + if (forecastData) { + sql.append("lid, validtime, value, revision, shef_qual_code, "); + sql.append("quality_code, product_id, producttime, postingtime, "); + sql.append("basistime, probability "); + sql.append("from ").append(tablename); + sql.append(" where lid = '").append(lid).append("'"); + sql.append(" and pe = '").append(pe).append("'"); + sql.append(" and ts = '").append(ts).append("'"); + sql.append(" and dur = ").append(dur); + sql.append(" and extremum = '").append(ext).append("'"); + sql.append(" and validtime > '") + .append(dateFormat.format(startTime)).append("'"); + sql.append(" and validtime < '").append(dateFormat.format(endTime)) + .append("'"); + sql.append(" and basistime = '").append(basisTime).append("'"); + sql.append(" order by validtime desc"); + } else { + sql.append("lid, obstime, value, revision, shef_qual_code, "); + sql.append("quality_code, product_id, producttime, postingtime "); + sql.append("from ").append(tablename); + sql.append(" where lid = '").append(lid).append("'"); + sql.append(" and pe = '").append(pe).append("'"); + sql.append(" and ts = '").append(ts).append("'"); + sql.append(" and dur = ").append(dur); + sql.append(" and extremum = '").append(ext).append("'"); + sql.append(" and obstime > '").append(dateFormat.format(startTime)) + .append("'"); + sql.append(" and obstime < '").append(dateFormat.format(endTime)) + .append("'"); + sql.append(" order by obstime desc"); + } + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sql.toString()); + } + + ArrayList tabularData = new ArrayList(); + ArrayList results = (ArrayList) DirectDbQuery + .executeQuery(sql.toString(), HydroConstants.IHFS, + QueryLanguage.SQL); + + for (int i = 0; i < results.size(); i++) { + Object[] oa = results.get(i); + TabularData td = new TabularData(); + td.setLid((String) oa[0]); + td.setObsTime((Date) oa[1]); + td.setValue((Double) oa[2]); + td.setRevision((Integer) oa[3]); + td.setShefQualCode((String) oa[4]); + td.setQualityCode((Integer) oa[5]); + td.setProductId((String) oa[6]); + td.setProductTime((Date) oa[7]); + td.setPostingTime((Date) oa[8]); + if (forecastData) { + td.setValidTime((Date) oa[9]); + td.setProbability((Float) oa[10]); + } + tabularData.add(td); + } + + return tabularData; + } + + /** + * Get the record count of the table. + * + * @param table + * The table to query + * @param where + * The where statement + * @return Number of rows in the table, or -1 if error + * @throws VizException + */ + public long recordCount(String table, String where) throws VizException { + if ((table == null) || table.equals("")) { + return -1; + } + + String sql = "select count(*) from " + table + where; + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sql); + } + + List results = DirectDbQuery.executeQuery(sql.toString(), + HydroConstants.IHFS, QueryLanguage.SQL); + + if ((results == null) || (results.get(0) == null)) { + return -1; + } + + return (Long) results.get(0)[0]; + } + + /** + * Delete the record. + * + * @param tablename + * The tablename to query + * @param where + * The where statement + * @throws VizException + */ + public void deleteRecord(String tablename, String where) + throws VizException { + String sql = "delete from " + tablename + " " + where; + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sql); + } + DirectDbQuery.executeStatement(sql, HydroConstants.IHFS, + QueryLanguage.SQL); + } + + /** + * Delete a list of items. + * + * @param queryList + * list of queries + * @throws VizException + */ + public void deleteRecords(ArrayList queryList) throws VizException { + StringBuilder sb = new StringBuilder(); + for (String query : queryList) { + sb.append(query); + } + + DirectDbQuery.executeStatement(sb.toString(), HydroConstants.IHFS, + QueryLanguage.SQL); + } + + /** + * Add a data record. + * + * @param tablename + * The tablename to query + * @param dr + * The data record to add + * @return int + * @throws VizException + */ + public int addDataRecord(String tablename, DataRecord dr) + throws VizException { + StringBuilder sb = new StringBuilder(); + Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); + if (tablename.startsWith("Fcst") || tablename.startsWith("fcst") + || tablename.startsWith("Contingency")) { + sb.append("insert into " + tablename + + "(lid, pe, dur, ts, extremum, "); + sb.append("probability, validtime, basistime, value, quality_code, "); + sb.append("shef_qual_code, revision, product_id, producttime, postingtime) "); + sb.append("values ('" + dr.getLid() + "', '" + + dr.getPe().toUpperCase() + "', "); + sb.append(dr.getDur() + ", '" + dr.getTs().toUpperCase() + "', '"); + sb.append(dr.getExt().toUpperCase() + "', -1, "); + Date d; + if (dr.getObsTime() instanceof Timestamp) { + d = timestampToDate((Timestamp) dr.getObsTime()); + sb.append("'" + dateFormat.format(d) + "', '"); + } else { + sb.append("'" + dateFormat.format(dr.getObsTime()) + "', '"); + } + sb.append(dr.getBasisTime() + "', " + dr.getValue() + ", "); + sb.append(dr.getQualityCode() + ", '" + dr.getShefQualCode() + + "', "); + sb.append(dr.getRevision() + ", '" + dr.getProductId() + "', "); + if (dr.getObsTime() instanceof Timestamp) { + d = timestampToDate((Timestamp) dr.getProductTime()); + sb.append("'" + dateFormat.format(d) + "', '"); + } else { + sb.append("'" + dateFormat.format(dr.getProductTime()) + "', '"); + } + sb.append(dateFormat.format(now) + "')"); + + } else { + sb.append("insert into " + tablename + + "(lid, pe, dur, ts, extremum, "); + sb.append("obstime, postingtime, value, quality_code, shef_qual_code, productTime, "); + sb.append("revision, product_Id) "); + sb.append("values ('" + dr.getLid() + "', '" + + dr.getPe().toUpperCase() + "', "); + sb.append(dr.getDur() + ", '" + dr.getTs().toUpperCase() + "', '"); + sb.append(dr.getExt().toUpperCase() + "', "); + Date d; + if (dr.getObsTime() instanceof Timestamp) { + d = timestampToDate((Timestamp) dr.getObsTime()); + sb.append("'" + dateFormat.format(d) + "', '"); + } else { + sb.append("'" + dateFormat.format(dr.getObsTime()) + "', '"); + } + + sb.append(dateFormat.format(now) + "', "); + + sb.append(dr.getValue() + ", "); + sb.append(dr.getQualityCode() + ", '"); + sb.append(dr.getShefQualCode() + "', '"); + sb.append(dr.getProductTime() + "', "); + sb.append("0, '" + dr.getProductId() + "')"); + } + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sb.toString()); + } + + return DirectDbQuery.executeStatement(sb.toString(), + HydroConstants.IHFS, QueryLanguage.SQL); + } + + /** + * Update sql. + * + * @param sql + * The sql string + * @return int + * @throws VizException + */ + public int update(String sql) throws VizException { + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sql); + } + + return DirectDbQuery.executeStatement(sql, HydroConstants.IHFS, + QueryLanguage.SQL); + } + + /** + * Insert rejected data record. + * + * @param dr + * The data record + * @return int + * @throws VizException + */ + public int insertRejectedData(DataRecord dr) throws VizException { + Rejecteddata rd = new Rejecteddata(); + RejecteddataId rdid = new RejecteddataId(); + Date d = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); + + /* set basistime to obstime for observed data */ + if (dr.getBasisTime() != null) { + try { + rdid.setBasistime(HydroConstants.DATE_FORMAT.parse(dr + .getBasisTime())); + } catch (ParseException e) { + rdid.setBasistime(dr.getObsTime()); + } + } else { + rdid.setBasistime(dr.getObsTime()); + } + + rdid.setDur((short) dr.getDur()); + rdid.setExtremum(dr.getExt()); + rdid.setLid(dr.getLid()); + rdid.setPe(dr.getPe()); + + /* set postingtime to current time */ + rdid.setPostingtime(d); + + rdid.setProbability(-1); + rdid.setTs(dr.getTs()); + rdid.setValidtime(dr.getValidTime()); + rd.setId(rdid); + + rd.setProductId(dr.getProductId()); + rd.setProducttime(dr.getProductTime()); + rd.setQualityCode((int) dr.getQualityCode()); + + /* set reject_type to M for Manual */ + rd.setRejectType("M"); + + rd.setRevision((short) dr.getRevision()); + rd.setShefQualCode(dr.getShefQualCode()); + rd.setUserid(LocalizationManager.getInstance().getCurrentUser()); + rd.setValue(dr.getValue()); + + /* set validtime for observed data */ + if (rdid.getValidtime() == null) { + rdid.setValidtime(dr.getObsTime()); + } + + return DirectDbQuery.saveOrUpdate(rd, HydroConstants.IHFS); + } + + /** + * Insert a list of items into the rejected table + * + * @param recordList + * List of DataRecord objects + * @return + * @throws VizException + */ + public int insertRejectedData(ArrayList recordList) + throws VizException { + StringBuilder sb = new StringBuilder(); + + Date d = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); + for (DataRecord dr : recordList) { + sb.append("insert into rejecteddata(lid, pe, dur, ts, extremum, "); + sb.append("probability, validtime, basistime, postingtime, value, "); + sb.append("revision, shef_qual_code, product_id, producttime, quality_code, "); + sb.append("reject_type, userid) VALUES("); + + sb.append("'" + dr.getLid() + "', "); + sb.append("'" + dr.getPe() + "', "); + sb.append(dr.getDur() + ", "); + sb.append("'" + dr.getTs() + "', "); + sb.append("'" + dr.getExt() + "', "); + sb.append(-1 + ", "); + + /* set validtime for observed data */ + if (dr.getValidTime() != null) { + sb.append("'" + + HydroConstants.DATE_FORMAT.format(dr.getValidTime()) + + "', "); + } else { + sb.append("'" + + (HydroConstants.DATE_FORMAT.format(dr.getObsTime())) + + "', "); + } + + if (dr.getBasisTime() != null) { + try { + sb.append("'" + + (HydroConstants.DATE_FORMAT.parse(dr + .getBasisTime())) + "', "); + } catch (ParseException e) { + sb.append("'" + + (HydroConstants.DATE_FORMAT.format(dr + .getObsTime())) + "', "); + } + } else { + sb.append("'" + + (HydroConstants.DATE_FORMAT.format(dr.getObsTime())) + + "', "); + } + + sb.append("'" + HydroConstants.DATE_FORMAT.format(d) + "', "); + sb.append(dr.getValue() + ", "); + sb.append(dr.getRevision() + ", "); + sb.append("'" + dr.getShefQualCode() + "', "); + sb.append("'" + dr.getProductId() + "', "); + sb.append("'" + + HydroConstants.DATE_FORMAT.format(dr.getProductTime()) + + "', "); + sb.append(dr.getQualityCode() + ", "); + sb.append("'M', "); + sb.append("'" + LocalizationManager.getInstance().getCurrentUser() + + "');"); + } + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sb.toString()); + } + + return DirectDbQuery.executeStatement(sb.toString(), + HydroConstants.IHFS, QueryLanguage.SQL); + } + + private Object getDataFromDB(ForecastData dr, String field) { + StringBuilder sql = new StringBuilder("select " + field + " from "); + String tablename = DbUtils.getTableName(dr.getPe(), dr.getTs()); + sql.append(tablename + " where "); + sql.append("lid = '" + dr.getLid() + "' "); + sql.append("and pe = '" + dr.getPe().toUpperCase() + "' "); + sql.append("and dur =" + dr.getDur() + " "); + sql.append("and ts = '" + dr.getTs().toUpperCase() + "' "); + sql.append("and extremum = '" + dr.getExtremum().toUpperCase() + "' "); + if (dr.getTs().toUpperCase().startsWith("F") + || dr.getTs().toUpperCase().startsWith("C")) { + sql.append("and validtime = '" + dr.getValidTime() + "' "); + sql.append("and basistime = '" + dr.getBasisTime() + "';"); + } else {// obs data + sql.append("and obstime = '" + dr.getObsTime() + "';"); + } + List sqlResult; + try { + sqlResult = (DirectDbQuery.executeQuery(sql.toString(), + HydroConstants.IHFS, QueryLanguage.SQL)); + if (sqlResult != null && sqlResult.size() > 0 + && sqlResult.get(0)[0] != null) { return sqlResult.get(0)[0]; } - } catch (VizException e) { - e.printStackTrace(); - return null; - } - - return null; - } - - public int insertRejectedData(List deleteList) throws VizException { - StringBuilder sb = new StringBuilder(); - - Date currentTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); - for (ForecastData dr : deleteList) { - - int probability=-1; - int revision=0; - if (dr.getTs().toUpperCase().startsWith("F") || dr.getTs().toUpperCase().startsWith("C")) { - probability=0; - revision=1; - } - - Date productTime=dr.getProductTime(); - if (productTime==null) { - productTime=(Date)getDataFromDB(dr,"producttime"); - } - - String productID=(String)getDataFromDB(dr,"product_id"); - if (productID==null) { - productID=dr.getProductID(); - } - - Integer qualityCode=(Integer)getDataFromDB(dr,"quality_code"); - if (qualityCode==null) { - qualityCode=new Integer(dr.getQualityCode()); - } - - sb.append("insert into rejecteddata(lid, pe, dur, ts, extremum, "); - sb.append("probability, validtime, basistime, postingtime, value, "); - sb.append("revision, shef_qual_code, product_id, producttime, quality_code, "); - sb.append("reject_type, userid) VALUES("); - - sb.append("'" + dr.getLid() + "', "); - sb.append("'" + dr.getPe().toUpperCase() + "', "); - sb.append(dr.getDur() + ", "); - sb.append("'" + dr.getTs().toUpperCase() + "', "); - sb.append("'" + dr.getExtremum().toUpperCase() + "', "); - sb.append(probability + ", "); - - /* set validtime for observed data */ - if (dr.getValidTime() != null) { - sb.append("'" - + HydroConstants.DATE_FORMAT.format(dr.getValidTime()) - + "', "); - } else { - sb.append("'" - + (HydroConstants.DATE_FORMAT.format(dr.getObsTime())) - + "', "); - } - - if (dr.getBasisTime() != null) { - sb.append("'" - + (dr.getBasisTime()) + "', "); - } else { - sb.append("'" - + (HydroConstants.DATE_FORMAT.format(dr.getObsTime())) - + "', "); - } - - sb.append("'" + HydroConstants.DATE_FORMAT.format(currentTime) + "', "); - sb.append(dr.getValue() + ", "); - sb.append(revision + ", "); - sb.append("'M', ");//shef_qual_code always M - sb.append("'" + productID + "', "); - sb.append("'" - + HydroConstants.DATE_FORMAT.format(productTime) - + "', "); - sb.append(qualityCode + ", "); - sb.append("'M', "); - sb.append("'" + LocalizationManager.getInstance().getCurrentUser() - + "');"); - } - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sb.toString()); - } - - return DirectDbQuery.executeStatement(sb.toString(), - HydroConstants.IHFS, QueryLanguage.SQL); - - } - - /** - * Deletes a list of Observations. - * - * @param deleteList - * List of Observations to delete. - * @return The number of rows modified - * @throws VizException - */ - public int delete(List deleteList) throws VizException { - int status = -1; - - for (int i = 0; i < deleteList.size(); i++) { - ForecastData data = deleteList.get(i); - String tablename = DbUtils.getTableName(data.getPe(), data.getTs()); - - StringBuilder sql = new StringBuilder("delete from "); - sql.append(tablename + " where "); - sql.append("lid = '" + data.getLid() + "' "); - sql.append("and pe = '"+data.getPe().toUpperCase()+"' "); - sql.append("and dur = " + data.getDur() + " "); - sql.append("and ts = '"+data.getTs().toUpperCase()+"' "); - sql.append("and extremum = '" + data.getExtremum().toUpperCase() - + "' "); - - if (data.getValidTime() != null) { - sql.append("and validtime = '" - + dbFormat.format(data.getValidTime()) + "'"); - } else { - sql.append("and obstime = '" - + dbFormat.format(data.getObsTime()) + "'"); - } - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); - } - - status = DirectDbQuery.executeStatement(sql.toString(), - HydroConstants.IHFS, QueryLanguage.SQL); - } - - return status; - } - - /** - * Inserts a list of Observations. - * - * @param insertList - * List of Observations to insert. - * @return The number of rows modified - * @throws VizException - */ - public int insert(List insertList) throws VizException { - int status = -1; - Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); - - for (int i = 0; i < insertList.size(); i++) { - ForecastData data = insertList.get(i); - String tablename = DbUtils.getTableName(data.getPe(), data.getTs()); - - SqlBuilder sql = new SqlBuilder(tablename); - sql.setSqlType(SqlBuilder.INSERT); - sql.addString("lid", data.getLid()); - sql.addString("pe", data.getPe().toUpperCase()); - sql.addInt("dur", data.getDur()); - sql.addString("ts", data.getTs().toUpperCase()); - sql.addString("extremum", data.getExtremum().toUpperCase()); - sql.addString("product_id", data.getProductID().toUpperCase()); - - if (data.getValidTime() != null) { - sql.addString("validTime", - dateFormat.format(data.getValidTime())); - sql.addInt("probability", -1); - sql.addString("basisTime", - dateFormat.format(data.getBasisTime())); - if (data.getProductTime() == null) { - sql.addString( - "producttime", - dateFormat.format(Calendar.getInstance( - TimeZone.getTimeZone("GMT")).getTime())); - } else { - sql.addString("producttime", - dateFormat.format(data.getProductTime())); - } - } else { - sql.addString("obstime", dateFormat.format(data.getObsTime())); - sql.addString("producttime", - dateFormat.format(data.getObsTime())); - } - - sql.addDouble("value", data.getValue()); - sql.addString("shef_qual_code", "M"); - sql.addInt("quality_code", TimeSeriesUtil.DEFAULT_QC_VALUE); - sql.addInt("revision", 0); - sql.addString("postingtime", dateFormat.format(now)); - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql.toString()); - } - - status = DirectDbQuery.executeStatement(sql.toString(), - HydroConstants.IHFS, QueryLanguage.SQL); - } - - return status; - } - - /** - * Edits a list of Observations. - * - * @param editList - * List of Observations to edit. - * @return The number of rows modified - * @throws VizException - */ - public int edit(List editList) throws VizException { - int status = -1; - Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); - - for (int i = 0; i < editList.size(); i++) { - ForecastData data = editList.get(i); - String tablename = DbUtils.getTableName(data.getPe(), data.getTs()); - - SqlBuilder sql = new SqlBuilder(tablename); - sql.setSqlType(SqlBuilder.UPDATE); - sql.addDouble("value", data.getValue()); - sql.addString("postingTime", HydroConstants.DATE_FORMAT.format(now)); - if (data.getProductTime() == null) { - sql.addString("producttime", - HydroConstants.DATE_FORMAT.format(Calendar.getInstance( - TimeZone.getTimeZone("GMT")).getTime())); - } - - StringBuilder where = new StringBuilder(); - where.append(" where lid = '" + data.getLid().toUpperCase() + "' "); - where.append("and dur = " + data.getDur() + " "); - where.append("and ts = '" + data.getTs().toUpperCase() + "' "); - where.append("and extremum = '" + data.getExtremum().toUpperCase() - + "' "); - if (data.getValidTime() != null) { - where.append("and validtime = '" - + dateFormat.format(data.getValidTime()) + "'"); - where.append(" and basistime = '" - + dateFormat.format(data.getBasisTime()) + "'"); - } else { - where.append("and obstime = '" - + dateFormat.format(data.getObsTime()) + "'"); - } - - sql.setWhereClause(where.toString()); - - if (data.getValue() == HydroConstants.MISSING_VALUE) { - DataRecord dr = new DataRecord(); - Date productTime=data.getProductTime(); - if (productTime==null) { - productTime= now; - } - - dr.setDur(data.getDur()); - dr.setExt(data.getExtremum().toUpperCase()); - dr.setLid(data.getLid()); - dr.setObsTime(data.getObsTime()); - dr.setPe(data.getPe().toUpperCase()); - dr.setPostingTime(now); - dr.setQualityCode(TimeSeriesUtil.DEFAULT_QC_VALUE); - dr.setRevision(data.getRevision()); - dr.setShefQualCode("M"); - dr.setTs(data.getTs().toUpperCase()); - dr.setValue(data.getPreviousValue()); - dr.setProductTime(productTime); - dr.setProductId(data.getProductID()); - if (data.getValidTime() != null) { - dr.setValidTime(data.getValidTime()); - dr.setBasisTime(dateFormat.format(data.getBasisTime())); - } else { - dr.setValidTime(data.getObsTime()); - } - - insertRejectedData(dr); - } - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); - } - - DirectDbQuery.executeStatement(sql.toString(), HydroConstants.IHFS, - QueryLanguage.SQL); - } - - return status; - } - - /** - * Get the product's productId and productTime. - * - * @param where - * The where statement - * @param table - * The table to get the data from - * @return List of String[] productId, productTime - * @throws VizException - */ - public String[] getProductIdTime(final String where, final String table) - throws VizException { - - StringBuilder sql = new StringBuilder(); - sql.append("select product_id, productTime from " + table); - sql.append(where); - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + sql); - } - - List rs = DirectDbQuery.executeQuery(sql.toString(), - HydroConstants.IHFS, QueryLanguage.SQL); - - String[] sa = null; - if ((rs != null) && (rs.size() > 0)) { - Object[] item = rs.get(0); - sa = new String[2]; - sa[0] = (String) item[0]; - sa[1] = dateFormat.format((Date) item[1]); - } - - return sa; - } - - /** - * Get the list of forecast data. - * - * @param where - * The where statement - * @param table - * The table to get the data from - * @return List of String[] productId, productTime - * @throws VizException - */ - public ArrayList getForecast(final String where, - final String table) throws VizException { - ArrayList returnList = new ArrayList(); - - StringBuilder query = new StringBuilder("select "); - query.append("lid, pe, dur, ts, extremum, probability, validtime, "); - query.append("basistime, value, shef_qual_code, quality_code, "); - query.append("revision, product_id, producttime, postingtime "); - query.append("from " + table + " " + where); - - AppsDefaults ad = AppsDefaults.getInstance(); - boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, - false); - - if (debug) { - System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" - + ad.getToken(HydroConstants.PGPORT) + ":" - + ad.getToken(HydroConstants.DB_NAME)); - System.out.println("Query: " + query.toString()); - } - - List results = DirectDbQuery.executeQuery(query.toString(), - HydroConstants.IHFS, QueryLanguage.SQL); - - if ((results == null) || (results.size() == 0)) { - return returnList; - } - returnList.ensureCapacity(results.size()); - int i = 0; - for (Object[] item : results) { - i = 0; - Fcstheight fh = new Fcstheight(); - FcstheightId fhid = new FcstheightId(); - fhid.setLid((String) item[i++]); - fhid.setPe((String) item[i++]); - Integer in = (Integer) item[i++]; - fhid.setDur(in.shortValue()); - fhid.setTs((String) item[i++]); - fhid.setExtremum((String) item[i++]); - fhid.setProbability((Float) item[i++]); - fhid.setValidtime((Date) item[i++]); - fhid.setBasistime((Date) item[i++]); - fh.setId(fhid); - fh.setValue((Double) item[i++]); - fh.setShefQualCode((String) item[i++]); - fh.setQualityCode((Integer) item[i++]); - in = (Integer) item[i++]; - fh.setRevision(in.shortValue()); - fh.setProductId((String) item[i++]); - fh.setProducttime((Date) item[i++]); - fh.setPostingtime((Date) item[i++]); - - returnList.add(fh); - } - - return returnList; - } - - /** - * Insert/Update the forecast tables. - * - * @param dataObj - * The persistent data object to insert/update - * @return The number of objects inserted/updated - * @throws VizException - */ - public int putForecast(PersistableDataObject dataObj) throws VizException { - int rv = 0; - - rv = DirectDbQuery.saveOrUpdate(dataObj, HydroConstants.IHFS); - - return rv; - } - - /** - * Get the Use Latest Forecast flag from riverstat table. - * - * @param lid - * The location id - * @return The use latestes forecast flag, or null if nothing in db - */ - public String getUseLatestForecast(String lid) { - String useLatest = null; - - String query = "select use_latest_fcst from riverstat where lid = '" - + lid + "'"; - - ArrayList rs = runQuery(query); - - if ((rs != null) && (rs.size() > 0)) { - useLatest = (String) rs.get(0)[0]; - } - - return useLatest; - } - - /** - * Convert Timestamp object to java.util.Date object. - * - * @param timestamp - * The Timestamp to convert - * @return The Date object - */ - public Date timestampToDate(Timestamp timestamp) { - long milliseconds = timestamp.getTime();// + (timestamp.getNanos() / - // 1000000); - return new java.util.Date(milliseconds); - } - - /** - * Get the station display map. - * - * @return The map of station displays - */ - public Map getStationDisplayMap() { - return stnDisplayMap; - } + } catch (VizException e) { + e.printStackTrace(); + return null; + } + + return null; + } + + public int insertRejectedData(List deleteList) + throws VizException { + StringBuilder sb = new StringBuilder(); + + Date currentTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")) + .getTime(); + for (ForecastData dr : deleteList) { + + int probability = -1; + int revision = 0; + if (dr.getTs().toUpperCase().startsWith("F") + || dr.getTs().toUpperCase().startsWith("C")) { + probability = 0; + revision = 1; + } + + Date productTime = dr.getProductTime(); + if (productTime == null) { + productTime = (Date) getDataFromDB(dr, "producttime"); + } + + String productID = (String) getDataFromDB(dr, "product_id"); + if (productID == null) { + productID = dr.getProductID(); + } + + Integer qualityCode = (Integer) getDataFromDB(dr, "quality_code"); + if (qualityCode == null) { + qualityCode = new Integer(dr.getQualityCode()); + } + + sb.append("insert into rejecteddata(lid, pe, dur, ts, extremum, "); + sb.append("probability, validtime, basistime, postingtime, value, "); + sb.append("revision, shef_qual_code, product_id, producttime, quality_code, "); + sb.append("reject_type, userid) VALUES("); + + sb.append("'" + dr.getLid() + "', "); + sb.append("'" + dr.getPe().toUpperCase() + "', "); + sb.append(dr.getDur() + ", "); + sb.append("'" + dr.getTs().toUpperCase() + "', "); + sb.append("'" + dr.getExtremum().toUpperCase() + "', "); + sb.append(probability + ", "); + + /* set validtime for observed data */ + if (dr.getValidTime() != null) { + sb.append("'" + + HydroConstants.DATE_FORMAT.format(dr.getValidTime()) + + "', "); + } else { + sb.append("'" + + (HydroConstants.DATE_FORMAT.format(dr.getObsTime())) + + "', "); + } + + if (dr.getBasisTime() != null) { + sb.append("'" + (dr.getBasisTime()) + "', "); + } else { + sb.append("'" + + (HydroConstants.DATE_FORMAT.format(dr.getObsTime())) + + "', "); + } + + sb.append("'" + HydroConstants.DATE_FORMAT.format(currentTime) + + "', "); + sb.append(dr.getValue() + ", "); + sb.append(revision + ", "); + sb.append("'M', ");// shef_qual_code always M + sb.append("'" + productID + "', "); + sb.append("'" + HydroConstants.DATE_FORMAT.format(productTime) + + "', "); + sb.append(qualityCode + ", "); + sb.append("'M', "); + sb.append("'" + LocalizationManager.getInstance().getCurrentUser() + + "');"); + } + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sb.toString()); + } + + return DirectDbQuery.executeStatement(sb.toString(), + HydroConstants.IHFS, QueryLanguage.SQL); + + } + + /** + * Deletes a list of Observations. + * + * @param deleteList + * List of Observations to delete. + * @return The number of rows modified + * @throws VizException + */ + public int delete(List deleteList) throws VizException { + int status = -1; + + for (int i = 0; i < deleteList.size(); i++) { + ForecastData data = deleteList.get(i); + String tablename = DbUtils.getTableName(data.getPe(), data.getTs()); + + StringBuilder sql = new StringBuilder("delete from "); + sql.append(tablename + " where "); + sql.append("lid = '" + data.getLid() + "' "); + sql.append("and pe = '" + data.getPe().toUpperCase() + "' "); + sql.append("and dur = " + data.getDur() + " "); + sql.append("and ts = '" + data.getTs().toUpperCase() + "' "); + sql.append("and extremum = '" + data.getExtremum().toUpperCase() + + "' "); + + if (data.getValidTime() != null) { + sql.append("and validtime = '" + + dbFormat.format(data.getValidTime()) + "'"); + } else { + sql.append("and obstime = '" + + dbFormat.format(data.getObsTime()) + "'"); + } + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sql); + } + + status = DirectDbQuery.executeStatement(sql.toString(), + HydroConstants.IHFS, QueryLanguage.SQL); + } + + return status; + } + + /** + * Inserts a list of Observations. + * + * @param insertList + * List of Observations to insert. + * @return The number of rows modified + * @throws VizException + */ + public int insert(List insertList) throws VizException { + int status = -1; + Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); + + for (int i = 0; i < insertList.size(); i++) { + ForecastData data = insertList.get(i); + String tablename = DbUtils.getTableName(data.getPe(), data.getTs()); + + SqlBuilder sql = new SqlBuilder(tablename); + sql.setSqlType(SqlBuilder.INSERT); + sql.addString("lid", data.getLid()); + sql.addString("pe", data.getPe().toUpperCase()); + sql.addInt("dur", data.getDur()); + sql.addString("ts", data.getTs().toUpperCase()); + sql.addString("extremum", data.getExtremum().toUpperCase()); + sql.addString("product_id", data.getProductID().toUpperCase()); + + if (data.getValidTime() != null) { + sql.addString("validTime", + dateFormat.format(data.getValidTime())); + sql.addInt("probability", -1); + sql.addString("basisTime", + dateFormat.format(data.getBasisTime())); + if (data.getProductTime() == null) { + sql.addString( + "producttime", + dateFormat.format(Calendar.getInstance( + TimeZone.getTimeZone("GMT")).getTime())); + } else { + sql.addString("producttime", + dateFormat.format(data.getProductTime())); + } + } else { + sql.addString("obstime", dateFormat.format(data.getObsTime())); + sql.addString("producttime", + dateFormat.format(data.getObsTime())); + } + + sql.addDouble("value", data.getValue()); + sql.addString("shef_qual_code", "M"); + sql.addInt("quality_code", TimeSeriesUtil.DEFAULT_QC_VALUE); + sql.addInt("revision", 0); + sql.addString("postingtime", dateFormat.format(now)); + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sql.toString()); + } + + status = DirectDbQuery.executeStatement(sql.toString(), + HydroConstants.IHFS, QueryLanguage.SQL); + } + + return status; + } + + /** + * Edits a list of Observations. + * + * @param editList + * List of Observations to edit. + * @return The number of rows modified + * @throws VizException + */ + public int edit(List editList) throws VizException { + int status = -1; + Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); + + for (int i = 0; i < editList.size(); i++) { + ForecastData data = editList.get(i); + String tablename = DbUtils.getTableName(data.getPe(), data.getTs()); + + SqlBuilder sql = new SqlBuilder(tablename); + sql.setSqlType(SqlBuilder.UPDATE); + sql.addDouble("value", data.getValue()); + sql.addString("postingTime", HydroConstants.DATE_FORMAT.format(now)); + if (data.getProductTime() == null) { + sql.addString( + "producttime", + HydroConstants.DATE_FORMAT.format(Calendar.getInstance( + TimeZone.getTimeZone("GMT")).getTime())); + } + + StringBuilder where = new StringBuilder(); + where.append(" where lid = '" + data.getLid().toUpperCase() + "' "); + where.append("and dur = " + data.getDur() + " "); + where.append("and ts = '" + data.getTs().toUpperCase() + "' "); + where.append("and extremum = '" + data.getExtremum().toUpperCase() + + "' "); + if (data.getValidTime() != null) { + where.append("and validtime = '" + + dateFormat.format(data.getValidTime()) + "'"); + where.append(" and basistime = '" + + dateFormat.format(data.getBasisTime()) + "'"); + } else { + where.append("and obstime = '" + + dateFormat.format(data.getObsTime()) + "'"); + } + + sql.setWhereClause(where.toString()); + + if (data.getValue() == HydroConstants.MISSING_VALUE) { + DataRecord dr = new DataRecord(); + Date productTime = data.getProductTime(); + if (productTime == null) { + productTime = now; + } + + dr.setDur(data.getDur()); + dr.setExt(data.getExtremum().toUpperCase()); + dr.setLid(data.getLid()); + dr.setObsTime(data.getObsTime()); + dr.setPe(data.getPe().toUpperCase()); + dr.setPostingTime(now); + dr.setQualityCode(TimeSeriesUtil.DEFAULT_QC_VALUE); + dr.setRevision(data.getRevision()); + dr.setShefQualCode("M"); + dr.setTs(data.getTs().toUpperCase()); + dr.setValue(data.getPreviousValue()); + dr.setProductTime(productTime); + dr.setProductId(data.getProductID()); + if (data.getValidTime() != null) { + dr.setValidTime(data.getValidTime()); + dr.setBasisTime(dateFormat.format(data.getBasisTime())); + } else { + dr.setValidTime(data.getObsTime()); + } + + insertRejectedData(dr); + } + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sql); + } + + DirectDbQuery.executeStatement(sql.toString(), HydroConstants.IHFS, + QueryLanguage.SQL); + } + + return status; + } + + /** + * Get the product's productId and productTime. + * + * @param where + * The where statement + * @param table + * The table to get the data from + * @return List of String[] productId, productTime + * @throws VizException + */ + public String[] getProductIdTime(final String where, final String table) + throws VizException { + + StringBuilder sql = new StringBuilder(); + sql.append("select product_id, productTime from " + table); + sql.append(where); + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + sql); + } + + List rs = DirectDbQuery.executeQuery(sql.toString(), + HydroConstants.IHFS, QueryLanguage.SQL); + + String[] sa = null; + if ((rs != null) && (rs.size() > 0)) { + Object[] item = rs.get(0); + sa = new String[2]; + sa[0] = (String) item[0]; + sa[1] = dateFormat.format((Date) item[1]); + } + + return sa; + } + + /** + * Get the list of forecast data. + * + * @param where + * The where statement + * @param table + * The table to get the data from + * @return List of String[] productId, productTime + * @throws VizException + */ + public ArrayList getForecast(final String where, + final String table) throws VizException { + ArrayList returnList = new ArrayList(); + + StringBuilder query = new StringBuilder("select "); + query.append("lid, pe, dur, ts, extremum, probability, validtime, "); + query.append("basistime, value, shef_qual_code, quality_code, "); + query.append("revision, product_id, producttime, postingtime "); + query.append("from " + table + " " + where); + + AppsDefaults ad = AppsDefaults.getInstance(); + boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, + false); + + if (debug) { + System.out.println(ad.getToken(HydroConstants.PGHOST) + ":" + + ad.getToken(HydroConstants.PGPORT) + ":" + + ad.getToken(HydroConstants.DB_NAME)); + System.out.println("Query: " + query.toString()); + } + + List results = DirectDbQuery.executeQuery(query.toString(), + HydroConstants.IHFS, QueryLanguage.SQL); + + if ((results == null) || (results.size() == 0)) { + return returnList; + } + returnList.ensureCapacity(results.size()); + int i = 0; + for (Object[] item : results) { + i = 0; + Fcstheight fh = new Fcstheight(); + FcstheightId fhid = new FcstheightId(); + fhid.setLid((String) item[i++]); + fhid.setPe((String) item[i++]); + Integer in = (Integer) item[i++]; + fhid.setDur(in.shortValue()); + fhid.setTs((String) item[i++]); + fhid.setExtremum((String) item[i++]); + fhid.setProbability((Float) item[i++]); + fhid.setValidtime((Date) item[i++]); + fhid.setBasistime((Date) item[i++]); + fh.setId(fhid); + fh.setValue((Double) item[i++]); + fh.setShefQualCode((String) item[i++]); + fh.setQualityCode((Integer) item[i++]); + in = (Integer) item[i++]; + fh.setRevision(in.shortValue()); + fh.setProductId((String) item[i++]); + fh.setProducttime((Date) item[i++]); + fh.setPostingtime((Date) item[i++]); + + returnList.add(fh); + } + + return returnList; + } + + /** + * Insert/Update the forecast tables. + * + * @param dataObj + * The persistent data object to insert/update + * @return The number of objects inserted/updated + * @throws VizException + */ + public int putForecast(PersistableDataObject dataObj) throws VizException { + int rv = 0; + + rv = DirectDbQuery.saveOrUpdate(dataObj, HydroConstants.IHFS); + + return rv; + } + + /** + * Get the Use Latest Forecast flag from riverstat table. + * + * @param lid + * The location id + * @return The use latestes forecast flag, or null if nothing in db + */ + public String getUseLatestForecast(String lid) { + String useLatest = null; + + String query = "select use_latest_fcst from riverstat where lid = '" + + lid + "'"; + + ArrayList rs = runQuery(query); + + if ((rs != null) && (rs.size() > 0)) { + useLatest = (String) rs.get(0)[0]; + } + + return useLatest; + } + + /** + * Convert Timestamp object to java.util.Date object. + * + * @param timestamp + * The Timestamp to convert + * @return The Date object + */ + public Date timestampToDate(Timestamp timestamp) { + long milliseconds = timestamp.getTime();// + (timestamp.getNanos() / + // 1000000); + return new java.util.Date(milliseconds); + } + + /** + * Get the station display map. + * + * @return The map of station displays + */ + public Map getStationDisplayMap() { + return stnDisplayMap; + } } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java index d3de7f402a..ccfdfb4fd4 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java @@ -392,7 +392,6 @@ public class MPEDisplayManager { } return null; } - private final Set timeChangedListeners = new LinkedHashSet(); private final Set fieldChangedListeners = new LinkedHashSet(); @@ -707,7 +706,6 @@ public class MPEDisplayManager { // Remove old resource list.removeRsc(displayedFieldResource); } - fieldResourceData.setFieldData(fieldToDisplay); fieldResourceData.setArealDisplay(arealDisplay); fieldResourceData.setAccumulationInterval(accumulationHrs); @@ -725,7 +723,6 @@ public class MPEDisplayManager { listener.displayFieldChanged(oldField, fieldToDisplay); } } - // reset gages List rscs = display.getDescriptor() .getResourceList() diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java index a0cd17806b..c2fc4ef102 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java @@ -109,6 +109,8 @@ public class MPEGageResource extends AbstractMPEInputResource implements private static final double POINT_RADIUS = 2; + private static final RGB WHITE = new RGB(255, 255, 255); + private final SimpleDateFormat sdf; private final Object mutex = new Object(); @@ -361,7 +363,10 @@ public class MPEGageResource extends AbstractMPEInputResource implements for (Coordinate point : dataMap.keySet()) { if (extent.contains(new double[] { point.x, point.y })) { MPEGageData gageData = dataMap.get(point); - RGB gageColor = getGageColor(gageData); + RGB gageColor = WHITE; + if (displayIsEdit) { + gageColor = getGageColor(gageData); + } boolean isReportedMissing = gageData.isReported_missing(); boolean isMissing = ((gageData.getGval() == -999.f || gageData diff --git a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java index f22fd148cf..b61d296150 100644 --- a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java +++ b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java @@ -297,6 +297,7 @@ public class RegenHrFlds { e.printStackTrace(); } + /* Clear gage edits */ MPEDataManager.getInstance().clearEditGages(); shell.setCursor(null); } diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbAreaSourceDataAdaptor.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbAreaSourceDataAdaptor.java index f349ac8864..dad661e6c7 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbAreaSourceDataAdaptor.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbAreaSourceDataAdaptor.java @@ -39,6 +39,8 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; * ------------ ---------- ----------- -------------------------- * Sep 25, 2012 #15425 Qinglu Lin Updated createClosestPoint(). * Feb 13, 2012 1605 jsanchez Calculated the point based on lat,lon values. + * Mar 25, 2013 1810 jsanchez Allowed other values to be accepted as a true value for useDirs. + * Mar 25, 2013 1605 jsanchez Set ClosestPoint's prepGeom. * * * @@ -115,9 +117,10 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor { List partOfArea = getPartOfArea(ptFields, attributes, ptRslt.geometry); int gid = getGid(ptFields, attributes); - - return new ClosestPoint(name, point, population, warngenlev, + ClosestPoint cp = new ClosestPoint(name, point, population, warngenlev, partOfArea, gid); + cp.setPrepGeom(PreparedGeometryFactory.prepare(ptRslt.geometry)); + return cp; } /** @@ -156,8 +159,10 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor { Map attributes, Geometry geom) { List partOfArea = null; - boolean userDirections = Boolean.valueOf(String.valueOf(attributes - .get(useDirectionField))); + String userDir = String.valueOf(attributes.get(useDirectionField)) + .toLowerCase(); + boolean userDirections = Boolean.valueOf(userDir) + || userDir.equals("t") || userDir.equals("1"); if (userDirections) { PreparedGeometry prepGeom = PreparedGeometryFactory.prepare(geom); if (prepGeom.intersects(searchArea) && !prepGeom.within(searchArea)) { diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/ClosestPoint.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/ClosestPoint.java index e3fcb8ab00..1ef29c363f 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/ClosestPoint.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/ClosestPoint.java @@ -23,6 +23,7 @@ import java.util.Date; import java.util.List; import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.prep.PreparedGeometry; /** * @@ -40,6 +41,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Sep 25, 2012 #15425 Qinglu Lin Updated two ClosestPoint() and added getGid(). * Oct 17, 2012 jsanchez Added setter methods. * Feb 12, 2013 1600 jsanchez Removed adjustAngle method. + * Mar 25, 2013 1605 jsanchez Added prepGeom if an urban bound area. * * * @@ -77,6 +79,8 @@ public class ClosestPoint implements Comparable { protected int gid; + protected PreparedGeometry prepGeom; + public ClosestPoint() { } @@ -248,6 +252,10 @@ public class ClosestPoint implements Comparable { this.gid = gid; } + public void setPrepGeom(PreparedGeometry prepGeom) { + this.prepGeom = prepGeom; + } + /* * (non-Javadoc) * diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java index b99e4e5526..3c5636ad29 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java @@ -105,6 +105,7 @@ import com.vividsolutions.jts.geom.Point; * Jan 31, 2013 1557 jsanchez Used allowDuplicates flag to collect points with duplicate names. * Feb 12, 2013 1600 jsanchez Used adjustAngle method from AbstractStormTrackResource. * Mar 5, 2013 1600 jsanchez Used AdjustAngle instead of AbstractStormTrackResource to handle angle adjusting. + * Mar 25, 2013 1605 jsanchez Checks if a storm location is over an urban bound area. * * * @@ -722,6 +723,11 @@ public class Wx { latLonToLocal); double distance = localDistanceGeom.distance(localPt); + // Tests if storm location is over an urban bound area + if (cp.prepGeom != null + && cp.prepGeom.intersects(stormLocation)) { + distance = 0; + } if (distance <= thresholdInMeters) { if (allowDuplicates) { // collect all points that are within the threshold diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/AbstractLockingBehavior.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/AbstractLockingBehavior.java index b9149a023e..8379232b92 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/AbstractLockingBehavior.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/AbstractLockingBehavior.java @@ -53,7 +53,6 @@ import com.raytheon.viz.warngen.gis.AffectedAreas; * moved the following methods from InitialLockingBehavior to this class: * bulletIndices(), header(), firstBullet(), secondBullet(), getImmediateCausesPtrn(); * updated body(), header(), and secondBullet(); - * Mar 13, 2013 DR 15892 D. Friedman Fix bullet parsing. * * * @@ -142,13 +141,10 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns { private Integer[] bulletIndices() { List bulletIndices = new ArrayList(); - /* Assumes first line cannot be a bullet and that the '*' is - * at the start of a line. - */ - int index = text.indexOf("\n* "); + int index = text.indexOf("* "); while (index >= 0) { - bulletIndices.add(index + 1); - index = text.indexOf("\n* ", index + 3); + bulletIndices.add(index); + index = text.indexOf("* ", index + 2); } return bulletIndices.toArray(new Integer[bulletIndices.size()]); diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/FollowUpLockingBehavior.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/FollowUpLockingBehavior.java index 029573a5b0..a2783bc14c 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/FollowUpLockingBehavior.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/FollowUpLockingBehavior.java @@ -39,8 +39,6 @@ import com.raytheon.viz.warngen.gis.AffectedAreas; * ------------ ---------- ----------- -------------------------- * Sep 24, 2012 15322 jsanchez Initial creation * Jan 8, 2013 15664 Qinglu Lin Updated body(). - * Mar 13, 2013 15892 D. Friedman Fix headline locking. Do not - * lock "AND" or "FOR". * * * @@ -53,8 +51,10 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior { */ @Override public void body() { - headlines(); - super.body(); + if (action != WarningAction.COR) + headlines(); + else + super.body(); } /** @@ -66,7 +66,7 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior { // should be blank. Pattern headlinePtrn = Pattern .compile( - "^\\.\\.\\.(AN?|THE) (.*) (WARNING|ADVISORY) .*(REMAINS|EXPIRE|CANCELLED).*(\\.\\.\\.)$", + "^\\.\\.\\.(A|THE) (.*) (WARNING|ADVISORY) .*(REMAINS|EXPIRE|CANCELLED).*(\\.\\.\\.)$", Pattern.MULTILINE); Matcher m = headlinePtrn.matcher(text); @@ -187,8 +187,16 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior { + LOCK_START + "..." + LOCK_END; } // Locks warning type (i.e. SEVERE THUNDERSTORM) - headline = headline.replaceAll("(AN?|THE)( [\\w\\s]*?)(" + warningType + ")", - LOCK_START + "$1" + LOCK_END + "$2" + LOCK_START + "$3" + LOCK_END); + headline = headline.replaceAll("(A|THE) (" + warningType + ")", + LOCK_START + "$0" + LOCK_END); + + // Locks the 'FOR' in the headline + headline = headline.replaceFirst(" FOR ", " " + LOCK_START + "FOR" + + LOCK_END + " "); + + // Locks the 'AND' in the headline + headline = headline.replaceFirst(" AND ", " " + LOCK_START + "AND" + + LOCK_END + " "); return headline; } diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java index d56d3b0f2b..233810cd35 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/text/ICommonPatterns.java @@ -32,7 +32,6 @@ import java.util.regex.Pattern; * ------------ ---------- ----------- -------------------------- * Sep 24, 2012 15332 jsanchez Initial creation * Oct 18, 2012 15332 jsanchez Replaced listOfAreaNamesPtrn with String pattern. - * Mar 13, 2013 DR 15892 D. Friedman Allow some punctuation in area names. * * * @@ -56,7 +55,7 @@ public interface ICommonPatterns { // LOCK_END can be added at the start of the line if a previous line has // been locked. public static final String listOfAreaName = "^((" + LOCK_END - + "){0,1}((([\\?\\(\\)\\w\\.,/'-]+\\s{1})+\\w{2}-)*(([\\?\\(\\)\\w\\.,/'-]+\\s{1})+\\w{2}-)))"; + + "){0,1}(((\\w+\\s{1})+\\w{2}-)*((\\w+\\s{1})+\\w{2}-)))"; // LOCK_END should not be found at the beginning of a first bullet since the // previous line should be blank. diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FipsUtil.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FipsUtil.java index bb53428cc0..f15b8347e1 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FipsUtil.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FipsUtil.java @@ -346,7 +346,7 @@ public class FipsUtil { * @param fips * @return */ - public static ArrayList getListCounties(String fips) { + private static ArrayList getListCounties(String fips) { ArrayList rval = new ArrayList(); String matchStr = ""; diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java index e1e9949106..600c60c2de 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/util/FollowUpUtil.java @@ -28,7 +28,6 @@ import com.raytheon.viz.warngen.text.ICommonPatterns; * ------------ ---------- ----------- -------------------------- * Jul 22, 2008 #1284 bwoodle Initial creation * Oct 18, 2012 15332 jsanchez Fixed refactor bugs. - * Mar 13, 2013 DR 15892 D. Friedman Handle SMW format in canceledAreasFromText * * * @@ -44,8 +43,6 @@ public class FollowUpUtil { public static final Pattern vtecPtrn = Pattern .compile("/[OTEX]\\.([A-Z]{3})\\.[A-Za-z0-9]{4}\\.[A-Z]{2}\\.[WAYSFON]\\.\\d{4}\\.\\d{6}T\\d{4}Z-\\d{6}T\\d{4}Z/"); - private static final String SMW_CANCELED_AREAS_HEADER = "THE AFFECTED AREAS WERE..."; - /** * This method checks whether a particular followup should be available * given a Warning Record, a vtec Action, and a template configuration @@ -176,8 +173,7 @@ public class FollowUpUtil { String headline = ""; Pattern listOfAreaNamePtrn = Pattern .compile(ICommonPatterns.listOfAreaName); - String[] splitLines = originalText.trim().split("\n"); - for (String line : splitLines) { + for (String line : originalText.trim().split("\n")) { if (line.contains("TEST") || line.trim().length() == 0) { continue; } @@ -202,15 +198,8 @@ public class FollowUpUtil { headline += line; } } - String[] ugcs = FipsUtil.getListCounties(ugcLine).toArray(new String[0]); - String[] names; - boolean smwAreas = false; - if (namesLine.length() > 0) - names = namesLine.split("-"); - else { - names = parseSMWCanceledAreas(splitLines); - smwAreas = true; - } + String[] ugcs = ugcLine.split("-"); + String[] names = namesLine.split("-"); String[] areas = headline.split("\\.\\.\\."); ArrayList al = new ArrayList(); @@ -233,21 +222,13 @@ public class FollowUpUtil { areasNotation = "COUNTIES"; } } - - if (ugc.length() < 3) - continue; // TODO: log? fips = ugc.substring(ugc.length() - 3); if (i < names.length) { - if (!smwAreas && names[i].length() >= 3) { - name = names[i].substring(0, names[i].length() - 3); - stateAbbreviation = names[i].substring(names[i].length() - 2); - } else { - name = names[i]; - } - } else - break; + name = names[i].substring(0, names[i].length() - 3); + stateAbbreviation = names[i].substring(names[i].length() - 2); + } if (name != null) { for (String area : areas) { @@ -353,32 +334,4 @@ public class FollowUpUtil { return rval; } - - /** Parses the canceled areas of an SMW, which have a different format - * from other products. - */ - private static String[] parseSMWCanceledAreas(String[] splitLines) { - StringBuilder text = new StringBuilder(64); - boolean inAreas = false; - for (String line : splitLines) { - String trimmedLine = line.trim(); - if (SMW_CANCELED_AREAS_HEADER.equals(trimmedLine)) - inAreas = true; - else if (inAreas) { - if (trimmedLine.length() > 0) { - text.append(trimmedLine); - text.append('\n'); - } else - break; - } - } - int len = text.length(); - if (len >= 4 && "...\n".equals(text.substring(len - 4))) - text.delete(len - 4, len); - String[] areas = text.toString().split("\\.\\.\\.\\n"); - // Unwrap lines. - for (int i = 0; i < areas.length; ++i) - areas[i] = areas[i].replace("\n", " "); - return areas; - } } diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/VM_global_library.vm b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/VM_global_library.vm index 1a2cc5eb84..1ada94dece 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/VM_global_library.vm +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/VM_global_library.vm @@ -5,7 +5,6 @@ ##### Qinglu Lin 08-13-2012 DR 14493. Use corToNewMarker and corEventtime. ##### D. Friedman 11-09-2012 DR 15430. Rework included watches. ##### QINGLU LIN 12-27-2012 DR 15594. Added $lock to headlineLocList. -##### D. Friedman 03-13-2013 DR 15892. Do not lock portion of state in firstBullet. #################################################################################################### Mile Marker Test Code macro "mmarkers" use (called out of VM_global_library.vm): @@ -751,7 +750,7 @@ THE ${area.name}## #if(${intFIPS.parseInt($FIPS)} < 500 || ${area.stateabbr} == "TX") ${area.name} ${area.areaNotation} IN #areaFormat(${area.partOfParentRegion} true false) ${area.parentRegion}... #else -${area.name} IN #areaFormat(${area.partOfParentRegion} true false) ${area.parentRegion}... +${area.name} IN #areaFormat(${area.partOfParentRegion} true false) ${area.parentRegion}... #end #end ## COMMENTED OUT 5 LINES BELOW THIS IS GENERALLY NOT UTILIZED - you can unREMARK if desired diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/extremeWindWarningFollowup.vm b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/extremeWindWarningFollowup.vm index 58862f7b0d..f50dd40412 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/extremeWindWarningFollowup.vm +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/extremeWindWarningFollowup.vm @@ -4,7 +4,6 @@ ## Evan Bookbinder 4-25-2012 for OB 12.3.1 (corText) ## QINGLU LIN 7-31-2012 DR 15217 use roundAndPad ## Qinglu Lin 12-27-2012 DR 15594. Appended true to headlineLocList's parameter list. -## D. Friedman 03-13-2013 DR 15892. Use printcoords. ################################################ ## ### CREATE PHRASING DEPENDING ON WHETHER WE ISSUE EXP PRIOR TO EXPIRATION TIME OR NOT @@ -483,7 +482,10 @@ THIS IS A TEST MESSAGE.## THIS IS A TEST MESSAGE. DO NOT TAKE ACTION BASED ON THIS MESSAGE. #end -#printcoords(${areaPoly}, ${list}) +LAT...LON ## +#foreach(${coord} in ${areaPoly}) +#llFormat(${coord.y}) #llFormat(${coord.x}) ## +#end TIME...MOT...LOC ## ${dateUtil.format(${event}, ${timeFormat.time})}Z ## diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/significantWeatherAdvisory.vm b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/significantWeatherAdvisory.vm index afb5392f3f..bfab17d4a0 100644 --- a/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/significantWeatherAdvisory.vm +++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/warngen/significantWeatherAdvisory.vm @@ -8,7 +8,6 @@ ## Evan Bookbinder 4-25-2012 for OB 12.3.1 (MND) ## QINGLU LIN 7-31-2012 DR 15217 use roundAndPad ## ## Qinglu Lin 12-27-2012 DR 15594. Appended true to headlineLocList's parameter list. -## D. Friemdan 13-03-2013 DR 15892. Do not lock locations in headline. ###################################################### ## ##SET SOME INITIAL VARIABLES @@ -121,7 +120,7 @@ THIS IS A TEST MESSAGE. ## #end #if(${windSpeed} >= 40 || ${hailSize} >= 0.70) ...SIGNIFICANT WEATHER ADVISORY FOR ## -#headlineLocList(${areas} true false true false false) #secondBullet(${dateUtil},${expire},${timeFormat},${localtimezone},${secondtimezone}) +#headlineLocList(${areas} true false true false true) #secondBullet(${dateUtil},${expire},${timeFormat},${localtimezone},${secondtimezone}) ...## #elseif(${windSpeed} == 0 && ${hailSize} == 0) !** YOU DID NOT SELECT ANY WIND OR HAIL THREATS. PLEASE RE-GENERATE THIS ADVISORY **! diff --git a/edexOsgi/com.raytheon.edex.ingestsrv/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.ingestsrv/META-INF/MANIFEST.MF index 984896c3e4..a14fe72d67 100644 --- a/edexOsgi/com.raytheon.edex.ingestsrv/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.ingestsrv/META-INF/MANIFEST.MF @@ -11,4 +11,5 @@ Require-Bundle: com.raytheon.edex.common, Export-Package: com.raytheon.edex.services Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.raytheon.uf.edex.core, + com.raytheon.uf.common.status, com.raytheon.uf.edex.database.plugin diff --git a/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/IndexSrv.java b/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/IndexSrv.java index f1bccbf1cb..e0f678e18d 100644 --- a/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/IndexSrv.java +++ b/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/IndexSrv.java @@ -25,6 +25,10 @@ import org.apache.commons.logging.LogFactory; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginException; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.database.plugin.PluginDao; import com.raytheon.uf.edex.database.plugin.PluginFactory; @@ -36,10 +40,11 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * fgriffit Initial Creation. - * 20080408 1039 jkorman Added traceId for tracing data. - * Nov 11, 2008 chammack Refactored for Camel - * 02/06/09 1990 bphillip Refactored to use plugin daos + * fgriffit Initial Creation. + * 20080408 1039 jkorman Added traceId for tracing data. + * Nov 11, 2008 chammack Refactored for Camel + * 02/06/09 1990 bphillip Refactored to use plugin daos + * Mar 19, 2013 1785 bgonzale Added performance status to indexOne and index. * * * @author Frank Griffith @@ -53,6 +58,9 @@ public class IndexSrv { private Log logger = LogFactory.getLog(getClass()); + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("DataBase:"); + /** The default constructor */ public IndexSrv() { } @@ -73,9 +81,14 @@ public class IndexSrv { */ public PluginDataObject indexOne(PluginDataObject record) throws PluginException { - PluginDao dao = PluginFactory.getInstance().getPluginDao( - record.getPluginName()); + String pluginName = record.getPluginName(); + PluginDao dao = PluginFactory.getInstance().getPluginDao(pluginName); + ITimer timer = TimeUtil.getTimer(); + timer.start(); dao.persistToDatabase(record); + timer.stop(); + perfLog.logDuration(pluginName + ": Saved a record: Time to Save", + timer.getElapsedTime()); if (logger.isDebugEnabled()) { logger.debug("Persisted: " + record + " to database"); } @@ -100,10 +113,16 @@ public class IndexSrv { } try { - PluginDao dao = PluginFactory.getInstance().getPluginDao( - record[0].getPluginName()); + String pluginName = record[0].getPluginName(); + PluginDao dao = PluginFactory.getInstance().getPluginDao(pluginName); EDEXUtil.checkPersistenceTimes(record); + ITimer timer = TimeUtil.getTimer(); + timer.start(); PluginDataObject[] persisted = dao.persistToDatabase(record); + timer.stop(); + perfLog.logDuration(pluginName + ": Saved " + persisted.length + + " record(s): Time to Save", + timer.getElapsedTime()); if (logger.isDebugEnabled()) { for (PluginDataObject rec : record) { logger.debug("Persisted: " + rec + " to database"); diff --git a/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/PersistSrv.java b/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/PersistSrv.java index e8378306bf..0e4cc8f3e8 100644 --- a/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/PersistSrv.java +++ b/edexOsgi/com.raytheon.edex.ingestsrv/src/com/raytheon/edex/services/PersistSrv.java @@ -33,6 +33,10 @@ import com.raytheon.uf.common.datastorage.DuplicateRecordStorageException; import com.raytheon.uf.common.datastorage.StorageException; import com.raytheon.uf.common.datastorage.StorageStatus; import com.raytheon.uf.common.datastorage.records.IDataRecord; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.database.plugin.PluginDao; import com.raytheon.uf.edex.database.plugin.PluginFactory; @@ -44,9 +48,10 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Oct 31, 2008 chammack Initial creation + * Oct 31, 2008 chammack Initial creation * 02/06/09 1990 bphillip Refactored to use plugin specific daos * Nov 02, 2012 1302 djohnson Remove unused method, fix formatting. + * Mar 19, 2013 1785 bgonzale Added performance status to persist. * * * @author chammack @@ -62,6 +67,9 @@ public class PersistSrv { return instance; } + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("HDF5:"); + private PersistSrv() { } @@ -75,9 +83,16 @@ public class PersistSrv { EDEXUtil.checkPersistenceTimes(pdo); try { - PluginDao dao = PluginFactory.getInstance().getPluginDao( - pdo[0].getPluginName()); + String pluginName = pdo[0].getPluginName(); + PluginDao dao = PluginFactory.getInstance() + .getPluginDao(pluginName); + ITimer timer = TimeUtil.getTimer(); + timer.start(); StorageStatus ss = dao.persistToHDF5(pdo); + timer.stop(); + perfLog.logDuration(pluginName + ": Persisted " + pdo.length + + " record(s): Time to Persist", + timer.getElapsedTime()); StorageException[] se = ss.getExceptions(); pdoList.addAll(Arrays.asList(pdo)); if (se != null) { diff --git a/edexOsgi/com.raytheon.edex.plugin.bufrua/src/com/raytheon/edex/plugin/bufrua/BufrUADecoder.java b/edexOsgi/com.raytheon.edex.plugin.bufrua/src/com/raytheon/edex/plugin/bufrua/BufrUADecoder.java index 6c04c47ae0..2bec65d39d 100644 --- a/edexOsgi/com.raytheon.edex.plugin.bufrua/src/com/raytheon/edex/plugin/bufrua/BufrUADecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.bufrua/src/com/raytheon/edex/plugin/bufrua/BufrUADecoder.java @@ -37,6 +37,10 @@ import com.raytheon.uf.common.pointdata.PointDataDescription; import com.raytheon.uf.common.pointdata.PointDataView; import com.raytheon.uf.common.pointdata.spatial.ObStation; import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.bufrtools.AbstractBUFRDecoder; import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument; @@ -73,6 +77,8 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; * 20080408 1039 jkorman Added traceId for tracing data. * 11/25/08 #1684 chammack Camel Refactor * Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin + * Mar 19, 2013 1785 bgonzale Added performance status handler and added status + * to decodeData. * * * @author jkorman @@ -87,6 +93,9 @@ public class BufrUADecoder extends AbstractBUFRDecoder { private BUFRUAAdapterFactory adapterFactory; + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("BufrUA:"); + /** * * @param name @@ -128,7 +137,9 @@ public class BufrUADecoder extends AbstractBUFRDecoder { Iterator iterator = document.iterator(); String cor = isCor(wmoHeader); + ITimer timer = TimeUtil.getTimer(); + timer.start(); while (iterator.hasNext()) { logger.debug("Decoding one BUFRDataDocument"); @@ -152,6 +163,8 @@ public class BufrUADecoder extends AbstractBUFRDecoder { } } } + timer.stop(); + perfLog.logDuration("Time to Decode", timer.getElapsedTime()); } return decodedData; } diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.plugin.gfe/META-INF/MANIFEST.MF index 4c23760c26..ea4ea388a9 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/META-INF/MANIFEST.MF @@ -28,6 +28,7 @@ Require-Bundle: com.raytheon.uf.common.dataplugin.gfe;bundle-version="1.12.1174" com.raytheon.uf.common.dataplugin.grid;bundle-version="1.0.0", com.raytheon.uf.common.util;bundle-version="1.12.1174", com.google.guava;bundle-version="1.0.0", + org.apache.commons.lang;bundle-version="2.3.0" com.raytheon.uf.common.python.concurrent;bundle-version="1.0.0" Export-Package: com.raytheon.edex.plugin.gfe, com.raytheon.edex.plugin.gfe.config, diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/svcbu/ImportConfRequestHandler.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/svcbu/ImportConfRequestHandler.java index f30eb6bbf4..3462bbf8c3 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/svcbu/ImportConfRequestHandler.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/svcbu/ImportConfRequestHandler.java @@ -19,6 +19,8 @@ **/ package com.raytheon.edex.plugin.gfe.server.handler.svcbu; +import org.apache.commons.lang.BooleanUtils; + import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil; import com.raytheon.uf.common.dataplugin.gfe.request.ImportConfRequest; import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; @@ -33,7 +35,9 @@ import com.raytheon.uf.common.serialization.comm.IRequestHandler; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Aug 4, 2011 bphillip Initial creation + * Aug 04, 2011 bphillip Initial creation + * Mar 20, 2013 1447 dgilling Support troubleshooting mode + * added to match A1 DR 21404. * * * @@ -49,7 +53,8 @@ public class ImportConfRequestHandler implements ServerResponse sr = new ServerResponse(); SvcBackupUtil.execute("request_configuration", request.getPrimarySite() - .toLowerCase(), request.getFailedSite().toLowerCase()); + .toLowerCase(), request.getFailedSite().toLowerCase(), Integer + .toString(BooleanUtils.toInteger(request.isTrMode()))); return sr; } } diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/GribDecoder.py b/edexOsgi/com.raytheon.edex.plugin.grib/GribDecoder.py index 9da78b1cab..4c979a433a 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/GribDecoder.py +++ b/edexOsgi/com.raytheon.edex.plugin.grib/GribDecoder.py @@ -129,6 +129,8 @@ THINNED_GRID_VALUES = THINNED_GRID_PT_MAP.values() # Date Ticket# Engineer Description # ------------ ---------- ----------- -------------------------- # 04/7/09 #1994 bphillip Initial Creation. +# Mar 25, 2013 1821 bsteffen Reshape grib data arrays in +# place to improve performance. # class GribDecoder(): @@ -327,7 +329,7 @@ class GribDecoder(): if scanMode is not None: if not thinnedGrid: - numpyDataArray = numpy.resize(data, (ny, nx)) + numpyDataArray = numpy.reshape(data, (ny, nx)) # Check if rows are scanned in opposite direction. If so, we need to flip them around if scanMode & 16 == 16: @@ -373,7 +375,7 @@ class GribDecoder(): if subCoverage is not None: subGrid = spatialCache.getSubGrid(modelName, gridCoverage) # resize the data array - numpyDataArray = numpy.resize(numpyDataArray, (ny, nx)) + numpyDataArray = numpy.reshape(numpyDataArray, (ny, nx)) startx = subGrid.getUpperLeftX() starty = subGrid.getUpperLeftY() subnx = subGrid.getNX() @@ -399,7 +401,7 @@ class GribDecoder(): # set the new coverage gdsSectionValues['coverage'] = subCoverage - numpyDataArray = numpy.resize(numpyDataArray, (1, metadata[4])) + numpyDataArray = numpy.reshape(numpyDataArray, (1, metadata[4])) newAbbr = GribParamTranslator.getInstance().translateParameter(2, pdsSectionValues['parameterAbbreviation'], pdsSectionValues['centerid'], pdsSectionValues['subcenterid'], pdsSectionValues['genprocess'], dataTime, gridCoverage) diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java index ba9de0e745..59b58a9d80 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.grib/src/com/raytheon/edex/plugin/grib/GribDecoder.java @@ -33,9 +33,13 @@ import com.raytheon.edex.plugin.grib.exception.GribException; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.grid.GridRecord; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.python.decoder.PythonDecoder; /** @@ -47,6 +51,8 @@ import com.raytheon.uf.edex.python.decoder.PythonDecoder; * ------------ ---------- ----------- -------------------------- * 3/12/10 4758 bphillip Initial creation * 02/12/2013 1615 bgonzale public decode method to a Processor exchange method. + * Mar 19, 2013 1785 bgonzale Added performance status handler and added status + * to process. * * * @author njensen @@ -57,6 +63,11 @@ public class GribDecoder implements Processor { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(GribDecoder.class); + private static final String[] DecoderNames = { "Grib1", "Grib2" }; + + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler(""); + /** * @see org.apache.camel.Processor.process(Exchange) */ @@ -72,16 +83,22 @@ public class GribDecoder implements Processor { int edition = 0; GridRecord[] records = null; try { + ITimer timer = TimeUtil.getTimer(); + String decoderName; + raf = new RandomAccessFile(file.getAbsolutePath(), "r"); raf.order(RandomAccessFile.BIG_ENDIAN); edition = GribChecker.getEdition(raf); exchange.getIn().setHeader(DATA_TYPE, GRIB + edition); + timer.start(); switch (edition) { case 1: + decoderName = DecoderNames[0]; records = new Grib1Decoder().decode(file.getAbsolutePath()); break; case 2: + decoderName = DecoderNames[1]; records = decodeGrib2(file); break; default: @@ -108,6 +125,9 @@ public class GribDecoder implements Processor { record.constructDataURI(); } } + timer.stop(); + perfLog.logDuration(decoderName + ": Time to Decode", + timer.getElapsedTime()); } catch (Exception e) { statusHandler.handle(Priority.ERROR, "Failed to decode file: [" + file.getAbsolutePath() + "]", e); diff --git a/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/ObsDecoder.java b/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/ObsDecoder.java index fb59e60e91..d6b488f34c 100644 --- a/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/ObsDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/ObsDecoder.java @@ -26,17 +26,19 @@ package com.raytheon.edex.plugin.obs; * *
  *                     
- * OFTWARE HISTORY
- *                     
- * ate          Ticket#     Engineer    Description
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#     Engineer    Description
  * -----------  ----------  ----------- --------------------------
- * 4/27/07      199         bphillip    Initial creation                     
+ * 4/27/07      199         bphillip    Initial creation
  * 07/31/2007          411  jkorman     Added addition logging
  * 08/10/2007          379  jkorman     Added disposal behavior.
  * 20071217            453  jkorman     Added code to check for duplicate obs.
  * 20080314            995  jkorman     Changed setDecoderStrategy to check for
  *                                      empty data.
- * 20080408           1039 jkorman     Added traceId for tracing data.  
+ * 20080408           1039  jkorman     Added traceId for tracing data.  
+ * Mar 19, 2013       1785  bgonzale    Added performance status handler and added
+ *                                      status to decode.
  * 
* * @author bphillip @@ -50,6 +52,10 @@ import com.raytheon.edex.exception.DecoderException; import com.raytheon.edex.plugin.AbstractDecoder; import com.raytheon.edex.plugin.obs.metar.MetarDecoder; import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.wmo.message.WMOHeader; public class ObsDecoder extends AbstractDecoder { @@ -58,6 +64,9 @@ public class ObsDecoder extends AbstractDecoder { private final String PLUGIN_NAME; + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("Obs:"); + private String traceId = null; /** @@ -84,6 +93,8 @@ public class ObsDecoder extends AbstractDecoder { try { if (decoder != null) { + ITimer timer = TimeUtil.getTimer(); + timer.start(); reports = decoder.decode(data, headers); if (reports != null) { @@ -91,6 +102,8 @@ public class ObsDecoder extends AbstractDecoder { report.setTraceId(traceId); } } + timer.stop(); + perfLog.logDuration("Time to Decode", timer.getElapsedTime()); } } catch (Exception e) { logger.error(traceId + "- Error in ObsDecoder", e); diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/RadarDecoder.java b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/RadarDecoder.java index d62c704a9b..fddb62a83a 100644 --- a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/RadarDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/RadarDecoder.java @@ -65,10 +65,14 @@ import com.raytheon.uf.common.dataplugin.radar.util.TiltAngleBin; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.core.EDEXUtil; import com.raytheon.uf.edex.database.cluster.ClusterLockUtils; import com.raytheon.uf.edex.database.cluster.ClusterTask; @@ -87,7 +91,8 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; * Dec 17, 2007 600 bphillip Added dao pool usage * Dec 03, 2010 2235 cjeanbap EDEXUtility.sendMessageAlertViz() signature changed. * Mar 19, 2013 1804 bsteffen Optimize decoder performance. - * + * Mar 19, 2013 1785 bgonzale Added performance status handler and added status + * to decode. * * * @author bphillip @@ -131,6 +136,9 @@ public class RadarDecoder extends AbstractDecoder { private final String RADAR = "RADAR"; + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("Radar:"); + public RadarDecoder() throws DecoderException { String dir = ""; @@ -170,6 +178,9 @@ public class RadarDecoder extends AbstractDecoder { // decode the product String arch = new String(messageData, 0, 4); try { + ITimer timer = TimeUtil.getTimer(); + + timer.start(); // for level2 data, this does not happen very often if (LEVEL_TWO_IDENTS.contains(arch)) { decodeLevelTwoData(messageData, recordList); @@ -421,8 +432,11 @@ public class RadarDecoder extends AbstractDecoder { logger.error(e); return new PluginDataObject[0]; } - recordList.add(record); + timer.stop(); + perfLog.logDuration("Time to Decode", timer.getElapsedTime()); + + recordList.add(record); } } catch (Exception e) { theHandler.handle(Priority.ERROR, "Couldn't properly handle " diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/RadarDecompressor.java b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/RadarDecompressor.java index 2e990fb88c..24c4b13a74 100644 --- a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/RadarDecompressor.java +++ b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/RadarDecompressor.java @@ -19,11 +19,6 @@ **/ package com.raytheon.edex.plugin.radar; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.DataFormatException; @@ -45,6 +40,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * ------------ ---------- ----------- -------------------------- * Nov 11, 2010 mnash Initial creation * Jul 16, 2012 DR 14723 D.Friedman Decompress files atomically + * Mar 20, 2013 1804 bsteffen Switch all radar decompressing to be in + * memory. * * * @@ -66,6 +63,24 @@ public class RadarDecompressor { .compile("([A-Z]{4}[0-9]{2} [A-Z]{4} [0-9]{6})\\x0D\\x0D\\x0A(\\w{6})\\x0D\\x0D\\x0A"); public byte[] decompress(byte[] messageData, Headers headers) { + return decompressImpl(messageData, headers, false); + } + + public byte[] decompressWithHeader(byte[] messageData, Headers headers) { + return decompressImpl(messageData, headers, true); + } + + /** + * decompress the radar data in messageData. + * + * @param messageData + * @param headers + * @param keepHeader + * If true, keep any WMO/AWIPS heading found in file + * @return + */ + public byte[] decompressImpl(byte[] messageData, Headers headers, + boolean keepHeader) { byte[] radarData = null; try { int wmoHeaderSize; @@ -79,10 +94,23 @@ public class RadarDecompressor { if (isCompressed(messageData, wmoHeaderSize)) { radarData = decompressRadar(messageData, wmoHeaderSize, headers); - } else { + if (keepHeader) { + // put the header back on. + byte[] radarDataWithHeader = new byte[radarData.length + + wmoHeaderSize]; + System.arraycopy(messageData, 0, radarDataWithHeader, 0, + wmoHeaderSize); + System.arraycopy(radarData, 0, radarDataWithHeader, + wmoHeaderSize, radarData.length); + radarData = radarDataWithHeader; + } + } else if (!keepHeader && wmoHeaderSize > 0) { + // strip the header. radarData = new byte[messageData.length - wmoHeaderSize]; System.arraycopy(messageData, wmoHeaderSize, radarData, 0, radarData.length); + } else { + radarData = messageData; } } catch (Exception e) { theHandler.handle(Priority.ERROR, "Failed decompression on " @@ -124,106 +152,6 @@ public class RadarDecompressor { return false; } - /** - * Decompress file atomically. - * - * @param file - * @param headers - * @param keepHeader If true, keep any WMO/AWIPS heading found in file - * @return - */ - private File decompressToFileImpl(File file, Headers headers, boolean keepHeader) { - byte[] messageData = null; - FileInputStream input = null; - - try { - input = new FileInputStream(file); - int fileSize = (int) input.getChannel().size(); - messageData = new byte[fileSize]; - input.read(messageData); - } catch (FileNotFoundException e) { - theHandler.handle(Priority.ERROR, e.getMessage()); - } catch (IOException e) { - theHandler.handle(Priority.ERROR, e.getMessage()); - } finally { - if (input != null) { - try { - input.close(); - } catch (IOException e) { - theHandler.handle(Priority.ERROR, e.getMessage()); - } - } - } - - /* - * TODO: If reading fails, the code below will NPE. Is this - * done intentionally to stop processing? - */ - - String headerSearch = ""; - int start = 0; - if (messageData.length < 80) { - } else { - // skip the WMO header if any - headerSearch = new String(messageData, 0, 80); - start = findStartRadarData(headerSearch); - headerSearch = headerSearch.substring(0, start); - } - - messageData = decompress(messageData, headers); - - FileOutputStream output = null; - File tmpFile = null; - try { - tmpFile = File.createTempFile(file.getName() + ".", ".decompress", file.getParentFile()); - output = new FileOutputStream(tmpFile); - if (keepHeader) - output.write(headerSearch.getBytes()); - output.write(messageData); - output.close(); - output = null; - if (tmpFile.renameTo(file)) - tmpFile = null; - else - theHandler.handle(Priority.ERROR, - String.format("Cannot rename %s to %s", tmpFile, file)); - } catch (IOException e) { - theHandler.handle(Priority.ERROR, e.getMessage()); - } finally { - if (output != null) - try { - output.close(); - } catch (IOException e) { - theHandler.handle(Priority.ERROR, "error closing file", e); - } - if (tmpFile != null) - tmpFile.delete(); - } - return file; - } - - /** - * Used for things that need to write the data back out to a file - * - * @param messageData - * @return - */ - public File decompressToFile(File file, Headers headers) { - return decompressToFileImpl(file, headers, true); - } - - /** - * Used for things that need to write the data back out to a file, without a - * header. Same as decompressToFile, but will strip the header off before - * writing it back out. - * - * @param messageData - * @return - */ - public File decompressToFileWithoutHeader(File file, Headers headers) { - return decompressToFileImpl(file, headers, false); - } - private int findStartRadarData(String headerInfo) { int startOfRadarData = 0; Matcher matcher = WMO_PATTERN.matcher(headerInfo); diff --git a/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/RedbookDecoder.java b/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/RedbookDecoder.java index 1fd24999c7..3320f76d14 100644 --- a/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/RedbookDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.redbook/src/com/raytheon/edex/plugin/redbook/RedbookDecoder.java @@ -30,6 +30,10 @@ import com.raytheon.edex.plugin.redbook.dao.RedbookDao; import com.raytheon.edex.plugin.redbook.decoder.RedbookParser; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginException; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.database.plugin.PluginFactory; import com.raytheon.uf.edex.wmo.message.WMOHeader; @@ -49,6 +53,8 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; * 20090327 2019 jkorman Added code to check for non-redbook data. * 20120524 #647 dgilling Update persistence time in * createdBackDatedVersionIfNeeded. + * Mar 19, 2013 1785 bgonzale Added performance status handler and added + * status to decode. * * * @author jkorman @@ -79,13 +85,16 @@ public class RedbookDecoder extends AbstractDecoder { private static final String GIF87A_SIG = "GIF87a"; - private static final String GIF89A_SIG = "GIF89a"; + // This sig is currently not used. + // private static final String GIF89A_SIG = "GIF89a"; private static final String DIFAX_SIG = "DFAX"; // Name of the plugin controlling this decoder. private final String PLUGIN_NAME; + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("Redbook:"); private String traceId = null; /** @@ -117,6 +126,9 @@ public class RedbookDecoder extends AbstractDecoder { WMOHeader wmoHeader = new WMOHeader(rawMessage, headers); if (wmoHeader.isValid()) { + ITimer timer = TimeUtil.getTimer(); + timer.start(); + int start = wmoHeader.getMessageDataStart(); int len = rawMessage.length - start; @@ -145,6 +157,8 @@ public class RedbookDecoder extends AbstractDecoder { e); } } + timer.stop(); + perfLog.logDuration("Time to Decode", timer.getElapsedTime()); } else { logger.error(traceId + "- No valid WMO header found in data."); } diff --git a/edexOsgi/com.raytheon.edex.plugin.satellite/src/com/raytheon/edex/plugin/satellite/SatelliteDecoder.java b/edexOsgi/com.raytheon.edex.plugin.satellite/src/com/raytheon/edex/plugin/satellite/SatelliteDecoder.java index 2eea5d5684..55827a56ef 100644 --- a/edexOsgi/com.raytheon.edex.plugin.satellite/src/com/raytheon/edex/plugin/satellite/SatelliteDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.satellite/src/com/raytheon/edex/plugin/satellite/SatelliteDecoder.java @@ -43,8 +43,12 @@ import com.raytheon.uf.common.dataplugin.satellite.SatMapCoverage; import com.raytheon.uf.common.dataplugin.satellite.SatelliteMessageData; import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.util.ArraysUtil; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.decodertools.time.TimeTools; import com.raytheon.uf.edex.wmo.message.WMOHeader; @@ -53,15 +57,15 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; * *
  * 
- * OFTWARE HISTORY
- *                   
+ * SOFTWARE HISTORY
+ * 
  * Date         Ticket#     Engineer    Description
  * -----------  ----------  ----------- --------------------------
  * 006                      garmenda    Initial Creation
  * /14/2007     139         Phillippe   Modified to follow refactored plugin pattern
  * 8/30/07                  njensen     Added units, commented out data that
- *                                      is currently decoded but not used.    
- * 12/01/07     555         garmendariz Modified decompress method.     
+ *                                      is currently decoded but not used.
+ * 12/01/07     555         garmendariz Modified decompress method.
  * 12/06/07     555         garmendariz Modifed start point to remove satellite header
  * Dec 17, 2007 600         bphillip    Added dao pool usage
  * 04Apr2008    1068        MW Fegan    Modified decompression routine to prevent
@@ -69,13 +73,16 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
  * 11/11/2008               chammack    Refactored to be thread safe in camel
  * 02/05/2010   4120        jkorman     Modified removeWmoHeader to handle WMOHeader in
  *                                      various start locations.
- * 04/17/2012  14724        kshresth    This is a temporary workaround - Projection off CONUS                                    
+ * 04/17/2012  14724        kshresth    This is a temporary workaround - Projection off CONUS
  * - AWIPS2 Baseline Repository --------
  * 06/27/2012    798        jkorman     Using SatelliteMessageData to "carry" the decoded image.
  * 01/03/2013  15294        D. Friedman Start with File instead of byte[] to
  *                                      reduce memory usage.
  * Feb 15, 2013 1638        mschenke    Moved array based utilities from Util into ArraysUtil
  *
+ * Mar 19, 2013 1785        bgonzale    Added performance status handler and added status
+ *                                      to decode.
+ * 
  * 
* * @author bphillip @@ -93,6 +100,9 @@ public class SatelliteDecoder extends AbstractDecoder { private static final int INITIAL_READ = GINI_HEADER_SIZE + 128; + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("Satellite:"); + private SatelliteDao dao; public PluginDataObject[] decode(File file) throws Exception { @@ -105,6 +115,8 @@ public class SatelliteDecoder extends AbstractDecoder { return new PluginDataObject[0]; RandomAccessFile f = new RandomAccessFile(file, "r"); try { + ITimer timer = TimeUtil.getTimer(); + timer.start(); // Read in enough data to cover the WMO heading and GINI header. ByteBuffer byteBuffer = ByteBuffer.allocate(INITIAL_READ); f.getChannel().read(byteBuffer); @@ -429,6 +441,8 @@ public class SatelliteDecoder extends AbstractDecoder { record.setMessageData(dataRec); } } + timer.stop(); + perfLog.logDuration("Time to Decode", timer.getElapsedTime()); } finally { try { f.close(); diff --git a/edexOsgi/com.raytheon.edex.plugin.sfcobs/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.plugin.sfcobs/META-INF/MANIFEST.MF index d43c73a557..2bab9ddc40 100644 --- a/edexOsgi/com.raytheon.edex.plugin.sfcobs/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.plugin.sfcobs/META-INF/MANIFEST.MF @@ -6,7 +6,6 @@ Bundle-Version: 1.12.1174.qualifier Eclipse-RegisterBuddy: com.raytheon.edex.common, com.raytheon.uf.common.serialization Bundle-Vendor: RAYTHEON Require-Bundle: com.raytheon.edex.common, - com.raytheon.uf.edex.pointdata, com.raytheon.uf.edex.decodertools;bundle-version="1.0.0", org.apache.commons.logging, org.geotools, @@ -15,4 +14,8 @@ Require-Bundle: com.raytheon.edex.common, Export-Package: com.raytheon.edex.plugin.sfcobs.common Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Import-Package: com.raytheon.uf.common.dataplugin.sfcobs, - com.raytheon.uf.common.dataplugin.sfcobs.dao + com.raytheon.uf.common.dataplugin.sfcobs.dao, + com.raytheon.uf.common.pointdata, + com.raytheon.uf.common.pointdata.spatial, + com.raytheon.uf.edex.pointdata, + com.raytheon.uf.common.status diff --git a/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/SfcObsDecoder.java b/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/SfcObsDecoder.java index 543faa0719..7d67020f90 100644 --- a/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/SfcObsDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.sfcobs/src/com/raytheon/edex/plugin/sfcobs/SfcObsDecoder.java @@ -35,6 +35,10 @@ import com.raytheon.edex.plugin.sfcobs.decoder.SfcObsDecoderFactory; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.decodertools.core.DecoderTools; import com.raytheon.uf.edex.decodertools.time.TimeTools; import com.raytheon.uf.edex.wmo.message.WMOHeader; @@ -66,6 +70,8 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; * time in the future. * 20080215 887 jkorman Added null checks in decode. * 20080218 887 jkorman Reverse null checks in findDuplicate. + * Mar 19, 2013 1785 bgonzale Added performance status handler and added status + * to decode. * * * @author jkorman @@ -77,6 +83,9 @@ public class SfcObsDecoder extends AbstractDecoder { // Name of the plugin controlling this decoder. public static final String PLUGIN_NAME = "sfcobs"; + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("SfcObs:"); + /** The logger */ private Log logger = LogFactory.getLog(getClass()); @@ -124,6 +133,9 @@ public class SfcObsDecoder extends AbstractDecoder { SfcObsSeparator separator = SfcObsSeparator.separate(data, headers); List retVal = new ArrayList(); HashMap obsMap = new HashMap(); + ITimer timer = TimeUtil.getTimer(); + + timer.start(); while (separator.hasNext()) { SfcObsDecoderInput input = separator.next(); PluginDataObject report = null; @@ -169,7 +181,8 @@ public class SfcObsDecoder extends AbstractDecoder { } } } - + timer.stop(); + perfLog.logDuration("Time to Decode", timer.getElapsedTime()); return retVal.toArray(new PluginDataObject[retVal.size()]); } diff --git a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/database/PostShef.java b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/database/PostShef.java index e1b9239756..08af0a5363 100644 --- a/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/database/PostShef.java +++ b/edexOsgi/com.raytheon.edex.plugin.shef/src/com/raytheon/edex/plugin/shef/database/PostShef.java @@ -105,6 +105,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools; * 05/28/2009 2410 J. Sanchez Posted data for unknstnvalue. * 12/11/2009 2488 M. Duff Fixed problem with storing text products. * 03/07/2013 15545 w. kwock Added Observe time to log + * 03/21/2013 15967 w. kwock Fix the error in buildTsFcstRiv riverstatus table issue * * * @@ -1551,8 +1552,8 @@ public class PostShef { shefDataValue.setCreationDateObj(fcstHead[y].getId() .getBasistime()); shefDataValue.setValue(fcstHead[y].getValue()); - } - shefList.add(shefDataValue); + shefList.add(shefDataValue); + } } } catch (Exception e) { log.error("Query = [" + query + "]"); @@ -1707,8 +1708,7 @@ public class PostShef { for (int i = 0; i < ulCount; i++) { tsFirstChk[i] = 0; } - - Timestamp[] row = null; + Timestamp row = null; Timestamp validTime = null; for (int i = 0; i < fcstCount; i++) { @@ -1720,8 +1720,8 @@ public class PostShef { basisIndex[i] = MISSING; for (int j = 0; ((j < ulCount) && (basisIndex[i] == MISSING)); j++) { - row = (Timestamp[]) ulHead[j]; - ulBasisTime = row[j]; + row = (Timestamp) ulHead[j]; + ulBasisTime = row; if (ulBasisTime.compareTo(fcstBasisTime) == 0) { basisIndex[i] = j; @@ -1759,8 +1759,8 @@ public class PostShef { */ for (int j = 0; j < ulCount; j++) { - row = (Timestamp[]) ulHead[j]; - basisTime[j] = row[j]; + row = (Timestamp) ulHead[j]; + basisTime[j] = row; } /* diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java index 6c8143b151..77f94d918d 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPTemplates.java @@ -85,6 +85,7 @@ import com.vividsolutions.jts.io.WKBReader; * 02/01/13 1569 D.Hladky Constants * 03/01/13 DR13228 G. Zhang Add VGB county and related code * 02/20/13 1635 D. Hladky Constants + * 03/18/13 1817 D. Hladky Fixed issue with BOX where only 1 HUC was showing up. * * * @author dhladky @@ -250,11 +251,35 @@ public class FFMPTemplates { "No configuration file found, default settings applied"); // we use 4 because it is the 90% solution as a start point for - // the analysis - ArrayList hucParams = FFMPUtils.getHucParameters(4, + // the analysis. Added check to make sure at least 2 HUC layers are created. + int preliminarystart = 4; + // first crack + ArrayList hucParams = FFMPUtils.getHucParameters(preliminarystart, primaryCWA.getCwa()); - setHucDepthStart(hucParams.get(0)); - setTotalHucLevels(hucParams.get(1)); + int startDepth = hucParams.get(0); + int numlevels = hucParams.get(1); + int i = 1; + // recursively call until we have two layers + while (numlevels < 2) { + int checkDepth = preliminarystart - i; + hucParams = FFMPUtils.getHucParameters(checkDepth, + primaryCWA.getCwa()); + startDepth = hucParams.get(0); + numlevels = hucParams.get(1); + i++; + + // safety value in case it just won't work with this shape + if (checkDepth == 0) { + // bail, won't work + statusHandler + .handle(Priority.ERROR, + "Cannot create a good template. There are not enough unique HUC's to create more than 1 layer."); + return; + } + } + + setHucDepthStart(startDepth); + setTotalHucLevels(numlevels); setExtents(20000.0); setVirtual(true); diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPUtils.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPUtils.java index 0f60283353..9f98071a4b 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPUtils.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPUtils.java @@ -83,6 +83,7 @@ import com.vividsolutions.jts.io.WKTWriter; * 06/18/12 DR 15108 G. Zhang Fix County FIPS 4-digit issue * 01/02/13 DR 1569 D. Hladky constants, arraylist to list and moved common menthods here * 03/01/13 DR 13228 G. Zhang Add state for VGB query and related code + * 03/18/13 1817 D. Hladky Fixed issue with BOX where only 1 HUC was showing up. * * @author dhladky * @version 1 @@ -304,18 +305,20 @@ public class FFMPUtils { int startDepth = prelimstartDepth; for (int i = 0; i < pfafs.length; i++) { - int depth = pfafs[i].indexOf("0"); + int depth = pfafs[i].substring(prelimstartDepth).indexOf("0"); + depth = prelimstartDepth + depth; if (depth > maxDepth) { maxDepth = depth; } } - + // do an 80% analysis to find min (startDepth) if (pfafs.length > 0) { for (int myMinDepth = maxDepth; myMinDepth > 0; myMinDepth--) { int ilevelcount = 0; for (int i = 0; i < pfafs.length; i++) { - int idepth = pfafs[i].indexOf("0"); + int idepth = pfafs[i].substring(prelimstartDepth).indexOf("0"); + idepth = prelimstartDepth + idepth; if (idepth >= myMinDepth) { ilevelcount++; } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/python/GfePyIncludeUtil.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/python/GfePyIncludeUtil.java index eb0a043487..98bada2837 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/python/GfePyIncludeUtil.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/python/GfePyIncludeUtil.java @@ -37,6 +37,8 @@ import com.raytheon.uf.common.util.FileUtil; * Oct 9, 2008 njensen Initial creation * Sep 18, 2012 #1091 randerso added base directory to getGfeConfigIncludePath * Feb 27, 2013 #1447 dgilling Re-factor based on PythonPathIncludeUtil. + * Mar 06 2013 15717 jzeng Change CAVE_STATIC to COMMON_STATIC + * for GFE localization files * Mar 11, 2013 #1759 dgilling Add method getGfeConfigLF(). * * @@ -172,14 +174,14 @@ public class GfePyIncludeUtil extends PythonIncludePathUtil { public static String getProceduresIncludePath(boolean includeUser) { String baseDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.BASE), + LocalizationType.COMMON_STATIC, LocalizationLevel.BASE), PROCEDURES); String siteDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.SITE), + LocalizationType.COMMON_STATIC, LocalizationLevel.SITE), PROCEDURES); if (includeUser) { String userDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.USER), + LocalizationType.COMMON_STATIC, LocalizationLevel.USER), PROCEDURES); return PyUtil.buildJepIncludePath(userDir, siteDir, baseDir); } else { @@ -193,15 +195,15 @@ public class GfePyIncludeUtil extends PythonIncludePathUtil { public static String getTextUtilitiesIncludePath(boolean includeUser) { String baseDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.BASE), REGULAR); + LocalizationType.COMMON_STATIC, LocalizationLevel.BASE), REGULAR); String configDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.CONFIGURED), + LocalizationType.COMMON_STATIC, LocalizationLevel.CONFIGURED), REGULAR); String siteDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.SITE), REGULAR); + LocalizationType.COMMON_STATIC, LocalizationLevel.SITE), REGULAR); if (includeUser) { String userDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.USER), + LocalizationType.COMMON_STATIC, LocalizationLevel.USER), REGULAR); return PyUtil.buildJepIncludePath(userDir, siteDir, configDir, baseDir); @@ -216,17 +218,17 @@ public class GfePyIncludeUtil extends PythonIncludePathUtil { public static String getTextProductsIncludePath(boolean includeUser) { String baseDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.BASE), + LocalizationType.COMMON_STATIC, LocalizationLevel.BASE), TEXT_PRODUCTS); String configDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.CONFIGURED), + LocalizationType.COMMON_STATIC, LocalizationLevel.CONFIGURED), TEXT_PRODUCTS); String siteDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.SITE), + LocalizationType.COMMON_STATIC, LocalizationLevel.SITE), TEXT_PRODUCTS); if (includeUser) { String userDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.USER), + LocalizationType.COMMON_STATIC, LocalizationLevel.USER), TEXT_PRODUCTS); return PyUtil.buildJepIncludePath(userDir, siteDir, configDir, baseDir); @@ -241,14 +243,14 @@ public class GfePyIncludeUtil extends PythonIncludePathUtil { public static String getSmartToolsIncludePath(boolean includeUser) { String baseDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.BASE), + LocalizationType.COMMON_STATIC, LocalizationLevel.BASE), SMART_TOOLS); String siteDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.SITE), + LocalizationType.COMMON_STATIC, LocalizationLevel.SITE), SMART_TOOLS); if (includeUser) { String userDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.USER), + LocalizationType.COMMON_STATIC, LocalizationLevel.USER), SMART_TOOLS); return PyUtil.buildJepIncludePath(userDir, siteDir, baseDir); } else { @@ -262,14 +264,14 @@ public class GfePyIncludeUtil extends PythonIncludePathUtil { public static String getUtilitiesIncludePath(boolean includeUser) { String baseDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.BASE), + LocalizationType.COMMON_STATIC, LocalizationLevel.BASE), UTILITIES); String siteDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.SITE), + LocalizationType.COMMON_STATIC, LocalizationLevel.SITE), UTILITIES); if (includeUser) { String userDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.USER), + LocalizationType.COMMON_STATIC, LocalizationLevel.USER), UTILITIES); return PyUtil.buildJepIncludePath(userDir, siteDir, baseDir); } else { @@ -299,12 +301,12 @@ public class GfePyIncludeUtil extends PythonIncludePathUtil { public static String getConfigIncludePath(boolean includeUser) { String baseDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.BASE), CONFIG); + LocalizationType.COMMON_STATIC, LocalizationLevel.BASE), CONFIG); String siteDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.SITE), CONFIG); + LocalizationType.COMMON_STATIC, LocalizationLevel.SITE), CONFIG); if (includeUser) { String userDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.USER), + LocalizationType.COMMON_STATIC, LocalizationLevel.USER), CONFIG); return PyUtil.buildJepIncludePath(userDir, siteDir, baseDir); } else { @@ -328,7 +330,7 @@ public class GfePyIncludeUtil extends PythonIncludePathUtil { } public static String getTextProductsTemplatesIncludePath() { - return getPath(PATH_MANAGER.getContext(LocalizationType.CAVE_STATIC, + return getPath(PATH_MANAGER.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.BASE), TEXT_PRODUCTS); } @@ -338,14 +340,14 @@ public class GfePyIncludeUtil extends PythonIncludePathUtil { public static String getCombinationsIncludePath(boolean includeUser) { String configDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.CONFIGURED), + LocalizationType.COMMON_STATIC, LocalizationLevel.CONFIGURED), COMBINATIONS); String siteDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.SITE), + LocalizationType.COMMON_STATIC, LocalizationLevel.SITE), COMBINATIONS); if (includeUser) { String userDir = getPath(PATH_MANAGER.getContext( - LocalizationType.CAVE_STATIC, LocalizationLevel.USER), + LocalizationType.COMMON_STATIC, LocalizationLevel.USER), COMBINATIONS); return PyUtil.buildJepIncludePath(userDir, siteDir, configDir); } else { diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/ImportConfRequest.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/ImportConfRequest.java index d75f845e51..fb7104dbdd 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/ImportConfRequest.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/request/ImportConfRequest.java @@ -31,7 +31,9 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Aug 4, 2011 bphillip Initial creation + * Aug 04, 2011 bphillip Initial creation + * Mar 20, 2013 1447 dgilling Add support for service backup + * troubleshooting mode from A1. * * * @@ -48,13 +50,18 @@ public class ImportConfRequest extends AbstractGfeRequest { @DynamicSerializeElement private String failedSite; + @DynamicSerializeElement + private boolean trMode; + public ImportConfRequest() { } - public ImportConfRequest(String primarySite, String failedSite) { + public ImportConfRequest(String primarySite, String failedSite, + boolean trMode) { this.primarySite = primarySite; this.failedSite = failedSite; + this.trMode = trMode; } /** @@ -87,4 +94,12 @@ public class ImportConfRequest extends AbstractGfeRequest { this.failedSite = failedSite; } + public void setTrMode(boolean trMode) { + this.trMode = trMode; + } + + public boolean isTrMode() { + return trMode; + } + } diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ModifyProduct.java b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ModifyProduct.java index a6fa5407dc..fbf0fba128 100644 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ModifyProduct.java +++ b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ModifyProduct.java @@ -41,6 +41,7 @@ import com.raytheon.uf.edex.dissemination.transmitted.TransmittedProductList; * ------------ ---------- ----------- -------------------------- * Nov 13, 2009 njensen Initial creation * 08/20/2012 DR 15340 D. Friedman Fix BBB problems + * 03/08/2013 15564 mgamazaychikov Trimmed extra spaces in afosId * * * @@ -71,7 +72,7 @@ public class ModifyProduct { List list = dao.lookupAfosId(ttaaii, cccc).getIdList(); String productId = null; for (AfosToAwips ata : list) { - String afosId = ata.getAfosid(); + String afosId = ata.getAfosid().trim(); String awipsId = afosId.substring(3); if (awipsId.equals(productAwipsId)) { productId = afosId; diff --git a/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/StaticDataGenerator.java b/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/StaticDataGenerator.java index e4df17246f..87c6154cfb 100644 --- a/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/StaticDataGenerator.java +++ b/edexOsgi/com.raytheon.uf.edex.grid.staticdata/src/com/raytheon/uf/edex/grid/staticdata/StaticDataGenerator.java @@ -71,7 +71,6 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao; * Dec 3, 2010 rjpeter Initial creation * Feb 15, 2013 1638 mschenke Moved DataURINotificationMessage to uf.common.dataplugin * Mar 07, 2013 1587 bsteffen rewrite static data generation. - * Mar 14, 2013 1587 bsteffen Fix persisting to datastore. * * * @@ -269,7 +268,7 @@ public class StaticDataGenerator { for (GridRecord staticRecord : datastoreRecords) { populateMessageData(staticRecord); } - dao.persistToHDF5(datastoreRecords.toArray(new PluginDataObject[0])); + dao.persistToHDF5(databaseRecords.toArray(new PluginDataObject[0])); } if (!databaseRecords.isEmpty()) { dao.persistToDatabase(databaseRecords @@ -425,8 +424,7 @@ public class StaticDataGenerator { datasets = Collections.emptyList(); } } - if (!datasets.contains(staticRecord.getParameter() - .getAbbreviation())) { + if (datasets.contains(missing)) { missing.add(staticRecord); } } diff --git a/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/DPADecoder-spring.xml b/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/DPADecoder-spring.xml index f483d69124..b1a37fd210 100644 --- a/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/DPADecoder-spring.xml +++ b/edexOsgi/com.raytheon.uf.edex.ohd/res/spring/DPADecoder-spring.xml @@ -44,7 +44,7 @@ - +