Merge "Issue #1473: Fix Alarm Alert NPE" into development

Former-commit-id: e176fcbf06 [formerly edaf980163ff2f3770cb125b9a837a23ca1b16b2]
Former-commit-id: 0f705ac355
This commit is contained in:
Richard Peter 2013-01-14 11:55:35 -06:00 committed by Gerrit Code Review
commit 621a4cd147

View file

@ -120,7 +120,7 @@ public class AlarmAlertFunctions {
private static final Pattern UGC_FOLLOW_PATTERN = Pattern
.compile("^(\\d{3})$");
private static String DEFAULT_DISTANCE="3000";
private static String DEFAULT_DISTANCE = "3000";
private static final String HYPHEN = Pattern.quote("-");
@ -148,17 +148,15 @@ public class AlarmAlertFunctions {
}
if (!"".equals(prod.getAorDistance())) {
/*
* DR15555 - check the text content,
* if it is not a valid number set the
* text to default 3000 mi
* DR15555 - check the text content, if it is not a valid number set
* the text to default 3000 mi
*/
Scanner scn = new Scanner(prod.getAorDistance());
while (scn.hasNext()){
if (!scn.hasNextInt()){
while (scn.hasNext()) {
if (!scn.hasNextInt()) {
prod.setAorDistance(DEFAULT_DISTANCE);
break;
}
else {
} else {
scn.next();
}
}
@ -295,7 +293,7 @@ public class AlarmAlertFunctions {
/*
* DR1555 - Proximity_Alarm
*/
else if (PA.equals(pt)) {;
else if (PA.equals(pt)) {
String s = a.getProductId();
if (s != null) {
s = s.trim().toUpperCase();
@ -308,25 +306,29 @@ public class AlarmAlertFunctions {
Geometry messagePolygon = getMessagePolygon(stp);
if (a.isAor()) {
/*
* Check if polygon in the message
* is within the AOR
* Check if polygon in the message is
* within the AOR
*/
if (matchAOR(messagePolygon)) {
if (messagePolygon != null
&& matchAOR(messagePolygon)) {
prods.add(a);
}
} else if (!"".equals(a.getAorDistance())) {
/*
* Check if polygon in the message
* is within the AOR+distance
* Check if polygon in the message is
* within the AOR+distance
*/
if (matchAORExtention(a.getAorDistance(),
a.getAorLabel(), messagePolygon)) {
if (messagePolygon != null
&& matchAORExtention(
a.getAorDistance(),
a.getAorLabel(),
messagePolygon)) {
prods.add(a);
}
} else if (!"".equals(a.getUgcList())) {
/*
* Check if UGCs in the message
* match the UGCs in the alarm
* Check if UGCs in the message match
* the UGCs in the alarm
*/
String messageUGCs = getMessageUGCs(stp
.getProduct());
@ -379,7 +381,7 @@ public class AlarmAlertFunctions {
} catch (SpatialException e) {
e.printStackTrace();
}
if (cwa!=null) {
if (cwa != null) {
if (polygon.intersects(cwa)) {
return true;
}
@ -397,8 +399,8 @@ public class AlarmAlertFunctions {
*/
private static boolean matchUGCList(String alarmUGCs, String messageUGCs) {
List<String> alarmUGCList = getUGCs(alarmUGCs);
for ( String alarmUGC: alarmUGCList) {
if (messageUGCs.contains(alarmUGC) ) {
for (String alarmUGC : alarmUGCList) {
if (messageUGCs.contains(alarmUGC)) {
return true;
}
}
@ -584,6 +586,7 @@ public class AlarmAlertFunctions {
/**
* Process the extracted from the message latlon coordinates
*
* @param latLon
* @return
*/