Merge "Omaha #4654 - Added localization level filters to AlertViz messages. Added input test." into omaha_16.2.1

Former-commit-id: 9625c051a6f50dda6dcadd85ef79f4c0cbe07520
This commit is contained in:
Lee Venable 2015-08-18 10:11:16 -05:00 committed by Gerrit Code Review
commit 59a7743c16
4 changed files with 8 additions and 13 deletions

View file

@ -55,7 +55,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
* Sep 8, 2008 1433 chammack Initial creation
* Oct 18, 2010 5849 cjeanbap NullPointerExceptin thrown if category is null
* Jun 03, 2013 2026 randerso Fixed typo
* Jul 27, 2015 4654 skorolev Added a localization level filtration
* Jul 27, 2015 4654 skorolev Added a localization level filtration.
*
* </pre>
*
@ -146,18 +146,13 @@ public class Container implements IConfigurationChangedListener {
if (message.getFilters() != null && !message.getFilters().isEmpty()) {
Map<String, String> filters = message.getFilters();
if (filters.keySet().contains("") || filters.values().contains("")) {
throw new IllegalArgumentException(
"Filters must not have empty key and/or value :"
+ filters);
}
LocalizationLevel[] lvls = LocalizationLevel.values();
for (int i = 0; i < lvls.length; i++) {
String lvl = LocalizationManager.getContextName(lvls[i]);
String key = lvls[i].name();
if (filters.containsKey(key)) {
String value = filters.get(key);
if (!value.equals(lvl)) {
if (value != null && !value.equals(lvl)) {
return;
}
}

View file

@ -38,7 +38,7 @@ import os
# 04/14/11 4514 cjeanbap Change SYSTEM to Systat
# 05/03/11 5149 cjeanbap Updated usage statement.
# 11/11/2011 11484 rferrel Added SYSTEM for WSHNIMNAT
# 07/27/15 4654 skorolev Added level filters
# 07/27/15 4654 skorolev Added level filters. Added input test.
#
from ufpy import NotificationMessage
@ -70,7 +70,7 @@ if len(sys.argv) > 4:
if not filtersInput.strip():
raise ValueError('Filters input must not be empty or blank')
else:
fltrs=dict(item.split("=") for item in filtersInput.strip().split(","))
fltrs=dict(item.strip().split("=") for item in filtersInput.strip().split(","))
if importance.upper() == "URGENT":
pri = 1
elif importance.upper() == "SIGNIFICANT":

View file

@ -35,7 +35,7 @@ import os, socket
# 10/22/10 5849 cjeanbap Updated to use AlertVizMessage.
# 12/08/10 7656 cjeanbap Retrieve environment variable.
# 05/03/11 5149 cjeanbap Updated usage statement.
# 07/27/15 4654 skorolev Added filters
# 07/27/15 4654 skorolev Added filters and input test.
#
from ufpy import NotificationMessage
@ -110,7 +110,7 @@ def main():
if not filtersInput.strip():
raise ValueError('Filters input must not be empty or blank')
else:
filters=dict(item.split("=") for item in filtersInput.strip().split(","))
filters=dict(item.strip().split("=") for item in filtersInput.strip().split(","))
else:
filters={}

View file

@ -74,7 +74,7 @@ class AlertVizRequest(object):
def setFilters(self, filters):
if filters is None:
self.filters = {}
elif not(filters.has_key(None) or filters.values().count(None)>0):
elif not(filters.has_key(None) or filters.values().count(None)>0 or fltrs.has_key('') or fltrs.values().count('')>0):
self.filters = filters
else:
raise ValueError('Filters must not contain None in keys or values: %s' % filters)
raise ValueError('Filters must not contain None or empty keys or values: %s' % filters)