Merge "Issue #2176 Implemented emergency warning products." into development

Former-commit-id: 717a1f81ecc323e4e1cc10e923956befb99e3e04
This commit is contained in:
Richard Peter 2013-07-25 13:54:48 -05:00 committed by Gerrit Code Review
commit 89823b3681
10 changed files with 833 additions and 352 deletions

View file

@ -24,7 +24,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.site;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin.radar;bundle-version="1.0.0",
com.raytheon.uf.viz.localization,
com.raytheon.uf.common.auth;bundle-version="1.12.1174"
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin.warning;bundle-version="1.12.1174"
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.texteditor,
com.raytheon.viz.texteditor.alarmalert.dialogs,

View file

@ -0,0 +1,196 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.texteditor.dialogs;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.raytheon.uf.common.activetable.ActiveTableMode;
import com.raytheon.uf.common.activetable.ActiveTableRecord;
import com.raytheon.uf.common.activetable.GetActiveTableRequest;
import com.raytheon.uf.common.activetable.GetActiveTableResponse;
import com.raytheon.uf.common.dataplugin.warning.WarningRecord.WarningAction;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.core.mode.CAVEMode;
import com.raytheon.viz.texteditor.util.VtecObject;
import com.raytheon.viz.texteditor.util.VtecUtil;
/**
* Produces the product message and mode message for the warngen confirmation
* dialog for emergency warnings.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 23, 2013 2176 jsanchez Initial creation
*
* </pre>
*
* @author jsanchez
* @version 1.0
*/
public class EmergencyConfirmationMsg implements IWarnGenConfirmationable {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(EmergencyConfirmationMsg.class);
private String productMessage;
private static class EmergencyType {
private static final EmergencyType TORNADO = new EmergencyType(
"TORNADO EMERGENCY", "TO.W");
private static final EmergencyType FLASH_FLOOD = new EmergencyType(
"FLASH FLOOD EMERGENCY", "FF.W");
private final String value;
private final String phensig;
private final static EmergencyType[] values = new EmergencyType[] {
TORNADO, FLASH_FLOOD };
private EmergencyType(String type, String phensig) {
this.value = type;
this.phensig = phensig;
}
public static EmergencyType valueOf(String phensig) {
EmergencyType type = null;
for (EmergencyType t : values) {
if (t.phensig.equals(phensig)) {
type = t;
break;
}
}
return type;
}
};
/**
* Orders the ActiveTableRecord based on the issue time (ascending)
*/
private class ActiveTableRecordComparator implements
Comparator<ActiveTableRecord> {
@Override
public int compare(ActiveTableRecord o1, ActiveTableRecord o2) {
return o1.getIssueTime().compareTo(o2.getIssueTime());
}
}
@Override
public boolean checkWarningInfo(String header, String body, String nnn) {
VtecObject vtec = VtecUtil.parseMessage(body);
EmergencyType type = null;
WarningAction action = null;
if (vtec != null) {
type = EmergencyType.valueOf(vtec.getPhensig());
action = WarningAction.valueOf(vtec.getAction());
if (action == WarningAction.CAN && body.split("\\$\\$").length > 2) {
// It is possible for a warning products to have two segments: a
// CAN and a CON.'$$' denotes the end of one segment. VtecUtil
// only grabs the first VTEC. If there are multiple segments CAN
// should always be the first VTEC
action = WarningAction.CANCON;
}
}
// Check if the warning product is a valid EmergencyType.
if (type != null) {
boolean currentEmergency = body.contains("EMERGENCY");
if (action == WarningAction.NEW && currentEmergency) {
// Only occurs when the warning is first issued and not any
// other action
productMessage = "This is a " + type.value;
} else if (action == WarningAction.CON
|| action == WarningAction.EXT
|| action == WarningAction.CANCON) {
// Check if the warning was an upgrade or downgrade in the
// emergency warning for continuation, extension (FFW), or a
// cancel
// and continuation.
GetActiveTableRequest request = new GetActiveTableRequest();
if (CAVEMode.getMode().equals(CAVEMode.PRACTICE)) {
request.setMode(ActiveTableMode.PRACTICE);
} else {
request.setMode(ActiveTableMode.OPERATIONAL);
}
request.setSiteID(vtec.getOffice());
request.setPhensigList(vtec.getPhensig());
request.setEtn(String.format("%04d", vtec.getSequence()));
try {
GetActiveTableResponse response = (GetActiveTableResponse) ThriftClient
.sendRequest(request);
List<ActiveTableRecord> records = response.getActiveTable();
// There should be existing records since this is for follow
// ups. This is just a precaution
if (records != null && !records.isEmpty()) {
// Get latest active table record
Collections.sort(records,
new ActiveTableRecordComparator());
ActiveTableRecord record = records
.get(records.size() - 1);
boolean wasEmergency = record.getRawmessage().contains(
"EMERGENCY");
if (!wasEmergency && currentEmergency) {
productMessage = "This is an upgrade of a "
+ type.value;
} else if (wasEmergency && !currentEmergency) {
productMessage = "This is a downgrade of a "
+ type.value;
}
}
} catch (VizException e) {
statusHandler.handle(Priority.ERROR,
"Error making request to active table.");
}
}
}
return productMessage == null;
}
@Override
public String getTitle() {
return "Severe Weather Product";
}
@Override
public String getProductMessage() {
return productMessage;
}
@Override
public String getModeMessage() {
return "Should we proceed?\n";
}
}

