VLab Issue #4953 Refactored TPCWatchSrv to support TCV effort.
Change-Id: I8a5c5c7fa62235fdc6fa4d90e82ff2711e724a15 Former-commit-id: 9a2a6989687c749ee87291506a7ee44a6cd7e737
This commit is contained in:
parent
f440da9c70
commit
be856e2981
5 changed files with 82 additions and 65 deletions
|
@ -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;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
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.localization.PathManagerFactory;
|
||||||
import com.raytheon.uf.common.python.PyUtil;
|
import com.raytheon.uf.common.python.PyUtil;
|
||||||
import com.raytheon.uf.common.python.PythonScript;
|
import com.raytheon.uf.common.python.PythonScript;
|
||||||
import com.raytheon.uf.common.util.FileUtil;
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Add Description
|
* Area Dictionary Maker
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
|
@ -49,6 +50,7 @@ import com.raytheon.uf.common.util.FileUtil;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* May 4, 2011 wldougher Moved from MapManager
|
* May 4, 2011 wldougher Moved from MapManager
|
||||||
|
* Oct 8, 2014 #4953 randerso Added hooks for TCVAreaDictionary creation
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -66,21 +68,21 @@ public class AreaDictionaryMaker {
|
||||||
* Generate the AreaDictionary.py and CityLocation.py scripts for site,
|
* Generate the AreaDictionary.py and CityLocation.py scripts for site,
|
||||||
* using editAreaAttrs.
|
* using editAreaAttrs.
|
||||||
*
|
*
|
||||||
* @param site
|
* @param siteID
|
||||||
* The site for which the area dictionary file and city location
|
* The site for which the area dictionary file and city location
|
||||||
* file should be generated.
|
* file should be generated.
|
||||||
* @param editAreaAttrs
|
* @param editAreaAttrs
|
||||||
* A Map from edit area names to shape file attributes
|
* 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) {
|
Map<String, Map<String, Object>> editAreaAttrs) {
|
||||||
theLogger.info("Area Dictionary generation phase");
|
theLogger.info("Area Dictionary generation phase");
|
||||||
|
|
||||||
if (site == null) {
|
if (siteID == null) {
|
||||||
throw new IllegalArgumentException("site is null");
|
throw new IllegalArgumentException("site is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("".equals(site)) {
|
if ("".equals(siteID)) {
|
||||||
throw new IllegalArgumentException("site is an empty string");
|
throw new IllegalArgumentException("site is an empty string");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +104,7 @@ public class AreaDictionaryMaker {
|
||||||
LocalizationContext caveStaticConfig = pathMgr.getContext(
|
LocalizationContext caveStaticConfig = pathMgr.getContext(
|
||||||
LocalizationContext.LocalizationType.CAVE_STATIC,
|
LocalizationContext.LocalizationType.CAVE_STATIC,
|
||||||
LocalizationContext.LocalizationLevel.CONFIGURED);
|
LocalizationContext.LocalizationLevel.CONFIGURED);
|
||||||
caveStaticConfig.setContextName(site);
|
caveStaticConfig.setContextName(siteID);
|
||||||
File outputDirFile = pathMgr.getLocalizationFile(caveStaticConfig,
|
File outputDirFile = pathMgr.getLocalizationFile(caveStaticConfig,
|
||||||
FileUtil.join("gfe", "userPython", "textUtilities", "regular"))
|
FileUtil.join("gfe", "userPython", "textUtilities", "regular"))
|
||||||
.getFile();
|
.getFile();
|
||||||
|
@ -119,6 +121,19 @@ public class AreaDictionaryMaker {
|
||||||
// createCityLocation uses script globals modified by
|
// createCityLocation uses script globals modified by
|
||||||
// createAreaDictionary()
|
// createAreaDictionary()
|
||||||
pyScript.execute("createCityLocation", argMap);
|
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) {
|
} catch (JepException e) {
|
||||||
theLogger.error("Error generating area dictionary", e);
|
theLogger.error("Error generating area dictionary", e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -19,14 +19,13 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.edex.plugin.gfe.watch;
|
package com.raytheon.edex.plugin.gfe.watch;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
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.edex.plugin.gfe.util.SendNotifications;
|
||||||
import com.raytheon.uf.common.activetable.VTECPartners;
|
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.message.ServerResponse;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.GfeNotification;
|
import com.raytheon.uf.common.dataplugin.gfe.server.notify.GfeNotification;
|
||||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.UserMessageNotification;
|
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
|
* 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>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -61,31 +62,19 @@ public abstract class AbstractWatchNotifierSrv {
|
||||||
|
|
||||||
protected final String watchType;
|
protected final String watchType;
|
||||||
|
|
||||||
protected final String supportedPIL;
|
protected AbstractWatchNotifierSrv(String watchType) {
|
||||||
|
|
||||||
protected AbstractWatchNotifierSrv(String watchType, String supportedPIL) {
|
|
||||||
this.watchType = watchType;
|
this.watchType = watchType;
|
||||||
this.supportedPIL = supportedPIL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the warning records and generates a notification for each
|
* Processes the warning records and generates a notification for each
|
||||||
* currently activated GFE site if the storm affects the site.
|
* currently activated GFE site if the storm affects the site.
|
||||||
*
|
*
|
||||||
* @param pdos
|
* @param warningRecs
|
||||||
* A list of {@code PluginDataObject}s that are assumed to be
|
* A list of {@code AbstractWarningRecord}s all decoded from a
|
||||||
* {@code AbstractWarningRecord}s all decoded from a common
|
* common warning product.
|
||||||
* warning product.
|
|
||||||
*/
|
*/
|
||||||
public final void handleWatch(List<PluginDataObject> pdos) {
|
public void handleWatch(List<AbstractWarningRecord> warningRecs) {
|
||||||
List<AbstractWarningRecord> warningRecs = filterIncomingRecordsByPIL(pdos);
|
|
||||||
if (warningRecs.isEmpty()) {
|
|
||||||
String logMsg = String.format("%s notification: not %s product",
|
|
||||||
watchType, supportedPIL);
|
|
||||||
statusHandler.debug(logMsg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We are making an assumption that all PDOs came from the same source
|
* We are making an assumption that all PDOs came from the same source
|
||||||
* product. This is a safe assumption because WarningDecoder processes
|
* product. This is a safe assumption because WarningDecoder processes
|
||||||
|
@ -98,7 +87,7 @@ public abstract class AbstractWatchNotifierSrv {
|
||||||
String productText = warningRecs.get(0).getRawmessage();
|
String productText = warningRecs.get(0).getRawmessage();
|
||||||
Collection<String> wfos = WatchProductUtil.findAttnWFOs(productText);
|
Collection<String> wfos = WatchProductUtil.findAttnWFOs(productText);
|
||||||
|
|
||||||
for (String siteid : GFESiteActivation.getInstance().getActiveSites()) {
|
for (String siteid : getActiveSites()) {
|
||||||
if (!wfos.contains(siteid)) {
|
if (!wfos.contains(siteid)) {
|
||||||
String logMsg = String.format(
|
String logMsg = String.format(
|
||||||
"%s notification: my site %s not in ATTN list",
|
"%s notification: my site %s not in ATTN list",
|
||||||
|
@ -116,28 +105,8 @@ public abstract class AbstractWatchNotifierSrv {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected Set<String> getActiveSites() {
|
||||||
* Given a list of {@code PluginDataObject}s that are actually
|
return IFPServer.getActiveSites();
|
||||||
* {@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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,9 +36,11 @@ import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Oct 03, 2008 njensen Initial creation
|
* Oct 03, 2008 njensen Initial creation
|
||||||
* Jul 10, 2009 #2590 njensen Added multiple site support
|
* Jul 10, 2009 #2590 njensen Added multiple site support
|
||||||
* Jun 10, 2014 #3268 dgilling Re-factor based on AbstractWatchNotifierSrv.
|
* 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>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author njensen
|
* @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_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 SPC_SITE_ATTRIBUTE = "VTEC_SPC_SITE";
|
||||||
|
|
||||||
private static final String DEFAULT_SPC_SITE = "KNHC";
|
private static final String DEFAULT_SPC_SITE = "KNHC";
|
||||||
|
@ -71,8 +71,11 @@ public final class SPCWatchSrv extends AbstractWatchNotifierSrv {
|
||||||
phenTextMap = Collections.unmodifiableMap(phenTextMapTemp);
|
phenTextMap = Collections.unmodifiableMap(phenTextMapTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
public SPCWatchSrv() {
|
public SPCWatchSrv() {
|
||||||
super(SPC_WATCH_TYPE, SPC_SUPPORTED_PIL);
|
super(SPC_WATCH_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -39,9 +39,13 @@ import com.raytheon.uf.common.dataplugin.warning.AbstractWarningRecord;
|
||||||
* SOFTWARE HISTORY
|
* SOFTWARE HISTORY
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Oct 03, 2008 njensen Initial creation
|
* Oct 03, 2008 njensen Initial creation
|
||||||
* Jul 10, 2009 #2590 njensen Added multiple site support
|
* Jul 10, 2009 #2590 njensen Added multiple site support
|
||||||
* Jun 10, 2014 #3268 dgilling Re-factor based on AbstractWatchNotifierSrv.
|
* 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>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author njensen
|
* @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_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 TPC_SITE_ATTRIBUTE = "VTEC_TPC_SITE";
|
||||||
|
|
||||||
private static final String DEFAULT_TPC_SITE = "KNHC";
|
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. "
|
+ "Check for 'red' locks (owned by others) on your Hazard grid and resolve them. "
|
||||||
+ "If hazards are separated into temporary grids, please run Mergehazards. "
|
+ "If hazards are separated into temporary grids, please run Mergehazards. "
|
||||||
+ "Next...save Hazards grid. Finally, select PlotTPCEvents from Hazards menu.";
|
+ "Next...save Hazards grid. Finally, select PlotTPCEvents from Hazards menu.";
|
||||||
|
@ -83,8 +85,31 @@ public final class TPCWatchSrv extends AbstractWatchNotifierSrv {
|
||||||
actMap = Collections.unmodifiableMap(actMapTemp);
|
actMap = Collections.unmodifiableMap(actMapTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
public TPCWatchSrv() {
|
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
|
// create the message
|
||||||
StringBuilder msg = new StringBuilder(String.format(ALERT_TXT,
|
StringBuilder msg = new StringBuilder(ALERT_TXT);
|
||||||
supportedPIL));
|
|
||||||
for (String phensigStorm : phensigStormAct.keySet()) {
|
for (String phensigStorm : phensigStormAct.keySet()) {
|
||||||
Collection<String> acts = phensigStormAct.get(phensigStorm);
|
Collection<String> acts = phensigStormAct.get(phensigStorm);
|
||||||
String[] splitKey = phensigStorm.split(":");
|
String[] splitKey = phensigStorm.split(":");
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
<mapping key="pluginName">
|
<mapping key="pluginName">
|
||||||
<constraint constraintValue="warning" constraintType="EQUALS"/>
|
<constraint constraintValue="warning" constraintType="EQUALS"/>
|
||||||
</mapping>
|
</mapping>
|
||||||
|
<mapping key="pil">
|
||||||
|
<constraint constraintValue="WOU" constraintType="EQUALS"/>
|
||||||
|
</mapping>
|
||||||
</metadataMap>
|
</metadataMap>
|
||||||
</pluginNotification>
|
</pluginNotification>
|
||||||
<pluginNotification>
|
<pluginNotification>
|
||||||
|
@ -17,6 +20,9 @@
|
||||||
<mapping key="pluginName">
|
<mapping key="pluginName">
|
||||||
<constraint constraintValue="warning" constraintType="EQUALS"/>
|
<constraint constraintValue="warning" constraintType="EQUALS"/>
|
||||||
</mapping>
|
</mapping>
|
||||||
|
<mapping key="pil">
|
||||||
|
<constraint constraintValue="TCV" constraintType="EQUALS"/>
|
||||||
|
</mapping>
|
||||||
</metadataMap>
|
</metadataMap>
|
||||||
</pluginNotification>
|
</pluginNotification>
|
||||||
</pluginNotificationList>
|
</pluginNotificationList>
|
||||||
|
|
Loading…
Add table
Reference in a new issue