Omaha #3091 Remove the use of aviationForecastConfig.xml file and only using OUP.
Change-Id: Ibcd4c5389ba081b19a3134989c507b88b2d882b8 Former-commit-id:c226ef3596
[formerly 909a3f42bdb9d8149013056f9956bf0c38b764c5] Former-commit-id:039f4826ea
This commit is contained in:
parent
ad464cc0da
commit
6bfacf85ab
14 changed files with 477 additions and 681 deletions
|
@ -25,8 +25,6 @@ import java.util.ArrayList;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
@ -44,7 +42,6 @@ import org.eclipse.swt.widgets.Button;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
|
@ -61,10 +58,7 @@ import com.raytheon.viz.aviation.model.ForecastModel;
|
|||
import com.raytheon.viz.aviation.observer.TafMonitorDlg;
|
||||
import com.raytheon.viz.aviation.resource.ResourceConfigMgr;
|
||||
import com.raytheon.viz.aviation.utility.IBackupRestart;
|
||||
import com.raytheon.viz.aviation.xml.AviationForecasterConfig;
|
||||
import com.raytheon.viz.aviation.xml.ForecasterConfig;
|
||||
import com.raytheon.viz.avncommon.AvnMessageMgr.StatusMessageType;
|
||||
import com.raytheon.viz.avnconfig.AvnConfigFileUtil;
|
||||
import com.raytheon.viz.avnconfig.ITafSiteConfig;
|
||||
import com.raytheon.viz.avnconfig.TafSiteConfigFactory;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
@ -103,6 +97,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* 04/10/2013 1735 rferrel Changes for taf monitor speed up.
|
||||
* 08/09/2013 2033 mschenke Switched File.separator to IPathManager.SEPARATOR
|
||||
* 12 Aug 2013 #2256 lvenable Removed unnecessary font code and other code clean up.
|
||||
* 06 May 2014 3091 rferrel Use OUP authorization to bring up send dialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -113,10 +108,6 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(AviationDialog.class);
|
||||
|
||||
private static String FORECAST_CONFIG_FILE = "aviation"
|
||||
+ IPathManager.SEPARATOR + "avnwatch" + IPathManager.SEPARATOR
|
||||
+ "aviationForecasterConfig.xml";
|
||||
|
||||
/**
|
||||
* Font list to dispose of.
|
||||
*/
|
||||
|
@ -153,30 +144,23 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
|
|||
private ClimateMenuDlg climateMenuDlg;
|
||||
|
||||
/**
|
||||
* Selected user id number in the forecaster list.
|
||||
* Label to display forecaster.
|
||||
*/
|
||||
public static int USERID = 0;
|
||||
|
||||
/**
|
||||
* Selected user name in the forecaster list control.
|
||||
*/
|
||||
public static String USERNAME = "";
|
||||
|
||||
/**
|
||||
* Selected user name in the forecaster list control.
|
||||
*/
|
||||
public static boolean USERTRANSMIT = true;
|
||||
|
||||
/**
|
||||
* List control containing forecaster names.
|
||||
*/
|
||||
private List forecasterList;
|
||||
private Label forecasterLabel;
|
||||
|
||||
/**
|
||||
* Number of dialogs currently open,
|
||||
*/
|
||||
private final AtomicInteger dlgCount = new AtomicInteger(0);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return forecaster
|
||||
*/
|
||||
public static String getForecaster() {
|
||||
return LocalizationManager.getInstance().getCurrentUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a non-blocking dialog.
|
||||
*
|
||||
|
@ -286,7 +270,7 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
|
|||
*/
|
||||
private void initializeComponents() {
|
||||
createLabel();
|
||||
createList();
|
||||
createForecasterLabel();
|
||||
createComposite();
|
||||
initAcarsSounding();
|
||||
}
|
||||
|
@ -316,13 +300,6 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
|
|||
createAvnFPSLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the list on the display.
|
||||
*/
|
||||
private void createList() {
|
||||
createForecasterList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Composite that will contain the parts of the dialog.
|
||||
*/
|
||||
|
@ -476,65 +453,13 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create the forecaster list.
|
||||
* Create the forecaster label.
|
||||
*/
|
||||
private void createForecasterList() {
|
||||
private void createForecasterLabel() {
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
gd.heightHint = 200;
|
||||
forecasterList = new List(shell, SWT.BORDER | SWT.SINGLE);
|
||||
forecasterList.setLayoutData(gd);
|
||||
|
||||
forecasterList.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateUsername();
|
||||
}
|
||||
});
|
||||
|
||||
// Load the Forecaster Configuration Information.
|
||||
ArrayList<ForecasterConfig> forecasterArray = getForecasterConfig();
|
||||
|
||||
if (forecasterArray == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ForecasterConfig forecaster : forecasterArray) {
|
||||
forecasterList.add(forecaster.getName());
|
||||
}
|
||||
|
||||
forecasterList.setSelection(0);
|
||||
|
||||
updateUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user name and the transmit flag when a new users is selected
|
||||
* from the list.
|
||||
*/
|
||||
private void updateUsername() {
|
||||
USERNAME = forecasterList.getItem(forecasterList.getSelectionIndex());
|
||||
if (USERNAME == null) {
|
||||
USERID = 0;
|
||||
USERNAME = "";
|
||||
USERTRANSMIT = false;
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<ForecasterConfig> forecasterArray = getForecasterConfig();
|
||||
|
||||
if (forecasterArray == null) {
|
||||
USERID = 0;
|
||||
USERTRANSMIT = false;
|
||||
return;
|
||||
}
|
||||
|
||||
for (ForecasterConfig forecaster : forecasterArray) {
|
||||
if (forecaster.getName().compareTo(USERNAME) == 0) {
|
||||
USERID = forecaster.getId();
|
||||
USERTRANSMIT = forecaster.getXmitPrivilege();
|
||||
break;
|
||||
}
|
||||
}
|
||||
forecasterLabel = new Label(shell, SWT.CENTER);
|
||||
forecasterLabel.setText(getForecaster());
|
||||
forecasterLabel.setLayoutData(gd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -544,58 +469,6 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
|
|||
shell.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Forecaster Configuration information for current user.
|
||||
*/
|
||||
public static ArrayList<ForecasterConfig> getForecasterConfig() {
|
||||
File f = AvnConfigFileUtil.getStaticFile(FORECAST_CONFIG_FILE);
|
||||
ArrayList<ForecasterConfig> fcList = null;
|
||||
ForecasterConfig fc = null;
|
||||
String loginName = LocalizationManager.getInstance().getCurrentUser();
|
||||
|
||||
try {
|
||||
if (f == null) {
|
||||
fcList = null;
|
||||
} else {
|
||||
fcList = JAXB.unmarshal(f, AviationForecasterConfig.class)
|
||||
.getForecasterConfig();
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Error loading forecaster config no transmit privileges granted",
|
||||
e);
|
||||
fcList = null;
|
||||
}
|
||||
|
||||
if (fcList == null) {
|
||||
// Unable to determine transmit privileges
|
||||
fc = new ForecasterConfig();
|
||||
fc.setName(loginName);
|
||||
fc.setXmit(false);
|
||||
fcList = new ArrayList<ForecasterConfig>();
|
||||
fcList.add(fc);
|
||||
} else {
|
||||
fc = null;
|
||||
for (ForecasterConfig tmpFc : fcList) {
|
||||
if (loginName.equals(tmpFc.getName())) {
|
||||
fc = tmpFc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fc == null) {
|
||||
// Unknown user
|
||||
fc = new ForecasterConfig();
|
||||
fc.setName(loginName);
|
||||
fc.setXmit(false);
|
||||
}
|
||||
fcList.clear();
|
||||
fcList.add(fc);
|
||||
}
|
||||
return fcList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden method to restart the Taf Monitor.
|
||||
*/
|
||||
|
|
|
@ -234,6 +234,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* 02/12/2014 17076 lvenable Mark guidance tabs as not current so they get refreshed
|
||||
* 02/19/2014 16980 zhao add code to ensure the Alt flag is false after the Alt kay is released
|
||||
* 21Mar2014 #2925 lvenable Fixed NPE error found during testing.
|
||||
* 06May2014 3091 rferrel Use OUP authorization to bring up send dialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -1783,9 +1784,9 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
syntaxBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if ( checkBasicSyntaxError(true) ) {
|
||||
return;
|
||||
}
|
||||
if (checkBasicSyntaxError(true)) {
|
||||
return;
|
||||
}
|
||||
syntaxCheck();
|
||||
}
|
||||
});
|
||||
|
@ -1816,11 +1817,13 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
Button sendBtn = new Button(buttonComp, SWT.PUSH);
|
||||
sendBtn.setText("Send");
|
||||
sendBtn.setLayoutData(gd);
|
||||
sendBtn.setEnabled(AviationDialog.USERTRANSMIT);
|
||||
configMgr.setDefaultFontAndColors(sendBtn);
|
||||
sendBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (!SendDialog.isAuthorized()) {
|
||||
return;
|
||||
}
|
||||
// Assume editorTafTabComp is for the active tab.
|
||||
if (editorTafTabComp.isTafSent()) {
|
||||
putMessageToForecaster("Cannot send forecast: Forecast already sent");
|
||||
|
@ -2843,7 +2846,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
.getTextEditorControl();
|
||||
StringBuilder sb = new StringBuilder("Printed by ");
|
||||
|
||||
sb.append(AviationDialog.USERNAME);
|
||||
sb.append(AviationDialog.getForecaster());
|
||||
sb.append(" on ");
|
||||
sb.append(dt.format(Calendar.getInstance(
|
||||
TimeZone.getTimeZone("GMT")).getTime()));
|
||||
|
@ -3694,10 +3697,10 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
if (endIndex == -1) {
|
||||
endIndex = in.length();
|
||||
}
|
||||
boolean isWrapping = false;
|
||||
String thisSite = "";
|
||||
String lastLine = "";
|
||||
String line = in.substring(beginIndex, endIndex);
|
||||
boolean isWrapping = false;
|
||||
String thisSite = "";
|
||||
String lastLine = "";
|
||||
String line = in.substring(beginIndex, endIndex);
|
||||
int lineNumber = 1;
|
||||
Set<List<String>> keySet = results.keySet();
|
||||
int maxLevel = 0;
|
||||
|
@ -3707,9 +3710,9 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
int level = 0;
|
||||
int start = -1;
|
||||
int length = -1;
|
||||
|
||||
|
||||
if (line.startsWith("TAF")) {
|
||||
thisSite = in.substring(endIndex+1, endIndex+5);
|
||||
thisSite = in.substring(endIndex + 1, endIndex + 5);
|
||||
}
|
||||
|
||||
if (!line.startsWith("TAF")) {
|
||||
|
@ -3739,25 +3742,33 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
.get(key);
|
||||
|
||||
if (lineNumber == keyLineNum) {
|
||||
if (!isWrappingLine(line,thisSite)) {
|
||||
isWrapping = false;
|
||||
text = result.get("text").toString() + "\n";
|
||||
level = Integer.parseInt(result.get("level").toString());
|
||||
start = Integer.parseInt(temp.substring(temp.indexOf('.') + 1));
|
||||
temp = key.get(1);
|
||||
length = Integer.parseInt(temp.substring(temp.indexOf('.') + 1));
|
||||
length = length - start;
|
||||
start = beginIndex + start;
|
||||
break;
|
||||
} else {
|
||||
// a PROB30 group is wrapped in two lines
|
||||
isWrapping = true;
|
||||
text = result.get("text").toString() +"\n";
|
||||
level = Integer.parseInt(result.get("level").toString());
|
||||
start = beginIndex - 1 - lastLine.length() + lastLine.indexOf("PROB30");
|
||||
length = lastLine.substring(lastLine.indexOf("PROB30")).length() + 1 + line.length();
|
||||
break;
|
||||
}
|
||||
if (!isWrappingLine(line, thisSite)) {
|
||||
isWrapping = false;
|
||||
text = result.get("text").toString() + "\n";
|
||||
level = Integer.parseInt(result
|
||||
.get("level").toString());
|
||||
start = Integer.parseInt(temp
|
||||
.substring(temp.indexOf('.') + 1));
|
||||
temp = key.get(1);
|
||||
length = Integer.parseInt(temp
|
||||
.substring(temp.indexOf('.') + 1));
|
||||
length = length - start;
|
||||
start = beginIndex + start;
|
||||
break;
|
||||
} else {
|
||||
// a PROB30 group is wrapped in two lines
|
||||
isWrapping = true;
|
||||
text = result.get("text").toString() + "\n";
|
||||
level = Integer.parseInt(result
|
||||
.get("level").toString());
|
||||
start = beginIndex - 1 - lastLine.length()
|
||||
+ lastLine.indexOf("PROB30");
|
||||
length = lastLine.substring(
|
||||
lastLine.indexOf("PROB30"))
|
||||
.length()
|
||||
+ 1 + line.length();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3770,7 +3781,8 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
start = beginIndex + start;
|
||||
}
|
||||
|
||||
StyleRange sr = new StyleRange(start, length, null,qcColors[level]);
|
||||
StyleRange sr = new StyleRange(start, length, null,
|
||||
qcColors[level]);
|
||||
st.setStyleRange(sr);
|
||||
qcResultMap.put(sr, text);
|
||||
|
||||
|
@ -3795,7 +3807,7 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
beginIndex = endIndex = in.length();
|
||||
line = "";
|
||||
} else {
|
||||
lastLine = line;
|
||||
lastLine = line;
|
||||
line = in.substring(beginIndex, endIndex);
|
||||
}
|
||||
|
||||
|
@ -3813,21 +3825,22 @@ public class TafViewerEditorDlg extends CaveSWTDialog implements ITafSettable,
|
|||
} catch (IOException e) {
|
||||
setMessageStatusError("An Error occured while performing the QC check.");
|
||||
} catch (Exception e) {
|
||||
setMessageStatusError("An Error occured while performing the QC check.");
|
||||
setMessageStatusError("An Error occured while performing the QC check.");
|
||||
} finally {
|
||||
setWaitCursor(false);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isWrappingLine(String line, String site) {
|
||||
String tempLine = line.trim();
|
||||
if (tempLine.startsWith(site)||tempLine.startsWith("TEMPO")||tempLine.startsWith("FM")||tempLine.startsWith("PROB30")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
String tempLine = line.trim();
|
||||
if (tempLine.startsWith(site) || tempLine.startsWith("TEMPO")
|
||||
|| tempLine.startsWith("FM") || tempLine.startsWith("PROB30")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Read in the TAF viewer editor config XML.
|
||||
*
|
||||
* @return An array of viewer tab configuration data.
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.eclipse.swt.widgets.Composite;
|
|||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Spinner;
|
||||
|
||||
|
@ -52,7 +51,6 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
|
|||
import com.raytheon.viz.aviation.AviationDialog;
|
||||
import com.raytheon.viz.aviation.editor.EditorTafTabComp;
|
||||
import com.raytheon.viz.aviation.resource.ResourceConfigMgr;
|
||||
import com.raytheon.viz.aviation.xml.ForecasterConfig;
|
||||
import com.raytheon.viz.avnconfig.IStatusSettable;
|
||||
import com.raytheon.viz.avnconfig.ITafSiteConfig;
|
||||
import com.raytheon.viz.avnconfig.TafSiteConfigFactory;
|
||||
|
@ -72,6 +70,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 08AUG2012 15613 zhao Determine proper BBB for transmission
|
||||
* 09OCT2012 1229 rferrel Make dialog non-blocking.
|
||||
* 0yJUN2013 1981 mpduff Set user on the request.
|
||||
* 06May2014 3091 rferrel Use OUP authorization to bring up send dialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -111,9 +110,9 @@ public class SendDialog extends CaveSWTDialog {
|
|||
private Spinner secondSpnr;
|
||||
|
||||
/**
|
||||
* Person list control.
|
||||
* Forecaster.
|
||||
*/
|
||||
private List personList;
|
||||
private Label forecasterLabel;
|
||||
|
||||
/**
|
||||
* Tab composite containing the TAF Viewer and the TAF Editor.
|
||||
|
@ -130,16 +129,29 @@ public class SendDialog extends CaveSWTDialog {
|
|||
*/
|
||||
private Composite mainComp;
|
||||
|
||||
/**
|
||||
* Forecaster array.
|
||||
*/
|
||||
private ArrayList<ForecasterConfig> forecasterArray = null;
|
||||
|
||||
/**
|
||||
* Send the TAFs individually or as a collective.
|
||||
*/
|
||||
private final boolean sendCollective;
|
||||
|
||||
/**
|
||||
* @return true when user authorized to send TAFs.
|
||||
*/
|
||||
public static boolean isAuthorized() {
|
||||
TafQueueRequest request = new TafQueueRequest();
|
||||
request.setType(Type.CHECK_AUTHORIZED);
|
||||
request.setUser(UserController.getUserObject());
|
||||
request.setState(TafQueueRecord.TafQueueState.SENT);
|
||||
boolean response = false;
|
||||
try {
|
||||
ThriftClient.sendRequest(request);
|
||||
response = true;
|
||||
} catch (VizException e) {
|
||||
response = false;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -295,21 +307,10 @@ public class SendDialog extends CaveSWTDialog {
|
|||
configMgr.setDefaultFontAndColors(repsonsibleLbl);
|
||||
|
||||
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
personList = new List(listComp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
|
||||
personList.setLayoutData(gd);
|
||||
configMgr.setListBoxFont(personList);
|
||||
|
||||
forecasterArray = AviationDialog.getForecasterConfig();
|
||||
|
||||
for (ForecasterConfig forecaster : forecasterArray) {
|
||||
personList.add(forecaster.getName());
|
||||
}
|
||||
|
||||
int index = personList.indexOf(AviationDialog.USERNAME);
|
||||
|
||||
if (index >= 0) {
|
||||
personList.select(index);
|
||||
}
|
||||
forecasterLabel = new Label(listComp, SWT.CENTER);
|
||||
forecasterLabel.setText(AviationDialog.getForecaster());
|
||||
forecasterLabel.setLayoutData(gd);
|
||||
configMgr.setListBoxFont(forecasterLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -351,8 +352,7 @@ public class SendDialog extends CaveSWTDialog {
|
|||
request.setUser(UserController.getUserObject());
|
||||
|
||||
// Forecaster ID
|
||||
int forecasterId = forecasterArray.get(personList.getSelectionIndex())
|
||||
.getId();
|
||||
String forecasterId = forecasterLabel.getText();
|
||||
Calendar xmitTime = Calendar.getInstance();
|
||||
xmitTime.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
xmitTime.set(Calendar.HOUR_OF_DAY, hourSpnr.getSelection());
|
||||
|
@ -502,8 +502,7 @@ public class SendDialog extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
} catch (VizException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
return type + "A";
|
||||
|
|
|
@ -48,6 +48,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Initial creation
|
||||
* Oct 10, 2012 1229 rferrel Make dialog non-blocking.
|
||||
* May 07, 2014 3091 rferrel Use OUP authorization to bring up send dialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -98,7 +99,7 @@ public class ResourceEditorDlg extends CaveSWTDialog implements IResize {
|
|||
}
|
||||
|
||||
private void createTopLabelAndButtons() {
|
||||
String userName = AviationDialog.USERNAME;
|
||||
String userName = AviationDialog.getForecaster();
|
||||
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
Label title = new Label(shell, SWT.CENTER);
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
/**
|
||||
* 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.aviation.xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
|
||||
/**
|
||||
* Aviation Forecaster Configuration
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 2/7/2008 817 grichard Initial Creation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author grichard
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlRootElement(name = "aviationForecasterConfig")
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class AviationForecasterConfig implements ISerializableObject {
|
||||
|
||||
/**
|
||||
* The aviation forecaster configuration.
|
||||
*/
|
||||
@XmlElement(name = "forecaster")
|
||||
private ArrayList<ForecasterConfig> forecasterConfig;
|
||||
|
||||
/**
|
||||
* Method that gets the aviation forecaster configuration
|
||||
*
|
||||
* @return forecasterConfig
|
||||
*/
|
||||
public ArrayList<ForecasterConfig> getForecasterConfig() {
|
||||
return forecasterConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that sets the aviation forecaster configuration
|
||||
*
|
||||
* @param forecasterConfig
|
||||
* -- the aviation forecaster configuration
|
||||
*/
|
||||
public void setForecasterConfig(ArrayList<ForecasterConfig> forecasterConfig) {
|
||||
this.forecasterConfig = forecasterConfig;
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/**
|
||||
* 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.aviation.xml;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
* Forecaster Configuration class
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 2/6/2008 817 grichard Initial Creation.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author grichard
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class ForecasterConfig {
|
||||
/**
|
||||
* The forecaster's id number
|
||||
*/
|
||||
@XmlElement(name = "id")
|
||||
private String forecasterId = "0";
|
||||
|
||||
/**
|
||||
* The forecaster's name
|
||||
*/
|
||||
@XmlElement(name = "name")
|
||||
private String forecasterName;
|
||||
|
||||
/**
|
||||
* The forecaster's transmit privilege
|
||||
*/
|
||||
@XmlElement(name = "xmit")
|
||||
private String xmitPrivilege;
|
||||
|
||||
/**
|
||||
* Getters and setters
|
||||
*/
|
||||
|
||||
public String getName() {
|
||||
return forecasterName;
|
||||
}
|
||||
|
||||
public boolean getXmitPrivilege() {
|
||||
System.out.println("xmitPrivilege = " + xmitPrivilege);
|
||||
return Boolean.parseBoolean(xmitPrivilege);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return Integer.parseInt(forecasterId);
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.forecasterName = name;
|
||||
}
|
||||
|
||||
public void setXmit(boolean privilege) {
|
||||
this.xmitPrivilege = Boolean.toString(privilege);
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.forecasterId = String.format("%1$03d", id);
|
||||
}
|
||||
}
|
18
deltaScripts/14.4.1/DR3091/alter_taf_queue.sh
Executable file
18
deltaScripts/14.4.1/DR3091/alter_taf_queue.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
# DR #3091 This changes the awips.taf_queue forecasterid column from type integer
|
||||
# to a varchar converting any values in the table.
|
||||
|
||||
PSQL="/awips2/psql/bin/psql"
|
||||
|
||||
echo "INFO: Altering awips.taf_queue's forecaster column."
|
||||
|
||||
${PSQL} -U awips -d metadata -c "alter table awips.taf_queue alter column forecasterid set data type varchar(255)
|
||||
using to_char(forecasterid, '000');"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Failed to alter tabelawips.taf_queue's column forecasterid."
|
||||
echo "FATAL: The update has failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "INFO: awips.taf_queue's forecaster column altered successfully."
|
|
@ -48,6 +48,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* Aug 27, 2009 avarani Initial creation
|
||||
* Apr 30, 2012 14715 rferrel Refactored and moved.
|
||||
* Mar 21, 2013 15375 zhao Modified getInfo() to also handle VFT product
|
||||
* May 07, 2014 3091 rferrel Use OUP authorization to bring up send dialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,7 +58,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
@Entity
|
||||
@Table(name = "taf_queue")
|
||||
@DynamicSerialize
|
||||
public class TafQueueRecord implements IPersistableDataObject,
|
||||
public class TafQueueRecord implements IPersistableDataObject<Integer>,
|
||||
Comparable<TafQueueRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -73,7 +74,7 @@ public class TafQueueRecord implements IPersistableDataObject,
|
|||
|
||||
@DynamicSerializeElement
|
||||
@Column
|
||||
private int forecasterId;
|
||||
private String forecasterId;
|
||||
|
||||
@DynamicSerializeElement
|
||||
@Column(columnDefinition = "timestamp without time zone", nullable = false)
|
||||
|
@ -134,7 +135,7 @@ public class TafQueueRecord implements IPersistableDataObject,
|
|||
* @param stationId
|
||||
* @param headerTime
|
||||
*/
|
||||
public TafQueueRecord(int forecasterId, Date xmitTime, String tafText,
|
||||
public TafQueueRecord(String forecasterId, Date xmitTime, String tafText,
|
||||
String bbb, String siteId, String wmoId, String stationId,
|
||||
Date headerTime) {
|
||||
this.forecasterId = forecasterId;
|
||||
|
@ -159,14 +160,14 @@ public class TafQueueRecord implements IPersistableDataObject,
|
|||
*/
|
||||
public String getInfo() {
|
||||
String productTag = "TAF";
|
||||
if (forecasterId == TafQueueVftConfigMgr.getInstance().getFcstid()) { // for
|
||||
// VFT
|
||||
// product
|
||||
// (DR15375)
|
||||
// for VFT product (DR15375)
|
||||
if ((forecasterId != null)
|
||||
&& forecasterId.equals(TafQueueVftConfigMgr.getInstance()
|
||||
.getFcstid())) {
|
||||
productTag = "VFT";
|
||||
}
|
||||
return String
|
||||
.format("%1$03d-%7$s%8$s%5$s-%6$s-%7$s-%2$ty%2$tm%2$td%2$tH%2$tM-%4$s-%9$d",
|
||||
.format("%1$s-%7$s%8$s%5$s-%6$s-%7$s-%2$ty%2$tm%2$td%2$tH%2$tM-%4$s-%9$d",
|
||||
forecasterId, headerTime, tafText, bbb, siteId, wmoId,
|
||||
stationId, productTag, (xmitTime.getTime() / 1000));
|
||||
}
|
||||
|
@ -241,11 +242,11 @@ public class TafQueueRecord implements IPersistableDataObject,
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public int getForecasterId() {
|
||||
public String getForecasterId() {
|
||||
return forecasterId;
|
||||
}
|
||||
|
||||
public void setForecasterId(int forecasterId) {
|
||||
public void setForecasterId(String forecasterId) {
|
||||
this.forecasterId = forecasterId;
|
||||
}
|
||||
|
||||
|
@ -297,9 +298,15 @@ public class TafQueueRecord implements IPersistableDataObject,
|
|||
this.wmoId = wmoId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.common.dataplugin.persist.IPersistableDataObject#
|
||||
* getIdentifier()
|
||||
*/
|
||||
@Override
|
||||
public Object getIdentifier() {
|
||||
return id;
|
||||
public Integer getIdentifier() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* May 3, 2012 14715 rferrel Initial creation
|
||||
* Jun 07, 2013 1981 mpduff This is now an AbstractPrivilegedRequest
|
||||
* May 08, 2014 3091 rferrel Added CHECK_AUTHORIZED.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -50,7 +51,7 @@ public class TafQueueRequest extends AbstractPrivilegedRequest implements
|
|||
IServerRequest {
|
||||
|
||||
public enum Type {
|
||||
UNKNOWN, CREATE, GET_LIST, GET_LOG, GET_TAFS, REMOVE_SELECTED, RETRANSMIT
|
||||
UNKNOWN, CREATE, GET_LIST, GET_LOG, GET_TAFS, REMOVE_SELECTED, RETRANSMIT, CHECK_AUTHORIZED
|
||||
}
|
||||
|
||||
@DynamicSerializeElement
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.io.File;
|
|||
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
import org.apache.commons.configuration.HierarchicalINIConfiguration;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
|
@ -36,7 +37,8 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* This class is used to read in configuration for AvnFPS verification (VFT) product.
|
||||
* This class is used to read in configuration for AvnFPS verification (VFT)
|
||||
* product.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -45,129 +47,160 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 21, 2013 15375 zhao Initial creation
|
||||
* May 07, 2014 3091 rferrel fcstid now a string.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author zhao
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TafQueueVftConfigMgr {
|
||||
|
||||
private final IUFStatusHandler statusHandler = UFStatus.getHandler(TafQueueVftConfigMgr.class);
|
||||
|
||||
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TafQueueVftConfigMgr.class);
|
||||
|
||||
private static TafQueueVftConfigMgr instance = null;
|
||||
|
||||
private String wmoid = "NXUS98"; // default, to be replaced by wmo in config file
|
||||
private String siteid = "OAX"; // default (siteid in taf_queue table)
|
||||
private String stationid = "KOAX"; // default (stationid in taf_queue table)
|
||||
private int fcstid = 0; // default forecasterid for VFT
|
||||
private int period = 6; // number of hours; default period for VFT product creation, to be replaced by period in config file
|
||||
|
||||
|
||||
/** Default, to be replaced by wmo in config file. */
|
||||
private String wmoid = "NXUS98";
|
||||
|
||||
/** Default (siteid in taf_queue table). */
|
||||
private String siteid = "OAX";
|
||||
|
||||
/** Default (stationid in taf_queue table). */
|
||||
private String stationid = "KOAX";
|
||||
|
||||
/** Default forecasterid for VFT. */
|
||||
private String fcstid = "000";
|
||||
|
||||
/**
|
||||
* Number of hours; default period for VFT product creation, to be replaced
|
||||
* by period in config file.
|
||||
*/
|
||||
private int period = 6;
|
||||
|
||||
/**
|
||||
* BBB field for VFT product; non-configurable
|
||||
*/
|
||||
private String bbb = "___";
|
||||
|
||||
private static final String XMIT_FILE = "aviation" + File.separator + "config" + File.separator + "xmit.cfg";
|
||||
|
||||
private HierarchicalINIConfiguration xmitConfig = null;
|
||||
|
||||
public static TafQueueVftConfigMgr getInstance() {
|
||||
if ( instance == null ) {
|
||||
instance = new TafQueueVftConfigMgr();
|
||||
}
|
||||
return instance;
|
||||
private String bbb = "___";
|
||||
|
||||
private static final String XMIT_FILE = "aviation" + File.separator
|
||||
+ "config" + File.separator + "xmit.cfg";
|
||||
|
||||
private HierarchicalINIConfiguration xmitConfig = null;
|
||||
|
||||
public static synchronized TafQueueVftConfigMgr getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new TafQueueVftConfigMgr();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private TafQueueVftConfigMgr() {
|
||||
// read in configuration
|
||||
loadXmitConfigFile();
|
||||
if ( xmitConfig != null ) {
|
||||
readConfiguration();
|
||||
}
|
||||
// read in configuration
|
||||
loadXmitConfigFile();
|
||||
if (xmitConfig != null) {
|
||||
readConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadXmitConfigFile() {
|
||||
|
||||
private void loadXmitConfigFile() {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext context = pm.getContext(LocalizationType.CAVE_STATIC, LocalizationLevel.SITE);
|
||||
LocalizationContext context = pm.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.SITE);
|
||||
LocalizationFile lFile = pm.getLocalizationFile(context, XMIT_FILE);
|
||||
HierarchicalINIConfiguration config = new HierarchicalINIConfiguration();
|
||||
config.setDelimiterParsingDisabled(true);
|
||||
try {
|
||||
config.load(lFile.getFile());
|
||||
} catch (ConfigurationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Tafqueue VFT Configuration Manager: loading xmit.cfg file failed.\n" + e.getLocalizedMessage(), e);
|
||||
return;
|
||||
}
|
||||
this.xmitConfig =config;
|
||||
}
|
||||
|
||||
private void readConfiguration() {
|
||||
try {
|
||||
String wmo = xmitConfig.getString("verification.wmo");
|
||||
String [] wmosplits = wmo.split(" ");
|
||||
wmoid = wmosplits[0];
|
||||
stationid = wmosplits[1];
|
||||
siteid = stationid.substring(1);
|
||||
String fcstidStr = xmitConfig.getString("verification.fcstid");
|
||||
fcstid = Integer.parseInt(fcstidStr);
|
||||
String periodStr = xmitConfig.getString("verification.period");
|
||||
period = Integer.parseInt(periodStr);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Tafqueue VFT Configuration Manager: error occurred while reading configuration.\n" + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
statusHandler.handle(Priority.INFO, "Tafqueue VFT Configuration Manager: wmo = " + wmoid + " " + stationid + "; forecasterid = " + fcstid + "; period = " + period );
|
||||
return;
|
||||
}
|
||||
config.load(lFile.getFile());
|
||||
} catch (ConfigurationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Tafqueue VFT Configuration Manager: loading xmit.cfg file failed.\n"
|
||||
+ e.getLocalizedMessage(), e);
|
||||
return;
|
||||
}
|
||||
this.xmitConfig = config;
|
||||
}
|
||||
|
||||
public String getWmoid() {
|
||||
return wmoid;
|
||||
}
|
||||
private void readConfiguration() {
|
||||
try {
|
||||
String wmo = xmitConfig.getString("verification.wmo");
|
||||
String[] wmosplits = wmo.split(" ");
|
||||
wmoid = wmosplits[0];
|
||||
stationid = wmosplits[1];
|
||||
siteid = stationid.substring(1);
|
||||
String fcstidStr = xmitConfig.getString("verification.fcstid");
|
||||
if (fcstidStr != null) {
|
||||
setFcstid(fcstidStr);
|
||||
}
|
||||
String periodStr = xmitConfig.getString("verification.period");
|
||||
period = Integer.parseInt(periodStr);
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Tafqueue VFT Configuration Manager: error occurred while reading configuration.\n"
|
||||
+ e.getLocalizedMessage(), e);
|
||||
return;
|
||||
}
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"Tafqueue VFT Configuration Manager: wmo = " + wmoid + " "
|
||||
+ stationid + "; forecasterid = " + fcstid
|
||||
+ "; period = " + period);
|
||||
return;
|
||||
}
|
||||
|
||||
public void setWmoid(String wmoid) {
|
||||
this.wmoid = wmoid;
|
||||
}
|
||||
public String getWmoid() {
|
||||
return wmoid;
|
||||
}
|
||||
|
||||
public String getSiteid() {
|
||||
return siteid;
|
||||
}
|
||||
public void setWmoid(String wmoid) {
|
||||
this.wmoid = wmoid;
|
||||
}
|
||||
|
||||
public void setSiteid(String siteid) {
|
||||
this.siteid = siteid;
|
||||
}
|
||||
public String getSiteid() {
|
||||
return siteid;
|
||||
}
|
||||
|
||||
public String getStationid() {
|
||||
return stationid;
|
||||
}
|
||||
public void setSiteid(String siteid) {
|
||||
this.siteid = siteid;
|
||||
}
|
||||
|
||||
public void setStationid(String stationid) {
|
||||
this.stationid = stationid;
|
||||
}
|
||||
public String getStationid() {
|
||||
return stationid;
|
||||
}
|
||||
|
||||
public int getFcstid() {
|
||||
return fcstid;
|
||||
}
|
||||
public void setStationid(String stationid) {
|
||||
this.stationid = stationid;
|
||||
}
|
||||
|
||||
public void setFcstid(int fcstid) {
|
||||
this.fcstid = fcstid;
|
||||
}
|
||||
public String getFcstid() {
|
||||
return fcstid;
|
||||
}
|
||||
|
||||
public int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
public void setFcstid(String fcstid) {
|
||||
if (NumberUtils.isNumber(fcstid)) {
|
||||
// Handle old style ids.
|
||||
int id = Integer.parseInt(fcstid);
|
||||
this.fcstid = String.format("%03d", id);
|
||||
} else {
|
||||
this.fcstid = fcstid;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
public int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
public String getBbb() {
|
||||
return bbb;
|
||||
}
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public String getBbb() {
|
||||
return bbb;
|
||||
}
|
||||
|
||||
public void setBbb(String bbb) {
|
||||
this.bbb = bbb;
|
||||
}
|
||||
|
||||
public void setBbb(String bbb) {
|
||||
this.bbb = bbb;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* May 1, 2012 14715 rferrel Initial creation
|
||||
* Mar 21, 2013 15375 zhao Added methods for handling VFT product
|
||||
* May 07, 2014 3091 rferrel forecasterId now a string.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -277,40 +278,49 @@ public class TafQueueDao extends CoreDao {
|
|||
}
|
||||
|
||||
/**
|
||||
* (for DR15375)
|
||||
* Get last xmit time for a forecaster id (for VFT purpose)
|
||||
* (for DR15375) Get last xmit time for a forecaster id (for VFT purpose)
|
||||
*
|
||||
* @param forecasterid
|
||||
* @return last xmittime; return null if no record exists
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Date getLastXmitTimeByForecasterId(int forecasterid) throws DataAccessLayerException {
|
||||
Date lastXmittime = null;
|
||||
DatabaseQuery query = new DatabaseQuery(TafQueueRecord.class.getName());
|
||||
query.addQueryParam("forecasterId", forecasterid, QueryOperand.EQUALS);
|
||||
query.addOrder("xmitTime", false);
|
||||
List<TafQueueRecord> records = (List<TafQueueRecord>) queryByCriteria(query);
|
||||
if ( records.size() > 0 ) {
|
||||
lastXmittime = records.get(0).getXmitTime();
|
||||
}
|
||||
return lastXmittime;
|
||||
}
|
||||
public Date getLastXmitTimeByForecasterId(String forecasterid)
|
||||
throws DataAccessLayerException {
|
||||
Date lastXmittime = null;
|
||||
DatabaseQuery query = new DatabaseQuery(TafQueueRecord.class.getName());
|
||||
query.addQueryParam("forecasterId", forecasterid, QueryOperand.EQUALS);
|
||||
query.addOrder("xmitTime", false);
|
||||
List<TafQueueRecord> records = (List<TafQueueRecord>) queryByCriteria(query);
|
||||
if (records.size() > 0) {
|
||||
lastXmittime = records.get(0).getXmitTime();
|
||||
}
|
||||
return lastXmittime;
|
||||
}
|
||||
|
||||
/** (for DR15375)
|
||||
* Retrieves a list of TAF records sent since the last VFT product was created
|
||||
* @param lastVftTime (last VFT creation time)
|
||||
* @param forecasterid (forecaster ID for VFT)
|
||||
* @return a list of TAF records sent since lastVftTime or null when no such records exit
|
||||
/**
|
||||
* (for DR15375) Retrieves a list of TAF records sent since the last VFT
|
||||
* product was created
|
||||
*
|
||||
* @param lastVftTime
|
||||
* (last VFT creation time)
|
||||
* @param forecasterid
|
||||
* (forecaster ID for VFT)
|
||||
* @return a list of TAF records sent since lastVftTime or null when no such
|
||||
* records exit
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<TafQueueRecord> getRecordsForVFT(Date lastVftTime, int forecasterid) throws DataAccessLayerException {
|
||||
DatabaseQuery query = new DatabaseQuery(TafQueueRecord.class.getName());
|
||||
query.addQueryParam("xmitTime", lastVftTime, QueryOperand.GREATERTHANEQUALS);
|
||||
query.addQueryParam("forecasterId", forecasterid, QueryOperand.NOTEQUALS);
|
||||
query.addQueryParam("state", TafQueueState.SENT, QueryOperand.EQUALS);
|
||||
query.addOrder("xmitTime", true);
|
||||
List<TafQueueRecord> records = (List<TafQueueRecord>) queryByCriteria(query);
|
||||
return records;
|
||||
}
|
||||
public List<TafQueueRecord> getRecordsForVFT(Date lastVftTime,
|
||||
String forecasterid) throws DataAccessLayerException {
|
||||
DatabaseQuery query = new DatabaseQuery(TafQueueRecord.class.getName());
|
||||
query.addQueryParam("xmitTime", lastVftTime,
|
||||
QueryOperand.GREATERTHANEQUALS);
|
||||
query.addQueryParam("forecasterId", forecasterid,
|
||||
QueryOperand.NOTEQUALS);
|
||||
query.addQueryParam("state", TafQueueState.SENT, QueryOperand.EQUALS);
|
||||
query.addOrder("xmitTime", true);
|
||||
List<TafQueueRecord> records = (List<TafQueueRecord>) queryByCriteria(query);
|
||||
return records;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|||
* May 1, 2012 14715 rferrel Initial creation
|
||||
* May 08, 2013 1814 rjpeter Added time to live to topic
|
||||
* Jun 07, 2013 1981 mpduff TafQueueRequest is now protected.
|
||||
* May 08, 2014 3091 rferrel Added CHECK_AUTHORIZED.
|
||||
* </pre>
|
||||
*
|
||||
* @author rferrel
|
||||
|
@ -140,6 +141,10 @@ public class TafQueueRequestHandler extends
|
|||
sendNotification(Type.RETRANSMIT);
|
||||
}
|
||||
break;
|
||||
case CHECK_AUTHORIZED:
|
||||
response = new ServerResponse<String>();
|
||||
response.addMessage("User is authorized.");
|
||||
break;
|
||||
default:
|
||||
response = new ServerResponse<String>();
|
||||
response.addMessage("Unknown type: " + request.getType());
|
||||
|
|
|
@ -42,163 +42,201 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 07, 2013 15375 zhao Initial creation
|
||||
* May 07, 2014 3091 rferrel fcstid now a String.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author zhao
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TafQueueVFTMgr {
|
||||
|
||||
private final IUFStatusHandler statusHandler = UFStatus.getHandler(TafQueueVFTMgr.class);
|
||||
|
||||
private static TafQueueVFTMgr instance = null;
|
||||
|
||||
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TafQueueVFTMgr.class);
|
||||
|
||||
private static TafQueueVFTMgr instance = null;
|
||||
|
||||
private TafQueueVftConfigMgr config = null;
|
||||
|
||||
private String wmoid = "NXUS98"; // default, to be replaced by wmo in config file
|
||||
private String siteid = "OAX"; // default (siteid in taf_queue table)
|
||||
private String stationid = "KOAX"; // default (stationid in taf_queue table)
|
||||
private int fcstid = 0; // default forecasterid for VFT
|
||||
private int period = 6; // number of hours; default period of VFT product creation, to be replaced by period in config file
|
||||
private String bbb = "___"; // default BBB field for a VFT product
|
||||
|
||||
|
||||
/** The wmo in config file. */
|
||||
private String wmoid;
|
||||
|
||||
/** The siteid in config file. */
|
||||
private String siteid;
|
||||
|
||||
/** The stationid in config file. */
|
||||
private String stationid;
|
||||
|
||||
/** The forecasterid for VFT in config file. */
|
||||
private String fcstid;
|
||||
|
||||
/**
|
||||
* Number of hours; default period of VFT product creation, to be replaced
|
||||
* by period in config file.
|
||||
*/
|
||||
private int period;
|
||||
|
||||
/** Default BBB field for a VFT product. */
|
||||
private String bbb;
|
||||
|
||||
private Date lastVftTime = null;
|
||||
|
||||
private Date nextVftTime = null;
|
||||
|
||||
|
||||
private TafQueueVFTMgr() {
|
||||
init();
|
||||
statusHandler.handle(Priority.INFO, "Tafqueue VFT manager created.");
|
||||
init();
|
||||
statusHandler.handle(Priority.INFO, "Tafqueue VFT manager created.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an AvnFPS VFT product, and updates time for next VFT product
|
||||
* Create an AvnFPS VFT product, and updates time for next VFT product,
|
||||
*/
|
||||
public void makeVftProduct() {
|
||||
TafQueueDao dao = new TafQueueDao();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
nextVftTime = cal.getTime();
|
||||
try {
|
||||
List<TafQueueRecord> records = dao.getRecordsForVFT(lastVftTime, fcstid);
|
||||
if (records != null) {
|
||||
if (records.size() > 0) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (TafQueueRecord record : records) {
|
||||
sb.append(formatVftTafRecord(record));
|
||||
sb.append("\n");
|
||||
}
|
||||
String vftText = sb.toString();
|
||||
vftText = vftText.substring(0, vftText.length()-1);
|
||||
TafQueueRecord vftRecord = new TafQueueRecord(fcstid, nextVftTime, vftText, bbb, siteid, wmoid, stationid, nextVftTime);
|
||||
dao.create(vftRecord);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,"Tafqueue VFT manager: error occurred while making a VFT product.\n" + e.getLocalizedMessage(), e);
|
||||
}
|
||||
lastVftTime = nextVftTime;
|
||||
statusHandler.handle(Priority.INFO, "Tafqueue VFT manager: Last VFT xmit time = " + lastVftTime.toString());
|
||||
cal.add(Calendar.HOUR_OF_DAY, period);
|
||||
nextVftTime = cal.getTime();
|
||||
statusHandler.handle(Priority.INFO, "Tafqueue VFT manager: Next VFT xmit time = " + nextVftTime.toString());
|
||||
}
|
||||
public void makeVftProduct() {
|
||||
TafQueueDao dao = new TafQueueDao();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
nextVftTime = cal.getTime();
|
||||
try {
|
||||
List<TafQueueRecord> records = dao.getRecordsForVFT(lastVftTime,
|
||||
fcstid);
|
||||
if (records != null) {
|
||||
if (records.size() > 0) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (TafQueueRecord record : records) {
|
||||
sb.append(formatVftTafRecord(record));
|
||||
sb.append("\n");
|
||||
}
|
||||
String vftText = sb.toString();
|
||||
vftText = vftText.substring(0, vftText.length() - 1);
|
||||
TafQueueRecord vftRecord = new TafQueueRecord(fcstid,
|
||||
nextVftTime, vftText, bbb, siteid, wmoid,
|
||||
stationid, nextVftTime);
|
||||
dao.create(vftRecord);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Tafqueue VFT manager: error occurred while making a VFT product.\n"
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
lastVftTime = nextVftTime;
|
||||
statusHandler.handle(
|
||||
Priority.INFO,
|
||||
"Tafqueue VFT manager: Last VFT xmit time = "
|
||||
+ lastVftTime.toString());
|
||||
cal.add(Calendar.HOUR_OF_DAY, period);
|
||||
nextVftTime = cal.getTime();
|
||||
statusHandler.handle(
|
||||
Priority.INFO,
|
||||
"Tafqueue VFT manager: Next VFT xmit time = "
|
||||
+ nextVftTime.toString());
|
||||
}
|
||||
|
||||
private String formatVftTafRecord(TafQueueRecord record) {
|
||||
String tafText = record.getTafText();
|
||||
int indexOfTafPeriod = tafText.indexOf('/');
|
||||
String tafPeriod = tafText.substring(indexOfTafPeriod-4, indexOfTafPeriod+5);
|
||||
String tafBbb = record.getBbb();
|
||||
if ( tafBbb.equals("") || tafBbb.equals(" ") ) {
|
||||
tafBbb = "___";
|
||||
}
|
||||
return String.format("%1$s %2$s %3$ty%3$tm%3$td%3$tH%4$s " +
|
||||
"%5$s %6$s %7$ty%7$tm%7$td%7$tH%7$tm%8$s %9$s %10$03d",
|
||||
record.getWmoId(), record.getStationId(), record.getHeaderTime(), "00",
|
||||
tafBbb, record.getStationId().charAt(0)+record.getSiteId(),
|
||||
record.getXmitTime(), "Z", tafPeriod, record.getForecasterId());
|
||||
}
|
||||
|
||||
private void init() {
|
||||
config = TafQueueVftConfigMgr.getInstance();
|
||||
wmoid = config.getWmoid();
|
||||
siteid = config.getSiteid();
|
||||
stationid = config.getStationid();
|
||||
fcstid = config.getFcstid();
|
||||
period = config.getPeriod();
|
||||
bbb = config.getBbb();
|
||||
|
||||
// determine lastVftTime and nextVftTime
|
||||
TafQueueDao dao = new TafQueueDao();
|
||||
try {
|
||||
lastVftTime = dao.getLastXmitTimeByForecasterId(fcstid);
|
||||
} catch (DataAccessLayerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Tafqueue VFT manager: error occurred while querying for last VFT xmit time.\n" + e.getLocalizedMessage(), e);
|
||||
}
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
if ( lastVftTime == null ) {
|
||||
nextVftTime = cal.getTime();
|
||||
cal.add(Calendar.HOUR_OF_DAY, -period);
|
||||
lastVftTime = cal.getTime();
|
||||
} else {
|
||||
cal.setTime(lastVftTime);
|
||||
cal.add(Calendar.HOUR_OF_DAY, period);
|
||||
nextVftTime = cal.getTime();
|
||||
}
|
||||
statusHandler.handle(Priority.INFO, "Tafqueue VFT manager: Last VFT xmit time = " + lastVftTime.toString());
|
||||
statusHandler.handle(Priority.INFO, "Tafqueue VFT manager: Next VFT xmit time = " + nextVftTime.toString());
|
||||
}
|
||||
|
||||
public static TafQueueVFTMgr getInstance() {
|
||||
if ( instance == null ) {
|
||||
instance = new TafQueueVFTMgr();
|
||||
}
|
||||
return instance;
|
||||
String tafText = record.getTafText();
|
||||
int indexOfTafPeriod = tafText.indexOf('/');
|
||||
String tafPeriod = tafText.substring(indexOfTafPeriod - 4,
|
||||
indexOfTafPeriod + 5);
|
||||
String tafBbb = record.getBbb();
|
||||
if (tafBbb.equals("") || tafBbb.equals(" ")) {
|
||||
tafBbb = "___";
|
||||
}
|
||||
return String.format("%1$s %2$s %3$ty%3$tm%3$td%3$tH%4$s "
|
||||
+ "%5$s %6$s %7$ty%7$tm%7$td%7$tH%7$tm%8$s %9$s %10$s",
|
||||
record.getWmoId(), record.getStationId(),
|
||||
record.getHeaderTime(), "00", tafBbb, record.getStationId()
|
||||
.charAt(0) + record.getSiteId(), record.getXmitTime(),
|
||||
"Z", tafPeriod, record.getForecasterId());
|
||||
}
|
||||
|
||||
public void setWmoid(String wmoid) {
|
||||
this.wmoid = wmoid;
|
||||
}
|
||||
|
||||
public String getWmoid() {
|
||||
return wmoid;
|
||||
}
|
||||
private void init() {
|
||||
config = TafQueueVftConfigMgr.getInstance();
|
||||
wmoid = config.getWmoid();
|
||||
siteid = config.getSiteid();
|
||||
stationid = config.getStationid();
|
||||
fcstid = config.getFcstid();
|
||||
period = config.getPeriod();
|
||||
bbb = config.getBbb();
|
||||
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
// determine lastVftTime and nextVftTime
|
||||
TafQueueDao dao = new TafQueueDao();
|
||||
try {
|
||||
lastVftTime = dao.getLastXmitTimeByForecasterId(fcstid);
|
||||
} catch (DataAccessLayerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Tafqueue VFT manager: error occurred while querying for last VFT xmit time.\n"
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
if (lastVftTime == null) {
|
||||
nextVftTime = cal.getTime();
|
||||
cal.add(Calendar.HOUR_OF_DAY, -period);
|
||||
lastVftTime = cal.getTime();
|
||||
} else {
|
||||
cal.setTime(lastVftTime);
|
||||
cal.add(Calendar.HOUR_OF_DAY, period);
|
||||
nextVftTime = cal.getTime();
|
||||
}
|
||||
statusHandler.handle(
|
||||
Priority.INFO,
|
||||
"Tafqueue VFT manager: Last VFT xmit time = "
|
||||
+ lastVftTime.toString());
|
||||
statusHandler.handle(
|
||||
Priority.INFO,
|
||||
"Tafqueue VFT manager: Next VFT xmit time = "
|
||||
+ nextVftTime.toString());
|
||||
}
|
||||
|
||||
public int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
public static synchronized TafQueueVFTMgr getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new TafQueueVFTMgr();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void setSiteid(String siteid) {
|
||||
this.siteid = siteid;
|
||||
}
|
||||
public void setWmoid(String wmoid) {
|
||||
this.wmoid = wmoid;
|
||||
}
|
||||
|
||||
public String getSiteid() {
|
||||
return siteid;
|
||||
}
|
||||
public String getWmoid() {
|
||||
return wmoid;
|
||||
}
|
||||
|
||||
public void setStationid(String stationid) {
|
||||
this.stationid = stationid;
|
||||
}
|
||||
public void setPeriod(int period) {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public String getStationid() {
|
||||
return stationid;
|
||||
}
|
||||
public int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
public void setFcstid(int fcstid) {
|
||||
this.fcstid = fcstid;
|
||||
}
|
||||
public void setSiteid(String siteid) {
|
||||
this.siteid = siteid;
|
||||
}
|
||||
|
||||
public int getFcstid() {
|
||||
return fcstid;
|
||||
}
|
||||
public String getSiteid() {
|
||||
return siteid;
|
||||
}
|
||||
|
||||
public Date getNextVftTime() {
|
||||
return nextVftTime;
|
||||
}
|
||||
public void setStationid(String stationid) {
|
||||
this.stationid = stationid;
|
||||
}
|
||||
|
||||
public String getStationid() {
|
||||
return stationid;
|
||||
}
|
||||
|
||||
public void setFcstid(String fcstid) {
|
||||
this.fcstid = fcstid;
|
||||
}
|
||||
|
||||
public String getFcstid() {
|
||||
return fcstid;
|
||||
}
|
||||
|
||||
public Date getNextVftTime() {
|
||||
return nextVftTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<aviationForecasterConfig>
|
||||
<forecaster>
|
||||
<id>001</id>
|
||||
<name>Amanda</name>
|
||||
<xmit>true</xmit>
|
||||
</forecaster>
|
||||
<forecaster>
|
||||
<id>002</id>
|
||||
<name>Bailing</name>
|
||||
<xmit>true</xmit>
|
||||
</forecaster>
|
||||
<forecaster>
|
||||
<id>003</id>
|
||||
<name>Belinda</name>
|
||||
<xmit>true</xmit>
|
||||
</forecaster>
|
||||
<forecaster>
|
||||
<id>004</id>
|
||||
<name>George</name>
|
||||
<xmit>true</xmit>
|
||||
</forecaster>
|
||||
<forecaster>
|
||||
<id>005</id>
|
||||
<name>Mark</name>
|
||||
<xmit>true</xmit>
|
||||
</forecaster>
|
||||
<forecaster>
|
||||
<id>006</id>
|
||||
<name>Matt</name>
|
||||
<xmit>true</xmit>
|
||||
</forecaster>
|
||||
<forecaster>
|
||||
<id>007</id>
|
||||
<name>Mike</name>
|
||||
<xmit>true</xmit>
|
||||
</forecaster>
|
||||
</aviationForecasterConfig>
|
Loading…
Add table
Reference in a new issue