diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.plugin.radar/META-INF/MANIFEST.MF index 4223f2e7f6..7bdbdccb97 100644 --- a/edexOsgi/com.raytheon.edex.plugin.radar/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.plugin.radar/META-INF/MANIFEST.MF @@ -25,5 +25,6 @@ Import-Package: com.raytheon.uf.common.comm, com.raytheon.uf.common.menus, com.raytheon.uf.common.menus.xml, com.raytheon.uf.common.site.ingest, + com.raytheon.uf.common.dataplugin.text.db, org.apache.commons.logging, org.apache.tools.bzip2 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 ac70ad0fce..c52f153a38 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 @@ -33,6 +33,7 @@ import com.raytheon.edex.plugin.AbstractDecoder; import com.raytheon.edex.plugin.radar.dao.RadarStationDao; import com.raytheon.edex.plugin.radar.level2.Level2BaseRadar; import com.raytheon.edex.plugin.radar.level3.Level3BaseRadar; +import com.raytheon.edex.plugin.radar.util.RadarEdexTextProductUtil; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.radar.RadarRecord; @@ -165,7 +166,7 @@ public class RadarDecoder extends AbstractDecoder { AFOSProductId afos = new AFOSProductId("WSR", "ROB", siteId); // store the product ROB that is barely do-able - RadarTextProductUtil.storeTextProduct(afos, header, + RadarEdexTextProductUtil.storeTextProduct(afos, header, dataString, true, Calendar.getInstance()); return new PluginDataObject[0]; } @@ -491,7 +492,7 @@ public class RadarDecoder extends AbstractDecoder { RadarTextProductUtil.createAfosId(75, splits[1].substring(1))); // store the product to the text database - RadarTextProductUtil.storeTextProduct(afos, header, temp, true, + RadarEdexTextProductUtil.storeTextProduct(afos, header, temp, true, Calendar.getInstance()); // send message to alertviz diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/level3/Level3BaseRadar.java b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/level3/Level3BaseRadar.java index 739f790726..898b11841c 100644 --- a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/level3/Level3BaseRadar.java +++ b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/level3/Level3BaseRadar.java @@ -38,6 +38,7 @@ import org.apache.tools.bzip2.CBZip2InputStream; import com.raytheon.edex.esb.Headers; import com.raytheon.edex.plugin.radar.dao.RadarStationDao; +import com.raytheon.edex.plugin.radar.util.RadarEdexTextProductUtil; import com.raytheon.uf.common.dataplugin.radar.RadarStation; import com.raytheon.uf.common.dataplugin.radar.level3.AlertAdaptationParameters; import com.raytheon.uf.common.dataplugin.radar.level3.AlertMessage; @@ -822,7 +823,7 @@ public class Level3BaseRadar { AFOSProductId afos = new AFOSProductId(afosId); if (afos.isFilled()) { try { - RadarTextProductUtil.storeTextProduct(afos, header, + RadarEdexTextProductUtil.storeTextProduct(afos, header, tabularBlock.getString(), true, Calendar.getInstance()); } catch (Exception e) { @@ -913,7 +914,7 @@ public class Level3BaseRadar { AFOSProductId afos = new AFOSProductId(afosId); if (afos.isFilled()) { try { - RadarTextProductUtil.storeTextProduct(afos, header, + RadarEdexTextProductUtil.storeTextProduct(afos, header, tabularBlock.getString(), true, Calendar.getInstance()); } catch (Exception e) { diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/util/RadarEdexTextProductUtil.java b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/util/RadarEdexTextProductUtil.java new file mode 100644 index 0000000000..f132440acd --- /dev/null +++ b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/util/RadarEdexTextProductUtil.java @@ -0,0 +1,116 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.edex.plugin.radar.util; + +import java.text.SimpleDateFormat; +import java.util.Calendar; + +import com.raytheon.uf.common.dataplugin.text.db.OperationalStdTextProduct; +import com.raytheon.uf.common.dataplugin.text.db.PracticeStdTextProduct; +import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct; +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.edex.core.EDEXUtil; +import com.raytheon.uf.edex.decodertools.time.TimeTools; +import com.raytheon.uf.edex.wmo.message.AFOSProductId; +import com.raytheon.uf.edex.wmo.message.WMOHeader; + +/** + * TODO Add Description + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * May 18, 2012 dgilling Initial creation + * + *+ * + * @author dgilling + * @version 1.0 + */ + +public class RadarEdexTextProductUtil { + + private static final transient IUFStatusHandler theHandler = UFStatus + .getHandler(RadarEdexTextProductUtil.class); + + private static final String TEXT_ENDPOINT = "textDirectDecodedIngestRoute"; + + /** + * A private constructor so that Java does not attempt to create one for us. + * As this class should not be instantiated, do not attempt to ever call + * this constructor; it will simply throw an AssertionError. + * + */ + private RadarEdexTextProductUtil() { + throw new AssertionError(); + } + + public static void storeTextProduct(AFOSProductId afosId, WMOHeader wmoId, + String text, boolean operationalMode, Calendar cal) { + SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy HH:mm:ss"); + String temp = ""; + if (wmoId != null && wmoId.isValid()) { + temp = sdf.format(wmoId.getHeaderDate().getTime()); + } else { + temp = sdf.format(cal.getTime()); + } + if (!text.contains("Message Date:")) { + text = "Message Date: " + temp + "\n\n" + text; + } + text = text.replaceAll("Page \\d+", ""); + boolean isValid = wmoId.isValid(); + try { + if (afosId != null && text != null && !afosId.toString().isEmpty() + && !text.isEmpty()) { + StdTextProduct textProd = (operationalMode == true ? new OperationalStdTextProduct() + : new PracticeStdTextProduct()); + if (!isValid) { + textProd.setWmoid(" "); + textProd.setSite(" "); + textProd.setBbbid(" "); + textProd.setHdrtime(" "); + } else { + textProd.setWmoid(wmoId.getTtaaii()); + textProd.setSite(wmoId.getCccc()); + textProd.setHdrtime(wmoId.getYYGGgg()); + textProd.setBbbid(wmoId.getBBBIndicator()); + } + textProd.setCccid(afosId.getCcc()); + textProd.setNnnid(afosId.getNnn()); + textProd.setXxxid(afosId.getXxx()); + Long refTime = (TimeTools.allowArchive() ? wmoId + .getHeaderDate().getTimeInMillis() : System + .currentTimeMillis()); + textProd.setRefTime(refTime); + textProd.setProduct(text); + EDEXUtil.getMessageProducer() + .sendAsync(TEXT_ENDPOINT, textProd); + } + } catch (Exception e) { + theHandler.handle(Priority.ERROR, + "Unable to store product to text database", e); + } + } +} diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/util/RadarTextProductUtil.java b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/util/RadarTextProductUtil.java index 14e4f077c0..3046137f49 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/util/RadarTextProductUtil.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/util/RadarTextProductUtil.java @@ -19,22 +19,10 @@ **/ package com.raytheon.uf.common.dataplugin.radar.util; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Calendar; import java.util.HashMap; import java.util.List; -import com.raytheon.uf.common.dataplugin.text.db.OperationalStdTextProduct; -import com.raytheon.uf.common.dataplugin.text.db.PracticeStdTextProduct; -import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct; -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.edex.core.EDEXUtil; -import com.raytheon.uf.edex.wmo.message.AFOSProductId; -import com.raytheon.uf.edex.wmo.message.WMOHeader; - /** * Utility methods for handling radar Text Products. * @@ -54,14 +42,9 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader; */ public class RadarTextProductUtil { - /** The logger */ - private static final transient IUFStatusHandler theHandler = UFStatus - .getHandler(RadarTextProductUtil.class); private static final int RADAR_CODED_MSG = 74; - private static final String textEndpoint = "textDirectDecodedIngestRoute"; - public static final HashMap