Issue #1842: Use GetNextEtnRequest to handle ETN assignment for GFE VTEC

products.

Change-Id: Ice767da91252461fabf3fe8b5296e3d1e90a9c1d

Former-commit-id: 13d5d8dd7c59fcf399d62e83c9eb7021bca4c2d1
This commit is contained in:
David Gillingham 2013-05-14 16:54:35 -05:00
parent 60ae5df378
commit 9c688f7070
12 changed files with 415 additions and 82 deletions

View file

@ -18,6 +18,21 @@
# further licensing information.
##
#
# Port of A1 HazardsTable.py.
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# ??/??/?? ???????? Initial Creation.
# 05/14/13 1842 dgilling Use GFEVtecUtil to handle NEW
# ETN assignment.
#
#
import time, getopt, sys, copy, string, logging
import VTECTableUtil, VTECTable
import TimeRange, AbsTime, ActiveTableVtec
@ -28,6 +43,7 @@ from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceID
from com.raytheon.uf.common.dataplugin.gfe.discrete import DiscreteKey
from com.raytheon.uf.common.time import TimeRange as JavaTimeRange
from com.raytheon.viz.gfe.sampler import HistoSampler, SamplerRequest
from com.raytheon.viz.gfe.vtec import GFEVtecUtil
import cPickle
# This class makes an object that interfaces to the GFE hazard grid
@ -69,14 +85,14 @@ class HazardsTable(VTECTableUtil.VTECTableUtil):
self.__marineProds = ["CWF", "NSH", "GLF", "MWW", "OFF"]
# list of phen/sig from national centers and "until further notice"
self.__tpcKeys = [('HU','A'), ('HU','S'), ('HU','W'), ('TR','A'),
('TR','W')]
self.__tpcKeys = self.__processJavaCollection(GFEVtecUtil.TROPICAL_PHENSIGS, self.__convertPhensig)
self.__tpcBaseETN = '1001'
self.__ncKeys = [('TO','A'), ('SV','A'), ('HU', 'S'), ('HU','A'), ('HU','W'),
('TR','A'), ('TR','W')] # added HU.S
self.__ncKeys = self.__processJavaCollection(GFEVtecUtil.NATIONAL_PHENSIGS, self.__convertPhensig)
self.__ufnKeys = [('HU','A'), ('HU','S'), ('HU','W'), ('TR','A'), ('TR','W'),
('TY','A'), ('TY','W')]
self.__sitesIgnoreNatlEtn = self.__processJavaCollection(GFEVtecUtil.IGNORE_NATIONAL_ETN, str)
self.__marineZonesPrefix = ["AM", "GM", "PZ", "PK", "PH", "PM", "AN",
"PS", "SL"] #list of zone name prefix that are marine zones
@ -682,36 +698,31 @@ class HazardsTable(VTECTableUtil.VTECTableUtil):
assigned.extend(ids2)
# find highest etn in active table for phen/sig, returns it.
# This method has been dramatically re-written for A2 to use
# GFEVtecUtil to do preliminary ETN assignment instead of scrubbing
# the whole set of ActiveTableRecords to calculate it.
def __highestETNActiveTable(self, phen, sig, activeTable):
#check active table for highest etn
presentyear = time.gmtime(self.__time)[0]
etn_base = 0
for active in activeTable:
# find only records with
# 1. same phen and sig
# 2. in the present year
# and not from the national center
activeyear = time.gmtime(active['issueTime'])[0]
phensig = (active['phen'],active['sig'])
if active['phen'] == phen and active['sig'] == sig and \
activeyear == presentyear:
# find the max ETN...
# 1. highest ETN period for non-tropical and all GUM products (tpcKeys)
# or
# 2. highest ETN > 1000 for the tropical, non-GUM products (tpcKeys)
#
# Local WFOs do not assign these numbers, so they should have
# numbers < 1000
if active['etn'] > etn_base and \
phensig not in self.__tpcKeys:
etn_base = active['etn']
elif active['etn'] > etn_base and \
phensig in self.__tpcKeys:
if self.__siteID4 == 'PGUM':
etn_base = active['etn'] # GUM uses their own ETNs regardless of hazard
else:
if active['etn'] < 1001: # causes failure if tropical hazards are less than 1001
self.log.error("Incorrect ETN for tropical hazard.")
phensig = (phen, sig)
# find the max ETN...
# 1. highest ETN period for non-tropical and all GUM products (tpcKeys)
# or
# 2. highest ETN > 1000 for the tropical, non-GUM products (tpcKeys)
#
# Local WFOs do not assign these numbers, so they should have
# numbers < 1000
if phensig not in self.__tpcKeys or self.__siteID4 in self.__sitesIgnoreNatlEtn:
etn_base = GFEVtecUtil.getNextEtn(self.__siteID4, '.'.join(phensig), False) - 1
else:
presentyear = time.gmtime(self.__time)[0]
for active in activeTable:
activeyear = time.gmtime(active['issueTime'])[0]
activephensig = (active['phen'],active['sig'])
if phensig == activephensig and presentyear == activeyear:
# causes failure if tropical hazards are less than 1001
if active['etn'] < int(self.__tpcBaseETN):
LogStream.logProblem("Incorrect ETN for tropical hazard.")
return etn_base
#determine the new etn to use, using the etn cache
@ -2389,3 +2400,17 @@ class HazardsTable(VTECTableUtil.VTECTableUtil):
# return False #same phen/sig, not tpc, so. non separate track
# else:
# return true;
def __processJavaCollection(self, javaObj, processMethod=None):
retVal = []
iter = javaObj.iterator()
while iter.hasNext():
nextObj = iter.next()
if processMethod is not None:
nextObj = processMethod(nextObj)
retVal.append(nextObj)
return retVal
def __convertPhensig(self, javaPhensig):
phenSig = tuple(str(javaPhensig).split('.'))
return phenSig