View file

@ -0,0 +1,67 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.texteditor.dialogs;
/**
* Interface to retrieve the WarnGen Confirmation Dialog message values.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 23, 2013 2176 jsanchez Initial creation
*
* </pre>
*
* @author jsanchez
* @version 1.0
*/
public interface IWarnGenConfirmationable {
/**
* Returns true if the WarnGen Confirmation Dialog needs to pop-up.
*
* @param header
* @param body
* @param nnn
* @return
*/
public boolean checkWarningInfo(String header, String body, String nnn);
/**
*
* @return the title for the WarnGen Confirmation Dialog
*/
public String getTitle();
/**
*
* @return the product message in the WarnGen Confirmation Dialog
*/
public String getProductMessage();
/**
*
* @return the mode message in the WarnGen Confirmation Dialog
*/
public String getModeMessage();
}

View file

@ -0,0 +1,66 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.texteditor.dialogs;
import com.raytheon.viz.texteditor.qc.QualityControl;
/**
* Produces the product message and mode message for the warngen confirmation
* dialog for warnings failing QC.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 23, 2013 2176 jsanchez Initial creation
*
* </pre>
*
* @author jsanchez
* @version 1.0
*/
public class QCConfirmationMsg implements IWarnGenConfirmationable {
private QualityControl qcCheck = new QualityControl();
@Override
public boolean checkWarningInfo(String header, String body, String nnn) {
return qcCheck.checkWarningInfo(header, body, nnn);
}
@Override
public String getTitle() {
return "Problem Detected by QC";
}
@Override
public String getProductMessage() {
return qcCheck.getErrorMessage();
}
@Override
public String getModeMessage() {
return "Do you really want to Send?\n";
}
}

View file

@ -0,0 +1,102 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.texteditor.dialogs;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.raytheon.viz.core.mode.CAVEMode;
import com.raytheon.viz.texteditor.qc.QualityControl;
/**
* Produces the product message and mode message for the warngen confirmation
* dialog for sending a warning.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 23, 2013 2176 jsanchez Initial creation
*
* </pre>
*
* @author jsanchez
* @version 1.0
*/
public class SendConfirmationMsg implements IWarnGenConfirmationable {
private String title;
private boolean resend;
private String afosId;
public SendConfirmationMsg(boolean resend, String afosId, String nnn) {
this.resend = resend;
this.afosId = afosId;
title = QualityControl.getProductWarningType(nnn);
}
@Override
public boolean checkWarningInfo(String header, String body, String nnn) {
return true;
}
@Override
public String getTitle() {
return title;
}
@Override
public String getProductMessage() {
StringBuilder productMessage = new StringBuilder();
if (resend) {
productMessage.append("You are about to RESEND a " + afosId + "\n");
productMessage.append(title).append(".\n");
} else {
productMessage.append("You are about to SEND a " + afosId + "\n");
productMessage.append(title).append(".\n");
}
return productMessage.toString();
}
@Override
public String getModeMessage() {
CAVEMode mode = CAVEMode.getMode();
StringBuilder modeMessage = new StringBuilder();
modeMessage.append("The workstation is in ").append(mode)
.append(" mode.");
if (resend) {
modeMessage.append("\nThere is no QC check for resend product.");
}
Pattern p = Pattern.compile(".\\%[s].");
Matcher m = p.matcher(TextEditorDialog.STORED_SENT_MSG);
boolean result = (CAVEMode.OPERATIONAL.equals(mode) || CAVEMode.TEST
.equals(mode));
modeMessage.append(result ? m.replaceAll(" ") : m.replaceAll(" not "));
return modeMessage.toString();
}
}

