Merge "Issue #1400 fix for local and regional warnings, made the WatchesResource better handle extension" into development

Former-commit-id: 67d30566c0 [formerly 67d30566c0 [formerly e7b347563598a3f4809cc74096de1f2dc0ef0788]]
Former-commit-id: 823bedcebd
Former-commit-id: 0388c1b179
This commit is contained in:
Nate Jensen 2012-12-13 14:25:56 -06:00 committed by Gerrit Code Review
commit 6ac9952901
3 changed files with 65 additions and 41 deletions

View file

@ -28,7 +28,7 @@ import com.vividsolutions.jts.io.WKBReader;
import com.vividsolutions.jts.io.WKTReader;
public class CWASPSResource extends WarningsResource {
public class CWASPSResource extends WatchesResource {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(CWASPSResource.class);

View file

@ -34,35 +34,43 @@ public class WarningRecordComparator implements
public int compare(AbstractWarningRecord wr1, AbstractWarningRecord wr2) {
int rval = 0;
rval = wr1.getPhensig().compareTo(wr2.getPhensig());
if (wr1.getPhensig() != null && wr2.getPhensig() != null) {
rval = wr1.getPhensig().compareTo(wr2.getPhensig());
}
if (rval == 0) {
rval = Double.compare(Double.parseDouble(wr1.getEtn()),
Double.parseDouble(wr2.getEtn()));
if (wr1.getEtn() != null && wr2.getEtn() != null) {
rval = Double.compare(Double.parseDouble(wr1.getEtn()),
Double.parseDouble(wr2.getEtn()));
}
if (rval == 0) {
WarningAction act1 = WarningAction.valueOf(wr1.getAct());
WarningAction act2 = WarningAction.valueOf(wr2.getAct());
if (act1 == act2) {
rval = 0;
} else if (act1 == WarningAction.NEW) {
rval = -1;
} else if (act2 == WarningAction.NEW) {
rval = 1;
} else if (act1 == WarningAction.CON
&& (act2 == WarningAction.CAN || act2 == WarningAction.EXP)) {
return -1;
} else if (act2 == WarningAction.CON
&& (act1 == WarningAction.CAN || act1 == WarningAction.EXP)) {
return 1;
} else {
rval = wr1.getAct().compareTo(wr2.getAct());
if (wr1.getAct() != null && wr2.getAct() != null) {
WarningAction act1 = WarningAction.valueOf(wr1.getAct());
WarningAction act2 = WarningAction.valueOf(wr2.getAct());
if (act1 == act2) {
rval = 0;
} else if (act1 == WarningAction.NEW) {
rval = -1;
} else if (act2 == WarningAction.NEW) {
rval = 1;
} else if (act1 == WarningAction.CON
&& (act2 == WarningAction.CAN || act2 == WarningAction.EXP)) {
return -1;
} else if (act2 == WarningAction.CON
&& (act1 == WarningAction.CAN || act1 == WarningAction.EXP)) {
return 1;
} else {
rval = wr1.getAct().compareTo(wr2.getAct());
}
}
if (rval == 0) {
rval = wr1.getStartTime().compareTo(wr2.getStartTime());
// sort warnings in descending order
if (!wr1.getSig().equals("A")) {
rval *= -1;
if (wr1.getSig() != null) {
if (!wr1.getSig().equals("A")) {
rval *= -1;
}
}
}
}

View file

@ -221,29 +221,45 @@ public class WatchesResource extends AbstractWWAResource {
if (watchact != WarningAction.NEW) {
AbstractWarningRecord createShape = null;
if (watchact == null || watchact.toString() == null) {
createShape = watchrec;
}
for (String entryKey : entryMap.keySet()) {
WarningEntry entry = entryMap.get(entryKey);
AbstractWarningRecord rec = entry.record;
if (rec.getPhensig().equals(watchrec.getPhensig())
&& rec.getOfficeid().equals(
watchrec.getOfficeid())
&& rec.getEtn().equals(watchrec.getEtn())) {
int recSize = rec.getUgczones().size();
if (!entry.partialCancel) {
if (watchact == WarningAction.EXP
|| watchact == WarningAction.CAN) {
entry.partialCancel = true;
entry.record.setEndTime((Calendar) watchrec
.getStartTime().clone());
} else if (watchact == WarningAction.CON
&& recSize > watchSize
&& watchrec.getStartTime().after(
rec.getStartTime())) {
entry.partialCancel = true;
entry.record.setEndTime((Calendar) watchrec
.getStartTime().clone());
createShape = watchrec;
// checks for any possible null pointer exceptions in
// the following block of code, since there is the
// possibility of null values
if (rec.getPhensig() != null
&& watchrec.getPhensig() != null
&& rec.getOfficeid() != null
&& watchrec.getOfficeid() != null
&& rec.getUgczones() != null
&& rec.getStartTime() != null
&& watchrec.getStartTime() != null) {
if (rec.getPhensig().equals(watchrec.getPhensig())
&& rec.getOfficeid().equals(
watchrec.getOfficeid())
&& rec.getEtn().equals(watchrec.getEtn())) {
int recSize = rec.getUgczones().size();
if (!entry.partialCancel) {
if (watchact == WarningAction.EXP
|| watchact == WarningAction.CAN) {
entry.partialCancel = true;
entry.record
.setEndTime((Calendar) watchrec
.getStartTime().clone());
} else if (watchact == WarningAction.CON
&& recSize > watchSize
&& watchrec.getStartTime().after(
rec.getStartTime())) {
entry.partialCancel = true;
entry.record
.setEndTime((Calendar) watchrec
.getStartTime().clone());
createShape = watchrec;
}
}
}
}