diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.text.subscription/src/com/raytheon/uf/edex/plugin/text/subscription/services/TextTriggerHandler.java b/edexOsgi/com.raytheon.uf.edex.plugin.text.subscription/src/com/raytheon/uf/edex/plugin/text/subscription/services/TextTriggerHandler.java index cdb40bf087..3d8ccd0cf7 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.text.subscription/src/com/raytheon/uf/edex/plugin/text/subscription/services/TextTriggerHandler.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text.subscription/src/com/raytheon/uf/edex/plugin/text/subscription/services/TextTriggerHandler.java @@ -49,6 +49,7 @@ import com.raytheon.uf.edex.plugin.text.dbsrv.TextDBSrv; * Jan 4, 2016 5203 tjensen Initial creation * Jan 18, 2016 4562 tjensen Moved from edex.plugin.text to * edex.plugin.text.subscription + * Mar 4, 2015 4716 rferrel {@link #createProductRequestMessage(String)} determines if AWIPS or AFOS command. * * * @@ -64,6 +65,11 @@ public class TextTriggerHandler { */ protected transient Logger logger = LoggerFactory.getLogger(getClass()); + /** + * Triggering AWIPS commands have length of 10 while the AFOS is 9. + */ + private final int AWIPS_CMD_LEN = 10; + /** * Constructor. */ @@ -117,9 +123,9 @@ public class TextTriggerHandler { * via the Text Database Service. * * @param prodID - * AFOS PIL of the product to retrieve + * AWIPS or AFOS PIL of the product to retrieve * - * @return the latest product for the AFOS PIL + * @return the latest product for the AWIPS or AFOS PIL */ private String retrieveTextProduct(String prodID) { Message message = createProductRequestMessage(prodID); @@ -144,7 +150,7 @@ public class TextTriggerHandler { * * * @param prodID - * AFOS PIL of the product to retrieve + * AWIPS or AFOS PIL of the product to retrieve * * @return the product request message * @@ -156,7 +162,9 @@ public class TextTriggerHandler { properties.add(new Property("VIEW", "text")); properties.add(new Property("OP", "GET")); properties.add(new Property("SUBOP", "PROD")); - properties.add(new Property("AFOSCMD", prodID)); + properties.add(new Property( + (prodID.length() == AWIPS_CMD_LEN ? "AWIPSCMD" : "AFOSCMD"), + prodID)); header.setProperties(properties.toArray(new Property[] {})); message.setHeader(header); return message; @@ -196,10 +204,10 @@ public class TextTriggerHandler { /** * Writes the product to the file system. The product is written to * $FXA_DATA/trigger/{prodID} -- $FXA_DATA is obtained from the environment - * and {prodID} is the AFOS PIL of the product. + * and {prodID} is the AWIPS or AFOS PIL of the product. * * @param prodID - * AFOS PIL of the product + * AWIPS or AFOS PIL of the product * @param product * the product to export */ diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/TextDecoder.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/TextDecoder.java index 8425ffbeb0..19119c45eb 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/TextDecoder.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/TextDecoder.java @@ -42,7 +42,6 @@ import org.slf4j.LoggerFactory; import com.raytheon.edex.esb.Headers; import com.raytheon.edex.exception.DecoderException; -import com.raytheon.edex.plugin.AbstractDecoder; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.text.AfosWmoIdDataContainer; import com.raytheon.uf.common.dataplugin.text.db.AfosToAwips; @@ -83,13 +82,14 @@ import com.raytheon.uf.edex.plugin.text.impl.separator.WMOMessageSeparator; * May 12, 2014 2536 bclement added createTextRecord(), removed deprecated code * Jul 10, 2014 2914 garmendariz Remove EnvProperties * Dec 09, 2015 5166 kbisanz Update logging to use SLF4J. + * Mar 4, 2015 4716 rferrel Add AWIPS products to the TextRecords. * * * @author * @version 1 */ -public class TextDecoder extends AbstractDecoder { +public class TextDecoder { private static final String textToStageNotificationRoute = "jms-durable:queue:textToStageNotification"; @@ -148,9 +148,7 @@ public class TextDecoder extends AbstractDecoder { boolean success = textdb.writeProduct(textProduct); if (success) { - String productId = textProduct.getCccid() - + textProduct.getNnnid() + textProduct.getXxxid(); - pdo = createTextRecord(productId, textProduct.getRefTime()); + pdo = createTextRecord(textProduct); } else { // throw new Exception("product already exists"); } @@ -174,20 +172,41 @@ public class TextDecoder extends AbstractDecoder { } /** - * Construct a new text record with the given product ID and refTime + * Construct a new text record from the Standard Text Product. * - * @param productId - * @param refTime - * @return + * @param textProduct + * @return pdo */ - private static TextRecord createTextRecord(String productId, long refTime) { + private static TextRecord createTextRecord(StdTextProduct textProduct) { + + /* + * This assumes textProduct's site is 4 characters; cccid, nnnid and + * xxxid are 3 and the refTime is not null. + */ TextRecord pdo = new TextRecord(); - pdo.setProductId(productId); - DataTime dt = new DataTime(new Date(refTime)); + StringBuilder sb = new StringBuilder(10); + sb.append(textProduct.getCccid()); + sb.append(textProduct.getNnnid()); + sb.append(textProduct.getXxxid()); + pdo.setProductId(sb.toString()); + sb.replace(0, 3, textProduct.getSite()); + pdo.setAwipsProductId(sb.toString()); + DataTime dt = new DataTime(new Date(textProduct.getRefTime())); pdo.setDataTime(dt); return pdo; } + /** + * This generates a text record with Awips and Afos product id set to the + * values in the WMO Report Data. + */ + private static TextRecord createTextRecord(WMOReportData rpdData) { + TextRecord pdo = new TextRecord(); + pdo.setProductId(rpdData.getAfosProdId().toString()); + pdo.setAwipsProductId(rpdData.getAwipsProdId()); + return pdo; + } + /** * * @@ -271,7 +290,7 @@ public class TextDecoder extends AbstractDecoder { } } } catch (DataAccessLayerException e) { - + logger.warn("Unable to look up the AFOS Id.", e); } if (notMapped) { @@ -311,9 +330,7 @@ public class TextDecoder extends AbstractDecoder { operationalMode, headers); if (writeTime != Long.MIN_VALUE) { - String productId = rptData.getAfosProdId() - .toString(); - pdo = createTextRecord(productId, writeTime); + pdo = createTextRecord(rptData); stored++; } else { // throw new @@ -490,13 +507,16 @@ public class TextDecoder extends AbstractDecoder { } public String[] transformToProductIds(PluginDataObject[] pdos) { - String[] rval = new String[pdos.length]; + String[] rval = new String[0]; + List rvalList = new ArrayList<>(pdos.length * 2); try { for (int i = 0; i < pdos.length; i++) { TextRecord tr = (TextRecord) pdos[i]; - rval[i] = tr.getProductId(); + rvalList.add(tr.getProductId()); + rvalList.add(tr.getAwipsProductId()); } + rval = rvalList.toArray(rval); } catch (Exception e) { logger.error("Error transforming PDOs to Product IDs: ", e); } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/TextRecord.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/TextRecord.java index e2eb3d2172..f729f297df 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/TextRecord.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/TextRecord.java @@ -41,6 +41,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Aug 30, 2013 2298 rjpeter Make getPluginName abstract * May 12, 2014 2536 bclement removed IDecoderGettable * Oct 10, 2014 3549 njensen Remove unnecessary Column annotations + * Mar 4, 2016 4716 rferrel Added AWIPS product Id. * * * @@ -58,6 +59,12 @@ public class TextRecord extends PluginDataObject { @XmlElement private String productId; + // Correction indicator from wmo header + @DataURI(position = 2) + @DynamicSerializeElement + @XmlElement + private String awipsProductId; + /** * */ @@ -90,6 +97,14 @@ public class TextRecord extends PluginDataObject { this.productId = productId; } + public String getAwipsProductId() { + return this.awipsProductId; + } + + public void setAwipsProductId(String awipsProductId) { + this.awipsProductId = awipsProductId; + } + @Override public String getPluginName() { return "text"; diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/impl/WMOReportData.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/impl/WMOReportData.java index 1584e5a446..916137e1b7 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/impl/WMOReportData.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/impl/WMOReportData.java @@ -32,6 +32,7 @@ import com.raytheon.uf.common.wmo.WMOHeader; * ------------ ---------- ----------- -------------------------- * Oct 1, 2008 1538 jkorman Initial creation * May 20, 2014 2536 bclement moved from edex.textdb to edex.plugin.text + * Mar 4, 2016 4716 rferrel Added AWIPS product Id. * * * @author jkorman @@ -44,6 +45,8 @@ public class WMOReportData { private AFOSProductId afosProdId; + private String awipsProdId; + private String reportData; /** @@ -88,6 +91,10 @@ public class WMOReportData { copyAFOSProdId(afosProdId); } + public String getAwipsProdId() { + return this.awipsProdId; + } + /** * @return the reportData */ @@ -107,8 +114,15 @@ public class WMOReportData { if (prodId != null) { afosProdId = new AFOSProductId(prodId.getCcc(), prodId.getNnn(), prodId.getXxx()); + if (wmoHeader != null) { + awipsProdId = wmoHeader.getCccc() + afosProdId.getNnn() + + afosProdId.getXxx(); + } else { + awipsProdId = null; + } } else { afosProdId = null; + awipsProdId = null; } } diff --git a/edexOsgi/com.raytheon.uf.tools.cli/impl/myScript.sh b/edexOsgi/com.raytheon.uf.tools.cli/impl/myScript.sh index befc4f5da0..2e82a7ae47 100755 --- a/edexOsgi/com.raytheon.uf.tools.cli/impl/myScript.sh +++ b/edexOsgi/com.raytheon.uf.tools.cli/impl/myScript.sh @@ -25,7 +25,7 @@ LOG_FILE=$EDEX_HOME/logs/afos-trigger.log TIME_NOW=`date` if [ -z $1 ]; then - echo "$TIME_NOW: invalid process call, no AFOS PIL provided" >> $LOG_FILE + echo "$TIME_NOW: invalid process call, no AWIPS or AFOS PIL provided" >> $LOG_FILE exit 1 fi AFOS_PIL=$1 @@ -35,7 +35,7 @@ if [ -z $FXA_DATA ]; then fi FILE_PATH=$FXA_DATA/trigger/$AFOS_PIL if [ ! -f $FILE_PATH ]; then - echo "$TIME_NOW: unable to find file matching AFOS PIL: $AFOS_PIL" >> $LOG_FILE + echo "$TIME_NOW: unable to find file matching AWIPS or AFOS PIL: $AFOS_PIL" >> $LOG_FILE exit 1 fi echo "$TIME_NOW: processing $AFOS_PIL" >> $LOG_FILE diff --git a/edexOsgi/com.raytheon.uf.tools.cli/impl/src/conf/TDBConfig.py b/edexOsgi/com.raytheon.uf.tools.cli/impl/src/conf/TDBConfig.py index ac923c76a9..eb39c561a6 100644 --- a/edexOsgi/com.raytheon.uf.tools.cli/impl/src/conf/TDBConfig.py +++ b/edexOsgi/com.raytheon.uf.tools.cli/impl/src/conf/TDBConfig.py @@ -192,8 +192,8 @@ usage: textdb -r AFOSCmd Does a standard afos read textdb -s -a SS XXX CCC Adds XXX to state [SS] listing textdb -s -d SS XXX CCC Deletes XXX from state [SS] textdb -s -r SS Displays XXX list for state [SS] - textdb -pil -a productID script Adds a PIL watch warning product with script pathname - textdb -pil -d productID script Deletes a PIL watch warning product with script pathname + textdb -pil -a productID script Adds a AWIPS or AFOS PIL watch warning product with script pathname + textdb -pil -d productID script Deletes a AWIPS or AFOS PIL watch warning product with script pathname textdb -c Reviews AFOS commands textdb -k Reviews AWIPS commands textdb -n [site] Gets current node (CCC) site for running edex