Issue #646: Ensure radar obs use TimeTools to set reftime.

Former-commit-id: 091e0325ea [formerly c6c83792c753be9c248e951462830983d5a3ee2e]
Former-commit-id: 4f9061fcea
This commit is contained in:
David Gillingham 2012-05-18 16:31:16 -05:00
parent 9106c31a45
commit f12f83c80b
5 changed files with 123 additions and 64 deletions

View file

@ -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

View file

@ -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

View file

@ -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) {

View file

@ -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
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 18, 2012 dgilling Initial creation
*
* </pre>
*
* @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);
}
}
}

View file

@ -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<Integer, String> radarTable = new HashMap<Integer, String>() {
private static final long serialVersionUID = 1L;
@ -134,49 +117,6 @@ public class RadarTextProductUtil {
return afosId;
}
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());
textProd.setRefTime(System.currentTimeMillis());
textProd.setProduct(text);
EDEXUtil.getMessageProducer().sendAsync(textEndpoint, textProd);
}
} catch (Exception e) {
theHandler.handle(Priority.ERROR,
"Unable to store product to text database", e);
}
}
public static List<String> getRadarTableEntries() {
return new ArrayList<String>(radarTable.values());
}