ASM #15551 - WarnGen: only WCN should be used while including TOR/SVR watches in WarnGen products
Change-Id: Ia4350f8c17166c8f972779f8bde1763ec4cd3bd5 Former-commit-id:5e93999662
[formerly0e2be5afd8
[formerly e7ab29fbfebb1943e0b0702547dbd353367e797d]] Former-commit-id:0e2be5afd8
Former-commit-id:4bce4db9ef
This commit is contained in:
parent
ea4aed7b84
commit
7e6097f690
4 changed files with 115 additions and 64 deletions
|
@ -78,6 +78,8 @@ import com.vividsolutions.jts.geom.Polygon;
|
||||||
* Aug 28, 2014 ASM #15658 D. Friedman Add marine zones.
|
* Aug 28, 2014 ASM #15658 D. Friedman Add marine zones.
|
||||||
* Aug 29, 2014 ASM #15551 Qinglu Lin Sort watches by ETN and filter out ActiveTableRecord
|
* Aug 29, 2014 ASM #15551 Qinglu Lin Sort watches by ETN and filter out ActiveTableRecord
|
||||||
* with act of CAN and EXP in processRecords().
|
* with act of CAN and EXP in processRecords().
|
||||||
|
* Sep 12, 2014 ASM #15551 Qinglu Lin Prevent a county's WOU from being used while its
|
||||||
|
* corresponding WCN is canceled or expired.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -307,6 +309,8 @@ public class WatchUtil {
|
||||||
InstantiationException {
|
InstantiationException {
|
||||||
List<ActiveTableRecord> records = new ArrayList<ActiveTableRecord>(
|
List<ActiveTableRecord> records = new ArrayList<ActiveTableRecord>(
|
||||||
response.getNumResults());
|
response.getNumResults());
|
||||||
|
Map<Pair<String, String>, Set<String>> removedUgczones = new HashMap<Pair<String, String>, Set<String>>();
|
||||||
|
Set<String> ugczones = null;
|
||||||
for (Map<String, Object> result : response.getResults()) {
|
for (Map<String, Object> result : response.getResults()) {
|
||||||
WarningAction action = WarningAction.valueOf(String.valueOf(result
|
WarningAction action = WarningAction.valueOf(String.valueOf(result
|
||||||
.get(ACTION)));
|
.get(ACTION)));
|
||||||
|
@ -316,7 +320,7 @@ public class WatchUtil {
|
||||||
* fixed the underlying system. request.addConstraint("act", new
|
* fixed the underlying system. request.addConstraint("act", new
|
||||||
* RequestConstraint("CAN", ConstraintType.NOT_EQUALS));
|
* RequestConstraint("CAN", ConstraintType.NOT_EQUALS));
|
||||||
*/
|
*/
|
||||||
if (action != WarningAction.CAN || action != WarningAction.EXP) {
|
if (action != WarningAction.CAN && action != WarningAction.EXP) {
|
||||||
ActiveTableRecord record = entityClass.newInstance();
|
ActiveTableRecord record = entityClass.newInstance();
|
||||||
record.setIssueTime((Calendar) result.get(ISSUE_TIME_FIELD));
|
record.setIssueTime((Calendar) result.get(ISSUE_TIME_FIELD));
|
||||||
record.setStartTime((Calendar) result.get(START_TIME_FIELD));
|
record.setStartTime((Calendar) result.get(START_TIME_FIELD));
|
||||||
|
@ -327,6 +331,37 @@ public class WatchUtil {
|
||||||
record.setEtn(String.valueOf(result.get(ETN)));
|
record.setEtn(String.valueOf(result.get(ETN)));
|
||||||
record.setAct(String.valueOf(result.get(ACTION)));
|
record.setAct(String.valueOf(result.get(ACTION)));
|
||||||
records.add(record);
|
records.add(record);
|
||||||
|
} else {
|
||||||
|
Pair<String, String> key = new Pair<String, String>(null, null);
|
||||||
|
key.setFirst(String.valueOf(result.get(ETN)));
|
||||||
|
key.setSecond(String.valueOf(result.get(PHEN_SIG_FIELD)));
|
||||||
|
ugczones = removedUgczones.get(key);
|
||||||
|
if (ugczones == null) {
|
||||||
|
ugczones = new HashSet<String>();
|
||||||
|
}
|
||||||
|
ugczones.add(String.valueOf(result.get(UGC_ZONE_FIELD)));
|
||||||
|
removedUgczones.put(key, ugczones);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove ActiveTableRecord from records whose etn, ugcZone, and phensig is same as
|
||||||
|
// canceled or expired.
|
||||||
|
String etn, ugczone, phensig;
|
||||||
|
for (Pair<String, String> etnPhensig: removedUgczones.keySet()) {
|
||||||
|
ugczones = removedUgczones.get(etnPhensig);
|
||||||
|
etn = etnPhensig.getFirst();
|
||||||
|
phensig = etnPhensig.getSecond();
|
||||||
|
Iterator<String> iter = ugczones.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
ugczone = iter.next();
|
||||||
|
Iterator<ActiveTableRecord> iterator = records.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
ActiveTableRecord atr = iterator.next();
|
||||||
|
if (atr.getEtn().equals(etn) && atr.getUgcZone().equals(ugczone) &&
|
||||||
|
atr.getPhensig().equals(phensig)) {
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,9 +396,6 @@ public class WatchUtil {
|
||||||
Map<Watch, List<String>> map = new HashMap<Watch, List<String>>();
|
Map<Watch, List<String>> map = new HashMap<Watch, List<String>>();
|
||||||
// For each watch event, get the end time and list of active zones
|
// For each watch event, get the end time and list of active zones
|
||||||
for (ActiveTableRecord ar : activeTableRecords) {
|
for (ActiveTableRecord ar : activeTableRecords) {
|
||||||
if (ar.getAct().equals("CAN") || ar.getAct().equals("EXP")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Currently reports all zones in the watch even if a given zone is
|
* Currently reports all zones in the watch even if a given zone is
|
||||||
* not in the warning polygon. If the logic is changed to only show
|
* not in the warning polygon. If the logic is changed to only show
|
||||||
|
|
|
@ -141,8 +141,6 @@ import com.vividsolutions.jts.io.WKTReader;
|
||||||
* added determineAffectedMarinePortions().
|
* added determineAffectedMarinePortions().
|
||||||
* Jul 21, 2014 3419 jsanchez Refactored WatchUtil.
|
* Jul 21, 2014 3419 jsanchez Refactored WatchUtil.
|
||||||
* Aug 15, 2014 DR15701 mgamazaychikov Removed static field watchUtil.
|
* Aug 15, 2014 DR15701 mgamazaychikov Removed static field watchUtil.
|
||||||
* Aug 28, 2014 ASM #15551 Qinglu Lin Replaced 1200 PM/1200 AM by NOON/MIDNIGHT, removed days in
|
|
||||||
* included tornado/severe thunderstorm watch message.
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author njensen
|
* @author njensen
|
||||||
|
@ -874,37 +872,7 @@ public class TemplateRunner {
|
||||||
System.out.println("velocity time: "
|
System.out.println("velocity time: "
|
||||||
+ (System.currentTimeMillis() - tz0));
|
+ (System.currentTimeMillis() - tz0));
|
||||||
|
|
||||||
String watches[] = {"TORNADO WATCH", "SEVERE THUNDERSTORM WATCH"};
|
String text = script.toString();
|
||||||
int index1 = -1, index2 = -1, index1ToUse = -1;
|
|
||||||
String doubleDollar = "$$";
|
|
||||||
boolean firstTime = true;
|
|
||||||
for (String s: watches) {
|
|
||||||
index1 = script.indexOf(s, 0);
|
|
||||||
if (index1 > 0) {
|
|
||||||
index2 = script.indexOf(doubleDollar, index1);
|
|
||||||
}
|
|
||||||
if (firstTime && index1 > -1) {
|
|
||||||
index1ToUse = index1;
|
|
||||||
firstTime = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String days[] = {"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"};
|
|
||||||
String substring = "", text;
|
|
||||||
if (index1ToUse > -1 && index2 > -1) {
|
|
||||||
substring = script.substring(index1ToUse, index2).toUpperCase();
|
|
||||||
// remove day
|
|
||||||
for (String day: days) {
|
|
||||||
substring = substring.replaceAll(day + " ", "");
|
|
||||||
}
|
|
||||||
// replace 1200 PM/1200 AM with NOON/MIDNIGHT
|
|
||||||
substring = substring.replaceAll("1200 PM", "NOON");
|
|
||||||
substring = substring.replaceAll("1200 AM", "MIDNIGHT");
|
|
||||||
// concatenate strings
|
|
||||||
text = script.substring(0, index1ToUse - 1);
|
|
||||||
text = text + " " + substring + script.substring(index2, script.length());
|
|
||||||
} else {
|
|
||||||
text = script.toString();
|
|
||||||
}
|
|
||||||
WarningTextHandler handler = WarningTextHandlerFactory.getHandler(
|
WarningTextHandler handler = WarningTextHandlerFactory.getHandler(
|
||||||
selectedAction, text, config.getAutoLockText());
|
selectedAction, text, config.getAutoLockText());
|
||||||
String handledText = handler.handle(text, areas, cancelareas,
|
String handledText = handler.handle(text, areas, cancelareas,
|
||||||
|
|
|
@ -37,6 +37,7 @@ import com.raytheon.viz.texteditor.TextWarningConstants;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 06182008 bwoodle additional format method overloads, javadocs.
|
* 06182008 bwoodle additional format method overloads, javadocs.
|
||||||
|
* Sep 12, 2014 ASM RM#15551 Qinglu Lin Added formatUseNoonMidnight().
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -45,6 +46,8 @@ import com.raytheon.viz.texteditor.TextWarningConstants;
|
||||||
*/
|
*/
|
||||||
public class DateUtil {
|
public class DateUtil {
|
||||||
|
|
||||||
|
Pattern timePtrn = Pattern.compile("(1200\\s(AM|PM))");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a date for the severe weather warnings templates
|
* Format a date for the severe weather warnings templates
|
||||||
*
|
*
|
||||||
|
@ -107,6 +110,28 @@ public class DateUtil {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String formatUseNoonMidnight(Date date, DateFormat format, int interval, String tz) {
|
||||||
|
return formatUseNoonMidnight(date, format, interval, getTimeZoneFromString(tz));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formatUseNoonMidnight(Date date, DateFormat format, int interval, TimeZone tz) {
|
||||||
|
String str;
|
||||||
|
Date workingDate = date;
|
||||||
|
if (interval > 0) {
|
||||||
|
workingDate = roundDate(date, interval);
|
||||||
|
}
|
||||||
|
synchronized (format) {
|
||||||
|
format.setTimeZone(tz);
|
||||||
|
str = format.format(workingDate);
|
||||||
|
}
|
||||||
|
Matcher m = timePtrn.matcher(str);
|
||||||
|
if(m.find()) {
|
||||||
|
str = str.replace("1200 AM", "MIDNIGHT");
|
||||||
|
str = str.replace("1200 PM", "NOON");
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a date for the severe weather warnings templates
|
* Format a date for the severe weather warnings templates
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
##### Qinglu Lin 03-17-2014 DR 16309. Updated inserttorwatches and insertsvrwatches.
|
##### Qinglu Lin 03-17-2014 DR 16309. Updated inserttorwatches and insertsvrwatches.
|
||||||
##### Qinglu Lin 05-21-2014 DR 16309. Updated inserttorwatches and insertsvrwatches by changing 'FOR##' to 'FOR ##'.
|
##### Qinglu Lin 05-21-2014 DR 16309. Updated inserttorwatches and insertsvrwatches by changing 'FOR##' to 'FOR ##'.
|
||||||
##### D. Friedman 08-28-2014 ASM #15658. Add marine watch wording.
|
##### D. Friedman 08-28-2014 ASM #15658. Add marine watch wording.
|
||||||
##### Qinglu Lin 08-29-2014 ASM #15551. Overhauled inserttorwatches and insertsvrwatches.
|
##### Qinglu Lin 09-15-2014 ASM #15551. Overhauled inserttorwatches and insertsvrwatches, added until.
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
#*
|
#*
|
||||||
Mile Marker Test Code
|
Mile Marker Test Code
|
||||||
|
@ -200,25 +200,35 @@ ${drainage.name}##
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
#set($etns = [])
|
||||||
|
#set($lastTime = "")
|
||||||
|
#set($currTime = "")
|
||||||
#set($lastEtn = "")
|
#set($lastEtn = "")
|
||||||
#set($lastEndTime = "")
|
#set($count = 0)
|
||||||
#foreach(${watch} in ${tornadoWatches})
|
#foreach(${watch} in ${tornadoWatches})
|
||||||
#if($lastEtn != "" && ${watch.etn} != ${lastEtn})
|
#set($success = $etns.add(${watch.etn}))
|
||||||
|
#end
|
||||||
|
#foreach(${watch} in ${tornadoWatches})
|
||||||
|
#set($count = $count + 1)
|
||||||
|
#if(${lastEtn} != "" && ${watch.etn} != ${lastEtn})
|
||||||
. ##
|
. ##
|
||||||
#end
|
#end
|
||||||
#set($endTime = ${watch.endTime})
|
#set($endTime = ${watch.endTime})
|
||||||
#if(${watch.etn} == ${lastEtn})
|
#if(${watch.etn} != ${lastEtn})
|
||||||
#if(${endTime} == ${lastEndTime})
|
#set($lastTime = "#until(${endTime}, ${timeFormat}, ${secondtimezone}, ${watch})")
|
||||||
...##
|
A TORNADO WATCH${ALSO} REMAINS IN EFFECT ${lastTime}##
|
||||||
#else
|
|
||||||
...UNTIL ${dateUtil.format(${endTime}, ${timeFormat.plain}, 15, ${localtimezone})} FOR ##
|
|
||||||
#end
|
|
||||||
#else
|
|
||||||
A TORNADO WATCH${ALSO} REMAINS IN EFFECT UNTIL ${dateUtil.format(${endTime}, ${timeFormat.plain}, 15, ${localtimezone})} FOR ##
|
|
||||||
#set($ALSO = " ALSO")
|
#set($ALSO = " ALSO")
|
||||||
|
#else
|
||||||
|
#if(!$foreach.hasNext() || ${watch.etn} != $etns.get(${count}))
|
||||||
|
AND ##
|
||||||
|
#else
|
||||||
|
...##
|
||||||
|
#end
|
||||||
|
#set($currTime = "#until(${endTime}, ${timeFormat}, ${secondtimezone}, ${watch})")
|
||||||
|
#if(${currTime} != ${lastTime})
|
||||||
|
${currTime}##
|
||||||
|
#set($lastTime = ${currTime})
|
||||||
#end
|
#end
|
||||||
#if(${secondtimezone})
|
|
||||||
/${dateUtil.format(${watch.getEndTime()}, ${timeFormat.plain}, 15, ${secondtimezone})}/##
|
|
||||||
#end
|
#end
|
||||||
#if(!${watch.marineAreas})
|
#if(!${watch.marineAreas})
|
||||||
#areaFormat(${watch.partOfState} true false true)${watch.state}##
|
#areaFormat(${watch.partOfState} true false true)${watch.state}##
|
||||||
|
@ -226,7 +236,6 @@ A TORNADO WATCH${ALSO} REMAINS IN EFFECT UNTIL ${dateUtil.format(${endTime}, ${t
|
||||||
#formatMarineAreas(${watch.marineAreas})
|
#formatMarineAreas(${watch.marineAreas})
|
||||||
#end
|
#end
|
||||||
#set($lastEtn = ${watch.etn})
|
#set($lastEtn = ${watch.etn})
|
||||||
#set($lastEndTime = ${watch.endTime})
|
|
||||||
#end
|
#end
|
||||||
#if(${lastEtn} != "")
|
#if(${lastEtn} != "")
|
||||||
.
|
.
|
||||||
|
@ -234,6 +243,14 @@ A TORNADO WATCH${ALSO} REMAINS IN EFFECT UNTIL ${dateUtil.format(${endTime}, ${t
|
||||||
#end
|
#end
|
||||||
########END MACRO
|
########END MACRO
|
||||||
|
|
||||||
|
#macro(until $endTime $timeFormat $secondtimezone $watch)
|
||||||
|
UNTIL ${dateUtil.formatUseNoonMidnight(${endTime}, ${timeFormat.clock}, 15, ${localtimezone})}##
|
||||||
|
#if(${secondtimezone})
|
||||||
|
/${dateUtil.formatUseNoonMidnight(${watch.getEndTime()}, ${timeFormat.clock}, 15, ${secondtimezone})}/##
|
||||||
|
#end
|
||||||
|
FOR ##
|
||||||
|
#end
|
||||||
|
|
||||||
#macro(insertsvrwatches $watches $list $secondtimezone $dateUtil $timeFormat)
|
#macro(insertsvrwatches $watches $list $secondtimezone $dateUtil $timeFormat)
|
||||||
#set($svrWatches = [])
|
#set($svrWatches = [])
|
||||||
#set($ALSO = "")
|
#set($ALSO = "")
|
||||||
|
@ -244,25 +261,35 @@ A TORNADO WATCH${ALSO} REMAINS IN EFFECT UNTIL ${dateUtil.format(${endTime}, ${t
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
#set($etns = [])
|
||||||
|
#set($lastTime = "")
|
||||||
|
#set($currTime = "")
|
||||||
#set($lastEtn = "")
|
#set($lastEtn = "")
|
||||||
#set($lastEndTime = "")
|
#set($count = 0)
|
||||||
#foreach(${watch} in ${svrWatches})
|
#foreach(${watch} in ${svrWatches})
|
||||||
#if($lastEtn != "" && ${watch.etn} != ${lastEtn})
|
#set($success = $etns.add(${watch.etn}))
|
||||||
|
#end
|
||||||
|
#foreach(${watch} in ${svrWatches})
|
||||||
|
#set($count = $count + 1)
|
||||||
|
#if(${lastEtn} != "" && ${watch.etn} != ${lastEtn})
|
||||||
. ##
|
. ##
|
||||||
#end
|
#end
|
||||||
#set($endTime = ${watch.endTime})
|
#set($endTime = ${watch.endTime})
|
||||||
#if(${watch.etn} == ${lastEtn})
|
#if(${watch.etn} != ${lastEtn})
|
||||||
#if(${endTime} == ${lastEndTime})
|
#set($lastTime = "#until(${endTime}, ${timeFormat}, ${secondtimezone}, ${watch})")
|
||||||
...##
|
A SEVERE THUNDERSTORM WATCH${ALSO} REMAINS IN EFFECT ${lastTime}##
|
||||||
#else
|
|
||||||
...UNTIL ${dateUtil.format(${endTime}, ${timeFormat.plain}, 15, ${localtimezone})} FOR ##
|
|
||||||
#end
|
|
||||||
#else
|
|
||||||
A SEVERE THUNDERSTORM WATCH${ALSO} REMAINS IN EFFECT UNTIL ${dateUtil.format(${endTime}, ${timeFormat.plain}, 15, ${localtimezone})} FOR ##
|
|
||||||
#set($ALSO = " ALSO")
|
#set($ALSO = " ALSO")
|
||||||
|
#else
|
||||||
|
#if(!$foreach.hasNext() || ${watch.etn} != $etns.get(${count}))
|
||||||
|
AND ##
|
||||||
|
#else
|
||||||
|
...##
|
||||||
|
#end
|
||||||
|
#set($currTime = "#until(${endTime}, ${timeFormat}, ${secondtimezone}, ${watch})")
|
||||||
|
#if(${currTime} != ${lastTime})
|
||||||
|
${currTime}##
|
||||||
|
#set($lastTime = ${currTime})
|
||||||
#end
|
#end
|
||||||
#if(${secondtimezone})
|
|
||||||
/${dateUtil.format(${watch.getEndTime()}, ${timeFormat.plain}, 15, ${secondtimezone})}/##
|
|
||||||
#end
|
#end
|
||||||
#if(!${watch.marineAreas})
|
#if(!${watch.marineAreas})
|
||||||
#areaFormat(${watch.partOfState} true false true)${watch.state}##
|
#areaFormat(${watch.partOfState} true false true)${watch.state}##
|
||||||
|
@ -270,7 +297,6 @@ A SEVERE THUNDERSTORM WATCH${ALSO} REMAINS IN EFFECT UNTIL ${dateUtil.format(${e
|
||||||
#formatMarineAreas(${watch.marineAreas})
|
#formatMarineAreas(${watch.marineAreas})
|
||||||
#end
|
#end
|
||||||
#set($lastEtn = ${watch.etn})
|
#set($lastEtn = ${watch.etn})
|
||||||
#set($lastEndTime = ${watch.endTime})
|
|
||||||
#end
|
#end
|
||||||
#if(${lastEtn} != "")
|
#if(${lastEtn} != "")
|
||||||
.
|
.
|
||||||
|
|
Loading…
Add table
Reference in a new issue