Omaha #4441 and #4442 Fix WarnGen QC and locking issues with mixed case.

Change-Id: I95705831aa37e0774b09a0d2acee42c86d361368

Former-commit-id: ac3c7983f3c287cad4e0f38b0231b64ad69a60a6
This commit is contained in:
Ron Anderson 2015-06-02 11:55:06 -05:00
parent cb8e59c56f
commit 15dfb5afef
13 changed files with 363 additions and 287 deletions

View file

@ -20,9 +20,7 @@
package com.raytheon.viz.texteditor.dialogs; package com.raytheon.viz.texteditor.dialogs;
import java.io.IOException; import org.eclipse.jface.resource.ImageDescriptor;
import java.io.InputStream;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
@ -38,6 +36,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.core.mode.CAVEMode; import com.raytheon.viz.core.mode.CAVEMode;
import com.raytheon.viz.texteditor.Activator;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/** /**
@ -57,6 +56,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* added to CaveSWTDialog. * added to CaveSWTDialog.
* 17 Sep 2013 #2384 lvenable Fixed memory leak and utilized the disposed() * 17 Sep 2013 #2384 lvenable Fixed memory leak and utilized the disposed()
* method. * method.
* May 29, 2015 #4441 randerso Fixed loading of images
* *
* </pre> * </pre>
* *
@ -120,36 +120,29 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
private void createImage(Composite mainComposite) { private void createImage(Composite mainComposite) {
InputStream is = null; String imagePath = null;
try { try {
ClassLoader cl = WarnGenConfirmationDlg.class.getClassLoader();
if (mode.equals(CAVEMode.OPERATIONAL)) { if (mode.equals(CAVEMode.OPERATIONAL)) {
// add Live image // add Live image
is = cl.getResourceAsStream(IMAGE_OPERATIONAL); imagePath = IMAGE_OPERATIONAL;
} else if (mode.equals(CAVEMode.TEST)) { } else if (mode.equals(CAVEMode.TEST)) {
// add Test image // add Test image
is = cl.getResourceAsStream(IMAGE_TEST); imagePath = IMAGE_TEST;
} else if (mode.equals(CAVEMode.PRACTICE)) { } else if (mode.equals(CAVEMode.PRACTICE)) {
// add Practice image // add Practice image
is = cl.getResourceAsStream(IMAGE_PRACTICE); imagePath = IMAGE_PRACTICE;
} else { } else {
// unknown // unknown
is = cl.getResourceAsStream(IMAGE_OPERATIONAL); imagePath = IMAGE_OPERATIONAL;
} }
stopSign = new Image(mainComposite.getDisplay(), is); ImageDescriptor id = Activator.imageDescriptorFromPlugin(
Activator.PLUGIN_ID, imagePath);
stopSign = id.createImage(mainComposite.getDisplay());
Label stopSignLbl = new Label(mainComposite, 0); Label stopSignLbl = new Label(mainComposite, 0);
stopSignLbl.setImage(stopSign); stopSignLbl.setImage(stopSign);
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} finally {
try {
is.close();
} catch (IOException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
} }
} }

View file

@ -36,7 +36,8 @@ import java.util.regex.Pattern;
* May 1, 2013 15893 mgamazaychikov Changed listOfAreaNamePtrn. * May 1, 2013 15893 mgamazaychikov Changed listOfAreaNamePtrn.
* Feb 26, 2014 16386 Qinglu Lin Updated listOfAreaNamePtrn to handle issue caused by * Feb 26, 2014 16386 Qinglu Lin Updated listOfAreaNamePtrn to handle issue caused by
* hyphens in county name, and that by "'" and "/" as well. * hyphens in county name, and that by "'" and "/" as well.
* * May 29, 2015 4441 randerso Made bullet patterns case insensitive
*
* </pre> * </pre>
* *
* @version 1.0 * @version 1.0
@ -61,14 +62,17 @@ public interface IQCCheck {
public static final Pattern listOfAreaNamePtrn = Pattern public static final Pattern listOfAreaNamePtrn = Pattern
.compile("^([\\w\\s\\.'/]*-)"); .compile("^([\\w\\s\\.'/]*-)");
public static final Pattern firstBulletPtrn = Pattern public static final Pattern firstBulletPtrn = Pattern.compile(
.compile("\\*\\s(.*)\\s(WARNING|ADVISORY)(\\sFOR(.*)|...)"); "\\*\\s(.*)\\s(WARNING|ADVISORY)(\\sFOR(.*)|...)",
Pattern.CASE_INSENSITIVE);
public static final Pattern secondBulletPtrn = Pattern public static final Pattern secondBulletPtrn = Pattern.compile(
.compile("\\*\\sUNTIL\\s(\\d{1,2})(\\d{2})\\s(AM|PM)\\s(\\w{3,4})"); "\\*\\sUNTIL\\s(\\d{1,2})(\\d{2})\\s(AM|PM)\\s(\\w{3,4})",
Pattern.CASE_INSENSITIVE);
public static final Pattern thirdBulletPtrn = Pattern public static final Pattern thirdBulletPtrn = Pattern.compile(
.compile("\\*\\sAT\\s(\\d{1,2})(\\d{2})\\s(AM|PM)\\s(\\w{3,4})(.*)"); "\\*\\sAT\\s(\\d{1,2})(\\d{2})\\s(AM|PM)\\s(\\w{3,4})(.*)",
Pattern.CASE_INSENSITIVE);
public static final Pattern latLonPtrn = Pattern public static final Pattern latLonPtrn = Pattern
.compile("LAT...LON+(\\s\\d{3,4}\\s\\d{3,5}){1,}"); .compile("LAT...LON+(\\s\\d{3,4}\\s\\d{3,5}){1,}");

View file

@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -41,7 +42,7 @@ import com.raytheon.viz.texteditor.util.VtecObject;
import com.raytheon.viz.texteditor.util.VtecUtil; import com.raytheon.viz.texteditor.util.VtecUtil;
/** /**
* TODO Add Description * QC text segment
* *
* <pre> * <pre>
* *
@ -52,15 +53,16 @@ import com.raytheon.viz.texteditor.util.VtecUtil;
* Initial creation * Initial creation
* 25 AUG 2011 10719 rferrel Changed ugcPtrn to handle multi-line UGCs * 25 AUG 2011 10719 rferrel Changed ugcPtrn to handle multi-line UGCs
* 01 SEP 2011 10764 rferrel Allow multiple bullet types for given Vtec. * 01 SEP 2011 10764 rferrel Allow multiple bullet types for given Vtec.
* 20 JUL 2012 15003 mgamazaychikov Allow standalone MWS have no headline * 20 JUL 2012 15003 mgamazaychikov Allow standalone MWS have no headline
* Add vtec to checkHeadline signature * Add vtec to checkHeadline signature
* 20 JUL 2012 15006 mgamazaychikov Do not perform search for a list of * 20 JUL 2012 15006 mgamazaychikov Do not perform search for a list of
* county/zones names in the MWS segment heading. * county/zones names in the MWS segment heading.
* 07 NOV 2012 15003 mgamazaychikov Do not perform QC check on standalone MWS headline. * 07 NOV 2012 15003 mgamazaychikov Do not perform QC check on standalone MWS headline.
* 21 MAY 2013 16200 Qinglu Lin Prevent countyOrZoneCounter from being increased for a line * 21 MAY 2013 16200 Qinglu Lin Prevent countyOrZoneCounter from being increased for a line
* that has no word County/Parish/Municipality in it. * that has no word County/Parish/Municipality in it.
* 13 MAY 2014 17177 Qinglu Lin Updated runQC(). * 13 MAY 2014 17177 Qinglu Lin Updated runQC().
* 15 SEP 2014 529 mgamazaychikov Create firstBulletImmediateCauseQCExclusions list and add IC to it. * 15 SEP 2014 529 mgamazaychikov Create firstBulletImmediateCauseQCExclusions list and add IC to it.
* 29 MAY 2015 4441 randerso Fixed QC to work with mixed case
* *
* </pre> * </pre>
* *
@ -88,11 +90,16 @@ public class TextSegmentCheck implements IQCCheck {
} }
} }
// List of immediate causes to be excluded from quality control check in the first bullet // List of immediate causes to be excluded from quality control check in the
private static List<String> firstBulletImmediateCauseQCExclusions = Arrays.asList("ER", "MC", "UU", "IC"); // first bullet
private static List<String> firstBulletImmediateCauseQCExclusions = Arrays
.asList("ER", "MC", "UU", "IC");
@Override @Override
public String runQC(String header, String body, String nnn) { public String runQC(String header, String body, String nnn) {
header = header.toUpperCase();
body = body.toUpperCase();
int countyOrZoneCounter = 0; int countyOrZoneCounter = 0;
int ugcLength = 0; int ugcLength = 0;
int czmType = 1; int czmType = 1;
@ -131,22 +138,17 @@ public class TextSegmentCheck implements IQCCheck {
} }
Set<String> countyParishMunicipality = new HashSet<String>(); Set<String> countyParishMunicipality = new HashSet<String>();
for (String countyType : QualityControl for (Entry<String, String> entry : QualityControl.getCountyTypeMap()
.getCountyTypeMap().values()) { .entrySet()) {
String key = entry.getKey();
String countyType = entry.getValue();
if (countyType.length() > 1) { if (countyType.length() > 1) {
countyParishMunicipality.add(countyType.trim()); countyParishMunicipality.add(countyType.trim().toUpperCase());
} else { } else if (key.length() > 1) {
countyParishMunicipality.add(key.toUpperCase());
}
}
}
}
for (String key : QualityControl.getCountyTypeMap().keySet()) {
if (QualityControl.getCountyTypeMap()
.get(key).length() <= 1) {
if (key.length() > 1) {
countyParishMunicipality.add(key);
}
}
}
countyParishMunicipality.remove("AK"); countyParishMunicipality.remove("AK");
countyParishMunicipality.remove("DC"); countyParishMunicipality.remove("DC");
countyParishMunicipality.add("CITY"); countyParishMunicipality.add("CITY");
@ -163,7 +165,7 @@ public class TextSegmentCheck implements IQCCheck {
if (line.equals("$$")) { if (line.equals("$$")) {
if (ugc.length() == 0 && vtec == null) { if ((ugc.length() == 0) && (vtec == null)) {
errorMsg.append("Badly placed segment end.\n"); errorMsg.append("Badly placed segment end.\n");
return errorMsg.toString(); return errorMsg.toString();
} }
@ -173,14 +175,14 @@ public class TextSegmentCheck implements IQCCheck {
ugc = ""; ugc = "";
/* /*
* DR15003 - Add vtec to signature ias n order * DR15003 - Add vtec to signature ias n order to distinguish
* to distinguish between standalone * between standalone and followup MWS a check of VTEC is
* and followup MWS a check of VTEC is needed. * needed.
*/ */
errorMsg.append(checkHeadline(headline, nnn, vtec)); errorMsg.append(checkHeadline(headline, nnn, vtec));
headline = ""; headline = "";
if (segmentCount > 1 if ((segmentCount > 1)
&& !QualityControl.segmentedNNN.contains(nnn)) { && !QualityControl.segmentedNNN.contains(nnn)) {
errorMsg.append("Segments exist in unsegmented product.\n"); errorMsg.append("Segments exist in unsegmented product.\n");
} }
@ -200,11 +202,11 @@ public class TextSegmentCheck implements IQCCheck {
if (ugc.matches("\\w{2}[CZ]\\d{3}[->].*") == false) { if (ugc.matches("\\w{2}[CZ]\\d{3}[->].*") == false) {
errorMsg.append("First UGC does not specify a zone or county.\n"); errorMsg.append("First UGC does not specify a zone or county.\n");
} }
if (ugc.length() > 2 && ugc.charAt(2) == 'C') { if ((ugc.length() > 2) && (ugc.charAt(2) == 'C')) {
++countyZoneCnt; ++countyZoneCnt;
countyBased = true; countyBased = true;
} }
if (ugc.length() > 2 && ugc.charAt(2) == 'Z') { if ((ugc.length() > 2) && (ugc.charAt(2) == 'Z')) {
++countyZoneCnt; ++countyZoneCnt;
} }
@ -264,15 +266,14 @@ public class TextSegmentCheck implements IQCCheck {
if (expectNamesList) { if (expectNamesList) {
m = listOfAreaNamePtrn.matcher(line); m = listOfAreaNamePtrn.matcher(line);
/* /*
* DR15006 - MWS does not have the list of * DR15006 - MWS does not have the list of marine zones names in
* marine zones names in the segment heading, * the segment heading, so skip the check for MWS
* so skip the check for MWS
*/ */
if ( !nnn.equalsIgnoreCase("MWS")) { if (!nnn.equalsIgnoreCase("MWS")) {
if (!m.find()) { if (!m.find()) {
errorMsg.append("List of county/zone names missing.\n"); errorMsg.append("List of county/zone names missing.\n");
} }
} }
expectNamesList = false; expectNamesList = false;
continue; continue;
} }
@ -297,7 +298,7 @@ public class TextSegmentCheck implements IQCCheck {
} }
// third bullet // third bullet
if (line.startsWith("*") && nb == 3) { if (line.startsWith("*") && (nb == 3)) {
m = thirdBulletPtrn.matcher(line); m = thirdBulletPtrn.matcher(line);
if (!line.substring(0, 5).equals("* AT ")) { if (!line.substring(0, 5).equals("* AT ")) {
errorMsg.append("Event bullet does not start with '* AT '\n."); errorMsg.append("Event bullet does not start with '* AT '\n.");
@ -309,9 +310,10 @@ public class TextSegmentCheck implements IQCCheck {
} }
// second bullet // second bullet
if (line.startsWith("*") && nb == 2) { if (line.startsWith("*") && (nb == 2)) {
m = secondBulletPtrn.matcher(line); m = secondBulletPtrn.matcher(line);
if (m.find() || line.contains("* UNTIL NOON") || line.contains("* UNTIL MIDNIGHT")) { if (m.find() || line.contains("* UNTIL NOON")
|| line.contains("* UNTIL MIDNIGHT")) {
secondBulletFound = true; secondBulletFound = true;
insideFirstBullet = false; insideFirstBullet = false;
continue; continue;
@ -360,14 +362,14 @@ public class TextSegmentCheck implements IQCCheck {
&& !secondBulletFound && !secondBulletFound
&& (line.contains("AREA...") && (line.contains("AREA...")
|| line.contains("AREAS...") || line || line.contains("AREAS...") || line
.contains("AREA WAS..."))) { .contains("AREA WAS..."))) {
insideFirstBullet = true; insideFirstBullet = true;
continue; continue;
} }
} }
if (insideFirstBullet) { if (insideFirstBullet) {
if (ic != null if ((ic != null)
&& !firstBulletImmediateCauseQCExclusions.contains(ic) && !firstBulletImmediateCauseQCExclusions.contains(ic)
&& checkIC) { && checkIC) {
boolean validIC = false; boolean validIC = false;
@ -391,7 +393,7 @@ public class TextSegmentCheck implements IQCCheck {
} }
if (czmType == 3) { if (czmType == 3) {
if (line != null && line.trim().startsWith("INCLUDING ")) { if ((line != null) && line.trim().startsWith("INCLUDING ")) {
insideFirstBullet = false; // stop adding counties/zones insideFirstBullet = false; // stop adding counties/zones
continue; continue;
} }
@ -402,7 +404,7 @@ public class TextSegmentCheck implements IQCCheck {
} }
boolean invalidCountyOrZone = true; boolean invalidCountyOrZone = true;
if (ugc.length() > 2 && ugc.charAt(2) == 'Z') { if ((ugc.length() > 2) && (ugc.charAt(2) == 'Z')) {
// zones do not use countyTypes // zones do not use countyTypes
if (line.contains(" IN ")) { if (line.contains(" IN ")) {
invalidCountyOrZone = false; invalidCountyOrZone = false;
@ -412,16 +414,18 @@ public class TextSegmentCheck implements IQCCheck {
.keySet()) { .keySet()) {
if (line.contains(state) if (line.contains(state)
&& line.contains(QualityControl && line.contains(QualityControl
.getCountyTypeMap().get(state))) { .getCountyTypeMap().get(state)
.toUpperCase())) {
invalidCountyOrZone = false; invalidCountyOrZone = false;
} }
} }
if (invalidCountyOrZone) { if (invalidCountyOrZone) {
for (String countyType : QualityControl for (String countyType : QualityControl
.getCountyTypeMap().values()) { .getCountyTypeMap().values()) {
if (countyType.trim().length() > 0 if ((countyType.trim().length() > 0)
&& line.contains(" " && line.contains(" "
+ countyType.trim())) { + countyType.trim()
.toUpperCase())) {
invalidCountyOrZone = false; invalidCountyOrZone = false;
break; break;
} }
@ -436,7 +440,7 @@ public class TextSegmentCheck implements IQCCheck {
int cpmCounter = 0; int cpmCounter = 0;
Iterator<String> iter = countyParishMunicipality.iterator(); Iterator<String> iter = countyParishMunicipality.iterator();
while(iter.hasNext()) { while (iter.hasNext()) {
if (line.contains(iter.next())) { if (line.contains(iter.next())) {
break; break;
} else { } else {
@ -482,8 +486,9 @@ public class TextSegmentCheck implements IQCCheck {
if (ugcLength == 0) { if (ugcLength == 0) {
errorMsg.append("No UGC text was found\n"); errorMsg.append("No UGC text was found\n");
} else if (nb > 0 && (czmType == 1 || (czmType == 2 && countyBased)) } else if ((nb > 0)
&& ugcLength != countyOrZoneCounter) { && ((czmType == 1) || ((czmType == 2) && countyBased))
&& (ugcLength != countyOrZoneCounter)) {
// DR 11060 - Don't count zone areas for hydro products // DR 11060 - Don't count zone areas for hydro products
errorMsg.append(ugcLength).append(" UGCs while ") errorMsg.append(ugcLength).append(" UGCs while ")
.append(countyOrZoneCounter) .append(countyOrZoneCounter)
@ -516,13 +521,13 @@ public class TextSegmentCheck implements IQCCheck {
pairs++; pairs++;
double lat = Double.parseDouble(m.group(1)); double lat = Double.parseDouble(m.group(1));
double lon = Double.parseDouble(m.group(2)); double lon = Double.parseDouble(m.group(2));
if (lat > 9000 || lon > 18000) { if ((lat > 9000) || (lon > 18000)) {
errorMsg += "Data error in the LAT...LON line.\n"; errorMsg += "Data error in the LAT...LON line.\n";
return errorMsg; return errorMsg;
} }
} }
if (pairs <= 2 || pairs > 20) { if ((pairs <= 2) || (pairs > 20)) {
errorMsg += "LAT...LON line missing or malformed.\n"; errorMsg += "LAT...LON line missing or malformed.\n";
} }
@ -546,13 +551,12 @@ public class TextSegmentCheck implements IQCCheck {
return errorMsg; return errorMsg;
} }
/* /*
* DR15003: no headline QC on standalone MWS. * DR15003: no headline QC on standalone MWS. To distinguish between
* To distinguish between standalone and follow up MWS * standalone and follow up MWS the VTEC check is performed as
* the VTEC check is performed as standalone MWS * standalone MWS do not contain VTEC
* do not contain VTEC
*/ */
if (nnn.equals("MWS") && vtec == null) { if (nnn.equals("MWS") && (vtec == null)) {
return ""; return "";
} }
if (headline.length() == 0) { if (headline.length() == 0) {

View file

@ -57,13 +57,39 @@ import com.raytheon.viz.warngen.gis.AffectedAreas;
* Apr 29, 2014 3033 jsanchez Moved patterns into ICommonPatterns * Apr 29, 2014 3033 jsanchez Moved patterns into ICommonPatterns
* May 1, 2014 DR 16627 Qinglu Lin Added hasStateAbbrev(), isOtherType(), lockListOfNames(), and updated lock(). * May 1, 2014 DR 16627 Qinglu Lin Added hasStateAbbrev(), isOtherType(), lockListOfNames(), and updated lock().
* May 13, 2014 DR 17177 Qinglu Lin Updated secondBullet(). * May 13, 2014 DR 17177 Qinglu Lin Updated secondBullet().
* May 29, 2015 4442 randerso Fixed WarnGen text locking to work with mixed case
* *
* </pre> * </pre>
* *
* @author jsanchez * @author jsanchez
* @version 1.0 * @version 1.0
*/ */
abstract public class AbstractLockingBehavior implements ICommonPatterns { abstract public class AbstractLockingBehavior {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AbstractLockingBehavior.class);
protected static String warningType = "(FLOOD ADVISORY)|(FLOOD WARNING)|(FLOOD STATEMENT)"
+ "|(SEVERE WEATHER STATEMENT)|(EXTREME WIND WARNING)|(FIRE WARNING)"
+ "|(FLASH FLOOD WARNING)|(FLASH FLOOD STATEMENT)|(SEVERE THUNDERSTORM WARNING)"
+ "|(TORNADO WARNING)|(MARINE WEATHER STATEMENT)|(SHORT TERM FORECAST)"
+ "|(SPECIAL WEATHER STATEMENT)|(SPECIAL MARINE WARNING)";
private static Pattern ugcPtrn = Pattern.compile(WarnGenPatterns.ugc
+ WarnGenPatterns.NEWLINE, Pattern.MULTILINE);
private static Pattern listOfAreaNamePtrn = Pattern.compile(
WarnGenPatterns.listOfAreaName + WarnGenPatterns.NEWLINE,
Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
private static Pattern startMND = Pattern
.compile("(BULLETIN - IMMEDIATE BROADCAST REQUESTED)|(BULLETIN - EAS ACTIVATION REQUESTED)|"
+ warningType);
private static Pattern stateAbbrevPtrn = Pattern.compile(
WarnGenPatterns.listOfAreaName + WarnGenPatterns.NEWLINE,
Pattern.MULTILINE);
private static Pattern immediateCausePtrn = null;
/** /**
* Sorts in reverse order the areas based on the length of the name. * Sorts in reverse order the areas based on the length of the name.
@ -86,19 +112,6 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
protected String text; protected String text;
protected static final String REPLACEMENT = LOCK_START + "$0" + LOCK_END;
protected String warningType = "(FLOOD ADVISORY)|(FLOOD WARNING)|(FLOOD STATEMENT)"
+ "|(SEVERE WEATHER STATEMENT)|(EXTREME WIND WARNING)|(FIRE WARNING)"
+ "|(FLASH FLOOD WARNING)|(FLASH FLOOD STATEMENT)|(SEVERE THUNDERSTORM WARNING)"
+ "|(TORNADO WARNING)|(MARINE WEATHER STATEMENT)|(SHORT TERM FORECAST)"
+ "|(SPECIAL WEATHER STATEMENT)|(SPECIAL MARINE WARNING)";
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AbstractLockingBehavior.class);
private static Pattern immediateCausePtrn = null;
protected WarningAction action = null; protected WarningAction action = null;
/** /**
@ -166,10 +179,11 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the header before the first bullet. * Locks the header before the first bullet.
*/ */
private void header() { private void header() {
// LOCK_END should not be found at the beginning since the previous line // ICommonPatterns.LOCK_END should not be found at the beginning since
// the previous line
// should be blank. // should be blank.
find(header.matcher(text)); find(WarnGenPatterns.header.matcher(text));
} }
/** /**
@ -205,8 +219,9 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
// immediate cause // immediate cause
m = immediateCausePtrn.matcher(line); m = immediateCausePtrn.matcher(line);
if (m.find()) { if (m.find()) {
String i = line.replace(line, LOCK_START + line String i = line.replace(line,
+ LOCK_END); WarnGenPatterns.LOCK_START + line
+ WarnGenPatterns.LOCK_END);
firstBulletText = firstBulletText.replace(line, i); firstBulletText = firstBulletText.replace(line, i);
continue; continue;
} }
@ -216,29 +231,31 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
String name = affectedArea.getName(); String name = affectedArea.getName();
String areaNotation = affectedArea.getAreaNotation(); String areaNotation = affectedArea.getAreaNotation();
String parentRegion = affectedArea.getParentRegion(); String parentRegion = affectedArea.getParentRegion();
if (name != null && name.trim().length() != 0 if ((name != null) && (name.trim().length() != 0)
&& line.contains(name.toUpperCase())) { && line.contains(name)) {
name = name.toUpperCase();
String t = line; String t = line;
if (!hasBeenLocked(line, name)) { if (!hasBeenLocked(line, name)) {
t = t.replace(name, LOCK_START + name + LOCK_END); t = t.replace(name, WarnGenPatterns.LOCK_START
+ name + WarnGenPatterns.LOCK_END);
} }
if (areaNotation != null if ((areaNotation != null)
&& areaNotation.trim().length() != 0) { && (areaNotation.trim().length() != 0)) {
areaNotation = areaNotation.toUpperCase(); if (!hasBeenLocked(line, areaNotation)) {
if (!hasBeenLocked(line, areaNotation.toUpperCase())) { t = t.replace(areaNotation,
t = t.replace(areaNotation, LOCK_START WarnGenPatterns.LOCK_START
+ areaNotation + LOCK_END); + areaNotation
+ WarnGenPatterns.LOCK_END);
} }
} }
if (parentRegion != null if ((parentRegion != null)
&& parentRegion.trim().length() != 0) { && (parentRegion.trim().length() != 0)) {
parentRegion = parentRegion.toUpperCase();
if (!hasBeenLocked(line, parentRegion)) { if (!hasBeenLocked(line, parentRegion)) {
t = t.replace(parentRegion, LOCK_START t = t.replace(parentRegion,
+ parentRegion + LOCK_END); WarnGenPatterns.LOCK_START
+ parentRegion
+ WarnGenPatterns.LOCK_END);
} }
} }
@ -251,8 +268,8 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
} }
} }
firstBulletText = firstBulletText.replaceAll(firstBullet, LOCK_START Matcher m = WarnGenPatterns.firstBulletPtrn.matcher(firstBulletText);
+ "$0" + LOCK_END); firstBulletText = m.replaceAll(WarnGenPatterns.REPLACEMENT);
this.text = text.replace(text.substring(start, end), firstBulletText); this.text = text.replace(text.substring(start, end), firstBulletText);
} }
@ -261,18 +278,19 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the second bullet. * Locks the second bullet.
*/ */
private void secondBullet() { private void secondBullet() {
find(secondBulletPtrn.matcher(text)); find(WarnGenPatterns.secondBulletPtrn.matcher(text));
} }
/** /**
* Set the immediateCausePtrn with the info in immediateCause.text. * Set the immediateCausePtrn with the info in immediateCause.text.
*/ */
private static Pattern getImmediateCausesPtrn() { private Pattern getImmediateCausesPtrn() {
String filename = "immediateCause.txt"; String filename = "immediateCause.txt";
StringBuffer pattern = new StringBuffer(); StringBuffer pattern = new StringBuffer();
try { try {
String immediateCause = WarnFileUtil.convertFileContentsToString(filename, null, null); String immediateCause = WarnFileUtil.convertFileContentsToString(
filename, null, null);
pattern.append("(.*)(A DAM BREAK"); pattern.append("(.*)(A DAM BREAK");
for (String ic : immediateCause.split("\n")) { for (String ic : immediateCause.split("\n")) {
String[] parts = ic.split("\\\\"); String[] parts = ic.split("\\\\");
@ -318,7 +336,6 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the UGC line or FIPS line. * Locks the UGC line or FIPS line.
*/ */
private void ugc() { private void ugc() {
Pattern ugcPtrn = Pattern.compile(ugc + NEWLINE, Pattern.MULTILINE);
find(ugcPtrn.matcher(text)); find(ugcPtrn.matcher(text));
} }
@ -326,22 +343,20 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the HTEC line. * Locks the HTEC line.
*/ */
private void htec() { private void htec() {
find(htecPtrn.matcher(text)); find(WarnGenPatterns.htecPtrn.matcher(text));
} }
/** /**
* Locks the VTEC line. * Locks the VTEC line.
*/ */
private void vtec() { private void vtec() {
find(vtecPtrn.matcher(text)); find(WarnGenPatterns.vtecPtrn.matcher(text));
} }
/** /**
* Locks the list of area names. * Locks the list of area names.
*/ */
private void areaNames() { private void areaNames() {
Pattern listOfAreaNamePtrn = Pattern.compile(listOfAreaName + NEWLINE,
Pattern.MULTILINE);
find(listOfAreaNamePtrn.matcher(text)); find(listOfAreaNamePtrn.matcher(text));
} }
@ -353,13 +368,16 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
protected void find(Matcher m) { protected void find(Matcher m) {
while (m.find()) { while (m.find()) {
String group = m.group(); String group = m.group();
// If line already starts with a LOCK_END, the LOCK_END is removed // If line already starts with a ICommonPatterns.LOCK_END, the
// and the line just adds to the LOCK_END at the end. // ICommonPatterns.LOCK_END is removed
if (group.startsWith(LOCK_END)) { // and the line just adds to the ICommonPatterns.LOCK_END at the
// end.
if (group.startsWith(WarnGenPatterns.LOCK_END)) {
this.text = text.replace(group, this.text = text.replace(group,
group.substring(LOCK_END.length()) + LOCK_END); group.substring(WarnGenPatterns.LOCK_END.length())
+ WarnGenPatterns.LOCK_END);
} else { } else {
this.text = m.replaceAll(LOCK_START + "$0" + LOCK_END); this.text = m.replaceAll(WarnGenPatterns.REPLACEMENT);
} }
} }
} }
@ -371,26 +389,21 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
int start = -1; int start = -1;
int end = -1; int end = -1;
StringBuffer mnd = new StringBuffer(
"(BULLETIN - IMMEDIATE BROADCAST REQUESTED)|(BULLETIN - EAS ACTIVATION REQUESTED)|"
+ warningType);
Pattern startMND = Pattern.compile(mnd.toString());
Matcher m = startMND.matcher(text); Matcher m = startMND.matcher(text);
if (m.find()) { if (m.find()) {
start = m.start(); start = m.start();
} }
m = datePtrn.matcher(text); m = WarnGenPatterns.datePtrn.matcher(text);
if (m.find()) { if (m.find()) {
end = m.start(); end = m.start();
} }
if (start != -1 && end != -1 && start < end) { if ((start != -1) && (end != -1) && (start < end)) {
String substring = text.substring(start, end); String substring = text.substring(start, end);
// There should be only one instance of an MND Header block // There should be only one instance of an MND Header block
this.text = text.replace(substring, LOCK_START + substring this.text = text.replace(substring, WarnGenPatterns.LOCK_START
+ LOCK_END); + substring + WarnGenPatterns.LOCK_END);
} }
} }
@ -398,14 +411,14 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Locks the date. * Locks the date.
*/ */
private void date() { private void date() {
find(datePtrn.matcher(text)); find(WarnGenPatterns.datePtrn.matcher(text));
} }
/** /**
* Locks the TIME...MOT...LINE (Can be multiple lines). * Locks the TIME...MOT...LINE (Can be multiple lines).
*/ */
private void tml() { private void tml() {
find(tmlPtrn.matcher(text)); find(WarnGenPatterns.tmlPtrn.matcher(text));
} }
/** /**
@ -413,27 +426,28 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
*/ */
private void latLon() { private void latLon() {
find(latLonPtrn.matcher(text)); find(WarnGenPatterns.latLonPtrn.matcher(text));
} }
/** /**
* Locks the Call To Action header and the segment tags. * Locks the Call To Action header and the segment tags.
*/ */
private void callToActions() { private void callToActions() {
find(cta.matcher(text)); find(WarnGenPatterns.cta.matcher(text));
} }
/** /**
* Locks the test messages. * Locks the test messages.
*/ */
private void testMessages() { private void testMessages() {
find(testPtrn.matcher(text)); find(WarnGenPatterns.testPtrn.matcher(text));
} }
private void clean() { private void clean() {
// where a lock close and lock open are only separated by whitespace // where a lock close and lock open are only separated by whitespace
// remove the close and open to join the two locked areas // remove the close and open to join the two locked areas
text = text.replaceAll("</L>([\\s\\n\\r]*)<L>", "$1"); text = text.replaceAll(WarnGenPatterns.LOCK_END + "([\\s\\n\\r]*)"
+ WarnGenPatterns.LOCK_START, "$1");
} }
/** /**
@ -444,20 +458,23 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
*/ */
protected boolean isMarineProduct() { protected boolean isMarineProduct() {
VtecObject vtecObj = VtecUtil.parseMessage(text); VtecObject vtecObj = VtecUtil.parseMessage(text);
boolean marineProduct = vtecObj != null boolean marineProduct = (vtecObj != null)
&& vtecObj.getPhenomena() != null && (vtecObj.getPhenomena() != null)
&& vtecObj.getPhenomena().equals("MA"); && vtecObj.getPhenomena().equals("MA");
return marineProduct; return marineProduct;
} }
/** /**
* Tests if the LOCK_START count matches the LOCK_END count. * Tests if the ICommonPatterns.LOCK_START count matches the
* ICommonPatterns.LOCK_END count.
* *
* @return * @return
*/ */
public static boolean validate(String modified) { public static boolean validate(String modified) {
int startCount = StringUtils.countMatches(modified, LOCK_START); int startCount = StringUtils.countMatches(modified,
int endCount = StringUtils.countMatches(modified, LOCK_END); WarnGenPatterns.LOCK_START);
int endCount = StringUtils.countMatches(modified,
WarnGenPatterns.LOCK_END);
return startCount == endCount; return startCount == endCount;
} }
@ -471,17 +488,19 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
protected boolean hasBeenLocked(String line, String name) { protected boolean hasBeenLocked(String line, String name) {
int index = line.indexOf(name); int index = line.indexOf(name);
if (index != -1) { if (index != -1) {
int startBefore = line.lastIndexOf(LOCK_START, index); int startBefore = line.lastIndexOf(WarnGenPatterns.LOCK_START,
int endBefore = line.lastIndexOf(LOCK_END, index); index);
int startAfter = line.indexOf(LOCK_START, index); int endBefore = line.lastIndexOf(WarnGenPatterns.LOCK_END, index);
int endAfter = line.indexOf(LOCK_END, index); int startAfter = line.indexOf(WarnGenPatterns.LOCK_START, index);
int endAfter = line.indexOf(WarnGenPatterns.LOCK_END, index);
if (startBefore != -1 && endAfter != -1 && startBefore < endAfter) { if ((startBefore != -1) && (endAfter != -1)
if (startAfter != -1 && startAfter < endAfter && (startBefore < endAfter)) {
&& startAfter > startBefore) { if ((startAfter != -1) && (startAfter < endAfter)
&& (startAfter > startBefore)) {
return false; return false;
} else if (endBefore != -1 && endBefore > startBefore } else if ((endBefore != -1) && (endBefore > startBefore)
&& endBefore < endAfter) { && (endBefore < endAfter)) {
return false; return false;
} }
@ -496,8 +515,6 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Check out if warning text has state abbreviations, e.g., " MD". * Check out if warning text has state abbreviations, e.g., " MD".
*/ */
private boolean hasStateAbbrev() { private boolean hasStateAbbrev() {
Pattern stateAbbrevPtrn = Pattern.compile(listOfAreaName + NEWLINE,
Pattern.MULTILINE);
Matcher m = stateAbbrevPtrn.matcher(this.text); Matcher m = stateAbbrevPtrn.matcher(this.text);
if (m.find()) { if (m.find()) {
return true; return true;
@ -510,28 +527,28 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
* Check out if pil of the product is SPS or NOW. * Check out if pil of the product is SPS or NOW.
*/ */
public boolean isDesiredPil() { public boolean isDesiredPil() {
String[] type = {"SPS", "NOW"}; String[] type = { "SPS", "NOW" };
int index = text.indexOf("000000") + 8; int index = text.indexOf("000000") + 8;
String pilAndCWA = text.substring(index, index + 6); String pilAndCWA = text.substring(index, index + 6);
for (String s: type) { for (String s : type) {
if (pilAndCWA.contains(s)) { if (pilAndCWA.contains(s)) {
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* Locks the list of area names in which state abbreviations, e.g., " MD", * Locks the list of area names in which state abbreviations, e.g., " MD",
* are not included. * are not included.
*/ */
private void lockListOfNames() { private void lockListOfNames() {
String[] timePattern = {" AM ", " PM ", "NOON", "MIDNIGHT"}; String[] timePattern = { " AM ", " PM ", "NOON", "MIDNIGHT" };
String text1 = ""; String text1 = "";
int indexOfDash = text.indexOf('-'); int indexOfDash = text.indexOf('-');
String text2 = text.substring(indexOfDash, text.length() - 1); String text2 = text.substring(indexOfDash, text.length() - 1);
int indexOfTimePattern; int indexOfTimePattern;
for (String s: timePattern) { for (String s : timePattern) {
indexOfTimePattern = text2.indexOf(s); indexOfTimePattern = text2.indexOf(s);
if (indexOfTimePattern != -1) { if (indexOfTimePattern != -1) {
text1 = text2.substring(0, indexOfTimePattern); text1 = text2.substring(0, indexOfTimePattern);
@ -540,11 +557,14 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
} }
int index1, index2; int index1, index2;
if (text1.length() > 0) { if (text1.length() > 0) {
index1 = text1.indexOf("</L>"); index1 = text1.indexOf(WarnGenPatterns.LOCK_END);
index2 = text1.lastIndexOf("-"); index2 = text1.lastIndexOf("-");
text2 = text1.substring(index1 + 4, index2 + 1); text2 = text1.substring(index1 + 4, index2 + 1);
index1 = text.indexOf(text2); index1 = text.indexOf(text2);
text = text.substring(0, index1) + "<L>" + text2 + "</L>" text = text.substring(0, index1)
+ WarnGenPatterns.LOCK_START
+ text2
+ WarnGenPatterns.LOCK_END
+ text.substring(index1 + text2.length(), text.length() - 1); + text.substring(index1 + text2.length(), text.length() - 1);
} }
} }

View file

@ -25,7 +25,6 @@ import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
import com.raytheon.viz.warngen.gis.AffectedAreas; import com.raytheon.viz.warngen.gis.AffectedAreas;
/** /**
@ -41,6 +40,7 @@ import com.raytheon.viz.warngen.gis.AffectedAreas;
* Jan 8, 2013 15664 Qinglu Lin Updated body(). * Jan 8, 2013 15664 Qinglu Lin Updated body().
* Mar 13, 2013 15892 D. Friedman Fix headline locking. Do not * Mar 13, 2013 15892 D. Friedman Fix headline locking. Do not
* lock "AND" or "FOR". * lock "AND" or "FOR".
* May 29, 2015 4442 randerso Fixed WarnGen text locking to work with mixed case
* *
* </pre> * </pre>
* *
@ -48,13 +48,39 @@ import com.raytheon.viz.warngen.gis.AffectedAreas;
* @version 1.0 * @version 1.0
*/ */
public class FollowUpLockingBehavior extends AbstractLockingBehavior { public class FollowUpLockingBehavior extends AbstractLockingBehavior {
private static Pattern headlinePtrn = Pattern
.compile(
"^\\.\\.\\.(AN?|THE) (.*) (WARNING|ADVISORY) .*(REMAINS|EXPIRE|CANCELLED).*(\\.\\.\\.)$",
Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
private static Pattern expirePtrn = Pattern
.compile(
"(HAS BEEN ALLOWED TO EXPIRE)|(WILL BE ALLOWED TO EXPIRE)|(WILL EXPIRE)|(HAS EXPIRED)|EXPIRED",
Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
private static Pattern timePtrn = Pattern.compile(
"AT \\d{3,4} (AM|PM) \\w{3,4}", Pattern.MULTILINE
| Pattern.CASE_INSENSITIVE);
private static Pattern remainsPtrn = Pattern.compile(
"REMAINS IN EFFECT UNTIL \\d{3,4} (AM|PM) \\w{3,4}",
Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
private static Pattern canceledPtrn = Pattern.compile(
"(IS|(HAS BEEN)) CANCELLED", Pattern.MULTILINE
| Pattern.CASE_INSENSITIVE);
private static Pattern warningPtrn = Pattern.compile(
"(AN?|THE)( [\\w\\s]*?)(" + warningType + ")", Pattern.MULTILINE
| Pattern.CASE_INSENSITIVE);
/** /**
* Locks the appropriate text of the body of an initial warning. * Locks the appropriate text of the body of an initial warning.
*/ */
@Override @Override
public void body() { public void body() {
headlines(); headlines();
super.body(); super.body();
} }
/** /**
@ -64,10 +90,6 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior {
private void headlines() { private void headlines() {
// LOCK_END should not be found at the beginning since the previous line // LOCK_END should not be found at the beginning since the previous line
// should be blank. // should be blank.
Pattern headlinePtrn = Pattern
.compile(
"^\\.\\.\\.(AN?|THE) (.*) (WARNING|ADVISORY) .*(REMAINS|EXPIRE|CANCELLED).*(\\.\\.\\.)$",
Pattern.MULTILINE);
Matcher m = headlinePtrn.matcher(text); Matcher m = headlinePtrn.matcher(text);
while (m.find()) { while (m.find()) {
@ -84,12 +106,12 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior {
* Locks the expired text. * Locks the expired text.
*/ */
private String expired(String followupHeadline) { private String expired(String followupHeadline) {
// Based on the templates, the expired text is for the affected areas Matcher m = expirePtrn.matcher(followupHeadline);
// not the canceled areas. followupHeadline = m.replaceAll(WarnGenPatterns.REPLACEMENT);
String expire = "(HAS BEEN ALLOWED TO EXPIRE)|(WILL BE ALLOWED TO EXPIRE)|(WILL EXPIRE)|(HAS EXPIRED)|EXPIRED";
String time = "AT \\d{3,4} (AM|PM) \\w{3,4}"; m = timePtrn.matcher(followupHeadline);
return followupHeadline.replaceAll(expire, REPLACEMENT).replaceAll( followupHeadline = m.replaceAll(WarnGenPatterns.REPLACEMENT);
time, REPLACEMENT); return followupHeadline;
} }
/** /**
@ -99,9 +121,9 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior {
* @return * @return
*/ */
private String remainsInEffect(String followupHeadline) { private String remainsInEffect(String followupHeadline) {
return followupHeadline.replaceFirst( Matcher m = remainsPtrn.matcher(followupHeadline);
"REMAINS IN EFFECT UNTIL \\d{3,4} (AM|PM) \\w{3,4}", LOCK_START followupHeadline = m.replaceFirst(WarnGenPatterns.REPLACEMENT);
+ "$0" + LOCK_END); return followupHeadline;
} }
/** /**
@ -111,8 +133,9 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior {
* @return * @return
*/ */
private String canceled(String canceledHeadline) { private String canceled(String canceledHeadline) {
return canceledHeadline.replaceAll("(IS|(HAS BEEN)) CANCELLED", Matcher m = canceledPtrn.matcher(canceledHeadline);
REPLACEMENT); canceledHeadline = m.replaceAll(WarnGenPatterns.REPLACEMENT);
return canceledHeadline;
} }
/** /**
@ -127,19 +150,19 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior {
Set<String> names = new HashSet<String>(); Set<String> names = new HashSet<String>();
for (AffectedAreas affectedArea : affectedAreas) { for (AffectedAreas affectedArea : affectedAreas) {
if (affectedArea.getAreaNotation() != null if ((affectedArea.getAreaNotation() != null)
&& affectedArea.getAreaNotation().trim().length() != 0) { && (affectedArea.getAreaNotation().trim().length() != 0)) {
notations.add(affectedArea.getAreaNotation().toUpperCase()); notations.add(affectedArea.getAreaNotation());
} }
if (affectedArea.getAreasNotation() != null if ((affectedArea.getAreasNotation() != null)
&& affectedArea.getAreasNotation().trim().length() != 0) { && (affectedArea.getAreasNotation().trim().length() != 0)) {
notations.add(affectedArea.getAreasNotation().toUpperCase()); notations.add(affectedArea.getAreasNotation());
} }
if (affectedArea.getName() != null if ((affectedArea.getName() != null)
&& affectedArea.getName().trim().length() != 0) { && (affectedArea.getName().trim().length() != 0)) {
names.add(affectedArea.getName().toUpperCase()); names.add(affectedArea.getName());
} }
} }
@ -150,8 +173,9 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior {
while (iterator1.hasNext()) { while (iterator1.hasNext()) {
String notation = iterator1.next(); String notation = iterator1.next();
if (!hasBeenLocked(headline, notation)) { if (!hasBeenLocked(headline, notation)) {
headline = headline.replace(notation, LOCK_START + notation headline = headline.replace(notation,
+ LOCK_END); WarnGenPatterns.LOCK_START + notation
+ WarnGenPatterns.LOCK_END);
} }
} }
@ -159,13 +183,15 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior {
while (iterator2.hasNext()) { while (iterator2.hasNext()) {
String name = iterator2.next(); String name = iterator2.next();
if (!hasBeenLocked(headline, name)) { if (!hasBeenLocked(headline, name)) {
headline = headline.replace(name, LOCK_START + name headline = headline.replace(name,
+ LOCK_END); WarnGenPatterns.LOCK_START + name
+ WarnGenPatterns.LOCK_END);
} }
} }
} else { } else {
// The full headline of a marine product should be locked. // The full headline of a marine product should be locked.
headline = LOCK_START + headline + LOCK_END; headline = WarnGenPatterns.LOCK_START + headline
+ WarnGenPatterns.LOCK_END;
} }
return headline; return headline;
@ -179,16 +205,19 @@ public class FollowUpLockingBehavior extends AbstractLockingBehavior {
*/ */
private String keywords(String headline) { private String keywords(String headline) {
// Locking the start of a head line (...) // Locking the start of a head line (...)
headline = headline.replaceFirst("^\\.\\.\\.", LOCK_START + "$0" headline = headline.replaceFirst("^\\.\\.\\.",
+ LOCK_END); WarnGenPatterns.REPLACEMENT);
// Locking the end of a head line (...) // Locking the end of a head line (...)
if (headline.endsWith("...")) { if (headline.endsWith("...")) {
headline = headline.substring(0, headline.length() - 3) headline = headline.substring(0, headline.length() - 3)
+ LOCK_START + "..." + LOCK_END; + WarnGenPatterns.LOCK_START + "..."
+ WarnGenPatterns.LOCK_END;
} }
// Locks warning type (i.e. SEVERE THUNDERSTORM) // Locks warning type (i.e. SEVERE THUNDERSTORM)
headline = headline.replaceAll("(AN?|THE)( [\\w\\s]*?)(" + warningType + ")", Matcher m = warningPtrn.matcher(headline);
LOCK_START + "$1" + LOCK_END + "$2" + LOCK_START + "$3" + LOCK_END); headline = m.replaceAll(WarnGenPatterns.LOCK_START + "$1"
+ WarnGenPatterns.LOCK_END + "$2" + WarnGenPatterns.LOCK_START
+ "$3" + WarnGenPatterns.LOCK_END);
return headline; return headline;
} }

View file

@ -41,12 +41,14 @@ import java.util.regex.Pattern;
* Apr 29, 2014 3033 jsanchez Added more patterns. * Apr 29, 2014 3033 jsanchez Added more patterns.
* May 1, 2014 DR 16627 Qinglu Lin Roll back the changes to listOfAreaName on January 6, 2014. * May 1, 2014 DR 16627 Qinglu Lin Roll back the changes to listOfAreaName on January 6, 2014.
* May 13, 2014 DR 17177 Qinglu Lin Updated secondBullet(). * May 13, 2014 DR 17177 Qinglu Lin Updated secondBullet().
* May 29, 2015 4441 randerso Made patterns case insensitive where necessary
* Renamed and changed from interface to class
* </pre> * </pre>
* *
* @author jsanchez * @author jsanchez
* @version 1.0 * @version 1.0
*/ */
public interface ICommonPatterns { public class WarnGenPatterns {
/** Start tag for locking */ /** Start tag for locking */
public static final String LOCK_START = "<L>"; public static final String LOCK_START = "<L>";
@ -54,6 +56,8 @@ public interface ICommonPatterns {
/** End tag for locking */ /** End tag for locking */
public static final String LOCK_END = "</L>"; public static final String LOCK_END = "</L>";
public static final String REPLACEMENT = LOCK_START + "$0" + LOCK_END;
public static final String NEWLINE = "\\n"; public static final String NEWLINE = "\\n";
// LOCK_END should not be found at the beginning since the previous line // LOCK_END should not be found at the beginning since the previous line
@ -68,8 +72,9 @@ public interface ICommonPatterns {
// LOCK_END should not be found at the beginning of a first bullet since the // LOCK_END should not be found at the beginning of a first bullet since the
// previous line should be blank. // previous line should be blank.
public static final String firstBullet = "^(\\* (.*) (WARNING|ADVISORY)( FOR(.*)|\\.\\.\\.)" public static final Pattern firstBulletPtrn = Pattern
+ NEWLINE + ")"; .compile("^(\\* (.*) (WARNING|ADVISORY)( FOR(.*)|\\.\\.\\.)"
+ NEWLINE + ")", Pattern.CASE_INSENSITIVE);
// LOCK_END can be added at the start of the line if a previous line has // LOCK_END can be added at the start of the line if a previous line has
// been locked. // been locked.
@ -82,7 +87,8 @@ public interface ICommonPatterns {
public static final Pattern header = Pattern.compile( public static final Pattern header = Pattern.compile(
"^((THE NATIONAL WEATHER SERVICE IN .{1,} HAS (ISSUED A|EXTENDED THE))" "^((THE NATIONAL WEATHER SERVICE IN .{1,} HAS (ISSUED A|EXTENDED THE))"
+ NEWLINE + ")$", Pattern.MULTILINE); + NEWLINE + ")$", Pattern.MULTILINE
| Pattern.CASE_INSENSITIVE);
/* /*
* LOCK_END should not be found at the beginning since the previous line * LOCK_END should not be found at the beginning since the previous line
@ -90,7 +96,8 @@ public interface ICommonPatterns {
public static final Pattern secondBulletPtrn = Pattern public static final Pattern secondBulletPtrn = Pattern
.compile( .compile(
"\\* UNTIL (\\d{3,4} (AM|PM)|NOON|MIDNIGHT) \\w{3,4}( \\w{6,9}){0,1}(\\/(\\d{3,4} (AM|PM)|NOON|MIDNIGHT) \\w{3,4}( \\w{6,9}){0,1}\\/){0,1}" "\\* UNTIL (\\d{3,4} (AM|PM)|NOON|MIDNIGHT) \\w{3,4}( \\w{6,9}){0,1}(\\/(\\d{3,4} (AM|PM)|NOON|MIDNIGHT) \\w{3,4}( \\w{6,9}){0,1}\\/){0,1}"
+ NEWLINE, Pattern.MULTILINE); + NEWLINE, Pattern.MULTILINE
| Pattern.CASE_INSENSITIVE);
public static final Pattern htecPtrn = Pattern public static final Pattern htecPtrn = Pattern
.compile( .compile(

View file

@ -113,9 +113,8 @@ public class WarningTextHandler {
String[] seperatedLines = text.replaceAll("\r", "").trim().split("\n"); String[] seperatedLines = text.replaceAll("\r", "").trim().split("\n");
boolean blankLine = false; boolean blankLine = false;
for (String line : seperatedLines) { for (String line : seperatedLines) {
if (line.replace(AbstractLockingBehavior.LOCK_START, "") if (line.replace(WarnGenPatterns.LOCK_START, "")
.replace(AbstractLockingBehavior.LOCK_END, "").trim() .replace(WarnGenPatterns.LOCK_END, "").trim().length() > 0) {
.length() > 0) {
sb.append(line + "\n"); sb.append(line + "\n");
blankLine = false; blankLine = false;
} else if (blankLine == false) { } else if (blankLine == false) {

View file

@ -20,7 +20,6 @@
package com.raytheon.viz.warngen.text; package com.raytheon.viz.warngen.text;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction; import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
@ -34,7 +33,8 @@ import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Sep 24, 2012 15322 jsanchez Initial creation * Sep 24, 2012 15322 jsanchez Initial creation
* Jun 02, 2015 4441 randerso Made first bullet regex case insensitive
* *
* </pre> * </pre>
* *
@ -69,14 +69,12 @@ public class WarningTextHandlerFactory {
} }
private static boolean isInitialWarning(WarningAction action, String text) { private static boolean isInitialWarning(WarningAction action, String text) {
if (action == WarningAction.NEW || action == WarningAction.EXT) { if ((action == WarningAction.NEW) || (action == WarningAction.EXT)) {
return true; return true;
} else if (action == WarningAction.COR) { } else if (action == WarningAction.COR) {
// TODO Need a better solution not to include the text in the // TODO Need a better solution not to include the text in the
// factory. // factory.
Pattern firstBulletPtrn = Pattern Matcher m = WarnGenPatterns.firstBulletPtrn.matcher(text);
.compile(InitialLockingBehavior.firstBullet);
Matcher m = firstBulletPtrn.matcher(text);
return m.find(); return m.find();
} }

View file

@ -40,7 +40,7 @@ import java.util.regex.Pattern;
* @author jsanchez * @author jsanchez
* @version 1.0 * @version 1.0
*/ */
public class WrapUtil implements ICommonPatterns { public class WrapUtil {
/** Maximum width of a warning */ /** Maximum width of a warning */
private static final int MAX_WIDTH = 69; private static final int MAX_WIDTH = 69;
@ -50,19 +50,24 @@ public class WrapUtil implements ICommonPatterns {
private static final String BULLET_START = "* "; private static final String BULLET_START = "* ";
// Guess at the amount of extra characters added by wrapping // Guess at the amount of extra characters added by wrapping
private static final int WRAP_COUNT_GUESS = 16 * 3; // *3 for bullet indent + \n private static final int WRAP_COUNT_GUESS = 16 * 3; // *3 for bullet indent
// + \n
private static final String DELIM_GROUP = "\0"; private static final String DELIM_GROUP = "\0";
private static final String[] NORMAL_DELIMS = { " ", "...", DELIM_GROUP, "-" };
private static final String[] NORMAL_DELIMS = { " ", "...", DELIM_GROUP,
"-" };
private static final String[] AREA_DELIMS = { "-", "...", DELIM_GROUP, " " }; private static final String[] AREA_DELIMS = { "-", "...", DELIM_GROUP, " " };
private static final String[] UGC_DELIMS = AREA_DELIMS; private static final String[] UGC_DELIMS = AREA_DELIMS;
// ugc pattern // ugc pattern
private static final Pattern ugcPtrn = Pattern.compile(ugc); private static final Pattern ugcPtrn = Pattern.compile(WarnGenPatterns.ugc);
// list of areas pattern // list of areas pattern
private static final Pattern listOfAreaNamePtrn = Pattern private static final Pattern listOfAreaNamePtrn = Pattern
.compile(listOfAreaName); .compile(WarnGenPatterns.listOfAreaName);
/** /**
* Wraps the text independent of being locked before or after. * Wraps the text independent of being locked before or after.
@ -78,7 +83,8 @@ public class WrapUtil implements ICommonPatterns {
String[] lines = text.split("\n"); String[] lines = text.split("\n");
for (int i = 0; i < lines.length; i++) { for (int i = 0; i < lines.length; i++) {
String line = lines[i]; String line = lines[i];
String unlocked = line.replaceAll(LOCK_START + "|" + LOCK_END, ""); String unlocked = line.replaceAll(WarnGenPatterns.LOCK_START + "|"
+ WarnGenPatterns.LOCK_END, "");
if (unlocked.trim().length() == 0) { // BLANK LINE if (unlocked.trim().length() == 0) { // BLANK LINE
inBullet = false; inBullet = false;
@ -93,7 +99,7 @@ public class WrapUtil implements ICommonPatterns {
// Add indenting if the template didn't account for it yet. // Add indenting if the template didn't account for it yet.
int add = wasInBullet && !unlocked.startsWith(INDENT) ? INDENT int add = wasInBullet && !unlocked.startsWith(INDENT) ? INDENT
.length() : 0; .length() : 0;
if (unlocked.length() <= MAX_WIDTH - add) { // LESS THAN MAX if (unlocked.length() <= (MAX_WIDTH - add)) { // LESS THAN MAX
if (add > 0) { if (add > 0) {
sb.append(INDENT); sb.append(INDENT);
} }
@ -104,7 +110,7 @@ public class WrapUtil implements ICommonPatterns {
} }
sb.append(addLine); sb.append(addLine);
if (i != lines.length - 1) { if (i != (lines.length - 1)) {
sb.append("\n"); sb.append("\n");
} }
} }
@ -138,7 +144,8 @@ public class WrapUtil implements ICommonPatterns {
* @param maxLength * @param maxLength
* @return * @return
*/ */
public static String wrapLongLine(String line, boolean inBullet, String[] delims, int maxLength) { public static String wrapLongLine(String line, boolean inBullet,
String[] delims, int maxLength) {
StringBuilder sb = new StringBuilder(line.length() + WRAP_COUNT_GUESS); StringBuilder sb = new StringBuilder(line.length() + WRAP_COUNT_GUESS);
int start = 0; int start = 0;
int allowLength = maxLength; int allowLength = maxLength;
@ -152,7 +159,7 @@ public class WrapUtil implements ICommonPatterns {
char[] cb = new char[2]; char[] cb = new char[2];
int i = indexIgnoringLockMarkers(line, start, 0); int i = indexIgnoringLockMarkers(line, start, 0);
int o = 0; int o = 0;
while (i < line.length() && o < 2) { while ((i < line.length()) && (o < 2)) {
cb[o++] = line.charAt(i); cb[o++] = line.charAt(i);
i = indexIgnoringLockMarkers(line, i, 1); i = indexIgnoringLockMarkers(line, i, 1);
} }
@ -188,15 +195,17 @@ public class WrapUtil implements ICommonPatterns {
int bestP = -1; int bestP = -1;
for (String delim : delims) { for (String delim : delims) {
if (delim == DELIM_GROUP) { if (delim == DELIM_GROUP) {
if (bestDelim != null) if (bestDelim != null) {
break; break;
}
continue; continue;
} }
int backup = " ".equals(delim) ? 0 : delim.length(); int backup = " ".equals(delim) ? 0 : delim.length();
int p = !failed ? line.lastIndexOf(delim, limit - backup) int p = !failed ? line.lastIndexOf(delim, limit - backup)
: line.indexOf(delim, limit - backup); : line.indexOf(delim, limit - backup);
if (p >= start && (bestDelim == null if ((p >= start)
|| !failed ? p > bestP : p < bestP)) { && ((bestDelim == null) || !failed ? p > bestP
: p < bestP)) {
bestDelim = delim; bestDelim = delim;
bestP = p; bestP = p;
} }
@ -212,7 +221,7 @@ public class WrapUtil implements ICommonPatterns {
if (inBullet) { if (inBullet) {
allowLength = maxLength - INDENT.length(); allowLength = maxLength - INDENT.length();
} }
} else if (! failed) { } else if (!failed) {
/* /*
* Failed to wrap before the margin. Try again, wrapping the * Failed to wrap before the margin. Try again, wrapping the
* line after the margin, but still as close to it as possible. * line after the margin, but still as close to it as possible.
@ -268,20 +277,23 @@ public class WrapUtil implements ICommonPatterns {
* of characters in text past start. * of characters in text past start.
* @return * @return
*/ */
private static int indexIgnoringLockMarkers(String text, int start, int count) { private static int indexIgnoringLockMarkers(String text, int start,
int count) {
int i = start; int i = start;
do { do {
if (text.startsWith(LOCK_START, i)) if (text.startsWith(WarnGenPatterns.LOCK_START, i)) {
i += LOCK_START.length(); i += WarnGenPatterns.LOCK_START.length();
else if (text.startsWith(LOCK_END, i)) } else if (text.startsWith(WarnGenPatterns.LOCK_END, i)) {
i += LOCK_END.length(); i += WarnGenPatterns.LOCK_END.length();
else if (count > 0) { } else if (count > 0) {
if (i >= text.length()) if (i >= text.length()) {
break; break;
}
++i; ++i;
--count; --count;
} else } else {
break; break;
}
} while (true); } while (true);
return i; return i;
} }
@ -290,21 +302,25 @@ public class WrapUtil implements ICommonPatterns {
* Append text.substring(start, end) to sb, removing any trailing * Append text.substring(start, end) to sb, removing any trailing
* whitespace. The trailing whitespace may have have embedded lock marks. * whitespace. The trailing whitespace may have have embedded lock marks.
*/ */
private static void appendRTrim(String text, int start, int end, StringBuilder sb) { private static void appendRTrim(String text, int start, int end,
StringBuilder sb) {
int sbStart = sb.length(); int sbStart = sb.length();
sb.append(text, start, end); sb.append(text, start, end);
int i = sb.length(); int i = sb.length();
while (i > sbStart) { while (i > sbStart) {
if (Character.isWhitespace(sb.charAt(i - 1))) { if (Character.isWhitespace(sb.charAt(i - 1))) {
sb.deleteCharAt(--i); sb.deleteCharAt(--i);
} else if (i - sbStart >= LOCK_START.length() && } else if (((i - sbStart) >= WarnGenPatterns.LOCK_START.length())
LOCK_START.equals(sb.substring(i - LOCK_START.length(), i))) { && WarnGenPatterns.LOCK_START.equals(sb.substring(i
i -= LOCK_START.length(); - WarnGenPatterns.LOCK_START.length(), i))) {
} else if (i - sbStart >= LOCK_END.length() && i -= WarnGenPatterns.LOCK_START.length();
LOCK_END.equals(sb.substring(i - LOCK_END.length(), i))) { } else if (((i - sbStart) >= WarnGenPatterns.LOCK_END.length())
i -= LOCK_END.length(); && WarnGenPatterns.LOCK_END.equals(sb.substring(i
} else - WarnGenPatterns.LOCK_END.length(), i))) {
i -= WarnGenPatterns.LOCK_END.length();
} else {
break; break;
}
} }
} }
@ -324,27 +340,30 @@ public class WrapUtil implements ICommonPatterns {
* @return The index in text at which processing for the next line should * @return The index in text at which processing for the next line should
* begin. * begin.
*/ */
private static int splitEndOfLine(String text, int start, boolean inBullet, StringBuilder sb) { private static int splitEndOfLine(String text, int start, boolean inBullet,
StringBuilder sb) {
int goodBreak = start; int goodBreak = start;
int i = start; int i = start;
while (i < text.length()) { while (i < text.length()) {
if (Character.isWhitespace(text.charAt(i))) { if (Character.isWhitespace(text.charAt(i))) {
++i; ++i;
} else if (text.startsWith(LOCK_START, i)) { } else if (text.startsWith(WarnGenPatterns.LOCK_START, i)) {
goodBreak = i; goodBreak = i;
i += LOCK_START.length(); i += WarnGenPatterns.LOCK_START.length();
break; break;
} else if (text.startsWith(LOCK_END, i)) { } else if (text.startsWith(WarnGenPatterns.LOCK_END, i)) {
i += LOCK_END.length(); i += WarnGenPatterns.LOCK_END.length();
goodBreak = i; goodBreak = i;
break; break;
} else } else {
break; break;
}
} }
if (i >= text.length()) if (i >= text.length()) {
goodBreak = i; goodBreak = i;
}
if (goodBreak >= start) { if (goodBreak >= start) {
appendRTrim(text, start, goodBreak, sb); appendRTrim(text, start, goodBreak, sb);
} }

View file

@ -51,6 +51,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 15, 2007 chammack Initial Creation. * Nov 15, 2007 chammack Initial Creation.
* Jun 02, 2016 4442 randerso Remove upper case conversion
* *
* </pre> * </pre>
* *
@ -84,13 +85,13 @@ public class Abbreviation {
String line = bufferedReader.readLine(); String line = bufferedReader.readLine();
String[] tokens = line.split("\\\\"); String[] tokens = line.split("\\\\");
if (tokens[0].trim().equalsIgnoreCase(DEFAULT)) { if (tokens[0].trim().equalsIgnoreCase(DEFAULT)) {
this.defaultAbbrev = tokens[1].trim().toUpperCase(); this.defaultAbbrev = tokens[1].trim();
} else if (tokens[0].trim().equalsIgnoreCase(DEFAULT_PLURAL)) { } else if (tokens[0].trim().equalsIgnoreCase(DEFAULT_PLURAL)) {
this.defaultPluralAbbrev = tokens[1].trim().toUpperCase(); this.defaultPluralAbbrev = tokens[1].trim();
} else { } else {
this.abbreviationMap.put(tokens[0].trim().toUpperCase(), this.abbreviationMap.put(tokens[0].trim(),
tokens.length < 2 || tokens[1] == null ? "" (tokens.length < 2) || (tokens[1] == null) ? ""
: tokens[1].trim().toUpperCase()); : tokens[1].trim());
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -98,14 +99,16 @@ public class Abbreviation {
} finally { } finally {
try { try {
if (bufferedReader != null) if (bufferedReader != null) {
bufferedReader.close(); bufferedReader.close();
}
} catch (IOException e1) { } catch (IOException e1) {
// ignore // ignore
} }
try { try {
if (fileReader != null) if (fileReader != null) {
fileReader.close(); fileReader.close();
}
} catch (IOException e) { } catch (IOException e) {
// ignore // ignore
} }
@ -114,7 +117,7 @@ public class Abbreviation {
public String translate(String abbreviation) { public String translate(String abbreviation) {
String str = this.abbreviationMap.get(abbreviation.toUpperCase()); String str = this.abbreviationMap.get(abbreviation.toUpperCase());
if (str == null && this.defaultAbbrev != null) { if ((str == null) && (this.defaultAbbrev != null)) {
return abbreviation.endsWith(PLURAL_SUFFIX) ? this.defaultPluralAbbrev return abbreviation.endsWith(PLURAL_SUFFIX) ? this.defaultPluralAbbrev
: this.defaultAbbrev; : this.defaultAbbrev;
} }

View file

@ -16,7 +16,7 @@ import com.raytheon.uf.common.time.SimulatedTime;
import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.viz.warngen.gis.AffectedAreas; import com.raytheon.viz.warngen.gis.AffectedAreas;
import com.raytheon.viz.warngen.text.ICommonPatterns; import com.raytheon.viz.warngen.text.WarnGenPatterns;
/** /**
* This utility will provide methods for determining what followup products are * This utility will provide methods for determining what followup products are
@ -176,7 +176,7 @@ public class FollowUpUtil {
String namesLine = ""; String namesLine = "";
String headline = ""; String headline = "";
Pattern listOfAreaNamePtrn = Pattern Pattern listOfAreaNamePtrn = Pattern
.compile(ICommonPatterns.listOfAreaName); .compile(WarnGenPatterns.listOfAreaName);
String[] splitLines = originalText.trim().split("\n"); String[] splitLines = originalText.trim().split("\n");
for (String line : splitLines) { for (String line : splitLines) {
if (line.contains("TEST") || line.trim().length() == 0) { if (line.contains("TEST") || line.trim().length() == 0) {
@ -282,7 +282,7 @@ public class FollowUpUtil {
public static String getUgcLineCanFromText(String originalText) { public static String getUgcLineCanFromText(String originalText) {
String ugcLine = ""; String ugcLine = "";
Pattern ugcPtrn = Pattern.compile(ICommonPatterns.ugc); Pattern ugcPtrn = Pattern.compile(WarnGenPatterns.ugc);
for (String line : originalText.replaceAll("\r", "").trim().split("\n")) { for (String line : originalText.replaceAll("\r", "").trim().split("\n")) {
Matcher m = ugcPtrn.matcher(line); Matcher m = ugcPtrn.matcher(line);
if (m.find()) { if (m.find()) {

View file

@ -1,23 +1,23 @@
LA \ PARISH LA \ Parish
LOUISIANA \ PARISH Louisiana \ Parish
LA+ \ PARISHES LA+ \ Parishes
LOUISIANA+ \ PARISHES Louisiana+ \ Parishes
DC \ DC \
DISTRICT OF COLUMBIA \ District of Columbia \
DC+ \ DC+ \
DISTRICT OF COLUMBIA+ \ District of Columbia+ \
AK \ AK \
ALASKA \ Alaska \
AK+ \ AK+ \
ALASKA+ \ Alaska+ \
PR \ MUNICIPALITY PR \ Municipality
PUERTO RICO \ MUNICIPALITY Puerto Rico \ Municipality
PR+ \ MUNICIPALITIES PR+ \ Municipalities
PUERTO RICO+ \ MUNICIPALITIES Puerto Rico+ \ Municipalities
GU \ GU \
GUAM \ Guam \
GU+ \ GU+ \
GUAM+ \ Guam+ \
DEFAULT+ \ COUNTIES DEFAULT+ \ Counties
DEFAULT \ COUNTY DEFAULT \ County
CITY \ City \

View file

@ -91,7 +91,7 @@ public class StdTextSeparator extends WMOMessageSeparator {
String product_id = TextDBStaticData.getProductId(ispanId); String product_id = TextDBStaticData.getProductId(ispanId);
// check whether to exclude from decoding for storage // check whether to exclude from decoding for storage
if (product_id != null if ((product_id != null)
&& TextDBStaticData.isExcluded(product_id.toString())) { && TextDBStaticData.isExcluded(product_id.toString())) {
logger.debug("NCF_ENTRY " + product_id.toString() + " is skipped"); logger.debug("NCF_ENTRY " + product_id.toString() + " is skipped");
return; return;
@ -172,8 +172,8 @@ public class StdTextSeparator extends WMOMessageSeparator {
// if no product_id is found, use ispanId to store and assign // if no product_id is found, use ispanId to store and assign
// a dummy to product_id so that such products can still be stored // a dummy to product_id so that such products can still be stored
// during the AFOS to AWIPS transition. // during the AFOS to AWIPS transition.
if (parsedMsg.length() > 6 && parsedMsg.charAt(6) != '\r' if ((parsedMsg.length() > 6) && (parsedMsg.charAt(6) != '\r')
&& parsedMsg.charAt(6) != '\n') { && (parsedMsg.charAt(6) != '\n')) {
nnnxxx = "NONAWIPS"; nnnxxx = "NONAWIPS";
} else { } else {
nnnxxx = parsedMsg.substring(0, (parsedMsg.length() > 6 ? 6 nnnxxx = parsedMsg.substring(0, (parsedMsg.length() > 6 ? 6