View file

@ -30,7 +30,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.viz.ui.personalities.awips;bundle-version="1.12.1174",
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.python;bundle-version="1.12.1174",
com.raytheon.uf.common.colormap;bundle-version="1.12.1174"
com.raytheon.uf.common.colormap;bundle-version="1.12.1174",
com.google.guava;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.gfe,
com.raytheon.viz.gfe.constants,
@ -63,6 +64,7 @@ Import-Package: com.raytheon.edex.meteoLib,
com.raytheon.uf.viz.ui.menus.widgets.tearoff,
com.raytheon.viz.core.gl,
com.raytheon.viz.pointdata,
com.raytheon.viz.texteditor.util,
com.raytheon.viz.ui.tools.map,
junit.framework,
org.eclipse.jdt.ui;resolution:=optional,

View file

@ -12,7 +12,35 @@
<property name="maxSaveThreads" value="3"/>
<property name="gridSaveThreshold" value="33554432"/>
<!-- threshold = 32*1024*1024 bytes (32 MB)-->
</bean>
</bean>
<bean id="gfeVtecConfig" class="com.raytheon.viz.gfe.vtec.GFEVtecConfig" factory-method="getInstance">
<property name="sitesIgnoreNationalEtn">
<set>
<value>PGUM</value>
</set>
</property>
<property name="nationalEtnPhensigs">
<set>
<value>TO.A</value>
<value>SV.A</value>
<value>HU.A</value>
<value>HU.S</value>
<value>HU.W</value>
<value>TR.A</value>
<value>TR.W</value>
</set>
</property>
<property name="tropicalEtnPhensigs">
<set>
<value>HU.A</value>
<value>HU.S</value>
<value>HU.W</value>
<value>TR.A</value>
<value>TR.W</value>
</set>
</property>
</bean>
<!-- FIXME: Uncomment to re-enable cache at CAVE startup
<bean id="gfeDiskCache" class="com.raytheon.uf.common.cache.disk.DiskCache" init-method="activateCache">