View file

@ -71,7 +71,7 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
private String IMAGE_PRACTICE = "res/images/twsPractice.gif";
protected WarnGenConfirmationDlg(Shell parentShell, String title,
String productMessage, String modeMessage, CAVEMode mode) {
String productMessage, String modeMessage) {
super(parentShell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL, CAVE.NONE
| CAVE.DO_NOT_BLOCK);
@ -79,7 +79,7 @@ public class WarnGenConfirmationDlg extends CaveSWTDialog {
this.productMessage = productMessage;
this.modeMessage = modeMessage;
this.mode = mode;
this.mode = CAVEMode.getMode();
setReturnValue(Boolean.FALSE);
}

View file

@ -37,6 +37,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* ------------ ---------- ----------- --------------------------
* Initial creation
* May 7, 2013 1973 rferrel Changes to properly display Issue Time.
* Jul 22, 2013 2176 jsanchez Added EMER to the display string in the update list.
*
* </pre>
*
@ -92,6 +93,9 @@ public class FollowupData extends WarningRecord {
rval.append(buildExpStr(status, record));
}
if (record.getRawmessage().contains("EMERGENCY")) {
rval.append(" EMER");
}
equvialentString = rval.substring(0,
record.getProductClass().equals("T") ? 20 : 18);

View file

@ -72,6 +72,7 @@ import com.vividsolutions.jts.geom.Geometry;
* May 10, 2013 1951 rjpeter Updated ugcZones references
* May 31, 2013 DR 16264 D. Friedman Fix query in prepare method.
* Jun 05, 2013 DR 16279 D. Friedman Fix updating of issuance time for followups.
* Jul 22, 2013 2176 jsanchez Set the raw message for an EXT.
* </pre>
*
* @author mschenke
@ -312,6 +313,7 @@ public class CurrentWarnings {
if (rval != null) {
rval.setEndTime(warning.getEndTime());
rval.setIssueTime(warning.getIssueTime());
rval.setRawmessage(warning.getRawmessage());
}
}
}

View file

@ -79,6 +79,7 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
* Apr 18, 2013 1877 jsanchez Had the child classes set the comparator. Fixed a null pointer.
* Remove frameAltered condition in matchesFrame. It prevented entries from being displayed.
* Check if geometry is null when inspecting.
* Jul 22, 2013 2176 jsanchez Updated the wire frame and text for EMERGENCY warnings.
* </pre>
*
* @author jsanchez
@ -358,14 +359,23 @@ public abstract class AbstractWWAResource extends
}
if (entry != null && entry.wireframeShape != null) {
LineStyle lineStyle = (record.getProductClass() != null && record
.getProductClass().equals("T")) ? LineStyle.DASHED
: LineStyle.SOLID;
LineStyle lineStyle = LineStyle.SOLID;
if (record.getProductClass() != null
&& record.getProductClass().equals("T")) {
lineStyle = LineStyle.DASHED;
}
int outlineWidth = getCapability(OutlineCapability.class)
.getOutlineWidth();
// Make wire frame outline thicker for EMERGENCY warnings
if (record.getRawmessage().contains("EMERGENCY")) {
outlineWidth *= 2;
}
target.drawWireframeShape(
entry.wireframeShape,
getCapability(ColorableCapability.class).getColor(),
getCapability(OutlineCapability.class)
.getOutlineWidth(), lineStyle);
outlineWidth, lineStyle);
} else if (entry != null && entry.shadedShape != null) {
target.drawShadedShape(entry.shadedShape, 1);
}
@ -409,6 +419,14 @@ public abstract class AbstractWWAResource extends
params.magnification = getCapability(
MagnificationCapability.class).getMagnification();
target.drawStrings(params);
// Draws the string again to have it appear bolder
if (textToPrintReversed[2].endsWith("EMER")) {
params.setText(new String[] { "", "", "EMER", "" },
color);
target.drawStrings(params);
}
}
}
}
@ -581,7 +599,11 @@ public abstract class AbstractWWAResource extends
}
textToPrint[0] += "." + record.getEtn();
textToPrint[1] = record.getPil();
if (record.getRawmessage().contains("EMERGENCY")) {
textToPrint[1] = record.getPil() + " EMER";
} else {
textToPrint[1] = record.getPil();
}
SimpleDateFormat startFormat = DEFAULT_FORMAT;
SimpleDateFormat endFormat = DEFAULT_FORMAT;