From face1ebeeb7dc33c07ffced4ed741df298805742 Mon Sep 17 00:00:00 2001 From: "Brian.Dyke" Date: Fri, 21 Mar 2014 12:43:50 -0400 Subject: [PATCH] OB_14.1.1-24 baseline Former-commit-id: 8b1e7457fc58021208e4233502f118cf34df7534 --- .../src/com/raytheon/uf/viz/core/VizApp.java | 38 +++---------------- .../viz/texteditor/TextDisplayModel.java | 33 +++++++--------- .../viz/texteditor/TextWarningConstants.java | 5 ++- .../com/raytheon/uf/common/site/SiteMap.java | 35 +++++++++-------- .../base/site3LetterTo4LetterOverride.dat | 2 +- 5 files changed, 42 insertions(+), 71 deletions(-) diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/VizApp.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/VizApp.java index 13b2ac02c9..40bd59022a 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/VizApp.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/VizApp.java @@ -21,10 +21,6 @@ package com.raytheon.uf.viz.core; import java.lang.management.ManagementFactory; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.util.Enumeration; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; @@ -52,6 +48,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager; * Jan 14, 2013 1469 bkowal Removed the hdf5 data directory. * Aug 27, 2013 2295 bkowal Removed the jms server property; added * jms connection string + * Feb 17, 2014 2812 njensen getHostName() now uses getWsId()'s hostname * * * @@ -255,45 +252,20 @@ public final class VizApp { private static String host = null; /** - * Gets the ip address of the host machine calling the function + * Gets the host name from the WsId of the host machine calling the function * * @return */ public static synchronized String getHostName() { if (host == null) { - InetAddress addrToUse = null; - boolean found = false; - try { - Enumeration nis = NetworkInterface - .getNetworkInterfaces(); - while (nis.hasMoreElements() && !found) { - NetworkInterface ni = nis.nextElement(); - ni.isVirtual(); - ni.isUp(); - Enumeration addrs = ni.getInetAddresses(); - while (addrs.hasMoreElements() && !found) { - InetAddress addr = addrs.nextElement(); - if (addr.isLinkLocalAddress() == false - && addr.isSiteLocalAddress() == false - && addr.isLoopbackAddress() == false) { - addrToUse = addr; - found = true; - } - } - } - } catch (SocketException e) { - e.printStackTrace(); - } - - if (addrToUse == null) { + host = getWsId().getHostName(); + if (host == null) { String hostname = System.getenv("HOSTNAME"); - if (hostname != null && hostname.trim().length() == 0) { + if (hostname != null && hostname.trim().length() > 0) { host = hostname; } else { host = "localhost"; } - } else { - host = addrToUse.getHostName(); } } return host; diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextDisplayModel.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextDisplayModel.java index 9daba6b99b..bdfe005144 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextDisplayModel.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextDisplayModel.java @@ -22,6 +22,7 @@ package com.raytheon.viz.texteditor; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -62,6 +63,7 @@ import com.raytheon.viz.texteditor.msgs.ITextWorkstationCallback; * Apr 14, 2010 4734 mhuang Corrected StdTextProduct import * dependency * 05/28/2010 2187 cjeanbap Added StdTextProductFactory functionality. + * 03/18/2014 DR 17174 D. Friedman Return correct 3-letter site IDs in getNnnXxx. * * * @author grichard @@ -78,7 +80,7 @@ public final class TextDisplayModel { private static final Map vtecPpToNnn = new HashMap(); private static final Pattern warningPattern = Pattern - .compile("/[A-Z]\\.([A-Z]{3})\\.\\p{Alnum}{1}(\\p{Alnum}{3})\\.([A-Z]{2}\\.[A-Z]{1})"); + .compile("/[A-Z]\\.([A-Z]{3})\\.(\\p{Alnum}{4})\\.([A-Z]{2}\\.[A-Z]{1})"); private static final Pattern nnnxxxPattern = Pattern .compile("[\\r\\n]+([A-Z]{3})([A-Z]{3})(| WRKWG[0-9])[\\r\\n]+"); @@ -514,29 +516,20 @@ public final class TextDisplayModel { * @return the product category and product designator strings */ public static String[] getNnnXxx(String warning) { - String[] rval = { "nnn", "xxx" }; if (warning != null) { Matcher m = warningPattern.matcher(warning); - if (m.find()) { - if (m.group(1).equals("NEW") - && vtecPpToNnn.containsKey(m.group(3))) { - rval[0] = vtecPpToNnn.get(m.group(3)); - rval[1] = m.group(2); - } else { - m = nnnxxxPattern.matcher(warning); - if (m.find()) { - rval[0] = m.group(1); - rval[1] = m.group(2); - } - } - } else { - m = nnnxxxPattern.matcher(warning); - if (m.find()) { - rval[0] = m.group(1); - rval[1] = m.group(2); + if (m.find() && m.group(1).equals("NEW")) { + String nnn = vtecPpToNnn.get(m.group(3)); + Set siteSet = SiteMap.getInstance().getSite3LetterIds(m.group(2)); + if (nnn != null && siteSet.size() == 1) { + return new String[] { nnn, siteSet.iterator().next() }; } } + m = nnnxxxPattern.matcher(warning); + if (m.find()) { + return new String[] { m.group(1), m.group(2) }; + } } - return rval; + return new String[] { "nnn", "xxx" }; } } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWarningConstants.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWarningConstants.java index 21984552c1..98b90619c7 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWarningConstants.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWarningConstants.java @@ -31,6 +31,7 @@ import java.util.TimeZone; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 8, 2008 1737 grichard Initial creation. + * Mar 14, 2014 DR 17175 D. Friedman Fixed Atlantic and Samoa time zones * * * @author grichard @@ -82,8 +83,8 @@ public final class TextWarningConstants { timeZoneAbbreviationMap.put("M", TimeZone.getTimeZone("MST7MDT")); timeZoneAbbreviationMap.put("m", TimeZone.getTimeZone("MST")); timeZoneAbbreviationMap.put("P", TimeZone.getTimeZone("PST8PDT")); - timeZoneAbbreviationMap.put("S", TimeZone.getTimeZone("AST")); - timeZoneAbbreviationMap.put("V", TimeZone.getTimeZone("VST")); + timeZoneAbbreviationMap.put("S", TimeZone.getTimeZone("US/Samoa")); + timeZoneAbbreviationMap.put("V", TimeZone.getTimeZone("America/Puerto_Rico")); } /** diff --git a/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/SiteMap.java b/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/SiteMap.java index 52f1e4fcc5..63cfe9324e 100644 --- a/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/SiteMap.java +++ b/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/SiteMap.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -60,6 +61,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * Apr 09, 2012 DR14765 mhuang Map out correct CCCC site ID for backup * sites. * May 15, 2013 1040 mpduff Add awips_site_list.xml. + * Mar 18, 2014 DR 17173 D. Friedmna Re-implement DR 14765. * * * @@ -93,6 +95,8 @@ public class SiteMap { private final Map> siteTo3LetterSite = new HashMap>(); + private final Set site3to4LetterOverrides = new HashSet(); + private final Map siteMap = new TreeMap(); /** JAXB context */ @@ -163,6 +167,7 @@ public class SiteMap { nationalCategoryMap.clear(); siteTo4LetterSite.clear(); siteTo3LetterSite.clear(); + site3to4LetterOverrides.clear(); siteMap.clear(); // load base afos lookup @@ -311,6 +316,11 @@ public class SiteMap { } } + // Currently, only the 3-letter IDs are used (in + // getSite4LetterId(), but it should be possible + // to also add the 4-letter IDs to this set. + site3to4LetterOverrides.add(site3); + site3To4LetterMap.put(site3, site4); // Add the entry to the reverse lookup map @@ -390,22 +400,17 @@ public class SiteMap { public String getSite4LetterId(String site3LetterId) { String site = siteTo4LetterSite.get(site3LetterId); - // if site not found default to K - if (site == null) { + /* If site not found default to K + 3-letter-ID. + * + * Or, if the 4-letter site ID that was looked up does not + * start with a 'K' and did not come from + * site3LetterTo4LetterOverride.dat, also return + * K + 3-letter-ID. + */ + if (site == null + || (site.length() > 0 && site.charAt(0) != 'K' && + !site3to4LetterOverrides.contains(site3LetterId))) { site = "K" + site3LetterId; - } else { - // DR_14765, in case the site hashed out from combined mapping - // table from both national_category_table and afo_lookup_table - // does not start with K but not from - // site3LetterTo4LetterOerride.dat - // which are starting with P or T - char[] siteChar = site.toCharArray(); - if (siteChar[0] != 'K') { - if (!((siteChar[0] == 'P' && (siteChar[1] == 'A' - || siteChar[1] == 'G' || siteChar[1] == 'H')) || (siteChar[0] == 'T' && siteChar[1] == 'S'))) { - site = "K" + site3LetterId; - } - } } return site; diff --git a/edexOsgi/com.raytheon.uf.common.site/utility/common_static/base/site3LetterTo4LetterOverride.dat b/edexOsgi/com.raytheon.uf.common.site/utility/common_static/base/site3LetterTo4LetterOverride.dat index 8b2f954ef6..d8b94e5aba 100644 --- a/edexOsgi/com.raytheon.uf.common.site/utility/common_static/base/site3LetterTo4LetterOverride.dat +++ b/edexOsgi/com.raytheon.uf.common.site/utility/common_static/base/site3LetterTo4LetterOverride.dat @@ -8,4 +8,4 @@ AFG PAFG AJK PAJK GUM PGUM HFO PHFO -SJU TSJU +SJU TJSJ