From 2417d5a2a7c3ef71c917808bbe3556bd87e2822b Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Fri, 14 Nov 2014 14:03:00 -0600 Subject: [PATCH] Omaha #3885: Merge VTEC route and request changes from VLab. Original Ticket: VLab Issue #4953 Added support for managing JSON files in practice mode. Change-Id: I5ec7c695866554e6209b0c15f6dbe1a460d9d7d9 Former-commit-id: 16e32018de233fb128a7518415b84e032074932f --- .../formatterlauncher/StoreTransmitDlg.java | 38 +++-- .../res/spring/warning-common.xml | 77 ++++----- .../res/spring/warning-ingest.xml | 105 +++++------- .../PracticeProductOfftimeRequest.java | 124 -------------- .../SendPracticeProductRequest.java | 72 +++++++- .../res/spring/activetable-common.xml | 99 +++-------- .../res/spring/activetable-ingest.xml | 74 +++++--- .../res/spring/activetable-request.xml | 160 +++++++++--------- .../uf/edex/activetable/ActiveTable.java | 16 +- .../PracticeProductOfftimeHandler.java | 138 --------------- .../decoder/PracticeVtecDecoder.java} | 45 +++-- .../SendPracticeProductHandler.java} | 12 +- .../common_static/base/python/TimeUtil.py | 27 --- 13 files changed, 354 insertions(+), 633 deletions(-) delete mode 100644 edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/PracticeProductOfftimeRequest.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/PracticeProductOfftimeHandler.java rename edexOsgi/{com.raytheon.uf.edex.python.decoder/src/com/raytheon/uf/edex/python/decoder/TimeOffsetDecoder.java => com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/decoder/PracticeVtecDecoder.java} (64%) rename edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/{PracticeVtecHandler.java => handler/SendPracticeProductHandler.java} (78%) delete mode 100644 edexOsgi/com.raytheon.uf.edex.activetable/utility/common_static/base/python/TimeUtil.py 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 535ddd2f7b..e379e3e735 100644 --- 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 @@ -23,6 +23,7 @@ import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.TimeZone; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -38,7 +39,6 @@ import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import com.raytheon.uf.common.activetable.PracticeProductOfftimeRequest; import com.raytheon.uf.common.activetable.SendPracticeProductRequest; import com.raytheon.uf.common.activetable.response.GetNextEtnResponse; import com.raytheon.uf.common.dissemination.OUPRequest; @@ -84,6 +84,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Dec 18, 2013 2641 dgilling Support changes to GFEVtecUtil.getVtecLinesThatNeedEtn(). * Jan 06, 2014 2649 dgilling Make ETN assignment process optional. * Feb 17, 2014 2774 dgilling Merge changes from 14.1 baseline to 14.2. + * Nov 14, 2014 4953 randerso Cleaned up practice product requests * * * @@ -541,26 +542,27 @@ public class StoreTransmitDlg extends CaveSWTDialog implements /** * Method to transmit the product. + * + * @param practice + * true if we are transmitting a practice product */ - private void transmitProduct(boolean decode) { + private void transmitProduct(boolean practice) { IServerRequest req = null; - if (decode) { - if (SimulatedTime.getSystemTime().isRealTime()) { - req = new SendPracticeProductRequest(); - ((SendPracticeProductRequest) req).setProductText(productText); - } else { - req = new PracticeProductOfftimeRequest(); - ((PracticeProductOfftimeRequest) req) - .setProductText(productText); - ((PracticeProductOfftimeRequest) req).setNotifyGFE(true); + if (practice) { + SendPracticeProductRequest practiceReq = new SendPracticeProductRequest(); + practiceReq.setNotifyGFE(true); + practiceReq.setProductText(productText); + + if (!SimulatedTime.getSystemTime().isRealTime()) { SimpleDateFormat dateFormatter = new SimpleDateFormat( "yyyyMMdd_HHmm"); - ((PracticeProductOfftimeRequest) req) - .setDrtString(dateFormatter.format(SimulatedTime - .getSystemTime().getTime())); + dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT")); + practiceReq.setDrtString(dateFormatter.format(SimulatedTime + .getSystemTime().getTime())); } + req = practiceReq; } else { - req = new OUPRequest(); + OUPRequest oupReq = new OUPRequest(); OfficialUserProduct oup = new OfficialUserProduct(); // make sure the awipsWanPil is exactly 10 characters space-padded // long @@ -580,8 +582,10 @@ public class StoreTransmitDlg extends CaveSWTDialog implements // oup.setAddress(parentEditor.getAutoSendAddress()); oup.setNeedsWmoHeader(false); oup.setSource("GFE"); - ((OUPRequest) req).setProduct(oup); - ((OUPRequest) req).setUser(UserController.getUserObject()); + oupReq.setProduct(oup); + oupReq.setUser(UserController.getUserObject()); + + req = oupReq; } try { diff --git a/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-common.xml b/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-common.xml index 56ca4d5c55..78f500c5df 100644 --- a/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-common.xml +++ b/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-common.xml @@ -1,48 +1,43 @@ - + - - - - - - + + + + + + - - - - + + + + - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - + + + + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-ingest.xml b/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-ingest.xml index 30c3990723..8af101ccf8 100644 --- a/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-ingest.xml +++ b/edexOsgi/com.raytheon.edex.plugin.warning/res/spring/warning-ingest.xml @@ -1,67 +1,50 @@ - - - - - - - - - - - + + + + + + + + + + - + - - - - - - - warning - - - - --> - - - - - - warning - - - - - - - - - - - - - - - - - java.lang.Throwable - - - - - + + + + + warning + + + + + + + + + + + + + + + + + java.lang.Throwable + + + + + diff --git a/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/PracticeProductOfftimeRequest.java b/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/PracticeProductOfftimeRequest.java deleted file mode 100644 index 6dcd9f10a1..0000000000 --- a/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/PracticeProductOfftimeRequest.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.common.activetable; - -import java.util.Map; - -import com.raytheon.uf.common.message.IMessage; -import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; -import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; - -/** - * A SendPracticeProductRequest with the addition of an offset time string. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jun 27, 2011            wldougher     Initial creation
- * 
- * 
- * - * @author wldougher - * @version 1.0 - */ - -@DynamicSerialize -public class PracticeProductOfftimeRequest extends SendPracticeProductRequest - implements IMessage { - - @DynamicSerializeElement - private String drtString; - - @DynamicSerializeElement - private boolean notifyGFE; - - private int offsetSeconds; - - private Map headers; - - /** - * @return the drtString - */ - public String getDrtString() { - return drtString; - } - - /** - * @param drtString - * the drtString to set - */ - public void setDrtString(String drtString) { - this.drtString = drtString; - } - - /** - * @param offsetSeconds - * the offsetSeconds to set - */ - public void setOffsetSeconds(int offsetSeconds) { - this.offsetSeconds = offsetSeconds; - } - - /** - * @return the offsetSeconds - */ - public int getOffsetSeconds() { - return offsetSeconds; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.common.message.IMessage#getHeaders() - */ - @Override - public Map getHeaders() { - return headers; - } - - /** - * @param headers - * the headers to set - */ - public void setHeaders(Map headers) { - this.headers = headers; - } - - /** - * Set the flag value that tells whether GFE notifications should be sent. - * - * @param notifyGFE - * the notifyGFE to set - */ - public void setNotifyGFE(boolean notifyGFE) { - this.notifyGFE = notifyGFE; - } - - /** - * @return the notifyGFE - */ - public boolean isNotifyGFE() { - return notifyGFE; - } - -} diff --git a/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/SendPracticeProductRequest.java b/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/SendPracticeProductRequest.java index a46012f2d0..9688af981d 100644 --- a/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/SendPracticeProductRequest.java +++ b/edexOsgi/com.raytheon.uf.common.activetable/src/com/raytheon/uf/common/activetable/SendPracticeProductRequest.java @@ -19,38 +19,102 @@ **/ package com.raytheon.uf.common.activetable; +import java.util.HashMap; +import java.util.Map; + +import com.raytheon.uf.common.message.IMessage; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.serialization.comm.IServerRequest; /** - * TODO Add Description + * A SendPracticeProductRequest with an optional offset time string. * *
  * 
  * SOFTWARE HISTORY
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Feb 10, 2010            njensen     Initial creation
+ * Jun 27, 2011            wldougher   Initial creation
+ * Nov 14, 2014  4953      randerso    Merged PracticeProductOfftimeRequest with this
  * 
  * 
* - * @author njensen + * @author wldougher * @version 1.0 */ @DynamicSerialize -public class SendPracticeProductRequest implements IServerRequest { +public class SendPracticeProductRequest implements IServerRequest, IMessage { @DynamicSerializeElement private String productText; + @DynamicSerializeElement + private String drtString; + + @DynamicSerializeElement + private boolean notifyGFE; + + /** + * @return the productText + */ public String getProductText() { return productText; } + /** + * @param productText + * the productText to set + */ public void setProductText(String productText) { this.productText = productText; } + /** + * @return the drtString + */ + public String getDrtString() { + return drtString; + } + + /** + * @param drtString + * the drtString to set + */ + public void setDrtString(String drtString) { + this.drtString = drtString; + } + + /** + * Set the flag value that tells whether GFE notifications should be sent. + * + * @param notifyGFE + * the notifyGFE to set + */ + public void setNotifyGFE(boolean notifyGFE) { + this.notifyGFE = notifyGFE; + } + + /** + * @return the notifyGFE + */ + public boolean isNotifyGFE() { + return notifyGFE; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.common.message.IMessage#getHeaders() + */ + @Override + public Map getHeaders() { + Map headers = new HashMap(2, 1.0f); + headers.put("drtstring", getDrtString()); + headers.put("notifygfe", isNotifyGFE()); + return headers; + } + } diff --git a/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-common.xml b/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-common.xml index ef83b1b3dc..9368d4ac74 100644 --- a/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-common.xml +++ b/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-common.xml @@ -1,86 +1,25 @@ - - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - java.lang.Throwable - - - - - - - - - - ${body?.drtString} - - - ${body?.offsetSeconds} - - - ${body?.notifyGFE} - - - - - - - - ${header?.notifygfe.booleanValue} - - - - - - java.lang.Throwable - - - - - + diff --git a/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-ingest.xml b/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-ingest.xml index 1a9ee5f976..54b17c4d41 100644 --- a/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-ingest.xml +++ b/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-ingest.xml @@ -1,40 +1,66 @@ - - - - + + + + + + + + + + + + + + - + java.lang.Throwable - - - - + + + + + + - - - - + + + + ${body?.notifyGFE} + + + + + + ${header?.notifygfe.booleanValue} + + + + + + + + + + + java.lang.Throwable - + + - - - - - + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-request.xml b/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-request.xml index a5e9dd59a7..120497e66e 100644 --- a/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-request.xml +++ b/edexOsgi/com.raytheon.uf.edex.activetable/res/spring/activetable-request.xml @@ -1,6 +1,5 @@ - @@ -8,101 +7,94 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - - - - - - java.lang.Throwable - - + + + + + + + + java.lang.Throwable + + - - + + - - + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/ActiveTable.java b/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/ActiveTable.java index 28597ce764..2c5e9db8a7 100644 --- a/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/ActiveTable.java +++ b/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/ActiveTable.java @@ -34,7 +34,6 @@ import jep.JepException; import org.apache.log4j.Logger; import com.raytheon.edex.site.SiteUtil; -import com.raytheon.edex.util.Util; import com.raytheon.uf.common.activetable.ActiveTableMode; import com.raytheon.uf.common.activetable.ActiveTableRecord; import com.raytheon.uf.common.activetable.MergeResult; @@ -94,6 +93,8 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery; * Jun 17, 2014 3296 randerso Cached PythonScript. Moved active table * backup and purging to a separate thread. * Added performance logging + * Nov 14, 2014 4953 randerso Moved dumpProductToTempFile into PracticeVtecDecoder + * since it had no reason to be in this class * * * @@ -626,19 +627,6 @@ public class ActiveTable { dao.executeNativeSql(sql); } - /** - * Dump product text to temp file - * - * @param productText - * product text - * @return the temp file - */ - public static File dumpProductToTempFile(String productText) { - File file = Util.createTempFile(productText.getBytes(), "vtec"); - file.deleteOnExit(); - return file; - } - /** * Get the last assigned ETN for the specified site and phensig combination. * diff --git a/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/PracticeProductOfftimeHandler.java b/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/PracticeProductOfftimeHandler.java deleted file mode 100644 index 1f805e10c4..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/PracticeProductOfftimeHandler.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.edex.activetable; - -import java.io.File; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import jep.JepException; - -import com.raytheon.uf.common.activetable.PracticeProductOfftimeRequest; -import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.python.PythonScript; -import com.raytheon.uf.common.serialization.comm.IRequestHandler; -import com.raytheon.uf.edex.core.EDEXUtil; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jun 27, 2011            wldougher     Initial creation
- * 
- * 
- * - * @author wldougher - * @version 1.0 - */ - -public class PracticeProductOfftimeHandler implements - IRequestHandler { - - private static String timeUtil; - - private static String includePath; - static { - IPathManager pathMgr = PathManagerFactory.getPathManager(); - LocalizationContext commonCx = pathMgr.getContext( - LocalizationType.COMMON_STATIC, LocalizationLevel.BASE); - timeUtil = pathMgr.getFile(commonCx, - "python" + File.separator + "TimeUtil.py").getPath(); - includePath = pathMgr.getFile(commonCx, "python").getPath(); - } - - @Override - public Object handleRequest(PracticeProductOfftimeRequest request) - throws Exception { - String drtString = request.getDrtString(); - request.setOffsetSeconds(offsetSecs(drtString)); - request.setHeaders(new HashMap()); - EDEXUtil.getMessageProducer().sendAsync("practiceVtecOffsetRoute", - request); - - return null; - - } - - /** - * @param request - * @return The product text of the request - */ - public String process(PracticeProductOfftimeRequest request) { - return request.getProductText(); - } - - /** - * Call determineDrtOffset() (in Python) to determine the offset in seconds - * for a particular string. - * - * @param drtString - * The string to convert - * @return the offset in seconds - * @throws Exception - * if the Python call fails - */ - protected int offsetSecs(String drtString) throws Exception { - int rtnVal = 0; - - if (drtString != null) { - - Map args = new HashMap(); - args.put("timeStr", drtString); - - PythonScript python = null; - Object obj = null; - try { - python = new PythonScript(timeUtil, includePath, getClass() - .getClassLoader()); - obj = python.execute("determineDrtOffset", args); - } catch (JepException e) { - throw new Exception("Python exception:" + e.getMessage(), e); - } finally { - if (python != null) { - python.dispose(); - } - } - // determineDrtOffset returns a tuple. - // In the current implementation, it comes back as a String: - // "( -12345678, ...)", but it might change in the future. - if (obj instanceof String) { - String objStr = (String) obj; - String intStr = objStr.substring(1, objStr.indexOf(",")); - rtnVal = Integer.parseInt(intStr); - } else if (obj instanceof List) { - rtnVal = (Integer) ((List) obj).get(0); - } else if (obj.getClass().isArray()) { - rtnVal = (Integer) ((Object[]) obj)[0]; - } - } - return rtnVal; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.python.decoder/src/com/raytheon/uf/edex/python/decoder/TimeOffsetDecoder.java b/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/decoder/PracticeVtecDecoder.java similarity index 64% rename from edexOsgi/com.raytheon.uf.edex.python.decoder/src/com/raytheon/uf/edex/python/decoder/TimeOffsetDecoder.java rename to edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/decoder/PracticeVtecDecoder.java index 979cdefdb6..2f88b3ec59 100644 --- a/edexOsgi/com.raytheon.uf.edex.python.decoder/src/com/raytheon/uf/edex/python/decoder/TimeOffsetDecoder.java +++ b/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/decoder/PracticeVtecDecoder.java @@ -17,14 +17,16 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.python.decoder; +package com.raytheon.uf.edex.activetable.decoder; import java.io.File; import java.util.HashMap; import java.util.Map; -import com.raytheon.edex.esb.Headers; +import com.raytheon.edex.util.Util; +import com.raytheon.uf.common.activetable.SendPracticeProductRequest; import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.edex.python.decoder.PythonDecoder; /** * A PythonDecoder, modified to allow a time offset string (as passed in -z @@ -40,6 +42,10 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject; * ------------- -------- ----------- -------------------------- * Jun 27, 2011 wldougher Initial creation * Oct 03, 2013 2402 bsteffen Make PythonDecoder more extendable. + * Nov 14, 2014 4953 randerso Renamed to PracticeVtecDecoder since it is now + * used for all practice VTEC products + * Changed to take in the SendPracticeProductRequest + * to simplify spring wiring * * * @@ -47,40 +53,51 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject; * @version 1.0 */ -public class TimeOffsetDecoder extends PythonDecoder { +public class PracticeVtecDecoder extends PythonDecoder { /** * Constructor. */ - public TimeOffsetDecoder() { + public PracticeVtecDecoder() { super(); } /** - * Decode a file with an offset time. + * Dump product text to temp file * - * @param file - * The file to decode - * @param drtString - * The time offset string as used by - * TimeUtil.py::determineDrtOffset() + * @param productText + * product text + * @return the temp file + */ + public static File dumpProductToTempFile(String productText) { + File file = Util.createTempFile(productText.getBytes(), "vtec"); + file.deleteOnExit(); + return file; + } + + /** + * Decode a practice VTEC product with a time offset. + * + * @param req * @return An array of decoded records, which may be zero-length, but is not * null. * @throws Exception * if anything goes wrong, typically in Python or converting * Python structures to Java */ - public PluginDataObject[] decode(File file, Headers headers) + public PluginDataObject[] decode(SendPracticeProductRequest req) throws Exception { + File file = dumpProductToTempFile(req.getProductText()); + StringBuilder sb = new StringBuilder("cmd -f "); sb.append(file.getPath()); - Boolean notifyGFE = (Boolean) headers.get("notifygfe"); + Boolean notifyGFE = req.isNotifyGFE(); if (Boolean.TRUE.equals(notifyGFE)) { sb.append(" -g"); } - String drtString = (String) headers.get("drtstring"); - if (drtString != null && !"".equals(drtString)) { + String drtString = req.getDrtString(); + if ((drtString != null) && !drtString.isEmpty()) { sb.append(" -z ").append(drtString); } diff --git a/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/PracticeVtecHandler.java b/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/handler/SendPracticeProductHandler.java similarity index 78% rename from edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/PracticeVtecHandler.java rename to edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/handler/SendPracticeProductHandler.java index f935feab60..717a556990 100644 --- a/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/PracticeVtecHandler.java +++ b/edexOsgi/com.raytheon.uf.edex.activetable/src/com/raytheon/uf/edex/activetable/handler/SendPracticeProductHandler.java @@ -17,14 +17,14 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.edex.activetable; +package com.raytheon.uf.edex.activetable.handler; import com.raytheon.uf.common.activetable.SendPracticeProductRequest; import com.raytheon.uf.common.serialization.comm.IRequestHandler; import com.raytheon.uf.edex.core.EDEXUtil; /** - * TODO Add Description + * Send Practice VTEC Product * *
  * 
@@ -32,6 +32,8 @@ import com.raytheon.uf.edex.core.EDEXUtil;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 10, 2010            njensen     Initial creation
+ * Nov 14, 2014  4953      randerso    Changed to use sendAsyncThriftUri so headers
+ *                                     are not lost
  * 
  * 
* @@ -39,14 +41,14 @@ import com.raytheon.uf.edex.core.EDEXUtil; * @version 1.0 */ -public class PracticeVtecHandler implements +public class SendPracticeProductHandler implements IRequestHandler { @Override public Object handleRequest(SendPracticeProductRequest request) throws Exception { - EDEXUtil.getMessageProducer().sendAsync("practiceVtecRoute", - request.getProductText()); + EDEXUtil.getMessageProducer().sendAsyncThriftUri( + "jms-generic:queue:practiceVtec", request); return null; } diff --git a/edexOsgi/com.raytheon.uf.edex.activetable/utility/common_static/base/python/TimeUtil.py b/edexOsgi/com.raytheon.uf.edex.activetable/utility/common_static/base/python/TimeUtil.py deleted file mode 100644 index a706e63152..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.activetable/utility/common_static/base/python/TimeUtil.py +++ /dev/null @@ -1,27 +0,0 @@ -## -# This software was developed and / or modified by Raytheon Company, -# pursuant to Contract DG133W-05-CQ-1067 with the US Government. -# -# U.S. EXPORT CONTROLLED TECHNICAL DATA -# This software product contains export-restricted data whose -# export/transfer/disclosure is restricted by U.S. law. Dissemination -# to non-U.S. persons whether in the United States or abroad requires -# an export license or other authorization. -# -# Contractor Name: Raytheon Company -# Contractor Address: 6825 Pine Street, Suite 340 -# Mail Stop B8 -# Omaha, NE 68106 -# 402.291.0100 -# -# See the AWIPS II Master Rights File ("Master Rights File.pdf") for -# further licensing information. -## - -from ufpy import TimeUtil - -def determineDrtOffset(timeStr): - return TimeUtil.determineDrtOffset(timeStr) - -def makeTime(timeStr): - return TimeUtil.makeTime(timeStr) \ No newline at end of file