Omaha #3885: Fix purging of practice VTECproducts when submitted in simulated time.

Change-Id: I5c4afa6ab0faf975388a25916d6616ce9eb05098

Former-commit-id: ae5a0f55d1 [formerly 35ae2af301ec8b66a65e1564c17f6e3f8d7623d2]
Former-commit-id: a41cc32a40
This commit is contained in:
David Gillingham 2014-12-09 11:21:29 -06:00
parent d36bb7a1d3
commit 02af20bcd9
2 changed files with 35 additions and 9 deletions

View file

@ -36,6 +36,10 @@
<setHeader headerName="notifygfe">
<simple>${body?.notifyGFE}</simple>
</setHeader>
<setHeader headerName="drtstring">
<simple>${body?.drtString}</simple>
</setHeader>
<bean ref="practiceVtecDecoder" method="decode"/>
<bean ref="index" method="index"/>
<multicast parallelProcessing="false">

View file

@ -19,7 +19,13 @@
**/
package com.raytheon.uf.edex.activetable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.common.activetable.ActiveTableMode;
@ -45,6 +51,8 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* Jul 14, 2009 #2950 njensen Multiple site support
* Dec 21, 2009 #4055 njensen No site filtering
* Jun 17, 2014 3296 randerso Added performance logging
* Dec 09, 2014 3885 dgilling Handle offset time from camel route
* headers.
*
* </pre>
*
@ -102,19 +110,12 @@ public class ActiveTableSrv {
*/
public void practiceVtecArrived(List<AbstractWarningRecord> records,
Headers headers) {
Integer offsetSeconds = null;
if (headers != null) {
offsetSeconds = (Integer) headers.get("offsetseconds");
}
if (offsetSeconds == null) {
offsetSeconds = Integer.valueOf(0);
}
int offsetSeconds = getOffsetTime((String) headers.get("drtstring"));
if (records != null && records.size() > 0) {
ActiveTable activeTable = threadLocalActiveTable.get();
try {
activeTable.merge(ActiveTableRecord.transformFromWarnings(
records, ActiveTableMode.PRACTICE), offsetSeconds
.intValue());
records, ActiveTableMode.PRACTICE), offsetSeconds);
} catch (Throwable t) {
statusHandler
.handle(Priority.PROBLEM,
@ -123,4 +124,25 @@ public class ActiveTableSrv {
}
}
}
private int getOffsetTime(String drtTimeString) {
if (drtTimeString != null) {
DateFormat drtParse = new SimpleDateFormat("yyyyMMdd_HHmm");
drtParse.setTimeZone(TimeZone.getTimeZone("GMT"));
try {
Date drtTime = drtParse.parse(drtTimeString);
Date currentTime = new Date();
long diffInMillis = drtTime.getTime() - currentTime.getTime();
return (int) TimeUnit.SECONDS.convert(diffInMillis,
TimeUnit.MILLISECONDS);
} catch (ParseException e) {
statusHandler.error("Could not parse DRT time string: "
+ drtTimeString, e);
}
}
return 0;
}
}