VLab Issue #4953 Refactored TPCWatchSrv to support TCV effort.

Change-Id: I8a5c5c7fa62235fdc6fa4d90e82ff2711e724a15

Former-commit-id: 9a2a6989687c749ee87291506a7ee44a6cd7e737
This commit is contained in:
Ron Anderson 2014-10-08 11:51:00 -05:00
parent f440da9c70
commit be856e2981
5 changed files with 82 additions and 65 deletions

View file

@ -34,13 +34,14 @@ import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonScript;
import com.raytheon.uf.common.util.FileUtil;
/**
* TODO Add Description
* Area Dictionary Maker
*
* <pre>
*
@ -49,6 +50,7 @@ import com.raytheon.uf.common.util.FileUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 4, 2011 wldougher Moved from MapManager
* Oct 8, 2014 #4953 randerso Added hooks for TCVAreaDictionary creation
*
* </pre>
*
@ -66,21 +68,21 @@ public class AreaDictionaryMaker {
* Generate the AreaDictionary.py and CityLocation.py scripts for site,
* using editAreaAttrs.
*
* @param site
* @param siteID
* The site for which the area dictionary file and city location
* file should be generated.
* @param editAreaAttrs
* A Map from edit area names to shape file attributes
*/
public void genAreaDictionary(String site,
public void genAreaDictionary(String siteID,
Map<String, Map<String, Object>> editAreaAttrs) {
theLogger.info("Area Dictionary generation phase");
if (site == null) {
if (siteID == null) {
throw new IllegalArgumentException("site is null");
}
if ("".equals(site)) {
if ("".equals(siteID)) {
throw new IllegalArgumentException("site is an empty string");
}
@ -102,7 +104,7 @@ public class AreaDictionaryMaker {
LocalizationContext caveStaticConfig = pathMgr.getContext(
LocalizationContext.LocalizationType.CAVE_STATIC,
LocalizationContext.LocalizationLevel.CONFIGURED);
caveStaticConfig.setContextName(site);
caveStaticConfig.setContextName(siteID);
File outputDirFile = pathMgr.getLocalizationFile(caveStaticConfig,
FileUtil.join("gfe", "userPython", "textUtilities", "regular"))
.getFile();
@ -119,6 +121,19 @@ public class AreaDictionaryMaker {
// createCityLocation uses script globals modified by
// createAreaDictionary()
pyScript.execute("createCityLocation", argMap);
// check to see if Hazard_TCV was configured for this site
LocalizationFile lf = pathMgr.getLocalizationFile(caveStaticConfig,
FileUtil.join("gfe", "userPython", "textProducts",
"Hazard_TCV.py"));
if (lf.exists()) {
// TODO: Sarah add your TCVAreaDictionary creation code here
// if you add your code as a new method in
// createAreaDictionary.py which is probably the easiest way to
// do it, you can run it with the following line:
// pyScript.execute("createTCVAreaDictionary", argMap);
}
} catch (JepException e) {
theLogger.error("Error generating area dictionary", e);
} finally {

View file

@ -19,14 +19,13 @@
**/
package com.raytheon.edex.plugin.gfe.watch;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import com.raytheon.edex.plugin.gfe.config.GFESiteActivation;
import com.raytheon.edex.plugin.gfe.server.IFPServer;
import com.raytheon.edex.plugin.gfe.util.SendNotifications;
import com.raytheon.uf.common.activetable.VTECPartners;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.dataplugin.gfe.server.notify.GfeNotification;
import com.raytheon.uf.common.dataplugin.gfe.server.notify.UserMessageNotification;
@ -46,7 +45,9 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 10, 2014 #3268 dgilling Initial creation
* Jun 10, 2014 #3268 dgilling Initial creation
* Oct 08, 2014 #4953 randerso Refactored AbstractWatchNotifierSrv to allow
* subclasses to handle all watches if desired.
*
* </pre>
*
@ -61,31 +62,19 @@ public abstract class AbstractWatchNotifierSrv {
protected final String watchType;
protected final String supportedPIL;
protected AbstractWatchNotifierSrv(String watchType, String supportedPIL) {
protected AbstractWatchNotifierSrv(String watchType) {
this.watchType = watchType;
this.supportedPIL = supportedPIL;
}
/**
* Processes the warning records and generates a notification for each
* currently activated GFE site if the storm affects the site.
*
* @param pdos
* A list of {@code PluginDataObject}s that are assumed to be
* {@code AbstractWarningRecord}s all decoded from a common
* warning product.
* @param warningRecs
* A list of {@code AbstractWarningRecord}s all decoded from a
* common warning product.
*/
public final void handleWatch(List<PluginDataObject> pdos) {
List<AbstractWarningRecord> warningRecs = filterIncomingRecordsByPIL(pdos);
if (warningRecs.isEmpty()) {
String logMsg = String.format("%s notification: not %s product",
watchType, supportedPIL);
statusHandler.debug(logMsg);
return;
}
public void handleWatch(List<AbstractWarningRecord> warningRecs) {
/*
* We are making an assumption that all PDOs came from the same source
* product. This is a safe assumption because WarningDecoder processes
@ -98,7 +87,7 @@ public abstract class AbstractWatchNotifierSrv {
String productText = warningRecs.get(0).getRawmessage();
Collection<String> wfos = WatchProductUtil.findAttnWFOs(productText);
for (String siteid : GFESiteActivation.getInstance().getActiveSites()) {
for (String siteid : getActiveSites()) {
if (!wfos.contains(siteid)) {
String logMsg = String.format(
"%s notification: my site %s not in ATTN list",
@ -116,28 +105,8 @@ public abstract class AbstractWatchNotifierSrv {
}
}
/**
* Given a list of {@code PluginDataObject}s that are actually
* {@code AbstractWarningRecord}s, filters the list for only those records
* which have the right PIL code.
*
* @param pdos
* List of {@code AbstractWarningRecord}s to filter.
* @return The list of supported {@code AbstractWarningRecord}s as defined
* by {@code getSupportedPIL}.
*/
protected List<AbstractWarningRecord> filterIncomingRecordsByPIL(
List<PluginDataObject> pdos) {
List<AbstractWarningRecord> warningRecords = new ArrayList<AbstractWarningRecord>();
for (PluginDataObject pdo : pdos) {
AbstractWarningRecord warning = (AbstractWarningRecord) pdo;
if (warning.getPil().startsWith(supportedPIL)) {
warningRecords.add(warning);
}
}
return warningRecords;
protected Set<String> getActiveSites() {
return IFPServer.getActiveSites();
}
/**

View file

@ -36,9 +36,11 @@ import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 03, 2008 njensen Initial creation
* Jul 10, 2009 #2590 njensen Added multiple site support
* Jun 10, 2014 #3268 dgilling Re-factor based on AbstractWatchNotifierSrv.
* Oct 03, 2008 njensen Initial creation
* Jul 10, 2009 #2590 njensen Added multiple site support
* Jun 10, 2014 #3268 dgilling Re-factor based on AbstractWatchNotifierSrv.
* Oct 08, 2014 #4953 randerso Refactored AbstractWatchNotifierSrv to allow
* subclasses to handle all watches if desired.
* </pre>
*
* @author njensen
@ -49,8 +51,6 @@ public final class SPCWatchSrv extends AbstractWatchNotifierSrv {
private static final String SPC_WATCH_TYPE = "SPC";
private static final String SPC_SUPPORTED_PIL = "WOU";
private static final String SPC_SITE_ATTRIBUTE = "VTEC_SPC_SITE";
private static final String DEFAULT_SPC_SITE = "KNHC";
@ -71,8 +71,11 @@ public final class SPCWatchSrv extends AbstractWatchNotifierSrv {
phenTextMap = Collections.unmodifiableMap(phenTextMapTemp);
}
/**
* Constructor
*/
public SPCWatchSrv() {
super(SPC_WATCH_TYPE, SPC_SUPPORTED_PIL);
super(SPC_WATCH_TYPE);
}
/*

View file

@ -39,9 +39,13 @@ import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 03, 2008 njensen Initial creation
* Jul 10, 2009 #2590 njensen Added multiple site support
* Jun 10, 2014 #3268 dgilling Re-factor based on AbstractWatchNotifierSrv.
* Oct 03, 2008 njensen Initial creation
* Jul 10, 2009 #2590 njensen Added multiple site support
* Jun 10, 2014 #3268 dgilling Re-factor based on AbstractWatchNotifierSrv.
* Oct 08, 2014 #4953 randerso Refactored AbstractWatchNotifierSrv to allow
* subclasses to handle all watches if desired.
* Added hooks for TCVAdvisory creation
*
* </pre>
*
* @author njensen
@ -52,13 +56,11 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
private static final String TPC_WATCH_TYPE = "TPC";
private static final String TPC_SUPPORTED_PIL = "TCV";
private static final String TPC_SITE_ATTRIBUTE = "VTEC_TPC_SITE";
private static final String DEFAULT_TPC_SITE = "KNHC";
private static final String ALERT_TXT = "Alert: %s has arrived from TPC. "
private static final String ALERT_TXT = "Alert: TCV has arrived from TPC. "
+ "Check for 'red' locks (owned by others) on your Hazard grid and resolve them. "
+ "If hazards are separated into temporary grids, please run Mergehazards. "
+ "Next...save Hazards grid. Finally, select PlotTPCEvents from Hazards menu.";
@ -83,8 +85,31 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
actMap = Collections.unmodifiableMap(actMapTemp);
}
/**
* Constructor
*/
public TPCWatchSrv() {
super(TPC_WATCH_TYPE, TPC_SUPPORTED_PIL);
super(TPC_WATCH_TYPE);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.edex.plugin.gfe.watch.AbstractWatchNotifierSrv#handleWatch
* (java.util.List)
*/
@Override
public void handleWatch(List<AbstractWarningRecord> warningRecs) {
super.handleWatch(warningRecs);
for (String siteId : getActiveSites()) {
for (AbstractWarningRecord record : warningRecs) {
// TODO: Sarah, add a call to your method that
// handles the TCV here:
// example: processTCV(siteID, record);
}
}
}
/*
@ -123,8 +148,7 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
}
// create the message
StringBuilder msg = new StringBuilder(String.format(ALERT_TXT,
supportedPIL));
StringBuilder msg = new StringBuilder(ALERT_TXT);
for (String phensigStorm : phensigStormAct.keySet()) {
Collection<String> acts = phensigStormAct.get(phensigStorm);
String[] splitKey = phensigStorm.split(":");

View file

@ -7,6 +7,9 @@
<mapping key="pluginName">
<constraint constraintValue="warning" constraintType="EQUALS"/>
</mapping>
<mapping key="pil">
<constraint constraintValue="WOU" constraintType="EQUALS"/>
</mapping>
</metadataMap>
</pluginNotification>
<pluginNotification>
@ -17,6 +20,9 @@
<mapping key="pluginName">
<constraint constraintValue="warning" constraintType="EQUALS"/>
</mapping>
<mapping key="pil">
<constraint constraintValue="TCV" constraintType="EQUALS"/>
</mapping>
</metadataMap>
</pluginNotification>
</pluginNotificationList>