Omaha #4510 Sending TAF now uses forecaster ID instead of name.
Change-Id: If8dd7c6cbea2da7b5c392786e26e67c96eb616c4 Former-commit-id: 81e54aad427a151b1fd61a3d2ea25ecd50686a04
This commit is contained in:
parent
3b75cc1455
commit
ee32011be0
4 changed files with 276 additions and 1 deletions
|
@ -19,12 +19,15 @@
|
|||
**/
|
||||
package com.raytheon.viz.aviation.observer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
|
@ -38,6 +41,7 @@ import org.eclipse.swt.widgets.Layout;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Spinner;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -51,6 +55,9 @@ 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.AviationForecasterConfig;
|
||||
import com.raytheon.viz.aviation.xml.ForecasterConfig;
|
||||
import com.raytheon.viz.avnconfig.AvnConfigFileUtil;
|
||||
import com.raytheon.viz.avnconfig.IStatusSettable;
|
||||
import com.raytheon.viz.avnconfig.ITafSiteConfig;
|
||||
import com.raytheon.viz.avnconfig.TafSiteConfigFactory;
|
||||
|
@ -71,6 +78,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 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.
|
||||
* 20May2015 4510 rferrel Added {@link #getForecasterId()}.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -83,6 +91,14 @@ public class SendDialog extends CaveSWTDialog {
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(SendDialog.class);
|
||||
|
||||
/** Site file to use to find user's forecater id. */
|
||||
private final String FORECAST_CONFIG_FILE = "aviation"
|
||||
+ IPathManager.SEPARATOR + "avnwatch" + IPathManager.SEPARATOR
|
||||
+ "aviationForecasterConfig.xml";
|
||||
|
||||
/** Default forecaster id. */
|
||||
private final String DEFAULT_ID = "000";
|
||||
|
||||
/**
|
||||
* Expression to find time stamp in a TAF.
|
||||
*/
|
||||
|
@ -352,7 +368,7 @@ public class SendDialog extends CaveSWTDialog {
|
|||
request.setUser(UserController.getUserObject());
|
||||
|
||||
// Forecaster ID
|
||||
String forecasterId = forecasterLabel.getText();
|
||||
String forecasterId = getForecasterId();
|
||||
Calendar xmitTime = Calendar.getInstance();
|
||||
xmitTime.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
xmitTime.set(Calendar.HOUR_OF_DAY, hourSpnr.getSelection());
|
||||
|
@ -507,4 +523,47 @@ public class SendDialog extends CaveSWTDialog {
|
|||
|
||||
return type + "A";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine forcaster's id for the user. When none found return the
|
||||
* {@link #DEFAULT_ID}. This string will be in the VFT product.
|
||||
*
|
||||
* @return forecasterId - padded to 3 character so an id of 1 will return
|
||||
* 001
|
||||
*/
|
||||
private String getForecasterId() {
|
||||
File f = AvnConfigFileUtil.getStaticFile(FORECAST_CONFIG_FILE);
|
||||
ArrayList<ForecasterConfig> fcList = null;
|
||||
String forecasterName = AviationDialog.getForecaster();
|
||||
|
||||
if (f == null) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM, "Unable to load, "
|
||||
+ FORECAST_CONFIG_FILE + ", using default ID "
|
||||
+ DEFAULT_ID);
|
||||
return DEFAULT_ID;
|
||||
}
|
||||
|
||||
try {
|
||||
fcList = JAXB.unmarshal(f, AviationForecasterConfig.class)
|
||||
.getForecasterConfig();
|
||||
} catch (RuntimeException ex) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to parse, " + FORECAST_CONFIG_FILE
|
||||
+ ", using default ID " + DEFAULT_ID, ex);
|
||||
return DEFAULT_ID;
|
||||
}
|
||||
|
||||
if ((fcList != null) && !fcList.isEmpty()) {
|
||||
for (ForecasterConfig fc : fcList) {
|
||||
if (forecasterName.equals(fc.getName())) {
|
||||
return fc.getFormattedId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
statusHandler.handle(Priority.PROBLEM, "No forecaster Id for "
|
||||
+ forecasterName + "using default " + DEFAULT_ID);
|
||||
return DEFAULT_ID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
* 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.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
* Forecaster Configuration class
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 2/6/2008 817 grichard Initial creation
|
||||
* 5/20/2015 4510 rferrel Added {@link #getFormattedId()}.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author grichard
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType
|
||||
public class ForecasterConfig {
|
||||
/**
|
||||
* The forecaster's id number
|
||||
*/
|
||||
@XmlElement(name = "id")
|
||||
private int 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() {
|
||||
return Boolean.parseBoolean(xmitPrivilege);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return forecasterId;
|
||||
}
|
||||
|
||||
/**
|
||||
* This formats the id to a 3 character string needed for generating the VFT
|
||||
* products.
|
||||
*
|
||||
* @return formattedId
|
||||
*/
|
||||
public String getFormattedId() {
|
||||
return String.format("%1$03d", 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 = id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<!--
|
||||
The xmit tag is no longer used and can be removed. Permissions are now determined using CAVE's
|
||||
AWIPS User Administration under Component "Official User Product in the Official User Product Users Tab
|
||||
assigning the Defined Roles/Permissions "awips.oup". Note if user ALL is defined then everyone has the permission.
|
||||
-->
|
||||
<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