View file

@ -95,6 +95,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Apr 24, 2013 1936 dgilling Remove initialization of
* TextProductManager from this class, clean
* up warnings.
* May 15, 2013 1842 dgilling Pass DataManager instance down to sub-
* components.
*
* </pre>
*
@ -714,7 +716,8 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
ProductAreaComp comp = new ProductAreaComp(tabFolder, this,
newTab.getText(), tabName.equals(PRODUCT_EDITOR),
textProductMgr, CAVEMode.getMode().equals(CAVEMode.PRACTICE));
textProductMgr, dataMgr, CAVEMode.getMode().equals(
CAVEMode.PRACTICE));
productMap.put(tabName, comp);
newTab.setControl(productMap.get(tabName));

View file

@ -35,6 +35,7 @@ import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.TabFolder;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.dialogs.FormatterLauncherDialog;
import com.raytheon.viz.gfe.dialogs.formatterlauncher.ConfigData.productStateEnum;
import com.raytheon.viz.gfe.tasks.AbstractGfeTask;
@ -45,7 +46,7 @@ import com.raytheon.viz.gfe.textformatter.TextProductManager;
/**
* Composite containing the product area and its controls.
*
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
@ -58,12 +59,14 @@ import com.raytheon.viz.gfe.textformatter.TextProductManager;
* based on VTECMessageType setting.
* 10 AUG 2012 15178 mli Add autoWrite and autoStore capability
* 26 SEP 2012 15423 ryu Fix product correction in practice mode
*
* 15 MAY 2013 1842 dgilling Change constructor signature to accept a
* DataManager instance.
*
* </pre>
*
*
* @author lvenable
* @version 1.0
*
*
*/
public class ProductAreaComp extends Composite implements
TextProductFinishListener, ITransmissionState {
@ -189,25 +192,29 @@ public class ProductAreaComp extends Composite implements
private TextProductManager textProductMgr;
private final DataManager dataMgr;
private boolean practiceMode;
private boolean isTabClosed = false;
/**
* Constructor.
*
*
* @param parent
* Parent composite.
*/
public ProductAreaComp(TabFolder parent, IProductTab productTabCB,
String productName, boolean editorCorrectionMode,
TextProductManager textProductMgr, boolean practiceMode) {
TextProductManager textProductMgr, DataManager dataMgr,
boolean practiceMode) {
super(parent, SWT.NONE);
this.productName = productName;
this.editorCorrectionMode = editorCorrectionMode;
this.productTabCB = productTabCB;
this.textProductMgr = textProductMgr;
this.dataMgr = dataMgr;
this.practiceMode = practiceMode;
init();
@ -439,14 +446,14 @@ public class ProductAreaComp extends Composite implements
.get("pil");
}
if (pil != null) {
String vtecMode = textProductMgr.getVtecMessageType(
pil.substring(0, 3));
String vtecMode = textProductMgr.getVtecMessageType(pil
.substring(0, 3));
if (vtecMode == null) {
pracType = 0;
pracType = 0;
} else if ("O".equals(vtecMode)) {
pracType = 1;
} else if ("E".equals(vtecMode)) {
pracType = 2;
pracType = 2;
} else if ("X".equals(vtecMode)) {
pracType = 3;
} else if ("T".equals(vtecMode)) {
@ -592,7 +599,7 @@ public class ProductAreaComp extends Composite implements
private void createProductEditorComp() {
productEditorComp = new ProductEditorComp(stackGridComp,
textProductMgr.getProductDefinition(productName), productName,
editorCorrectionMode, this);
editorCorrectionMode, this, dataMgr);
((GridData) productEditorComp.getLayoutData()).exclude = true;
productEditorComp.setVisible(false);
stackGridComp.layout();
@ -609,7 +616,7 @@ public class ProductAreaComp extends Composite implements
}
/**
*
*
* @return the textProductManager
*/
public TextProductManager getTextProductManager() {
@ -618,7 +625,7 @@ public class ProductAreaComp extends Composite implements
/**
* Sets the textProductManager
*
*
* @param textProductManager
*/
public void setTextProductManager(TextProductManager textProductManager) {

View file

@ -113,7 +113,6 @@ import com.raytheon.uf.viz.spellchecker.dialogs.SpellCheckDlg;
import com.raytheon.viz.core.mode.CAVEMode;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEPreference;
import com.raytheon.viz.gfe.GFEServerException;
import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.dialogs.formatterlauncher.ConfigData.productStateEnum;
@ -151,6 +150,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Add mouselistener in createTextControl() for StyledText
* 28 Feb 2013 15889 ryu Removed detachAttributionPhrase and getVTECActionCodes
* 02/12/2013 #1597 randerso Code cleanup. Fixed possible widget disposed errors on shut down.
* 05/08/2013 #1842 dgilling Add alternate setProductText(), fix
* warnings.
*
* </pre>
*
@ -406,6 +407,8 @@ public class ProductEditorComp extends Composite implements
private String prodEditorDirectory = null;
private final DataManager dm;
/**
* Constructor.
*
@ -414,7 +417,8 @@ public class ProductEditorComp extends Composite implements
*/
public ProductEditorComp(Composite parent,
ProductDefinition productDefinition, String productName,
boolean editorCorrectionMode, ITransmissionState transmissionCB) {
boolean editorCorrectionMode, ITransmissionState transmissionCB,
DataManager dataMgr) {
super(parent, SWT.BORDER);
this.parent = parent;
@ -422,6 +426,7 @@ public class ProductEditorComp extends Composite implements
this.productName = productName;
this.editorCorrectionMode = editorCorrectionMode;
this.transmissionCB = transmissionCB;
this.dm = dataMgr;
IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
@ -454,8 +459,7 @@ public class ProductEditorComp extends Composite implements
}
testVTEC = GFEPreference.getBooleanPreference("TestVTECDecode");
DataManager dm = DataManager.getCurrentInstance();
if (dm.getOpMode().equals(CAVEMode.PRACTICE)) {
if (CAVEMode.getMode().equals(CAVEMode.PRACTICE)) {
testVTEC = true;
}
@ -1063,7 +1067,7 @@ public class ProductEditorComp extends Composite implements
* Set the transmission controls to reflect live or disabled transmission.
*/
public void setLiveTransmission() {
CAVEMode mode = DataManager.getCurrentInstance().getOpMode();
CAVEMode mode = CAVEMode.getMode();
if (mode.equals(CAVEMode.OPERATIONAL)) {
transmitBtn.setImage(transLiveImg);
transmitMI.setImage(transLiveImg);
@ -1765,14 +1769,8 @@ public class ProductEditorComp extends Composite implements
* @return
*/
private TimeZone getLocalTimeZone() {
// get the time zone
DataManager dm = DataManager.getCurrentInstance();
TimeZone timeZone = TimeZone.getTimeZone("GMT");
try {
timeZone = TimeZone.getTimeZone(dm.getClient().getDBGridLocation()
.getTimeZone());
} catch (GFEServerException e1) {/* do nothing, use GMT */
}
TimeZone timeZone = TimeZone.getTimeZone(dm.getParmManager()
.compositeGridLocation().getTimeZone());
return timeZone;
}
@ -2646,9 +2644,15 @@ public class ProductEditorComp extends Composite implements
}
public void setProductText(String text) {
setProductText(text, true);
}
public void setProductText(String text, boolean reviveEditor) {
textComp.setProductText(text);
revive();
setPurgeTime();
if (reviveEditor) {
revive();
setPurgeTime();
}
}
public String getProductText() {

View file

@ -49,8 +49,8 @@ import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.core.mode.CAVEMode;
import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.product.TextDBUtil;
import com.raytheon.viz.gfe.vtec.GFEVtecUtil;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
@ -66,6 +66,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* functionality.
* 09 NOV 2012 1298 rferrel Changes for non-blocking dialog.
* 02apr2013 15564 mgamazaychikov Ensured awipsWanPil to be 10 characters space-padded long
* 08 MAY 2013 1842 dgilling Use VtecUtil to set product ETNs, fix
* warnings.
* </pre>
*
* @author lvenable
@ -152,7 +154,7 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
@Override
protected void initializeComponents(Shell shell) {
String title = null;
CAVEMode opMode = DataManager.getCurrentInstance().getOpMode();
CAVEMode opMode = CAVEMode.getMode();
if (opMode.equals(CAVEMode.OPERATIONAL)) {
if (isStoreDialog == true) {
title = "Store in AWIPS TextDB";
@ -272,7 +274,7 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
gd = new GridData(150, SWT.DEFAULT);
final Button actionBtn = new Button(buttons, SWT.PUSH);
CAVEMode opMode = DataManager.getCurrentInstance().getOpMode();
CAVEMode opMode = CAVEMode.getMode();
if (opMode.equals(CAVEMode.OPERATIONAL)) {
if (isStoreDialog == true) {
actionBtn.setText("Store");
@ -325,10 +327,28 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
/**
* Method to store or transmit the product.
*/
@Override
public void storeTransmitProduct() {
// Store/Transmit the product...
if (!countdownThread.threadCancelled()) {
try {
productText = GFEVtecUtil.finalizeETNs(productText);
} catch (VizException e) {
statusHandler.handle(Priority.CRITICAL,
"Error setting ETNs for product", e);
sendTransmissionStatus(ConfigData.productStateEnum.Failed);
VizApp.runAsync(new Runnable() {
@Override
public void run() {
StoreTransmitDlg.this.parentEditor.revive();
}
});
return;
}
VizApp.runSync(new Runnable() {
@Override
@ -388,8 +408,10 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
} else {
req = new OUPRequest();
OfficialUserProduct oup = new OfficialUserProduct();
// make sure the awipsWanPil is exactly 10 characters space-padded long
String awipsWanPil = String.format("%-10s", productIdTF.getText().trim());
// make sure the awipsWanPil is exactly 10 characters space-padded
// long
String awipsWanPil = String.format("%-10s", productIdTF.getText()
.trim());
oup.setAwipsWanPil(awipsWanPil);
oup.setProductText(productText);
@ -451,6 +473,8 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
}
statusHandler.handle(p, resp.getMessage());
}
this.parentEditor.setProductText(productText, false);
this.parentEditor.brain();
} catch (VizException e) {
statusHandler.handle(Priority.CRITICAL, "Error sending product", e);

View file

@ -0,0 +1,102 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.gfe.vtec;
import java.util.Collections;
import java.util.Set;
/**
* Class to hold exceptions for GFE ETN assignment logic in HazardsTable.py and
* GFEVtecUtil. Values are intended to be injected via spring from
* com.raytheon.viz.gfe/res/spring/gfe.xml.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 14, 2013 #1842 dgilling Initial creation
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public class GFEVtecConfig {
private static final GFEVtecConfig INSTANCE = new GFEVtecConfig();
private Set<String> sitesIgnoreNationalEtn = Collections.emptySet();
private Set<String> nationalEtnPhensigs = Collections.emptySet();
private Set<String> tropicalEtnPhensigs = Collections.emptySet();
private GFEVtecConfig() {
}
public static GFEVtecConfig getInstance() {
return INSTANCE;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GFEVtecConfig [sitesIgnoreNationalEtn=");
builder.append(sitesIgnoreNationalEtn);
builder.append(", nationalEtnPhensigs=");
builder.append(nationalEtnPhensigs);
builder.append(", tropicalEtnPhensigs=");
builder.append(tropicalEtnPhensigs);
builder.append("]");
return builder.toString();
}
public Set<String> getSitesIgnoreNationalEtn() {
return sitesIgnoreNationalEtn;
}
public Set<String> getNationalEtnPhensigs() {
return nationalEtnPhensigs;
}
public Set<String> getTropicalEtnPhensigs() {
return tropicalEtnPhensigs;
}
public void setSitesIgnoreNationalEtn(Set<String> sitesIgnoreNationalEtn) {
this.sitesIgnoreNationalEtn = sitesIgnoreNationalEtn;
}
public void setNationalEtnPhensigs(Set<String> nationalEtnPhensigs) {
this.nationalEtnPhensigs = nationalEtnPhensigs;
}
public void setTropicalEtnPhensigs(Set<String> tropicalEtnPhensigs) {
this.tropicalEtnPhensigs = tropicalEtnPhensigs;
}
}

View file

@ -0,0 +1,102 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.gfe.vtec;
import java.util.Collection;
import java.util.regex.Matcher;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.texteditor.util.VtecObject;
import com.raytheon.viz.texteditor.util.VtecUtil;
/**
* Utility class to set ETNs on GFE VTEC products prior to transmission. Logic
* for ETN assignment/replacement based on A1 HazardsTable.py code; thus didn't
* want to contaminate the generic <code>VtecUtil</code> with A1 GFE-specific
* logic.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 14, 2013 #1842 dgilling Initial creation
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public class GFEVtecUtil {
public static final Collection<String> TROPICAL_PHENSIGS = ImmutableSet
.copyOf(GFEVtecConfig.getInstance().getTropicalEtnPhensigs());
public static final Collection<String> NATIONAL_PHENSIGS = ImmutableSet
.copyOf(GFEVtecConfig.getInstance().getNationalEtnPhensigs());
public static final Collection<String> IGNORE_NATIONAL_ETN = ImmutableSet
.copyOf(GFEVtecConfig.getInstance().getSitesIgnoreNationalEtn());
/**
* A private constructor so that Java does not attempt to create one for us.
* As this class should not be instantiated, do not attempt to ever call
* this constructor; it will simply throw an AssertionError.
*
*/
private GFEVtecUtil() {
throw new AssertionError();
}
public static int getNextEtn(String office, String phensig, boolean lockEtn)
throws VizException {
return VtecUtil.getNextEtn(office, phensig, lockEtn);
}
public static String finalizeETNs(String message) throws VizException {
if (Strings.isNullOrEmpty(message)) {
return message;
}
Matcher vtecMatcher = VtecUtil.VTEC_REGEX.matcher(message);
StringBuffer finalOutput = new StringBuffer();
while (vtecMatcher.find()) {
VtecObject vtec = new VtecObject(vtecMatcher.group());
// To best match the ETN assignment logic in HazardsTable.py, it
// seems we should assume all ETNs assigned to tropical products are
// automatically correct
if (("NEW".equals(vtec.getAction()))
&& ((!NATIONAL_PHENSIGS.contains(vtec.getPhensig())) || (IGNORE_NATIONAL_ETN
.contains(vtec.getOffice()) && TROPICAL_PHENSIGS
.contains(vtec.getPhensig())))) {
int newEtn = VtecUtil.getNextEtn(vtec.getOffice(),
vtec.getPhensig(), true);
vtec.setSequence(newEtn);
}
vtecMatcher.appendReplacement(finalOutput, vtec.getVtecString());
}
vtecMatcher.appendTail(finalOutput);
return finalOutput.toString();
}
}

View file

@ -33,6 +33,7 @@ import java.util.regex.Pattern;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 14, 2009 bwoodle Initial creation
* May 08, 2013 #1842 dgilling Add getPhensig() method.
*
* </pre>
*
@ -321,4 +322,8 @@ public class VtecObject {
return String.format(PARTIAL_MATCH_FORMAT, this.office, this.phenomena,
this.significance);
}
public String getPhensig() {
return phenomena + '.' + significance;
}
}

View file

@ -33,14 +33,16 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.core.mode.CAVEMode;
/**
* TODO Add Description
* Utility class for assigning the next ETN to a VTEC string in a transmitted
* VTEC product.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 9, 2009 bwoodle Initial creation
* Feb 09, 2009 bwoodle Initial creation
* May 08, 2013 #1842 dgilling Code cleanup.
*
* </pre>
*
@ -52,6 +54,19 @@ public class VtecUtil {
private static final String dateFormat = "%1$ty%1$tm%1$tdT%1$tH%1$tMZ";
public static final Pattern VTEC_REGEX = Pattern
.compile("\\/([OTEX])\\.([A-Z]{3})\\.([A-Za-z0-9]{4})\\.([A-Z]{2})\\.([WAYSFON])\\.(\\d{4})\\.(\\d{6}T\\d{4}Z)-(\\d{6}T\\d{4}Z)\\/");
/**
* A private constructor so that Java does not attempt to create one for us.
* As this class should not be instantiated, do not attempt to ever call
* this constructor; it will simply throw an AssertionError.
*
*/
private VtecUtil() {
throw new AssertionError();
}
/**
* Gets the next available ETN for a specific product and office
*
@ -121,15 +136,8 @@ public class VtecUtil {
}
public static VtecObject parseMessage(String message) {
String pVtecParseFormat = "\\/([OTEX])\\.([A-Z]{3})\\.([A-Za-z0-9]{4})\\.([A-Z]{2})\\.([WAYSFON])\\.(\\d{4})\\.(\\d{6}T\\d{4}Z)-(\\d{6}T\\d{4}Z)\\/";
/**
* The pattern used for matching either a P-VTEC or an H-VTEC string.
*/
Pattern cPattern = Pattern.compile(String
.format("%s", pVtecParseFormat));
VtecObject rval = null;
Matcher m = cPattern.matcher(message);
Matcher m = VTEC_REGEX.matcher(message);
if (m.find()) {
rval = new VtecObject(m.group());
}

View file

@ -73,9 +73,11 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 17, 2009 njensen Initial creation
* Dec 21, 2009 4055 njensen Queued thread for updates
* Feb 26, 2013 1447 dgilling Add routine to use MergeVTEC as basis
* for merge logic.
* Dec 21, 2009 4055 njensen Queued thread for updates
* Feb 26, 2013 1447 dgilling Add routine to use MergeVTEC as basis
* for merge logic.
* May 14, 2013 1842 dgilling Also delete cluster locks when purging
* PRACTICE active table.
*
* </pre>
*
@ -219,7 +221,7 @@ public class ActiveTable {
public static Integer getNextEtn(String siteId, ActiveTableMode mode,
String phensig, Calendar currentTime, boolean isLock) {
String lockName = NEXT_ETN_LOCK + "_" + siteId + "_" + mode.name();
String lockName = getEtnClusterLockName(siteId, mode);
ClusterTask ct = null;
CurrentTimeClusterLockHandler lockHandler = null;
if (isLock) {
@ -268,6 +270,22 @@ public class ActiveTable {
return new Integer(nextEtn);
}
/**
* Returns the EDEX cluster lock name for the given site and active table
* mode.
*
* @param siteId
* 4-char site identifier
* @param mode
* The active table mode
* @return The cluster lock name for the given site and active table.
*/
private static String getEtnClusterLockName(String siteId,
ActiveTableMode mode) {
String lockName = NEXT_ETN_LOCK + "_" + siteId + "_" + mode.name();
return lockName;
}
/**
* Updates the active table with the new warnings
*
@ -571,6 +589,11 @@ public class ActiveTable {
CoreDao dao = practiceDao;
String sql = "delete from practice_activetable;";
dao.executeNativeSql(sql);
sql = "delete from cluster_task where name ='"
+ getEtnClusterLockName(requestedSiteId,
ActiveTableMode.PRACTICE) + "';";
dao.executeNativeSql(sql);
}
public static File dumpProductToTempFile(String productText) {