Issue #2757. Added filter for removed stations and cleaned code.

Change-Id: I9998cf3bd20b2ec43956284257ee3dfcb8b52534

Former-commit-id: c7c40a3467 [formerly c7c40a3467 [formerly b613a9d5b7e9b1c17fa354c9c6b617da040d1d71]]
Former-commit-id: fa59172d87
Former-commit-id: 4ec22d9530
This commit is contained in:
Slav Korolev 2014-02-04 09:49:48 -05:00
parent 9370df47fe
commit 65ea06a366
3 changed files with 150 additions and 132 deletions

View file

@ -47,6 +47,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasMonitor;
* @version 1.0 * @version 1.0
*/ */
public class SSThresholdMgr extends AbstractThresholdMgr { public class SSThresholdMgr extends AbstractThresholdMgr {
private static SSThresholdMgr classInstance; private static SSThresholdMgr classInstance;
private SSThresholdMgr() { private SSThresholdMgr() {
@ -54,14 +55,19 @@ public class SSThresholdMgr extends AbstractThresholdMgr {
"DefaultSSMonitorThresholds.xml", "safeseas"); "DefaultSSMonitorThresholds.xml", "safeseas");
areaConfigMgr = getAreaConfigMgr(); areaConfigMgr = getAreaConfigMgr();
init(); // call init() after areaConfigMgr is set // call init() after areaConfigMgr is set
init();
} }
public static SSThresholdMgr getInstance() { /**
* Get instance.
*
* @return
*/
public static synchronized SSThresholdMgr getInstance() {
if (classInstance == null) { if (classInstance == null) {
classInstance = new SSThresholdMgr(); classInstance = new SSThresholdMgr();
} }
return classInstance; return classInstance;
} }
@ -69,7 +75,7 @@ public class SSThresholdMgr extends AbstractThresholdMgr {
* DR#11279: When monitor area configuration is changed, threshold manager * DR#11279: When monitor area configuration is changed, threshold manager
* needs to be re-initialized using the new monitor area configuration * needs to be re-initialized using the new monitor area configuration
*/ */
public static void reInitialize() { public static synchronized void reInitialize() {
if (classInstance != null) { if (classInstance != null) {
classInstance = null; classInstance = null;
} }
@ -79,6 +85,13 @@ public class SSThresholdMgr extends AbstractThresholdMgr {
classInstance.saveMonitorThresholds(); classInstance.saveMonitorThresholds();
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr#getThresholdKeys
* (com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey)
*/
@Override @Override
protected ArrayList<String> getThresholdKeys(DataUsageKey dataUsage) { protected ArrayList<String> getThresholdKeys(DataUsageKey dataUsage) {
ArrayList<String> threshKeys = new ArrayList<String>(); ArrayList<String> threshKeys = new ArrayList<String>();
@ -96,6 +109,13 @@ public class SSThresholdMgr extends AbstractThresholdMgr {
return threshKeys; return threshKeys;
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr#getAreaConfigMgr
* ()
*/
@Override @Override
public MonitorConfigurationManager getAreaConfigMgr() { public MonitorConfigurationManager getAreaConfigMgr() {
if (areaConfigMgr == null) { if (areaConfigMgr == null) {
@ -107,57 +127,4 @@ public class SSThresholdMgr extends AbstractThresholdMgr {
} }
return areaConfigMgr; return areaConfigMgr;
} }
// /**
// * Get the path where the display thresholds XML files are contained.
// * @return File path.
// */
// @Override
// public String getDisplayThresholdPath()
// {
// String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder();
//
// sb.append("safeseas").append(fs);
// sb.append("threshold").append(fs);
// sb.append("display").append(fs);
//
// return sb.toString();
// }
//
// /**
// * Get the path where the monitor thresholds XML files are contained.
// * @return File path.
// */
// @Override
// public String getMonitorThresholdPath()
// {
// String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder();
//
// sb.append("safeseas").append(fs);
// sb.append("threshold").append(fs);
// sb.append("monitor").append(fs);
//
// return sb.toString();
// }
//
// /**
// * Get the path where the XML file containing the user selected
// * default file is located.
// * @return The path of the user selected default file XML.
// */
// @Override
// public String getDefaultThresholdFilePath()
// {
// String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder();
//
// sb.append("safeseas").append(fs);
// sb.append("threshold").append(fs);
// sb.append("display").append(fs);
// sb.append("defaultThresh").append(fs);
//
// return sb.toString();
// }
} }

View file

@ -54,10 +54,16 @@ public class SnowThresholdMgr extends AbstractThresholdMgr {
"DefaultSnowMonitorThresholds.xml", "snow"); "DefaultSnowMonitorThresholds.xml", "snow");
areaConfigMgr = getAreaConfigMgr(); areaConfigMgr = getAreaConfigMgr();
init(); // call init() after areaConfigMgr is set // call init() after areaConfigMgr is set
init();
} }
public static SnowThresholdMgr getInstance() { /**
* Get instance.
*
* @return
*/
public static synchronized SnowThresholdMgr getInstance() {
if (classInstance == null) { if (classInstance == null) {
classInstance = new SnowThresholdMgr(); classInstance = new SnowThresholdMgr();
} }
@ -69,7 +75,7 @@ public class SnowThresholdMgr extends AbstractThresholdMgr {
* DR#11279: When monitor area configuration is changed, threshold manager * DR#11279: When monitor area configuration is changed, threshold manager
* needs to be re-initialized using the new monitor area configuration * needs to be re-initialized using the new monitor area configuration
*/ */
public static void reInitialize() { public static synchronized void reInitialize() {
if (classInstance != null) { if (classInstance != null) {
classInstance = null; classInstance = null;
} }
@ -79,6 +85,13 @@ public class SnowThresholdMgr extends AbstractThresholdMgr {
classInstance.saveMonitorThresholds(); classInstance.saveMonitorThresholds();
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr#getThresholdKeys
* (com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey)
*/
@Override @Override
protected ArrayList<String> getThresholdKeys(DataUsageKey dataUsage) { protected ArrayList<String> getThresholdKeys(DataUsageKey dataUsage) {
ArrayList<String> threshKeys = new ArrayList<String>(); ArrayList<String> threshKeys = new ArrayList<String>();
@ -96,6 +109,13 @@ public class SnowThresholdMgr extends AbstractThresholdMgr {
return threshKeys; return threshKeys;
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr#getAreaConfigMgr
* ()
*/
@Override @Override
public MonitorConfigurationManager getAreaConfigMgr() { public MonitorConfigurationManager getAreaConfigMgr() {
if (areaConfigMgr == null) { if (areaConfigMgr == null) {
@ -107,57 +127,4 @@ public class SnowThresholdMgr extends AbstractThresholdMgr {
} }
return areaConfigMgr; return areaConfigMgr;
} }
// /**
// * Get the path where the display thresholds XML files are contained.
// * @return File path.
// */
// @Override
// public String getDisplayThresholdPath()
// {
// String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder();
//
// sb.append("snow").append(fs);
// sb.append("threshold").append(fs);
// sb.append("display").append(fs);
//
// return sb.toString();
// }
//
// /**
// * Get the path where the monitor thresholds XML files are contained.
// * @return File path.
// */
// @Override
// public String getMonitorThresholdPath()
// {
// String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder();
//
// sb.append("snow").append(fs);
// sb.append("threshold").append(fs);
// sb.append("monitor").append(fs);
//
// return sb.toString();
// }
//
// /**
// * Get the path where the XML file containing the user selected
// * default file is located.
// * @return The path of the user selected default file XML.
// */
// @Override
// public String getDefaultThresholdFilePath()
// {
// String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder();
//
// sb.append("snow").append(fs);
// sb.append("threshold").append(fs);
// sb.append("display").append(fs);
// sb.append("defaultThresh").append(fs);
//
// return sb.toString();
// }
} }

View file

@ -33,12 +33,16 @@ import com.raytheon.uf.common.dataplugin.fssobs.FSSObsRecord;
import com.raytheon.uf.common.dataplugin.fssobs.FSSObsRecordTransform; import com.raytheon.uf.common.dataplugin.fssobs.FSSObsRecordTransform;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.pointdata.PointDataContainer; import com.raytheon.uf.common.pointdata.PointDataContainer;
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.common.time.DataTime; import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.alerts.AlertMessage; import com.raytheon.uf.viz.core.alerts.AlertMessage;
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.core.notification.NotificationMessage; import com.raytheon.uf.viz.core.notification.NotificationMessage;
import com.raytheon.uf.viz.monitor.data.MonitoringArea;
import com.raytheon.uf.viz.monitor.data.ObReport; import com.raytheon.uf.viz.monitor.data.ObReport;
import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent; import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent;
import com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent; import com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent;
@ -54,6 +58,7 @@ import com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent;
* Feb 25, 2010 4759 dhladky Initial creation. * Feb 25, 2010 4759 dhladky Initial creation.
* Mar 15, 2012 14510 zhao modified processProductAtStartup() * Mar 15, 2012 14510 zhao modified processProductAtStartup()
* Sep 11, 2013 2277 mschenke Got rid of ScriptCreator references * Sep 11, 2013 2277 mschenke Got rid of ScriptCreator references
* Feb 04, 2014 2757 skorolev Added filter for removed stations
* *
* </pre> * </pre>
* *
@ -63,9 +68,26 @@ import com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent;
*/ */
public abstract class ObsMonitor extends Monitor { public abstract class ObsMonitor extends Monitor {
@Override
protected abstract boolean filterNotifyMessage(NotificationMessage alertMessage);
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(ObsMonitor.class);
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.Monitor#filterNotifyMessage(com.raytheon.
* uf.viz.core.notification.NotificationMessage)
*/
@Override
protected abstract boolean filterNotifyMessage(
NotificationMessage alertMessage);
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.monitor.Monitor#nullifyMonitor()
*/
@Override @Override
protected abstract void nullifyMonitor(); protected abstract void nullifyMonitor();
@ -86,25 +108,59 @@ public abstract class ObsMonitor extends Monitor {
* *
* @param result * @param result
*/ */
protected abstract void process(ObReport result) protected abstract void process(ObReport result) throws Exception;
throws Exception;
/**
* This method processes the incoming messages at startup
*
* @param report
*/
protected abstract void processAtStartup(ObReport report); protected abstract void processAtStartup(ObReport report);
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.Monitor#processNotifyMessage(com.raytheon
* .uf.viz.core.notification.NotificationMessage)
*/
@Override @Override
protected abstract void processNotifyMessage(NotificationMessage filtered); protected abstract void processNotifyMessage(NotificationMessage filtered);
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.Monitor#processProductMessage(com.raytheon
* .uf.viz.core.alerts.AlertMessage)
*/
@Override @Override
protected abstract void processProductMessage(AlertMessage filtered); protected abstract void processProductMessage(AlertMessage filtered);
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.monitor.listeners.IMonitorThresholdListener#
* thresholdUpdate
* (com.raytheon.uf.viz.monitor.events.IMonitorThresholdEvent)
*/
@Override @Override
public abstract void thresholdUpdate(IMonitorThresholdEvent me); public abstract void thresholdUpdate(IMonitorThresholdEvent me);
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.monitor.listeners.IMonitorConfigurationListener#
* configUpdate
* (com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent)
*/
@Override @Override
public abstract void configUpdate(IMonitorConfigurationEvent me); public abstract void configUpdate(IMonitorConfigurationEvent me);
/** /**
* use this to do the initial filtering * use this to do the initial filtering
*
* @see com.raytheon.uf.viz.monitor.Monitor#filterProductMessage(com.raytheon.uf.viz.core.alerts.AlertMessage)
*/ */
public boolean filterProductMessage(AlertMessage alertMessage) { public boolean filterProductMessage(AlertMessage alertMessage) {
// Determine whether or not there is a station ID present in the decoded // Determine whether or not there is a station ID present in the decoded
@ -140,23 +196,38 @@ public abstract class ObsMonitor extends Monitor {
Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
public void run() { public void run() {
try { try {
ObReport result = GenerateFSSObReport // Filter removed stations
.generateObReport(objectToSend); ArrayList<String> zones = MonitoringArea
System.out.println("New FSSrecord ===> " .getZoneIds(objectToSend
+ objectToSend.getDataURI()); .getPlatformId());
process(result); if (!zones.isEmpty()) {
ObReport result = GenerateFSSObReport
.generateObReport(objectToSend);
statusHandler
.handle(Priority.INFO,
"New FSSrecord ===> "
+ objectToSend
.getDataURI());
process(result);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); statusHandler
.handle(Priority.PROBLEM,
"An error has occured processing the incoming messages.",
e);
} }
} }
}); });
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); statusHandler
.handle(Priority.PROBLEM,
"An error has occured processing incoming dataURIs.",
e);
} }
} }
} catch (final Exception e) { } catch (final Exception e) {
System.err.println("ObsMonitor: URI: " + dataURI statusHandler.handle(Priority.PROBLEM, "ObsMonitor: URI: "
+ " failed to process. " + e.getMessage()); + dataURI + " failed to process. " + e.getMessage());
} }
} }
@ -201,18 +272,31 @@ public abstract class ObsMonitor extends Monitor {
} }
FSSObsRecord[] obsRecords = requestFSSObs(vals, selectedTimes); FSSObsRecord[] obsRecords = requestFSSObs(vals, selectedTimes);
for (PluginDataObject objectToSend : obsRecords) { for (FSSObsRecord objectToSend : obsRecords) {
ObReport result = GenerateFSSObReport // Filter removed stations
.generateObReport(objectToSend); ArrayList<String> zones = MonitoringArea
processAtStartup(result); .getZoneIds(objectToSend.getPlatformId());
if (!zones.isEmpty()) {
ObReport result = GenerateFSSObReport
.generateObReport(objectToSend);
processAtStartup(result);
}
} }
} }
} catch (final VizException e) { } catch (final VizException e) {
System.err statusHandler.handle(Priority.PROBLEM,
.println("No data in database at startup. " + monitorUse); "No data in database at startup. " + monitorUse);
} }
} }
/**
* Gets array of FSSObs records.
*
* @param constraints
* @param times
* @return FSSObsRecord[]
* @throws VizException
*/
private FSSObsRecord[] requestFSSObs( private FSSObsRecord[] requestFSSObs(
Map<String, RequestConstraint> constraints, DataTime[] times) Map<String, RequestConstraint> constraints, DataTime[] times)
throws VizException { throws VizException {