Merge "Omaha #4716 Triggers for ingest StdTextProducts now check for AWIPS PILs." into omaha_16.2.2
Former-commit-id: a56b684482f1f54190151a1cbd975b392319beda
This commit is contained in:
commit
bd5d380a83
6 changed files with 85 additions and 28 deletions
|
@ -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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -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 {
|
|||
* </PRE>
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
* </pre>
|
||||
*
|
||||
* @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(StdTextProduct textProduct) {
|
||||
|
||||
/*
|
||||
* This assumes textProduct's site is 4 characters; cccid, nnnid and
|
||||
* xxxid are 3 and the refTime is not null.
|
||||
*/
|
||||
private static TextRecord createTextRecord(String productId, long refTime) {
|
||||
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<String> 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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -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";
|
||||
|
|
|
@ -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.
|
||||
* </pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue