Merge tag 'OB_14.4.1-16m' into omaha_15.1.1

14.4.1-16m


Former-commit-id: 85b687be0b [formerly 468600e9d5144873e5af1529ae0d38673e81bb17]
Former-commit-id: 379163b888
This commit is contained in:
Steve Harris 2015-03-09 18:54:39 -05:00
commit 2ce988ce9f
52 changed files with 2144 additions and 2550 deletions

Binary file not shown.

View file

@ -37,7 +37,6 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
@ -69,6 +68,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Mar 05, 2014 2632 mpduff Changed task set to map of user->task.
* Mar 27, 2014 2632 mpduff Sorted users in combo box, changed how Add action works.
* Jun 12, 2014 3269 mpduff Changed to use the unsaved values upon open.
* Feb 25, 2015 4154 mapeters Added null check in constructor, removed editFlag field.
*
* </pre>
*
@ -82,10 +82,10 @@ public class AddNotifierDlg extends CaveSWTDialog {
private final String[] userIds;
/** Map of buttons to Notifiers */
private final Map<Button, Notifier> buttonMap = new HashMap<Button, Notifier>();
private final Map<Button, Notifier> buttonMap = new HashMap<>();
/** Set of NotifierTask objects */
private Map<String, NotifierTask> taskMap = new HashMap<String, NotifierTask>();
private Map<String, NotifierTask> taskMap;
/** The user select Combo box */
private Combo userCbo;
@ -102,28 +102,28 @@ public class AddNotifierDlg extends CaveSWTDialog {
/** Close callback */
private final ICloseCallback callback;
/** Flag for dialog mode, edit or new */
private boolean editFlag;
/**
* Constructor.
*
* @param parent
* @param userIds
* @param editFlag
* Flag for dialog mode (edit or new)
* @param taskMap
* @param callback
*/
public AddNotifierDlg(Shell parent, String[] userIds, boolean editFlag, Map<String, NotifierTask> taskMap,
ICloseCallback callback) {
public AddNotifierDlg(Shell parent, String[] userIds, boolean editFlag,
Map<String, NotifierTask> taskMap, ICloseCallback callback) {
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
if (editFlag) {
setText("Edit Notifier");
setText("Edit Notifier");
} else {
setText("Add Notifier");
setText("Add Notifier");
}
this.userIds = userIds;
this.callback = callback;
this.editFlag = editFlag;
this.taskMap = taskMap;
this.taskMap = taskMap == null ? new HashMap<String, NotifierTask>()
: taskMap;
}
public AddNotifierDlg(Shell parent, String[] userIds) {
@ -319,7 +319,7 @@ public class AddNotifierDlg extends CaveSWTDialog {
GridData btnData = new GridData(75, SWT.DEFAULT);
Button okBtn = new Button(comp, SWT.PUSH);
okBtn.setText("OK");
okBtn.setText("OK");
okBtn.setLayoutData(btnData);
okBtn.addSelectionListener(new SelectionAdapter() {
@Override

View file

@ -1,42 +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.gfe.dialogs.formatterlauncher;
/**
* Interface for storing/transmitting a product.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 18 APR 2008 ### lvenable Initial creation
*
* </pre>
*
* @author lvenable
* @version 1.0
*
*/
public interface IStoreTransmitProduct {
/**
* Store/Transmit method call.
*/
void storeTransmitProduct();
}

View file

@ -1,225 +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.gfe.dialogs.formatterlauncher;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ProgressBar;
import com.raytheon.viz.core.mode.CAVEMode;
import com.raytheon.viz.gfe.core.DataManager;
/**
* Thread used for counting down Storing/Transmitting products.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 18 APR 2008 ### lvenable Initial creation
* 20 AUG 2010 4687 cjeanbap &quot;null&quot; showed up in
* countdown message.
*
* </pre>
*
* @author lvenable
* @version 1.0
*
*/
public class StoreTransmitCountdownThread extends Thread {
/**
* Parent display.
*/
private Display display;
/**
* Progress bar to be updated.
*/
private ProgressBar progressBar;
/**
* Flag indicating if the thread is done running.
*/
private boolean isDone = false;
/**
* Flag indicating if the thread has been canceled.
*/
private boolean isCancelled = false;
/**
* Count down label.
*/
private Label countdownLbl;
/**
* Count down string.
*/
private String countdownStr;
/**
* Counter.
*/
private int counter = 5;
/**
* Store/Transmit callback.
*/
private IStoreTransmitProduct storeCB;
/**
* Count down prefix string.
*/
private String countdownPrefix;
/**
* Constructor.
*
* @param display
* Parent display.
* @param progressBar
* Progress bar.
* @param countdownLbl
* Count down label.
* @param countdownStr
* Count down string.
* @param cb
* Callback interface.
* @param isStore
* True to display store, false to display transmit.
*/
public StoreTransmitCountdownThread(Display display,
ProgressBar progressBar, Label countdownLbl, String countdownStr,
IStoreTransmitProduct cb, boolean isStore) {
this.display = display;
this.progressBar = progressBar;
this.countdownLbl = countdownLbl;
this.countdownStr = countdownStr;
this.storeCB = cb;
countdownPrefix = new String();
CAVEMode opMode = DataManager.getCurrentInstance().getOpMode();
if (!opMode.equals(CAVEMode.OPERATIONAL)) {
countdownPrefix = "Simulated ";
}
if (isStore == true) {
countdownPrefix += "Store in ";
} else {
countdownPrefix += "Transmit in ";
}
}
/**
* Thread's run method.
*/
@Override
public void run() {
isDone = false;
countdownLabelStart();
for (int i = 0; i < 6; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (isCancelled == false) {
display.asyncExec(new Runnable() {
public void run() {
if (progressBar.isDisposed()) {
return;
}
// Increment the progress bar
progressBar.setSelection(progressBar.getSelection() + 1);
countdownLbl.setText(countdownPrefix + counter
+ " seconds...");
--counter;
}
});
} else {
break;
}
}
if (isCancelled == false) {
countdownLabelFinished();
}
isDone = true;
storeCB.storeTransmitProduct();
}
/**
* Check if the thread is done running.
*
* @return True if the thread is done running, false if it is still running.
*/
public boolean isDone() {
return isDone;
}
/**
* Cancel the running thread.
*/
public void cancelThread() {
isCancelled = true;
}
/**
* Check if the thread has been canceled.
*
* @return True if the thread was canceled, false otherwise.
*/
public boolean threadCancelled() {
return isCancelled;
}
/**
* Set the count down label to have a red background and white text while
* the Store/Transmit is in count down mode.
*/
private void countdownLabelStart() {
display.asyncExec(new Runnable() {
public void run() {
countdownLbl.setBackground(display
.getSystemColor(SWT.COLOR_RED));
countdownLbl.setForeground(display
.getSystemColor(SWT.COLOR_WHITE));
}
});
}
/**
* Set the count down label back to its original state.
*/
private void countdownLabelFinished() {
display.asyncExec(new Runnable() {
public void run() {
countdownLbl.setText(countdownStr);
countdownLbl.setBackground(display
.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
countdownLbl.setForeground(display
.getSystemColor(SWT.COLOR_BLACK));
}
});
}
}

View file

@ -26,6 +26,8 @@ import java.util.Map;
import java.util.TimeZone;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
@ -33,7 +35,6 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
@ -50,7 +51,7 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.SimulatedTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
@ -85,6 +86,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Jan 06, 2014 2649 dgilling Make ETN assignment process optional.
* Feb 17, 2014 2774 dgilling Merge changes from 14.1 baseline to 14.2.
* Nov 14, 2014 4953 randerso Cleaned up practice product requests
* Feb 26, 2015 4126 randerso Ensure transmit/store is properly cancelled if dialog is closed
* Code cleanup
*
* </pre>
*
@ -92,22 +95,23 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*
*/
public class StoreTransmitDlg extends CaveSWTDialog implements
IStoreTransmitProduct {
public class StoreTransmitDlg extends CaveSWTDialog {
private static final int COUNT_DOWN_SECONDS = 5;
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(StoreTransmitDlg.class);
private static int SEQ_NUMBER = 0;
/**
* PRoduct ID text control.
* Product ID text control.
*/
private Text productIdTF;
private Text productIdText;
/**
* Count down progress label.
*/
private Label progressLbl;
private Label progressLabel;
/**
* Count down text string.
@ -117,13 +121,7 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
/**
* Count down progress bar.
*/
private ProgressBar progBar;
/**
* Thread used to count down the store/transmit. A separate thread is needed
* so updates can be made to the display with user interruption.
*/
private StoreTransmitCountdownThread countdownThread;
private ProgressBar progressBar;
/**
* Label image that will display the Store/Transmit image.
@ -150,6 +148,10 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
private final boolean updateVtec;
private String countdownFormat;
private boolean isCancelled;
/**
* @param parent
* Parent shell.
@ -177,33 +179,28 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
this.productText = editor.getProductText();
this.pid = pid;
this.updateVtec = updateVtec;
CAVEMode opMode = CAVEMode.getMode();
String title = null;
if (isStoreDialog) {
countdownFormat = "Store in %s seconds...";
countdownText = "Store Countdown";
title = "Store in AWIPS TextDB";
} else {
countdownFormat = "Transmit in %s seconds...";
countdownText = "Transmit Countdown";
title = "Transmit to AWIPS *WAN*";
}
if (!opMode.equals(CAVEMode.OPERATIONAL)) {
countdownFormat = "Simulated " + countdownFormat;
countdownText = "Simulated " + countdownText;
title += " (" + opMode.name() + " MODE)";
}
setText(title);
}
@Override
protected void initializeComponents(Shell shell) {
String title = null;
CAVEMode opMode = CAVEMode.getMode();
if (opMode.equals(CAVEMode.OPERATIONAL)) {
if (isStoreDialog == true) {
title = "Store in AWIPS TextDB";
countdownText = "Store Countdown";
} else {
title = "Transmit to AWIPS *WAN*";
countdownText = "Transmit Countdown";
}
} else {
if (isStoreDialog == true) {
title = "Store in AWIPS TextDB";
countdownText = "Simulated Store Countdown";
} else {
title = "Store Transmit to AWIPS *WAN*";
countdownText = "Simulated Transmit Countdown";
}
title += " (" + opMode.name() + " MODE)";
}
shell.setText(title);
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, false);
@ -214,19 +211,26 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
// Initialize all of the controls and layouts
initializeComponents();
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
doCancel();
}
});
}
@Override
protected void preOpened() {
super.preOpened();
productIdTF.insert(pid);
productIdText.insert(pid);
}
/**
* Initialize the controls on the display.
*/
private void initializeComponents() {
if (isStoreDialog == true) {
if (isStoreDialog) {
labelImg = parentEditor.getImageRegistry().get("yieldsign");
} else {
labelImg = parentEditor.getImageRegistry().get("stopsign");
@ -234,11 +238,6 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
createMainControls();
createBottomButtons();
Display display = shell.getParent().getDisplay();
countdownThread = new StoreTransmitCountdownThread(display, progBar,
progressLbl, countdownText, this, isStoreDialog);
}
/**
@ -258,19 +257,19 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
productIdLbl.setText("AWIPS Product ID:");
GridData gd = new GridData(200, SWT.DEFAULT);
productIdTF = new Text(leftComp, SWT.BORDER);
productIdTF.setLayoutData(gd);
productIdText = new Text(leftComp, SWT.BORDER);
productIdText.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
progressLbl = new Label(leftComp, SWT.CENTER);
progressLbl.setText(countdownText);
progressLbl.setLayoutData(gd);
progressLabel = new Label(leftComp, SWT.CENTER);
progressLabel.setText(countdownText);
progressLabel.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
progBar = new ProgressBar(leftComp, SWT.SMOOTH);
progBar.setMinimum(0);
progBar.setMaximum(5);
progBar.setLayoutData(gd);
progressBar = new ProgressBar(leftComp, SWT.SMOOTH);
progressBar.setMinimum(0);
progressBar.setMaximum(COUNT_DOWN_SECONDS);
progressBar.setLayoutData(gd);
// -------------------------------------
// Create the right side image control
@ -300,30 +299,35 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
buttons.setLayout(new GridLayout(2, true));
gd = new GridData(150, SWT.DEFAULT);
final Button actionBtn = new Button(buttons, SWT.PUSH);
final Button actionButton = new Button(buttons, SWT.PUSH);
CAVEMode opMode = CAVEMode.getMode();
if (opMode.equals(CAVEMode.OPERATIONAL)) {
if (isStoreDialog == true) {
actionBtn.setText("Store");
if (isStoreDialog) {
actionButton.setText("Store");
} else {
actionBtn.setText("Transmit");
actionButton.setText("Transmit");
}
} else if (isStoreDialog == true) {
actionBtn.setText("Simulated Store");
} else if (isStoreDialog) {
actionButton.setText("Simulated Store");
} else {
actionBtn.setText("Simulated Transmit");
actionButton.setText("Simulated Transmit");
}
actionBtn.setLayoutData(gd);
actionBtn.addSelectionListener(new SelectionAdapter() {
actionButton.setLayoutData(gd);
actionButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
// Disable the store button.
actionBtn.setEnabled(false);
actionButton.setEnabled(false);
progressLabel.setText(String.format(countdownFormat,
COUNT_DOWN_SECONDS));
progressLabel.setBackground(progressLabel.getDisplay()
.getSystemColor(SWT.COLOR_RED));
progressLabel.setForeground(progressLabel.getDisplay()
.getSystemColor(SWT.COLOR_WHITE));
// Start the countdown thread.
countdownThread.start();
countDown();
}
});
@ -334,19 +338,6 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
cancelBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (countdownThread != null) {
if (countdownThread.isDone() == false) {
countdownThread.cancelThread();
progressLbl.setText(countdownText);
Display display = shell.getParent().getDisplay();
progressLbl.setBackground(display
.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
progressLbl.setForeground(display
.getSystemColor(SWT.COLOR_BLACK));
}
}
setReturnValue(null);
close();
}
});
@ -355,11 +346,9 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
/**
* Method to store or transmit the product.
*/
@Override
public void storeTransmitProduct() {
// Store/Transmit the product...
if (!countdownThread.threadCancelled()) {
if (!this.isCancelled) {
try {
if (updateVtec) {
// With GFE VTEC products, it's possible to have multiple
@ -433,113 +422,105 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
etnCache);
}
VizApp.runSync(new Runnable() {
@Override
public void run() {
String pid = productIdTF.getText();
if (parentEditor.isTestVTEC()) {
if (isStoreDialog) {
parentEditor.devStore(pid.substring(3));
} else {
parentEditor.devStore(pid.substring(4));
transmitProduct(true);
}
} else {
if (isStoreDialog) {
TextDBUtil.storeProduct(pid, productText,
parentEditor.isTestVTEC());
} else {
transmitProduct(false);
}
}
String pid = productIdText.getText();
if (parentEditor.isTestVTEC()) {
if (isStoreDialog) {
parentEditor.devStore(pid.substring(3));
} else {
parentEditor.devStore(pid.substring(4));
transmitProduct(true);
}
});
} else {
if (isStoreDialog) {
TextDBUtil.storeProduct(pid, productText,
parentEditor.isTestVTEC());
} else {
transmitProduct(false);
}
}
} catch (VizException e) {
statusHandler.handle(Priority.CRITICAL,
"Error preparing product for transmission.", e);
VizApp.runAsync(new Runnable() {
@Override
public void run() {
sendTransmissionStatus(ConfigData.productStateEnum.Failed);
StoreTransmitDlg.this.parentEditor.revive();
}
});
sendTransmissionStatus(ConfigData.productStateEnum.Failed);
StoreTransmitDlg.this.parentEditor.revive();
}
}
// The asyncExec call is used to dispose of the shell since it is
// called outside the GUI thread (count down thread).
VizApp.runAsync(new Runnable() {
@Override
public void run() {
close();
}
});
close();
}
private Integer getNextEtn(VtecObject vtec) throws VizException {
GetNextEtnResponse serverResponse = GFEVtecUtil.getNextEtn(
vtec.getOffice(), vtec.getPhensig(), true, true);
if (!serverResponse.isOkay()) {
final VtecObject vtecToFix = vtec;
final boolean[] exitLoopContainer = { false };
final Exception[] exceptionContainer = { null };
final GetNextEtnResponse[] responseContainer = { serverResponse };
boolean exitLoop = false;
Exception exception = null;
do {
getDisplay().syncExec(new Runnable() {
@Override
public void run() {
GetNextEtnResponse serverResponse = responseContainer[0];
ETNConfirmationDialog dlg = new ETNConfirmationDialog(
getShell(), serverResponse);
if (dlg.open() == ETNConfirmationDialog.OK) {
int etn = dlg.getProposedEtn();
statusHandler.info(String.format(
"User confirmed ETN for %s: %04d",
serverResponse.getPhensig(), etn));
try {
GetNextEtnResponse followupResp = GFEVtecUtil
.getNextEtn(vtecToFix.getOffice(),
vtecToFix.getPhensig(), true,
true, true, etn);
responseContainer[0] = followupResp;
} catch (VizException e) {
exceptionContainer[0] = e;
exitLoopContainer[0] = true;
}
} else {
statusHandler.info(
"User declined to fix ETN for %s",
serverResponse.getPhensig());
exitLoopContainer[0] = true;
}
ETNConfirmationDialog dlg = new ETNConfirmationDialog(
getShell(), serverResponse);
if (dlg.open() == ETNConfirmationDialog.OK) {
int etn = dlg.getProposedEtn();
statusHandler.info(String.format(
"User confirmed ETN for %s: %04d",
serverResponse.getPhensig(), etn));
try {
GetNextEtnResponse followupResp = GFEVtecUtil
.getNextEtn(vtec.getOffice(),
vtec.getPhensig(), true, true, true,
etn);
serverResponse = followupResp;
} catch (VizException e) {
exception = e;
exitLoop = true;
}
});
} while (!responseContainer[0].isOkay() && !exitLoopContainer[0]);
} else {
statusHandler.info("User declined to fix ETN for %s",
serverResponse.getPhensig());
exitLoop = true;
}
} while (!serverResponse.isOkay() && !exitLoop);
if (!responseContainer[0].isOkay()) {
if (!serverResponse.isOkay()) {
String msg = "Unable to set ETN for phensig "
+ responseContainer[0].getPhensig() + "\nStatus: "
+ responseContainer[0].toString();
Exception e = exceptionContainer[0];
+ serverResponse.getPhensig() + "\nStatus: "
+ serverResponse.toString();
Exception e = exception;
if (e == null) {
throw new VizException(msg);
} else {
throw new VizException(msg, e);
}
} else {
serverResponse = responseContainer[0];
}
}
return serverResponse.getNextEtn();
}
private void countDown() {
getShell().getDisplay().timerExec(1000, new Runnable() {
@Override
public void run() {
bumpCounter();
}
});
}
private void bumpCounter() {
if (!progressBar.isDisposed()) {
// Increment the progress bar
int count = progressBar.getSelection() + 1;
if (count < COUNT_DOWN_SECONDS) {
progressBar.setSelection(count);
progressLabel.setText(String.format(countdownFormat,
(COUNT_DOWN_SECONDS - count)));
countDown();
} else {
storeTransmitProduct();
}
}
}
/**
* Method to transmit the product.
*
@ -566,13 +547,13 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
OfficialUserProduct oup = new OfficialUserProduct();
// make sure the awipsWanPil is exactly 10 characters space-padded
// long
String awipsWanPil = String.format("%-10s", productIdTF.getText()
String awipsWanPil = String.format("%-10s", productIdText.getText()
.trim());
oup.setAwipsWanPil(awipsWanPil);
oup.setProductText(productText);
String tempName = awipsWanPil + "-" + SEQ_NUMBER + "-"
+ (System.currentTimeMillis() / 1000);
+ (System.currentTimeMillis() / TimeUtil.MILLIS_PER_SECOND);
oup.setFilename(tempName);
String type = parentEditor.getProductType();
@ -590,8 +571,8 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
try {
Object response = ThriftClient.sendRequest(req);
// TODO need a response on the other one? it's going
// async....
// TODO need a response on the other one?
// it's going async....
if (response instanceof OUPResponse) {
OUPResponse resp = (OUPResponse) response;
Priority p = null;
@ -646,8 +627,13 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
}
private void sendTransmissionStatus(ConfigData.productStateEnum status) {
if (isStoreDialog == false) {
if (!isStoreDialog) {
transmissionCB.setTransmissionState(status);
}
}
private void doCancel() {
this.isCancelled = true;
storeTransmitProduct();
}
}

View file

@ -64,6 +64,9 @@ import com.raytheon.viz.mpe.ui.rsc.PointPrecipResourceData;
import com.raytheon.viz.mpe.ui.rsc.PointTempPlotResource;
import com.raytheon.viz.mpe.ui.rsc.PointTempResourceData;
import com.raytheon.viz.mpe.util.DailyQcUtils;
import com.raytheon.viz.mpe.util.DailyQcUtils.Pdata;
import com.raytheon.viz.mpe.util.DailyQcUtils.Tdata;
import com.raytheon.viz.mpe.util.DailyQcUtils.Zdata;
/**
* TODO Add Description
@ -121,13 +124,13 @@ public class DrawDQCStations {
int pcpn_time = 0;
// Pdata pdata[] = dqc.pdata;
Pdata pdata[] = DailyQcUtils.pdata;
int old_isom = 0;
// Tdata tdata[] = DailyQcUtils.tdata;
Tdata tdata[] = DailyQcUtils.tdata;
// Zdata zdata[] = DailyQcUtils.zdata;
Zdata zdata[] = DailyQcUtils.zdata;
public static ColorMap colorMap = new ColorMap();
@ -311,10 +314,10 @@ public class DrawDQCStations {
grids_flag = DailyQcUtils.grids_flag;
dflag = DailyQcUtils.dflag;
pcpn_time = DailyQcUtils.pcpn_time;
// pdata = DailyQcUtils.pdata;
pdata = DailyQcUtils.pdata;
old_isom = DailyQcUtils.old_isom;
// tdata = DailyQcUtils.tdata;
// zdata = DailyQcUtils.zdata;
tdata = DailyQcUtils.tdata;
zdata = DailyQcUtils.zdata;
/*
* get the token dqc_preprocessor_basetime, the default value is 12Z
@ -732,10 +735,10 @@ public class DrawDQCStations {
/* Precipitation period is always 12z-12z. */
if ((pcpn_time < 2) && (pcpn_time_step == 0)) {
ltime.setTime(DailyQcUtils.pdata[pcpn_day].data_time);
ltime.setTime(pdata[pcpn_day].data_time);
ltime.add(Calendar.SECOND, -86400);
} else {
ltime.setTime(DailyQcUtils.pdata[pcpn_day].data_time);
ltime.setTime(pdata[pcpn_day].data_time);
}
tbuf.append("Precipitation ");
@ -785,18 +788,18 @@ public class DrawDQCStations {
tbuf.append(" ending at 12z");
}
if (DailyQcUtils.pdata[pcpn_day].level == 1) {
if (pdata[pcpn_day].level == 1) {
tbuf.append(" - Level 1");
} else if (DailyQcUtils.pdata[pcpn_day].level == 2) {
} else if (pdata[pcpn_day].level == 2) {
tbuf.append(" - Level 2");
}
if (DailyQcUtils.pdata[pcpn_day].used[ptime_pos] == 4) {
if (pdata[pcpn_day].used[ptime_pos] == 4) {
tbuf.append(" Saved");
} else if ((DailyQcUtils.pdata[pcpn_day].used[ptime_pos] == 3)
|| (DailyQcUtils.pdata[pcpn_day].used[ptime_pos] == 2)) {
} else if ((pdata[pcpn_day].used[ptime_pos] == 3)
|| (pdata[pcpn_day].used[ptime_pos] == 2)) {
tbuf.append(" Modified");
} else if (DailyQcUtils.pdata[pcpn_day].used[ptime_pos] == 1) {
} else if (pdata[pcpn_day].used[ptime_pos] == 1) {
tbuf.append(" Not Modified");
} else {
tbuf.append(" - No Data");
@ -811,19 +814,19 @@ public class DrawDQCStations {
if (dqcEndingObsTime == 12) {
/* Times: 18, 00, 06, 12 */
if (pcpn_time < 1) {
ltime.setTime(DailyQcUtils.zdata[pcpn_day].data_time);
ltime.setTime(zdata[pcpn_day].data_time);
ltime.add(Calendar.SECOND, -86400);
} else {
ltime.setTime(DailyQcUtils.zdata[pcpn_day].data_time);
ltime.setTime(zdata[pcpn_day].data_time);
}
} else {
/* Times 12, 18, 00, 06 */
if (pcpn_time < 2) {
ltime.setTime(DailyQcUtils.zdata[pcpn_day].data_time);
ltime.setTime(zdata[pcpn_day].data_time);
ltime.add(Calendar.SECOND, -86400);
} else {
ltime.setTime(DailyQcUtils.zdata[pcpn_day].data_time);
ltime.setTime(zdata[pcpn_day].data_time);
}
}
@ -883,20 +886,20 @@ public class DrawDQCStations {
}
if (DailyQcUtils.zdata[pcpn_day].level[ptime_pos] == 1) {
if (zdata[pcpn_day].level[ptime_pos] == 1) {
tbuf.append(" - Level 1");
} else if (DailyQcUtils.zdata[pcpn_day].level[ptime_pos] == 2) {
} else if (zdata[pcpn_day].level[ptime_pos] == 2) {
tbuf.append(" - Level 2");
}
if (DailyQcUtils.zdata[pcpn_day].used[ptime_pos] == 6) {
if (zdata[pcpn_day].used[ptime_pos] == 6) {
tbuf.append(" Calculated");
} else if (DailyQcUtils.zdata[pcpn_day].used[ptime_pos] == 4) {
} else if (zdata[pcpn_day].used[ptime_pos] == 4) {
tbuf.append(" Saved");
} else if ((DailyQcUtils.zdata[pcpn_day].used[ptime_pos] == 3)
|| (DailyQcUtils.zdata[pcpn_day].used[ptime_pos] == 2)) {
} else if ((zdata[pcpn_day].used[ptime_pos] == 3)
|| (zdata[pcpn_day].used[ptime_pos] == 2)) {
tbuf.append(" Modified");
} else if (DailyQcUtils.zdata[pcpn_day].used[ptime_pos] == 1) {
} else if (zdata[pcpn_day].used[ptime_pos] == 1) {
tbuf.append(" Not Modified");
} else {
tbuf.append(" - No Data");
@ -916,18 +919,18 @@ public class DrawDQCStations {
if (dqcEndingObsTime == 12) {
if ((pcpn_time < 1) && (pcpn_time_step == 0)) {
ltime.setTime(DailyQcUtils.tdata[pcpn_day].data_time);
ltime.setTime(tdata[pcpn_day].data_time);
ltime.add(Calendar.SECOND, -86400);
} else {
ltime.setTime(DailyQcUtils.tdata[pcpn_day].data_time);
ltime.setTime(tdata[pcpn_day].data_time);
}
} else {
if ((pcpn_time < 2) && (pcpn_time_step == 0)) {
ltime.setTime(DailyQcUtils.tdata[pcpn_day].data_time);
ltime.setTime(tdata[pcpn_day].data_time);
ltime.add(Calendar.SECOND, -86400);
} else {
ltime.setTime(DailyQcUtils.tdata[pcpn_day].data_time);
ltime.setTime(tdata[pcpn_day].data_time);
}
}
@ -995,18 +998,18 @@ public class DrawDQCStations {
tbuf.append(" ending at 12z");
}
if (DailyQcUtils.tdata[pcpn_day].level[ptime_pos] == 1) {
if (tdata[pcpn_day].level[ptime_pos] == 1) {
tbuf.append(" - Level 1");
} else if (DailyQcUtils.tdata[pcpn_day].level[ptime_pos] == 2) {
} else if (tdata[pcpn_day].level[ptime_pos] == 2) {
tbuf.append(" - Level 2");
}
if (DailyQcUtils.tdata[pcpn_day].used[ptime_pos] == 4) {
if (tdata[pcpn_day].used[ptime_pos] == 4) {
tbuf.append(" Saved");
} else if ((DailyQcUtils.tdata[pcpn_day].used[ptime_pos] == 3)
|| (DailyQcUtils.tdata[pcpn_day].used[ptime_pos] == 2)) {
} else if ((tdata[pcpn_day].used[ptime_pos] == 3)
|| (tdata[pcpn_day].used[ptime_pos] == 2)) {
tbuf.append(" Modified");
} else if (DailyQcUtils.tdata[pcpn_day].used[ptime_pos] == 1) {
} else if (tdata[pcpn_day].used[ptime_pos] == 1) {
tbuf.append(" Not Modified");
} else {
tbuf.append(" - No Data");

View file

@ -125,14 +125,14 @@ public class OtherPrecipOptions {
public void chg_precip_time(int data) {
int i = 0;
int points_flag = dqc.points_flag;
int grids_flag = dqc.grids_flag;
int map_flag = dqc.map_flag;
int points_flag = DailyQcUtils.points_flag;
int grids_flag = DailyQcUtils.grids_flag;
int map_flag = DailyQcUtils.map_flag;
/* 24 hour or 6 hour time step */
if (MPEDisplayManager.pcpn_time_step == 0) {
time_pos = dqc.pcpn_time;
time_pos = DailyQcUtils.pcpn_time;
} else {
time_pos = 4;
}
@ -141,7 +141,7 @@ public class OtherPrecipOptions {
return;
} else if (data == 2 && MPEDisplayManager.pcpn_time_step == 1) {
MPEDisplayManager.pcpn_time_step = 0;
dqc.pcp_flag = 3;
DailyQcUtils.pcp_flag = 3;
} else if (data == 3 && MPEDisplayManager.pcpn_time_step == 1) {
return;
} else if (data == 3 && MPEDisplayManager.pcpn_time_step == 0) {
@ -149,7 +149,7 @@ public class OtherPrecipOptions {
if (dqc.curHr18_00 == 1 || dqc.curHr00_06 == 1
|| dqc.curHr06_12 == 1) {
dqc.pcp_flag = 0;
DailyQcUtils.pcp_flag = 0;
}
if (rsmode == 0) {
@ -167,38 +167,38 @@ public class OtherPrecipOptions {
if (data == 0) {
/* 6 hour precip time step mode. */
if (MPEDisplayManager.pcpn_time_step == 0) {
dqc.pcp_flag--;
DailyQcUtils.pcp_flag--;
} else {
/* 24 hour precip time step mode. */
dqc.pcp_flag = dqc.pcp_flag - 4;
DailyQcUtils.pcp_flag = DailyQcUtils.pcp_flag - 4;
}
} else if (data == 1) {
/* 6 hour precip time step mode. */
if (MPEDisplayManager.pcpn_time_step == 0) {
dqc.pcp_flag++;
DailyQcUtils.pcp_flag++;
} else {
/* 24 hour precip time step mode. */
dqc.pcp_flag = dqc.pcp_flag + 4;
DailyQcUtils.pcp_flag = DailyQcUtils.pcp_flag + 4;
}
}
if (dqc.pcp_flag < 0) {
dqc.pcp_flag = 0;
if (DailyQcUtils.pcp_flag < 0) {
DailyQcUtils.pcp_flag = 0;
}
if (dqc.pcp_flag >= (MAX_GAGEQC_DAYS * 4)) {
dqc.pcp_flag = ((MAX_GAGEQC_DAYS * 4) - 1);
if (DailyQcUtils.pcp_flag >= (MAX_GAGEQC_DAYS * 4)) {
DailyQcUtils.pcp_flag = ((MAX_GAGEQC_DAYS * 4) - 1);
}
dqc.pcpn_day = dqc.pcp_flag / 4;
DailyQcUtils.pcpn_day = DailyQcUtils.pcp_flag / 4;
dqc.pcpn_time = 3 - (dqc.pcp_flag - dqc.pcpn_day * 4);
DailyQcUtils.pcpn_time = 3 - (DailyQcUtils.pcp_flag - DailyQcUtils.pcpn_day * 4);
if (MPEDisplayManager.pcpn_time_step == 0) {
time_pos = dqc.pcp_flag;
time_pos = DailyQcUtils.pcp_flag;
} else {
time_pos = 40 + dqc.pcpn_day;
time_pos = 40 + DailyQcUtils.pcpn_day;
}
QcPrecipOptionsDialog.dataSet.clear();
@ -207,7 +207,7 @@ public class OtherPrecipOptions {
QcPrecipOptionsDialog.setDataSetCombo(QcPrecipOptionsDialog.dataSet
.toArray(a));
if (dqc.pcp_in_use[time_pos] == -1) {
if (DailyQcUtils.pcp_in_use[time_pos] == -1) {
QcPrecipOptionsDialog.dataSet.clear();
QcPrecipOptionsDialog.dataSet.add(0,
QcPrecipOptionsDialog.dataType.get(0));
@ -218,7 +218,7 @@ public class OtherPrecipOptions {
.toArray(a));
}
if (points_flag == 1 && dqc.pcp_in_use[time_pos] == -1) {
if (points_flag == 1 && DailyQcUtils.pcp_in_use[time_pos] == -1) {
i = 0;
} else if (points_flag == 1 && grids_flag == -1 && map_flag == -1) {
i = 0;
@ -236,9 +236,9 @@ public class OtherPrecipOptions {
QcPrecipOptionsDialog.selectDataSetVal(i);
if (dqc.pdata[dqc.pcpn_day].stddev == 5.0) {
if (DailyQcUtils.pdata[DailyQcUtils.pcpn_day].stddev == 5.0) {
i = 0;
} else if (dqc.pdata[dqc.pcpn_day].stddev == 3.0) {
} else if (DailyQcUtils.pdata[DailyQcUtils.pcpn_day].stddev == 3.0) {
i = 1;
} else {
i = 2;
@ -246,14 +246,14 @@ public class OtherPrecipOptions {
QcPrecipOptionsDialog.pntScnCbo.select(i);
if ((dqc.pcp_in_use[time_pos] == -1)
&& ((((MPEDisplayManager.pcpn_time_step == 1) && (dqc.pdata[dqc.pcpn_day].used[4] != 0))) || ((MPEDisplayManager.pcpn_time_step == 0) && (dqc.pdata[dqc.pcpn_day].used[dqc.pcpn_time] != 0)))) {
if ((DailyQcUtils.pcp_in_use[time_pos] == -1)
&& ((((MPEDisplayManager.pcpn_time_step == 1) && (DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[4] != 0))) || ((MPEDisplayManager.pcpn_time_step == 0) && (DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[DailyQcUtils.pcpn_time] != 0)))) {
QcPrecipOptionsDialog.renderGridsBtn.setEnabled(true);
} else {
QcPrecipOptionsDialog.renderGridsBtn.setEnabled(false);
}
time_pos = 100 + dqc.pcp_flag;
time_pos = 100 + DailyQcUtils.pcp_flag;
if (MPEDisplayManager.pcpn_time_step == 1) {
@ -263,8 +263,8 @@ public class OtherPrecipOptions {
QcPrecipOptionsDialog.pcpTypeCbo.select(1);
} else {
if ((dqc.pcp_flag != 0 && (dqc.pcp_in_use[time_pos] == 1 || dqc.pcp_in_use[time_pos - 1] == 1))
|| (dqc.pcp_flag == 0 && dqc.pcp_in_use[time_pos] != -1)) {
if ((DailyQcUtils.pcp_flag != 0 && (DailyQcUtils.pcp_in_use[time_pos] == 1 || DailyQcUtils.pcp_in_use[time_pos - 1] == 1))
|| (DailyQcUtils.pcp_flag == 0 && DailyQcUtils.pcp_in_use[time_pos] != -1)) {
for (i = 0; i < 1; i++) {
QcPrecipOptionsDialog.pcpTypeCbo.setEnabled(true);
@ -286,10 +286,10 @@ public class OtherPrecipOptions {
}
Calendar tget = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
long offset = (dqc.pcpn_day * 86400);
long offset = (DailyQcUtils.pcpn_day * 86400);
tget.setTime(dqc.btime.getTime());
tget.add(Calendar.SECOND, (int) -offset);
dqc.isom = tget.get(Calendar.MONTH);
DailyQcUtils.isom = tget.get(Calendar.MONTH);
/*
* Set the sensitivity of the precipitation time step arrows based on
@ -301,8 +301,8 @@ public class OtherPrecipOptions {
public void set_precip_arrow_sensitivity() {
int num_qc_days = dqc.qcDays;
int pcp_flag = dqc.pcp_flag;
int num_qc_days = DailyQcUtils.qcDays;
int pcp_flag = DailyQcUtils.pcp_flag;
Button up_arrow = QcPrecipOptionsDialog.upTimeBtn;
Button down_arrow = QcPrecipOptionsDialog.dnTimeBtn;
@ -352,8 +352,8 @@ public class OtherPrecipOptions {
}
Calendar currentTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
Calendar tmpDate = (Calendar) currentTime.clone();
tmpDate.setTime(dqc.pdata[dqc.pcpn_day].data_time);
tmpDate.add(Calendar.HOUR_OF_DAY, (dqc.pcpn_time-3)*6);
tmpDate.setTime(DailyQcUtils.pdata[DailyQcUtils.pcpn_day].data_time);
tmpDate.add(Calendar.HOUR_OF_DAY, (DailyQcUtils.pcpn_time-3)*6);
if (currentTime.before(tmpDate)){
up_arrow.setEnabled(false);
@ -390,36 +390,36 @@ public class OtherPrecipOptions {
public void display_pcpn_options(int data) {
/* Initialize the display flags. */
dqc.points_flag = -1;
dqc.grids_flag = -1;
dqc.map_flag = -1;
dqc.contour_flag = -1;
DailyQcUtils.points_flag = -1;
DailyQcUtils.grids_flag = -1;
DailyQcUtils.map_flag = -1;
DailyQcUtils.contour_flag = -1;
if (data == 0) {
dqc.points_flag = 1;
DailyQcUtils.points_flag = 1;
}
else if (data == 1) {
dqc.grids_flag = 1;
DailyQcUtils.grids_flag = 1;
} else if (data == 2) {
dqc.map_flag = 1;
DailyQcUtils.map_flag = 1;
} else if (data == 3) {
dqc.points_flag = 1;
dqc.grids_flag = 1;
DailyQcUtils.points_flag = 1;
DailyQcUtils.grids_flag = 1;
} else if (data == 4) {
dqc.points_flag = 1;
dqc.map_flag = 1;
DailyQcUtils.points_flag = 1;
DailyQcUtils.map_flag = 1;
} else if (data == 5) {
dqc.points_flag = -1;
dqc.contour_flag = 1;
DailyQcUtils.points_flag = -1;
DailyQcUtils.contour_flag = 1;
} else if (data == 6) {
dqc.points_flag = 1;
dqc.contour_flag = 1;
DailyQcUtils.points_flag = 1;
DailyQcUtils.contour_flag = 1;
} else if (data == 7) {
dqc.contour_flag = -1;
dqc.points_flag = -1;
dqc.grids_flag = -1;
dqc.map_flag = -1;
DailyQcUtils.contour_flag = -1;
DailyQcUtils.points_flag = -1;
DailyQcUtils.grids_flag = -1;
DailyQcUtils.map_flag = -1;
}
send_expose();
}
@ -442,7 +442,7 @@ public class OtherPrecipOptions {
// Hrap_Grid hrap_grid = DailyQcUtils.getHrap_grid();
Calendar tmtime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
// ReadPrecipStationList rp = new ReadPrecipStationList();
int num_stations = dqc.precip_stations.size();
int num_stations = DailyQcUtils.precip_stations.size();
String s = appsDefaults.getToken(dqc_ending_6hour_obstime_tok);
int dqc_ending_6hour_obstime = ((!(null == s)) ? Integer.parseInt(s)
: -1);
@ -463,34 +463,34 @@ public class OtherPrecipOptions {
else if (clientdata == 0) {
BadValues bv = new BadValues();
bv.update_bad_values(dqc.pcpn_day);
bv.update_bad_values(DailyQcUtils.pcpn_day);
/*
* do not estimate daily and partial point precipitation from each
* other if run DQC on partial time frame and pcpn_day=0
*/
if (dqc.pcpn_day == 0
if (DailyQcUtils.pcpn_day == 0
&& (dqc.curHr00_06 == 1
|| dqc.curHr06_12 == 1 || dqc.curHr18_00 == 1)) {
// don't estimate
} else {
EstDailyStations ed = new EstDailyStations();
ed.estimate_daily_stations(dqc.pcpn_day,
dqc.precip_stations, num_stations);
ed.estimate_daily_stations(DailyQcUtils.pcpn_day,
DailyQcUtils.precip_stations, num_stations);
EstPartStations ep = new EstPartStations();
ep.estimate_partial_stations(dqc.pcpn_day,
dqc.precip_stations, num_stations);
ep.estimate_partial_stations(DailyQcUtils.pcpn_day,
DailyQcUtils.precip_stations, num_stations);
}
QCStations qs = new QCStations();
qs.quality_control_stations(dqc.pcpn_day,
dqc.precip_stations, num_stations);
qs.quality_control_stations(DailyQcUtils.pcpn_day,
DailyQcUtils.precip_stations, num_stations);
CheckConsistency cc = new CheckConsistency();
cc.check_consistency(dqc.pcpn_day,
dqc.precip_stations, num_stations);
cc.check_consistency(DailyQcUtils.pcpn_day,
DailyQcUtils.precip_stations, num_stations);
/* render Grids and MAP for 24 hr precipitation */
@ -499,19 +499,19 @@ public class OtherPrecipOptions {
* curHr06_12, for precipitation, do not display the 24 hr
* precipiation if the pcpn_day=0
*/
if ((dqc.pcpn_day == 0)
if ((DailyQcUtils.pcpn_day == 0)
&& (dqc.curHr18_00 == 1
|| dqc.curHr00_06 == 1 || dqc.curHr06_12 == 1)) {
dqc.pdata[dqc.pcpn_day].used[4] = 0;
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[4] = 0;
}
if (dqc.pdata[dqc.pcpn_day].used[4] != 0) {
if (DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[4] != 0) {
rpc.render_pcp(dqc.pcpn_day, dqc.pcpn_time,
1, num_stations, dqc.precip_stations,
dqc.getHrap_grid(), dqc.pdata, dqc.pcp_in_use);
rpc.render_pcp(DailyQcUtils.pcpn_day, DailyQcUtils.pcpn_time,
1, num_stations, DailyQcUtils.precip_stations,
DailyQcUtils.getHrap_grid(), DailyQcUtils.pdata, DailyQcUtils.pcp_in_use);
old_time = dqc.pdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.pdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
dbuf = String.format("%s%s_%04d%02d%02d",
@ -535,7 +535,7 @@ public class OtherPrecipOptions {
// write_dqc_netcdf_grids(dbuf, pdata[pcpn_day].data_time,
// &begin_time, 1);
// }
cm.create_map(40 + dqc.pcpn_day);
cm.create_map(40 + DailyQcUtils.pcpn_day);
}
/* render Grids and MAP for four 6hr precipitation */
@ -544,35 +544,35 @@ public class OtherPrecipOptions {
* 18-00, m=2 represents time frame 00-06Z
*/
if (dqc.pcpn_day == 0 && dqc.curHr18_00 == 1) {
dqc.pdata[dqc.pcpn_day].used[1] = 0;
dqc.pdata[dqc.pcpn_day].used[2] = 0;
dqc.pdata[dqc.pcpn_day].used[3] = 0;
} else if (dqc.pcpn_day == 0
if (DailyQcUtils.pcpn_day == 0 && dqc.curHr18_00 == 1) {
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[1] = 0;
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[2] = 0;
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[3] = 0;
} else if (DailyQcUtils.pcpn_day == 0
&& dqc.curHr00_06 == 1) {
dqc.pdata[dqc.pcpn_day].used[2] = 0;
dqc.pdata[dqc.pcpn_day].used[3] = 0;
} else if (dqc.pcpn_day == 0
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[2] = 0;
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[3] = 0;
} else if (DailyQcUtils.pcpn_day == 0
&& dqc.curHr06_12 == 1) {
dqc.pdata[dqc.pcpn_day].used[3] = 0;
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[3] = 0;
}
for (int m = 0; m < 4; m++) {
if (dqc.pdata[dqc.pcpn_day].used[m] == 0) {
if (DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[m] == 0) {
continue;
}
rpc.render_pcp(dqc.pcpn_day, m, 0, num_stations,
dqc.precip_stations, dqc.getHrap_grid(),
dqc.pdata, dqc.pcp_in_use);
rpc.render_pcp(DailyQcUtils.pcpn_day, m, 0, num_stations,
DailyQcUtils.precip_stations, DailyQcUtils.getHrap_grid(),
DailyQcUtils.pdata, DailyQcUtils.pcp_in_use);
if (m < 2) {
old_time = dqc.pdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.pdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
tmtime.add(Calendar.SECOND, -86400);
} else {
old_time = dqc.pdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.pdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
}
@ -596,28 +596,28 @@ public class OtherPrecipOptions {
// write_dqc_netcdf_grids(dbuf, pdata[pcpn_day].data_time,
// &begin_time, 1);
// }
int num = 4 * dqc.pcpn_day + 3 - m;
int num = 4 * DailyQcUtils.pcpn_day + 3 - m;
cm.create_map(num);
dqc.pdata[dqc.pcpn_day].used[m] = 3;
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[m] = 3;
}
EstMissingStations ems = new EstMissingStations();
ems.estimate_missing_stations(dqc.pcpn_day,
dqc.precip_stations, num_stations,
dqc.pdata);
ems.estimate_missing_stations(DailyQcUtils.pcpn_day,
DailyQcUtils.precip_stations, num_stations,
DailyQcUtils.pdata);
bv.restore_bad_values(dqc.pcpn_day,
dqc.precip_stations, num_stations);
bv.restore_bad_values(DailyQcUtils.pcpn_day,
DailyQcUtils.precip_stations, num_stations);
if ((dqc.pcpn_day == 0)
if ((DailyQcUtils.pcpn_day == 0)
&& (dqc.curHr18_00 == 1
|| dqc.curHr00_06 == 1 || dqc.curHr06_12 == 1)) {
dqc.pdata[dqc.pcpn_day].used[4] = 0;
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[4] = 0;
} else {
dqc.pdata[dqc.pcpn_day].used[4] = 3;
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[4] = 3;
}
QcPrecipOptionsDialog.dataSet.clear();
@ -628,55 +628,55 @@ public class OtherPrecipOptions {
.toArray(a));
if (MPEDisplayManager.pcpn_time_step == 0) {
time_pos = dqc.pcp_flag;
time_pos = DailyQcUtils.pcp_flag;
} else {
time_pos = 40 + dqc.pcpn_day;
time_pos = 40 + DailyQcUtils.pcpn_day;
}
if (dqc.points_flag == 1
&& dqc.pcp_in_use[time_pos] == -1) {
if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.pcp_in_use[time_pos] == -1) {
k = 0;
} else if (dqc.points_flag == 1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == -1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == -1) {
// Points
k = 0;
} else if (dqc.points_flag == -1
&& dqc.grids_flag == 1
&& dqc.map_flag == -1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == 1
&& DailyQcUtils.map_flag == -1) {
// Grids
k = 1;
} else if (dqc.points_flag == -1
&& dqc.grids_flag == -1
&& dqc.map_flag == 1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == 1) {
// MATs
k = 2;
} else if (dqc.points_flag == 1
&& dqc.grids_flag == 1
&& dqc.map_flag == -1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == 1
&& DailyQcUtils.map_flag == -1) {
// Points & Grids
k = 3;
} else if (dqc.points_flag == 1
&& dqc.grids_flag == -1
&& dqc.map_flag == 1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == 1) {
// Points & MATs
k = 4;
} else if (dqc.points_flag == -1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1) {
// Contours
k = 5;
} else if (dqc.points_flag == 1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == 1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == 1) {
// Points & Contours
k = 6;
} else if (dqc.points_flag == -1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == -1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == -1) {
// None
k = 7;
}
@ -698,25 +698,25 @@ public class OtherPrecipOptions {
* 18-00, m=2 represents time frame 00-06Z
*/
if (dqc.pcpn_day == 0 && dqc.curHr18_00 == 1) {
dqc.zdata[dqc.pcpn_day].used[1] = 0;
dqc.zdata[dqc.pcpn_day].used[2] = 0;
dqc.zdata[dqc.pcpn_day].used[3] = 0;
} else if (dqc.pcpn_day == 0
if (DailyQcUtils.pcpn_day == 0 && dqc.curHr18_00 == 1) {
DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[1] = 0;
DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[2] = 0;
DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[3] = 0;
} else if (DailyQcUtils.pcpn_day == 0
&& dqc.curHr00_06 == 1) {
dqc.zdata[dqc.pcpn_day].used[2] = 0;
dqc.zdata[dqc.pcpn_day].used[3] = 0;
} else if (dqc.pcpn_day == 0
DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[2] = 0;
DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[3] = 0;
} else if (DailyQcUtils.pcpn_day == 0
&& dqc.curHr06_12 == 1) {
dqc.zdata[dqc.pcpn_day].used[3] = 0;
DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[3] = 0;
}
for (m = 0; m < 4; m++) {
if (dqc.zdata[dqc.pcpn_day].used[m] == 0
|| dqc.zdata[dqc.pcpn_day].used[m] == 3
|| (dqc.zdata[dqc.pcpn_day].used[m] == 1 && dqc.zdata[dqc.pcpn_day].level[m] == 2)
|| dqc.zdata[dqc.pcpn_day].used[m] == 4) {
if (DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[m] == 0
|| DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[m] == 3
|| (DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[m] == 1 && DailyQcUtils.zdata[DailyQcUtils.pcpn_day].level[m] == 2)
|| DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[m] == 4) {
/*
* logMessage(
* "\n in other pcpn zdata used = %d pcpn_dauy=%d m=%d\n"
@ -725,9 +725,9 @@ public class OtherPrecipOptions {
continue;
}
rz.render_z(dqc.pcpn_day, m, 0, num_zstations,
dqc.freezing_stations, dqc.getHrap_grid(),
dqc.zdata, dqc.pcp_in_use);
rz.render_z(DailyQcUtils.pcpn_day, m, 0, num_zstations,
DailyQcUtils.freezing_stations, DailyQcUtils.getHrap_grid(),
DailyQcUtils.zdata, DailyQcUtils.pcp_in_use);
/*
* dqcEndingObsTime is controlled by the
* dqc_ending_6hour_obstime token. It should only be 06 or 12
@ -737,20 +737,20 @@ public class OtherPrecipOptions {
if (dqc.dqc_ending_6hour_obstime == 12) {
if (m < 1) {
old_time = dqc.zdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.zdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
tmtime.add(Calendar.SECOND, -86400);
} else {
old_time = dqc.zdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.zdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
}
} else {
if (m < 2) {
old_time = dqc.zdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.zdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
tmtime.add(Calendar.SECOND, -86400);
} else {
old_time = dqc.zdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.zdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
}
}
@ -763,9 +763,9 @@ public class OtherPrecipOptions {
wq.write_qpf_grids(dbuf);
int num = 100 + 4 * dqc.pcpn_day + 3 - m;
int num = 100 + 4 * DailyQcUtils.pcpn_day + 3 - m;
dqc.zdata[dqc.pcpn_day].used[m] = 3;
DailyQcUtils.zdata[DailyQcUtils.pcpn_day].used[m] = 3;
mr.make_rsel(num, num - 100);
/*
@ -782,52 +782,52 @@ public class OtherPrecipOptions {
QcFreezeOptionsDialog.dataDispCbo
.setItems(QcFreezeOptionsDialog.dataSet.toArray(a));
time_pos = 100 + dqc.pcp_flag;
time_pos = 100 + DailyQcUtils.pcp_flag;
if (dqc.points_flag == 1
&& dqc.pcp_in_use[time_pos] == -1) {
if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.pcp_in_use[time_pos] == -1) {
k = 0;
} else if (dqc.points_flag == 1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == -1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == -1) {
// Points
k = 0;
} else if (dqc.points_flag == -1
&& dqc.grids_flag == 1
&& dqc.map_flag == -1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == 1
&& DailyQcUtils.map_flag == -1) {
// Grids
k = 1;
} else if (dqc.points_flag == -1
&& dqc.grids_flag == -1
&& dqc.map_flag == 1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == 1) {
// MATs
k = 2;
} else if (dqc.points_flag == 1
&& dqc.grids_flag == 1
&& dqc.map_flag == -1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == 1
&& DailyQcUtils.map_flag == -1) {
// Points & Grids
k = 3;
} else if (dqc.points_flag == 1
&& dqc.grids_flag == -1
&& dqc.map_flag == 1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == 1) {
// Points & MATs
k = 4;
} else if (dqc.points_flag == -1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == 1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == 1) {
// Contours
k = 5;
} else if (dqc.points_flag == 1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == 1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == 1) {
// Points & Contours
} else if (dqc.points_flag == -1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == -1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == -1) {
// None
k = 7;
}
@ -840,50 +840,50 @@ public class OtherPrecipOptions {
ReadTemperatureStationList rt = new ReadTemperatureStationList();
int num_tstations = rt.getNumTstations();
BadTValues bt = new BadTValues();
bt.update_bad_tvalues(dqc.pcpn_day);
bt.update_bad_tvalues(DailyQcUtils.pcpn_day);
/*
* do not estimate daily and partial point precipitation from each
* other if run DQC on partial time frame and pcpn_day=0
*/
if (dqc.pcpn_day == 0
if (DailyQcUtils.pcpn_day == 0
&& (dqc.curHr00_06 == 1
|| dqc.curHr06_12 == 1 || dqc.curHr18_00 == 1)) {
// do not run estimate on stations
} else {
EstDailyTStations edt = new EstDailyTStations();
edt.estimate_daily_tstations(dqc.pcpn_day,
dqc.temperature_stations, num_tstations);
edt.estimate_daily_tstations(DailyQcUtils.pcpn_day,
DailyQcUtils.temperature_stations, num_tstations);
}
QCTStations qct = new QCTStations();
qct.quality_control_tstations(dqc.pcpn_day,
dqc.temperature_stations, num_tstations);
qct.quality_control_tstations(DailyQcUtils.pcpn_day,
DailyQcUtils.temperature_stations, num_tstations);
if (dqc.pcpn_day == 0 && dqc.curHr18_00 == 1) {
dqc.tdata[dqc.pcpn_day].used[1] = 0;
dqc.tdata[dqc.pcpn_day].used[2] = 0;
dqc.tdata[dqc.pcpn_day].used[3] = 0;
if (DailyQcUtils.pcpn_day == 0 && dqc.curHr18_00 == 1) {
DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[1] = 0;
DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[2] = 0;
DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[3] = 0;
} else if (dqc.pcpn_day == 0
} else if (DailyQcUtils.pcpn_day == 0
&& dqc.curHr00_06 == 1) {
dqc.tdata[dqc.pcpn_day].used[2] = 0;
dqc.tdata[dqc.pcpn_day].used[3] = 0;
DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[2] = 0;
DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[3] = 0;
} else if (dqc.pcpn_day == 0
} else if (DailyQcUtils.pcpn_day == 0
&& dqc.curHr06_12 == 1) {
dqc.tdata[dqc.pcpn_day].used[3] = 0;
DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[3] = 0;
}
RenderT rent = new RenderT();
if (dqc.tdata[dqc.pcpn_day].used[4] != 0) {
if (DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[4] != 0) {
rent.render_t(dqc.pcpn_day, dqc.pcpn_time, 1,
num_tstations, dqc.temperature_stations,
dqc.getHrap_grid(), dqc.tdata, dqc.pcp_in_use);
rent.render_t(DailyQcUtils.pcpn_day, DailyQcUtils.pcpn_time, 1,
num_tstations, DailyQcUtils.temperature_stations,
DailyQcUtils.getHrap_grid(), DailyQcUtils.tdata, DailyQcUtils.pcp_in_use);
old_time = dqc.tdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.tdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
dbuf = String.format("%s%s_%04d%02d%02d",
@ -895,17 +895,17 @@ public class OtherPrecipOptions {
wq.write_qpf_grids(dbuf);
dqc.tdata[dqc.pcpn_day].used[4] = 3;
DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[4] = 3;
}
if (dqc.tdata[dqc.pcpn_day].used[5] != 0) {
if (DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[5] != 0) {
rent.render_t(dqc.pcpn_day, dqc.pcpn_time, 2,
num_tstations, dqc.temperature_stations,
dqc.getHrap_grid(), dqc.tdata, dqc.pcp_in_use);
rent.render_t(DailyQcUtils.pcpn_day, DailyQcUtils.pcpn_time, 2,
num_tstations, DailyQcUtils.temperature_stations,
DailyQcUtils.getHrap_grid(), DailyQcUtils.tdata, DailyQcUtils.pcp_in_use);
old_time = dqc.tdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.tdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
@ -918,23 +918,23 @@ public class OtherPrecipOptions {
wq.write_qpf_grids(dbuf);
dqc.tdata[dqc.pcpn_day].used[5] = 3;
DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[5] = 3;
}
for (int m = 0; m < 4; m++) {
if (dqc.tdata[dqc.pcpn_day].used[m] == 0
|| dqc.tdata[dqc.pcpn_day].used[m] == 3
|| (dqc.tdata[dqc.pcpn_day].used[m] == 1 && dqc.tdata[dqc.pcpn_day].level[m] == 2)
|| dqc.tdata[dqc.pcpn_day].used[m] == 4) {
if (DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[m] == 0
|| DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[m] == 3
|| (DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[m] == 1 && DailyQcUtils.tdata[DailyQcUtils.pcpn_day].level[m] == 2)
|| DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[m] == 4) {
continue;
}
RenderT6 rt6 = new RenderT6();
rt6.render_t6(dqc.pcpn_day, m, 0, num_tstations,
dqc.temperature_stations, dqc.getHrap_grid(),
dqc.tdata, dqc.pcp_in_use);
rt6.render_t6(DailyQcUtils.pcpn_day, m, 0, num_tstations,
DailyQcUtils.temperature_stations, DailyQcUtils.getHrap_grid(),
DailyQcUtils.tdata, DailyQcUtils.pcp_in_use);
/*
* dqcEndingObsTime is controlled by the
@ -946,20 +946,20 @@ public class OtherPrecipOptions {
if (dqc_ending_6hour_obstime == 12) {
if (m < 1) {
old_time = dqc.tdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.tdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
tmtime.add(Calendar.SECOND, -86400);
} else {
old_time = dqc.tdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.tdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
}
} else {
if (m < 2) {
old_time = dqc.tdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.tdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
tmtime.add(Calendar.SECOND, -86400);
} else {
old_time = dqc.tdata[dqc.pcpn_day].data_time;
old_time = DailyQcUtils.tdata[DailyQcUtils.pcpn_day].data_time;
tmtime.setTime(old_time);
}
}
@ -973,25 +973,25 @@ public class OtherPrecipOptions {
wq.write_qpf_grids(dbuf);
int num = 150 + 4 * dqc.pcpn_day + 3 - m;
int num = 150 + 4 * DailyQcUtils.pcpn_day + 3 - m;
dqc.tdata[dqc.pcpn_day].used[m] = 3;
DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[m] = 3;
MakeMat mmat = new MakeMat();
mmat.make_mat(num, num - 150);
dqc.tdata[dqc.pcpn_day].used[m] = 3;
DailyQcUtils.tdata[DailyQcUtils.pcpn_day].used[m] = 3;
}
EstMissingTStations emt = new EstMissingTStations();
emt.estimate_missing_tstations(dqc.pcpn_day,
dqc.temperature_stations, num_tstations,
dqc.tdata);
emt.estimate_missing_tstations(DailyQcUtils.pcpn_day,
DailyQcUtils.temperature_stations, num_tstations,
DailyQcUtils.tdata);
BadTValues btv = new BadTValues();
btv.restore_bad_tvalues(dqc.pcpn_day,
dqc.temperature_stations, num_tstations);
btv.restore_bad_tvalues(DailyQcUtils.pcpn_day,
DailyQcUtils.temperature_stations, num_tstations);
QcTempOptionsDialog.dataSet.clear();
QcTempOptionsDialog.dataSet.addAll(QcTempOptionsDialog.dataType);
@ -999,46 +999,46 @@ public class OtherPrecipOptions {
QcTempOptionsDialog.dataDispCbo
.setItems(QcTempOptionsDialog.dataSet.toArray(a));
time_pos = 150 + dqc.pcp_flag;
time_pos = 150 + DailyQcUtils.pcp_flag;
if (dqc.points_flag == 1
&& dqc.pcp_in_use[time_pos] == -1) {
if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.pcp_in_use[time_pos] == -1) {
k = 0; // Points
} else if (dqc.points_flag == 1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == -1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == -1) {
k = 0; // Points
} else if (dqc.points_flag == -1
&& dqc.grids_flag == 1
&& dqc.map_flag == -1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == 1
&& DailyQcUtils.map_flag == -1) {
k = 1; // Grids
} else if (dqc.points_flag == -1
&& dqc.grids_flag == -1
&& dqc.map_flag == 1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == 1) {
k = 2; // MATs
} else if (dqc.points_flag == 1
&& dqc.grids_flag == 1
&& dqc.map_flag == -1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == 1
&& DailyQcUtils.map_flag == -1) {
k = 3; // Points + Grids
} else if (dqc.points_flag == 1
&& dqc.grids_flag == -1
&& dqc.map_flag == 1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == 1) {
k = 4; // Points + MATs
} else if (dqc.points_flag == -1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == 1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == 1) {
k = 5; // Contours
} else if (dqc.points_flag == 1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == 1) {
} else if (DailyQcUtils.points_flag == 1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == 1) {
k = 6; // Points + Contours
} else if (dqc.points_flag == -1
&& dqc.grids_flag == -1
&& dqc.map_flag == -1
&& dqc.contour_flag == -1) {
} else if (DailyQcUtils.points_flag == -1
&& DailyQcUtils.grids_flag == -1
&& DailyQcUtils.map_flag == -1
&& DailyQcUtils.contour_flag == -1) {
k = 7; // None
}

View file

@ -2503,7 +2503,12 @@ public class SaveLevel2Data {
}
Disagg6Hr d6h = new Disagg6Hr();
d6h.disagg6hr();
try {
d6h.disagg6hr();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/* Free DailyQC resources. */

View file

@ -23,6 +23,7 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -60,8 +61,10 @@ import com.raytheon.viz.mpe.ui.actions.OtherPrecipOptions;
import com.raytheon.viz.mpe.util.BadValues;
import com.raytheon.viz.mpe.util.CheckConsistency;
import com.raytheon.viz.mpe.util.DailyQcUtils;
import com.raytheon.viz.mpe.util.DailyQcUtils.Pdata;
import com.raytheon.viz.mpe.util.DailyQcUtils.Rain;
import com.raytheon.viz.mpe.util.DailyQcUtils.Station;
import com.raytheon.viz.mpe.util.DailyQcUtils.Ts;
import com.raytheon.viz.mpe.util.EstDailyStations;
import com.raytheon.viz.mpe.util.EstPartStations;
import com.raytheon.viz.mpe.util.QCStations;
@ -116,7 +119,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
private int pcpn_time_step = MPEDisplayManager.pcpn_time_step;
private int pcpn_time = dqc.pcpn_time;
private int pcpn_time = DailyQcUtils.pcpn_time;
private Button applyBtn;
@ -216,29 +219,29 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
int tcmode = OtherPrecipOptions.tcmode;
// Ts ts[] = DailyQcUtils.ts;
Ts ts[] = DailyQcUtils.ts;
int tsmax = dqc.tsmax;
int tsmax = DailyQcUtils.tsmax;
int isom = dqc.isom;
int isom = DailyQcUtils.isom;
int gage_char[] = dqc.gage_char;
int gage_char[] = DailyQcUtils.gage_char;
int method = dqc.method;
int qflag[] = dqc.qflag;
int qflag[] = DailyQcUtils.qflag;
// Pdata pdata[] = DailyQcUtils.pdata;
Pdata pdata[] = DailyQcUtils.pdata;
int dflag[] = dqc.dflag;
int dflag[] = DailyQcUtils.dflag;
int naflag;
// ArrayList<Station> precipStationList = DailyQcUtils.precip_stations;
ArrayList<Station> precipStationList = DailyQcUtils.precip_stations;
// ReadPrecipStationList rp = new ReadPrecipStationList();
int max_stations = dqc.precip_stations.size();
int max_stations = DailyQcUtils.precip_stations.size();
int i, m, x, y;
@ -248,7 +251,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
int[] allowedQualityCodes = dqc.func;
int pcpn_day = dqc.pcpn_day;
int pcpn_day = DailyQcUtils.pcpn_day;
Coordinate coord = new Coordinate();
@ -371,18 +374,18 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
ClosestStationFinder finder = new ClosestStationFinder(this);
isave = finder.findClosestStation(dqc.precip_stations, coord);
isave = finder.findClosestStation(precipStationList, coord);
if (isave == -1) {
return;
}
Rain frain = dqc.pdata[pcpn_day].stn[isave].frain[time_pos];
Rain frain = pdata[pcpn_day].stn[isave].frain[time_pos];
reset_value = 0;
initial_qual = frain.qual;
new_qual = initial_qual;
Rain srain = dqc.pdata[pcpn_day].stn[isave].srain[time_pos];
Rain srain = pdata[pcpn_day].stn[isave].srain[time_pos];
if (srain.data > -98) {
if (time_pos == HOURS_24 && srain.data >= 0) {
@ -413,7 +416,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
private void loadPrecipStationText(StringBuilder stationStringBuilder,
Station selectedStation) {
Rain frain = dqc.pdata[pcpn_day].stn[isave].frain[time_pos];
Rain frain = pdata[pcpn_day].stn[isave].frain[time_pos];
stationStringBuilder.append(selectedStation.hb5 + " "
+ selectedStation.parm + "\n" + selectedStation.name + "\n"
@ -440,13 +443,13 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
frain.stddev));
}
int frzlvl = dqc.pdata[pcpn_day].stn[isave].frzlvl[time_pos];
int frzlvl = pdata[pcpn_day].stn[isave].frzlvl[time_pos];
if (selectedStation.tip == 0 && time_pos != HOURS_24 && frzlvl > -99) {
stationStringBuilder.append(String.format("Freezing level %dft\n",
frzlvl));
}
short snoflag = dqc.pdata[pcpn_day].stn[isave].snoflag[time_pos];
short snoflag = pdata[pcpn_day].stn[isave].snoflag[time_pos];
if (snoflag > 0) {
stationStringBuilder.append("SNOTEL error is ");
@ -469,7 +472,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
}
Rain srain = dqc.pdata[pcpn_day].stn[isave].srain[time_pos];
Rain srain = pdata[pcpn_day].stn[isave].srain[time_pos];
if (srain.data > -98) {
@ -487,9 +490,9 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
double accumulatedAmount = get24HourPrecipTotal(
dqc.QPEaccum24hr, selectedStation.hrap_x
- dqc.getHrap_grid().hrap_minx,
- DailyQcUtils.getHrap_grid().hrap_minx,
selectedStation.hrap_y
- dqc.getHrap_grid().hrap_miny);
- DailyQcUtils.getHrap_grid().hrap_miny);
stationStringBuilder.append(String.format(
"accumulated amount %5.2f in.", accumulatedAmount));
@ -522,9 +525,9 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
// --------------------------------------------------------
public boolean shouldFilterOut(int stationIndex) {
boolean filteredOut = false;
Station station = dqc.precip_stations.get(stationIndex);
Station station = precipStationList.get(stationIndex);
Rain frain = dqc.pdata[pcpn_day].stn[stationIndex].frain[time_pos];
Rain frain = pdata[pcpn_day].stn[stationIndex].frain[time_pos];
if ((frain.data > QcPrecipOptionsDialog.getPointFilterReverseValue())
&& (frain.data < 20.00)) {
@ -532,7 +535,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
}
if (station.elev > 0
&& station.elev < dqc.elevation_filter_value) {
&& station.elev < DailyQcUtils.elevation_filter_value) {
return true;
}
@ -544,21 +547,21 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
return true;
}
if (tcmode == 0 && dqc.pdata[pcpn_day].stn[stationIndex].tcons == -1) {
if (tcmode == 0 && pdata[pcpn_day].stn[stationIndex].tcons == -1) {
return true;
}
if (tcmode == 1 && dqc.pdata[pcpn_day].stn[stationIndex].tcons == 1) {
if (tcmode == 1 && pdata[pcpn_day].stn[stationIndex].tcons == 1) {
return true;
}
if (dcmode == 0
&& dqc.pdata[pcpn_day].stn[stationIndex].scons[time_pos] == -1) {
&& pdata[pcpn_day].stn[stationIndex].scons[time_pos] == -1) {
return true;
}
if (dcmode == 1
&& dqc.pdata[pcpn_day].stn[stationIndex].scons[time_pos] == 1) {
&& pdata[pcpn_day].stn[stationIndex].scons[time_pos] == 1) {
return true;
}
@ -574,7 +577,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
for (m = 0; m < tsmax; m++) {
String kd = station.parm.substring(3, 5);
if ((kd.compareTo(dqc.ts[m].abr) == 0 && dflag[m + 1] == 1)) {
if ((kd.compareTo(ts[m].abr) == 0 && dflag[m + 1] == 1)) {
break;
}
}
@ -613,7 +616,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
dataComp.setLayoutData(gd);
StringBuilder stringBuilder = new StringBuilder();
Station selectedStation = dqc.precip_stations.get(isave);
Station selectedStation = precipStationList.get(isave);
loadPrecipStationText(stringBuilder, selectedStation);
gd = new GridData(SWT.FILL, SWT.DEFAULT, false, false);
@ -628,8 +631,8 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
snotelButton.setText("Use SWD for PPD");
snotelButton.setLayoutData(gd);
Rain srain = dqc.pdata[pcpn_day].stn[isave].srain[time_pos];
short sflag = dqc.pdata[pcpn_day].stn[isave].sflag[time_pos];
Rain srain = pdata[pcpn_day].stn[isave].srain[time_pos];
short sflag = pdata[pcpn_day].stn[isave].sflag[time_pos];
if (srain.data > -98) {
if (time_pos == HOURS_24 && srain.data >= 0) {
@ -665,7 +668,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
stnQualComp.setLayoutData(gd);
if (initial_qual < 0
|| dqc.pdata[pcpn_day].stn[isave].frain[time_pos].data < 0) {
|| pdata[pcpn_day].stn[isave].frain[time_pos].data < 0) {
naflag = 1;
} else {
naflag = 0;
@ -811,7 +814,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
*/
private void createStnLocComp() {
Station selectedStation = dqc.precip_stations.get(isave);
Station selectedStation = precipStationList.get(isave);
initial_pos = _textPosMgr.getTextPosition(selectedStation);
Group stnLocGroup = new Group(shell, SWT.NONE);
@ -843,7 +846,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
b.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Station station = dqc.precip_stations.get(isave);
Station station = precipStationList.get(isave);
int textPositionCode = (Integer) b.getData();
_textPosMgr
.changeStationLocation(textPositionCode, station);
@ -884,12 +887,12 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
qualityCodeStatusLabelArray[i] = new Label(stnConComp, SWT.CENTER);
int qualityCode = dqc.pdata[pcpn_day].stn[isave].frain[i].qual;
int qualityCode = pdata[pcpn_day].stn[isave].frain[i].qual;
String qualityText = getQualityTextFromCode(qualityCode);
qualityCodeStatusLabelArray[i].setText(qualityText);
Rain frainI = dqc.pdata[pcpn_day].stn[isave].frain[i];
Rain frainI = pdata[pcpn_day].stn[isave].frain[i];
precipValueTextArray[i].setEditable(true);
if (frainI.data < 0) {
@ -983,8 +986,8 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
@Override
public void widgetSelected(SelectionEvent e) {
AppLauncherHandler alh = new AppLauncherHandler();
String lid = dqc.precip_stations.get(isave).hb5;
String dataType = dqc.precip_stations.get(isave).parm;
String lid = precipStationList.get(isave).hb5;
String dataType = precipStationList.get(isave).parm;
final String TSL_BUNDLE_LOC = "bundles/run-TimeSeriesLite.xml";
try {
System.out
@ -1018,14 +1021,14 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
for (k = 0; k < 5; k++) {
dqc.pdata[pcpn_day].stn[isave].frain[k].qual = dqc.pdata[pcpn_day].stn[isave].rrain[k].qual;
pdata[pcpn_day].stn[isave].frain[k].qual = pdata[pcpn_day].stn[isave].rrain[k].qual;
dqc.pdata[pcpn_day].stn[isave].frain[k].data = dqc.pdata[pcpn_day].stn[isave].rrain[k].data;
pdata[pcpn_day].stn[isave].frain[k].data = pdata[pcpn_day].stn[isave].rrain[k].data;
}
reset_value = 1;
new_qual = dqc.pdata[pcpn_day].stn[isave].rrain[time_pos].qual;
new_qual = pdata[pcpn_day].stn[isave].rrain[time_pos].qual;
} else {
reset_value = 0;
@ -1043,7 +1046,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
}
new_qual = allowedQualityCodes[data];
dqc.pdata[pcpn_day].stn[isave].frain[time_pos].qual = (short) new_qual;
pdata[pcpn_day].stn[isave].frain[time_pos].qual = (short) new_qual;
System.out.println(header + " new_qual = " + new_qual);
}
@ -1051,7 +1054,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
String header = "EditPrecipStationsDialog.changeCustomFile(): ";
String pathName = getStationListPath(dqc.currentQcArea);
String pathName = getStationListPath(DailyQcUtils.currentQcArea);
String station_list_custom_file = pathName + "_label_position";
int i;
int time_pos;
@ -1065,10 +1068,10 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
Button rpbutton = QcPrecipOptionsDialog.renderGridsBtn;
int tcmode = OtherPrecipOptions.tcmode;
BufferedWriter out = null;
int pcp_flag = dqc.pcp_flag;
int grids_flag = dqc.grids_flag;
int points_flag = dqc.points_flag;
int map_flag = dqc.map_flag;
int pcp_flag = DailyQcUtils.pcp_flag;
int grids_flag = DailyQcUtils.grids_flag;
int points_flag = DailyQcUtils.points_flag;
int map_flag = DailyQcUtils.map_flag;
File custom = new File(station_list_custom_file);
custom.setReadable(true, false);
custom.setWritable(true, false);
@ -1092,7 +1095,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
out = new BufferedWriter(new FileWriter(custom));
for (i = 0; i < max_stations; i++) {
Station station = dqc.precip_stations.get(i);
Station station = precipStationList.get(i);
String rec = String.format("%s %s %d %d\n", station.hb5,
station.parm, station.xadd, station.yadd);
out.write(rec);
@ -1120,26 +1123,26 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
/* snotel path */
if (snow == true
&& ((bval == true && dqc.pdata[pcpn_day].stn[isave].sflag[HOURS_24] == -1) || (bval == false && dqc.pdata[pcpn_day].stn[isave].sflag[HOURS_24] == 1))) {
&& ((bval == true && pdata[pcpn_day].stn[isave].sflag[HOURS_24] == -1) || (bval == false && pdata[pcpn_day].stn[isave].sflag[HOURS_24] == 1))) {
dqc.pdata[pcpn_day].stn[isave].sflag[HOURS_24] = (short) -dqc.pdata[pcpn_day].stn[isave].sflag[HOURS_24];
pdata[pcpn_day].stn[isave].sflag[HOURS_24] = (short) -pdata[pcpn_day].stn[isave].sflag[HOURS_24];
if (dqc.pdata[pcpn_day].stn[isave].sflag[HOURS_24] == 1) {
if (pdata[pcpn_day].stn[isave].sflag[HOURS_24] == 1) {
dqc.pdata[pcpn_day].stn[isave].frain[HOURS_24].data = dqc.pdata[pcpn_day].stn[isave].srain[HOURS_24].data;
dqc.pdata[pcpn_day].stn[isave].frain[HOURS_24].qual = F_VERIFIED;
pdata[pcpn_day].stn[isave].frain[HOURS_24].data = pdata[pcpn_day].stn[isave].srain[HOURS_24].data;
pdata[pcpn_day].stn[isave].frain[HOURS_24].qual = F_VERIFIED;
}
else {
dqc.pdata[pcpn_day].stn[isave].frain[HOURS_24].data = dqc.pdata[pcpn_day].stn[isave].rrain[HOURS_24].data;
dqc.pdata[pcpn_day].stn[isave].frain[HOURS_24].qual = F_VERIFIED;
pdata[pcpn_day].stn[isave].frain[HOURS_24].data = pdata[pcpn_day].stn[isave].rrain[HOURS_24].data;
pdata[pcpn_day].stn[isave].frain[HOURS_24].qual = F_VERIFIED;
}
}
else {
boolean value_edit_flag = false;
val = dqc.pdata[pcpn_day].stn[isave].frain[time_pos].data;
val = pdata[pcpn_day].stn[isave].frain[time_pos].data;
p = -1;
// if (editVal != null) // null unless a value was edited
// {
@ -1158,12 +1161,12 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
/* need to ensure consistency in 6 and 24 hour data??? */
fdif = Math.abs(val
- dqc.pdata[pcpn_day].stn[isave].frain[time_pos].data);
- pdata[pcpn_day].stn[isave].frain[time_pos].data);
if (fdif > .005 && p == -1 && reset_value == 0) {
dqc.pdata[pcpn_day].stn[isave].frain[k].data = val;
dqc.pdata[pcpn_day].stn[isave].frain[k].qual = F_MANUAL;
dqc.pdata[pcpn_day].stn[isave].sflag[k] = -1;
pdata[pcpn_day].stn[isave].frain[k].data = val;
pdata[pcpn_day].stn[isave].frain[k].qual = F_MANUAL;
pdata[pcpn_day].stn[isave].sflag[k] = -1;
value_edit_flag = true;
}
@ -1172,9 +1175,9 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
rtotal = 0;
for (m = 0; m < 4; m++) {
if (dqc.pdata[pcpn_day].stn[isave].frain[m].data >= 0) {
if (pdata[pcpn_day].stn[isave].frain[m].data >= 0) {
rtotal = rtotal
+ dqc.pdata[pcpn_day].stn[isave].frain[m].data;
+ pdata[pcpn_day].stn[isave].frain[m].data;
}
}
@ -1184,17 +1187,17 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
*/
if ((Math
.abs(dqc.pdata[pcpn_day].stn[isave].frain[HOURS_24].data - 0.0) < 0.001)
.abs(pdata[pcpn_day].stn[isave].frain[HOURS_24].data - 0.0) < 0.001)
&& (time_pos == HOURS_24)) {
for (m = 0; m < 4; m++) {
dqc.pdata[pcpn_day].stn[isave].frain[m].data = 0;
dqc.pdata[pcpn_day].stn[isave].frain[m].qual = F_MANUAL;
pdata[pcpn_day].stn[isave].frain[m].data = 0;
pdata[pcpn_day].stn[isave].frain[m].qual = F_MANUAL;
}
rtotal = 0;
}
if (Math.abs(rtotal
- dqc.pdata[pcpn_day].stn[isave].frain[HOURS_24].data) > .005) {
- pdata[pcpn_day].stn[isave].frain[HOURS_24].data) > .005) {
read_text();
return;
@ -1204,16 +1207,16 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
else {
dqc.pdata[pcpn_day].stn[isave].frain[time_pos].qual = (short) new_qual;
pdata[pcpn_day].stn[isave].frain[time_pos].qual = (short) new_qual;
/* 24 hour data set bad/good then 6 hourly bad/good also */
if (new_qual == F_BAD && time_pos == HOURS_24
&& dqc.pdata[pcpn_day].stn[isave].sflag[time_pos] == 1) {
&& pdata[pcpn_day].stn[isave].sflag[time_pos] == 1) {
dqc.pdata[pcpn_day].stn[isave].frain[time_pos].data = dqc.pdata[pcpn_day].stn[isave].rrain[time_pos].data;
pdata[pcpn_day].stn[isave].frain[time_pos].data = pdata[pcpn_day].stn[isave].rrain[time_pos].data;
dqc.pdata[pcpn_day].stn[isave].sflag[time_pos] = -1;
pdata[pcpn_day].stn[isave].sflag[time_pos] = -1;
}
@ -1223,7 +1226,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
for (k = 0; k < 4; k++) {
/* if(pdata[pcpn_day].stn[isave].frain[k].qual!=1) */
dqc.pdata[pcpn_day].stn[isave].frain[k].qual = (short) new_qual;
pdata[pcpn_day].stn[isave].frain[k].qual = (short) new_qual;
}
}
@ -1239,13 +1242,13 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
if (time_pos != HOURS_24
&& new_qual == F_BAD
&& dqc.pdata[pcpn_day].stn[isave].frain[HOURS_24].qual != F_ESTIMATED
&& dqc.pdata[pcpn_day].stn[isave].frain[HOURS_24].data >= 0) {
&& pdata[pcpn_day].stn[isave].frain[HOURS_24].qual != F_ESTIMATED
&& pdata[pcpn_day].stn[isave].frain[HOURS_24].data >= 0) {
if (mpe_dqc_6hr_24hr_flag == 1) {
System.out
.println("6hr qual code set to Bad - 24hr qual code changed to Bad\n");
// frain24.qual = (short) new_qual;
dqc.pdata[pcpn_day].stn[isave].frain[HOURS_24].qual = (short) new_qual;
pdata[pcpn_day].stn[isave].frain[HOURS_24].qual = (short) new_qual;
}
}
@ -1254,12 +1257,12 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
* --
*/
if (dqc.pdata[pcpn_day].stn[isave].frain[4].qual == F_BAD
|| dqc.pdata[pcpn_day].stn[isave].frain[4].data < 0) {
if (pdata[pcpn_day].stn[isave].frain[4].qual == F_BAD
|| pdata[pcpn_day].stn[isave].frain[4].data < 0) {
if (tcmode == 0) {
dqc.pdata[pcpn_day].stn[isave].tcons = 1;
pdata[pcpn_day].stn[isave].tcons = 1;
} else {
dqc.pdata[pcpn_day].stn[isave].tcons = -1;
pdata[pcpn_day].stn[isave].tcons = -1;
}
}
} // end else
@ -1275,8 +1278,8 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
// pcp_in_use[time_pos] = -1;
if (dqc.pdata[pcpn_day].used[k] != 0) {
dqc.pdata[pcpn_day].used[k] = 2;
if (pdata[pcpn_day].used[k] != 0) {
pdata[pcpn_day].used[k] = 2;
}
}
@ -1296,7 +1299,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
time_pos = 40 + pcpn_day;
}
if (points_flag == 1 && dqc.pcp_in_use[time_pos] == -1) {
if (points_flag == 1 && DailyQcUtils.pcp_in_use[time_pos] == -1) {
k = 0;
} else if (points_flag == 1 && grids_flag == -1 && map_flag == -1) {
k = 0;
@ -1310,7 +1313,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
k = 4;
} else if (points_flag == -1 && grids_flag == -1 && map_flag == -1) {
k = 5;
} else if (points_flag == 1 && dqc.contour_flag == 1) {
} else if (points_flag == 1 && DailyQcUtils.contour_flag == 1) {
k = 6;
} else if (points_flag == -1 && grids_flag == -1 && map_flag == -1) {
k = 7;
@ -1334,21 +1337,21 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
// do nothing
} else {
EstDailyStations eds = new EstDailyStations();
eds.estimate_daily_stations(pcpn_day, dqc.precip_stations,
eds.estimate_daily_stations(pcpn_day, precipStationList,
max_stations);
EstPartStations eps = new EstPartStations();
eps.estimate_partial_stations(pcpn_day, dqc.precip_stations,
eps.estimate_partial_stations(pcpn_day, precipStationList,
max_stations);
}
QCStations qcs = new QCStations();
qcs.quality_control_stations(pcpn_day, dqc.precip_stations, max_stations);
qcs.quality_control_stations(pcpn_day, precipStationList, max_stations);
CheckConsistency cc = new CheckConsistency();
cc.check_consistency(pcpn_day, dqc.precip_stations, max_stations);
cc.check_consistency(pcpn_day, precipStationList, max_stations);
bv.restore_bad_values(pcpn_day, dqc.precip_stations, max_stations);
bv.restore_bad_values(pcpn_day, precipStationList, max_stations);
// logMessage("new_qual again %d station qual %d\n", new_qual,
// pdata[pcpn_day].stn[isave].frain[4].qual);
@ -1437,7 +1440,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
/* check if there is any change in the five partial values text fields */
for (k = 0; k < 5; k++) {
Rain frainK = dqc.pdata[pcpn_day].stn[isave].frain[k];
Rain frainK = pdata[pcpn_day].stn[isave].frain[k];
cstr = precipValueStringArray[k];
p = cstr.indexOf('M');
@ -1483,18 +1486,18 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
String cstr;
float val, fdif;
// int[] pcp_in_use = DailyQcUtils.pcp_in_use;
int pcp_flag = dqc.pcp_flag;
int pcp_flag = DailyQcUtils.pcp_flag;
Button rpbutton = QcPrecipOptionsDialog.renderGridsBtn;
int grids_flag = dqc.grids_flag;
int points_flag = dqc.points_flag;
int map_flag = dqc.map_flag;
int contour_flag = dqc.contour_flag;
int grids_flag = DailyQcUtils.grids_flag;
int points_flag = DailyQcUtils.points_flag;
int map_flag = DailyQcUtils.map_flag;
int contour_flag = DailyQcUtils.contour_flag;
Rain frain24 = dqc.pdata[pcpn_day].stn[isave].frain[HOURS_24];
Rain frain24 = pdata[pcpn_day].stn[isave].frain[HOURS_24];
for (k = 0; k < 5; k++) {
Rain frain = dqc.pdata[pcpn_day].stn[isave].frain[k];
Rain frain = pdata[pcpn_day].stn[isave].frain[k];
cstr = precipValueStringArray[k];
val = 0;
@ -1506,13 +1509,13 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
fdif = Math.abs(val - frain.data);
if (p != -1) {
dqc.pdata[pcpn_day].stn[isave].frain[k].data = -1;
pdata[pcpn_day].stn[isave].frain[k].data = -1;
p = -1;
} else if (fdif > .005 && p == -1) {
dqc.pdata[pcpn_day].stn[isave].frain[k].data = val;
dqc.pdata[pcpn_day].stn[isave].frain[k].qual = F_MANUAL;
dqc.pdata[pcpn_day].stn[isave].sflag[k] = -1;
pdata[pcpn_day].stn[isave].frain[k].data = val;
pdata[pcpn_day].stn[isave].frain[k].qual = F_MANUAL;
pdata[pcpn_day].stn[isave].sflag[k] = -1;
}
cstr = null;
@ -1525,7 +1528,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
if (Math.abs(frain24.data - 0.0) < 0.001) {
for (k = 0; k < 4; k++) {
dqc.pdata[pcpn_day].stn[isave].frain[k].data = 0.0f;
pdata[pcpn_day].stn[isave].frain[k].data = 0.0f;
}
}
@ -1539,8 +1542,8 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
// pcp_in_use[time_pos] = -1;
if (dqc.pdata[pcpn_day].used[k] != 0) {
dqc.pdata[pcpn_day].used[k] = 2;
if (pdata[pcpn_day].used[k] != 0) {
pdata[pcpn_day].used[k] = 2;
}
}
@ -1557,7 +1560,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
time_pos = 40 + pcpn_day;
}
if (points_flag == 1 && dqc.pcp_in_use[time_pos] == -1) {
if (points_flag == 1 && DailyQcUtils.pcp_in_use[time_pos] == -1) {
k = 0;
} else if (points_flag == 1 && grids_flag == -1 && map_flag == -1
&& contour_flag == -1) {
@ -1597,24 +1600,24 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
} else {
EstDailyStations eds = new EstDailyStations();
eds.estimate_daily_stations(pcpn_day, dqc.precip_stations,
eds.estimate_daily_stations(pcpn_day, precipStationList,
max_stations);
EstPartStations eps = new EstPartStations();
eps.estimate_partial_stations(pcpn_day, dqc.precip_stations,
eps.estimate_partial_stations(pcpn_day, precipStationList,
max_stations);
}
QCStations qcs = new QCStations();
qcs.quality_control_stations(pcpn_day, dqc.precip_stations, max_stations);
qcs.quality_control_stations(pcpn_day, precipStationList, max_stations);
CheckConsistency cc = new CheckConsistency();
cc.check_consistency(pcpn_day, dqc.precip_stations, max_stations);
cc.check_consistency(pcpn_day, precipStationList, max_stations);
bv.restore_bad_values(pcpn_day, dqc.precip_stations, max_stations);
bv.restore_bad_values(pcpn_day, precipStationList, max_stations);
if (k == 1 || k == 3) {
dqc.grids_flag = 1;
DailyQcUtils.grids_flag = 1;
}
OtherPrecipOptions op = new OtherPrecipOptions();
@ -1623,7 +1626,7 @@ public class EditPrecipStationsDialog extends AbstractMPEDialog implements
}
private String getStationListPath(String qcArea) {
String station_dir = dqc.mpe_station_list_dir;
String station_dir = DailyQcUtils.mpe_station_list_dir;
String dir;
if (qcArea != null) {

View file

@ -68,7 +68,7 @@ public class MPELegendInputHandler extends InputAdapter {
if ((mouseButton == 1 || mouseButton == 3)
&& (MPEDisplayManager.getCurrent().isGroupedt() == false)
&& pe.contains(v[0], v[1])
&& (DrawDQCStations.getInstance().grids_flag == 1 || DrawDQCStations.getInstance().map_flag == 1)) {
&& (DrawDQCStations.grids_flag == 1 || DrawDQCStations.map_flag == 1)) {
return execute(x, y, true);
}

View file

@ -70,6 +70,7 @@ import com.raytheon.viz.mpe.ui.actions.DrawDQCStations;
import com.raytheon.viz.mpe.ui.actions.OtherPrecipOptions;
import com.raytheon.viz.mpe.ui.dialogs.QcPrecipOptionsDialog;
import com.raytheon.viz.mpe.util.DailyQcUtils;
import com.raytheon.viz.mpe.util.DailyQcUtils.Pdata;
import com.raytheon.viz.mpe.util.DailyQcUtils.Station;
import com.raytheon.viz.mpe.util.DailyQcUtils.Stn;
import com.vividsolutions.jts.geom.Coordinate;
@ -125,6 +126,10 @@ public class PointPrecipPlotResource extends
"Blue", "Blue", "Yellow", "Yellow", "Yellow2", "VioletRed", "Red",
"White" };
Pdata pdata[];
ArrayList<Station> station;
private int time_pos = 0;
private Hashtable<String, Stn> pdataMap;
@ -148,6 +153,8 @@ public class PointPrecipPlotResource extends
public PointPrecipPlotResource(PointPrecipResourceData resourceData,
LoadProperties props) {
super(resourceData, props);
pdata = DailyQcUtils.pdata;
station = DailyQcUtils.precip_stations;
prevPcpnDay = 0;
df.setMaximumFractionDigits(2);
df.setMaximumIntegerDigits(4);
@ -172,9 +179,9 @@ public class PointPrecipPlotResource extends
strTree = new STRtree();
gageData = dqc.new Station();
if (!dqc.precip_stations.isEmpty()) {
if (!DailyQcUtils.precip_stations.isEmpty()) {
int i = 0;
for (ListIterator<Station> it = dqc.precip_stations.listIterator(); it
for (ListIterator<Station> it = DailyQcUtils.precip_stations.listIterator(); it
.hasNext();) {
gageData = it.next();
Coordinate xy = new Coordinate();
@ -188,7 +195,7 @@ public class PointPrecipPlotResource extends
kv.append(pm);
dataMap.put(kv.toString(), gageData);
pdataMap.put(kv.toString(),
DailyQcUtils.pdata[DailyQcUtils.pcpn_day].stn[i]);
pdata[DailyQcUtils.pcpn_day].stn[i]);
/* Create a small envelope around the point */
Coordinate p1 = new Coordinate(xy.x + .02, xy.y + .02);
@ -199,7 +206,7 @@ public class PointPrecipPlotResource extends
data.add("STATION: "
+ gageData.hb5
+ " VALUE: "
+ DailyQcUtils.pdata[DailyQcUtils.pcpn_day].stn[i].frain[time_pos].data);
+ pdata[DailyQcUtils.pcpn_day].stn[i].frain[time_pos].data);
strTree.insert(env, data);
i++;
}
@ -276,9 +283,9 @@ public class PointPrecipPlotResource extends
int dcmode = OtherPrecipOptions.dcmode;
int tcmode = OtherPrecipOptions.tcmode;
int dmvalue = dqc.dmvalue;
int tsmax = dqc.tsmax;
int tsmax = DailyQcUtils.tsmax;
boolean frzlvl_flag = dqc.frzlvl_flag;
int gage_char[] = dqc.gage_char;
int gage_char[] = DailyQcUtils.gage_char;
int find_station_flag = dqc.find_station_flag;
String mbuf = "";
String tbuf = "";
@ -304,7 +311,7 @@ public class PointPrecipPlotResource extends
return;
}
if ((station.elev >= 0)
&& (station.elev < dqc.elevation_filter_value)) {
&& (station.elev < DailyQcUtils.elevation_filter_value)) {
return;
}
@ -334,7 +341,7 @@ public class PointPrecipPlotResource extends
for (m = 0; m < tsmax; m++) {
if (station.parm.substring(3, 5)
.equalsIgnoreCase(dqc.ts[m].abr)
.equalsIgnoreCase(DailyQcUtils.ts[m].abr)
&& (DailyQcUtils.dflag[m + 1] == 1)) {
break;
}
@ -347,9 +354,9 @@ public class PointPrecipPlotResource extends
for (m = 0; m < 9; m++) {
if ((m == pdataMap.get(key).frain[time_pos].qual)
&& (dqc.qflag[m] == 1)) {
&& (DailyQcUtils.qflag[m] == 1)) {
break;
} else if ((m == 7) && (dqc.qflag[7] == 1)
} else if ((m == 7) && (DailyQcUtils.qflag[7] == 1)
&& (pdataMap.get(key).frain[time_pos].data == -99)
&& (pdataMap.get(key).frain[time_pos].qual == -99)) {
break;
@ -363,8 +370,8 @@ public class PointPrecipPlotResource extends
/* locate station in data stream */
if (((type == 4) || (type == 5))
&& (DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[time_pos] == 0)
&& (DailyQcUtils.pdata[DailyQcUtils.pcpn_day].level == 0)) {
&& (pdata[DailyQcUtils.pcpn_day].used[time_pos] == 0)
&& (pdata[DailyQcUtils.pcpn_day].level == 0)) {
return;
}
if (((type == 4) || (type == 5))
@ -410,8 +417,8 @@ public class PointPrecipPlotResource extends
tbuf = station.name;
} else if (type == 4) {
if ((DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[time_pos] == 0)
&& (DailyQcUtils.pdata[DailyQcUtils.pcpn_day].level == 0)) {
if ((pdata[DailyQcUtils.pcpn_day].used[time_pos] == 0)
&& (pdata[DailyQcUtils.pcpn_day].level == 0)) {
return;
}
@ -435,8 +442,8 @@ public class PointPrecipPlotResource extends
tbuf = mbuf;
} else if (type == 5) {
if ((DailyQcUtils.pdata[DailyQcUtils.pcpn_day].used[time_pos] == 0)
&& (DailyQcUtils.pdata[DailyQcUtils.pcpn_day].level == 0)) {
if ((pdata[DailyQcUtils.pcpn_day].used[time_pos] == 0)
&& (pdata[DailyQcUtils.pcpn_day].level == 0)) {
return;
}

View file

@ -60,6 +60,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 20, 2009 snaples Initial creation
* Mar 2, 2015 15660 snaples Fixed issues with the file writing and creating the new files.
*
* </pre>
*
@ -107,19 +108,19 @@ public class Compute1HrNeighborList {
DailyQcUtils dqc = DailyQcUtils.getInstance();
Station[] disagg_station_6hr = Disagg6Hr.disagg_station_6hr;
Station[] disagg_station_6hr = null;
Dist[] dist_6hr_to_1hr = Disagg6Hr.dist_6hr_to_1hr;
Dist[] dist_6hr_to_1hr = null;
public static Values_1hr[] valuesReadIn = null;
BufferedWriter disagg_log_fd = Disagg6Hr.disagg_log_fd;
Date station_list_time_stamp_6hr;
Date station_list_time_stamp_6hr = new Date();
String disagg_1hr_neighbors_fd = Disagg6Hr.disagg_1hr_neighbors_fd;
String neighbor_list_file = Disagg6Hr.neighbor_list_file;
String neighbor_list_file = null;
int ret_neighbors = Disagg6Hr.ret_neighbors;
@ -139,9 +140,7 @@ public class Compute1HrNeighborList {
public static Station[] disagg_station_1hr;
// int num_days_to_qc = DailyQcUtils.qcDays;
// static int mpe_dqc_max_precip_neighbors = DailyQcUtils.mpe_dqc_max_precip_neighbors;
int mpe_dqc_max_precip_neighbors = DailyQcUtils.mpe_dqc_max_precip_neighbors;
public Compute1HrNeighborList() {
// default constructor
@ -159,17 +158,20 @@ public class Compute1HrNeighborList {
MeanMonthlyPrecip mmp = new MeanMonthlyPrecip();
Isoh isoh = mmp.getIsoh();
int smonth = dqc.smonth;
int emonth = dqc.emonth;
int smonth = DailyQcUtils.smonth;
int emonth = DailyQcUtils.emonth;
String hb5 = "";
double dist1, dist2, dist;
double[] sorted = new double[dqc.mpe_dqc_max_precip_neighbors];
double[] sorted = new double[mpe_dqc_max_precip_neighbors];
int ind, h, i, ier, l, m, k;
char[] kbuf = new char[200];
QCHRAP hrap_point = new QCHRAP();
float lat, lon;
double conv = .0174533;
disagg_station_6hr = Disagg6Hr.disagg_station_6hr;
dist_6hr_to_1hr = Disagg6Hr.dist_6hr_to_1hr;
neighbor_list_file = Disagg6Hr.neighbor_list_file;
int num_disagg_stations = Disagg6Hr.num_disagg_stations;
int file_error = 0;
String area_id;
@ -189,11 +191,10 @@ public class Compute1HrNeighborList {
disagg_1hr_stations_dir = appsDefaults.getToken("mpe_station_list_dir");
area_id = appsDefaults.getToken("mpe_site_id");
BufferedReader in = null;
BufferedWriter out = disagg_log_fd;
BufferedWriter out = Disagg6Hr.getDisagg_log_fd();
BufferedWriter out2 = null;
try {
// out = new BufferedWriter(new FileWriter(disagg_log_fd));
if (area_id.length() > 0) {
disagg_1hr_stations_path = String.format("%s/%s%s",
@ -210,7 +211,8 @@ public class Compute1HrNeighborList {
}
/* Read the record containing the number of hourly stations. */
int p = in.read(kbuf, 0, 200);
String hstat = in.readLine().trim();
int p = hstat.length();
if (p == -1) {
out.write("could not read number of hourly stations from file\n");
@ -219,10 +221,9 @@ public class Compute1HrNeighborList {
}
ier = Integer.parseInt(kbuf.toString());
num_records = ier;
num_records = Integer.parseInt(hstat);
if (ier < 1) {
if (num_records < 1) {
out.write("could not read number of hourly stations from file\n");
in.close();
return;
@ -249,7 +250,7 @@ public class Compute1HrNeighborList {
/* Read the PPH stations. */
i = 0;
for (ind = 0; ind < num_records; ++ind) {
String pp = in.readLine();
String pp = in.readLine().trim();
if (pp == null) {
out.write(String
@ -266,10 +267,10 @@ public class Compute1HrNeighborList {
lon = s.nextFloat();
// ier=sscanf(kbuf,"%s %s %f %f ",hb5, temp_str, &lat, &lon);
disagg_station_1hr[i] = new DailyQcUtils().new Station();
disagg_station_1hr[i].isoh = new float[24];
disagg_station_1hr[i].hb5 = "";
disagg_station_1hr[i].index = new short[dqc.mpe_dqc_max_precip_neighbors];
disagg_station_1hr[i].index = new short[DailyQcUtils.mpe_dqc_max_precip_neighbors];
disagg_station_1hr[i].parm = "";
disagg_station_1hr[i].cparm = "";
@ -295,7 +296,11 @@ public class Compute1HrNeighborList {
disagg_station_1hr[i].hb5 = hb5;
disagg_station_1hr[i].lat = lat;
disagg_station_1hr[i].lon = lon;
float testlon = lon;
if (testlon > 0) {
testlon = testlon * -1;
}
disagg_station_1hr[i].lon = testlon;
/*
* Set elev to 1 ft. The value of 0 creates problems with
@ -345,10 +350,10 @@ public class Compute1HrNeighborList {
}
if (((int) hrap_point.x - xor) < maxx
&& ((int) hrap_point.y - yor) < maxy
&& ((int) hrap_point.x - xor) >= 0
&& ((int) hrap_point.y - yor) >= 0) {
if (((int) hrap_point.x < maxx)
&& ((int) hrap_point.y < maxy)
&& ((int) hrap_point.x >= xor)
&& ((int) hrap_point.y >=yor)) {
disagg_station_1hr[i].isoh[k] = isoh.value[k][(int) hrap_point.y
- yor][(int) hrap_point.x - xor];
@ -357,7 +362,7 @@ public class Compute1HrNeighborList {
}
i++;
s.close();
}
num_records = num_distinct_1hrs;
@ -394,7 +399,7 @@ public class Compute1HrNeighborList {
}
if (dqc.mpe_dqc_max_precip_neighbors != num_previous_neighbors
if (mpe_dqc_max_precip_neighbors != num_previous_neighbors
|| timestamp_previous_neighbors
.before(station_list_time_stamp_6hr)) {
generate = 1;
@ -402,11 +407,11 @@ public class Compute1HrNeighborList {
} else {
out.write(String.format(
"Reading %d nearest neighbor 1hr stations\n",
dqc.mpe_dqc_max_precip_neighbors));
mpe_dqc_max_precip_neighbors));
for (i = 0; i < Disagg6Hr.num_disagg_stations; i++) {
lines = in.readLine();
for (l = 0; l < dqc.mpe_dqc_max_precip_neighbors; l++) {
for (l = 0; l < mpe_dqc_max_precip_neighbors; l++) {
// read from neighbor list file
// read the 1hr station info for each 6hr station
lines = in.readLine();
@ -438,6 +443,7 @@ public class Compute1HrNeighborList {
generate = 0;
}
s.close();
} else {
generate = 1;
@ -453,9 +459,9 @@ public class Compute1HrNeighborList {
// ---------------------------------------------------------------
out.write(String.format(
"Generating %d nearest neighbor 1hr stations\n",
dqc.mpe_dqc_max_precip_neighbors));
mpe_dqc_max_precip_neighbors));
for (i = 0; i < Disagg6Hr.num_disagg_stations; i++) {
for (l = 0; l < dqc.mpe_dqc_max_precip_neighbors; l++) {
for (l = 0; l < mpe_dqc_max_precip_neighbors; l++) {
sorted[l] = 9999999;
}
@ -482,9 +488,9 @@ public class Compute1HrNeighborList {
// distance from the array.
// Note that the 'sorted' array is sorted literally!
for (l = 0; l < dqc.mpe_dqc_max_precip_neighbors; l++) {
for (l = 0; l < mpe_dqc_max_precip_neighbors; l++) {
if (dist < sorted[l]) {
for (h = dqc.mpe_dqc_max_precip_neighbors - 1; h > l; h--) {
for (h = mpe_dqc_max_precip_neighbors - 1; h > l; h--) {
sorted[h] = sorted[h - 1];
disagg_station_6hr[i].index[h] = disagg_station_6hr[i].index[h - 1];
@ -516,7 +522,7 @@ public class Compute1HrNeighborList {
out2 = new BufferedWriter(new FileWriter(neighbor_list_file));
if (generate == 1) {
in.close();
out2.write(String.format("%d\n", dqc.mpe_dqc_max_precip_neighbors));
out2.write(String.format("%d\n", mpe_dqc_max_precip_neighbors));
File nlf = new File(neighbor_list_file);
station_list_time_stamp_6hr.setTime(nlf.lastModified());
out2.write(String.format("%d\n",
@ -525,17 +531,17 @@ public class Compute1HrNeighborList {
}
/* print out list of 1hr nearest neighbor stations */
for (i = 0; i < Disagg6Hr.num_disagg_stations; i++) {
for (i = 0; i < num_disagg_stations; i++) {
out.write(String
.format("---%s---\n", disagg_station_6hr[i].hb5));
if (generate == 1) {
out2.write(String.format("%s\n", disagg_station_6hr[i].hb5));
}
for (l = 0; l < dqc.mpe_dqc_max_precip_neighbors; l++) {
for (l = 0; l < mpe_dqc_max_precip_neighbors; l++) {
temp_buf = String
.format("%d\t%s\t%5.2f\t%5.2f\t%6.2lf",
.format("%d\t%s\t%5.2f\t%5.2f\t%6.2f",
disagg_station_6hr[i].index[l],
disagg_station_1hr[disagg_station_6hr[i].index[l]].hb5,
disagg_station_1hr[disagg_station_6hr[i].index[l]].lat,
@ -548,7 +554,6 @@ public class Compute1HrNeighborList {
out.write(String.format("%s\n", temp_buf));
}
}
out.close();
out2.close();
} catch (IOException e) {
@ -557,9 +562,6 @@ public class Compute1HrNeighborList {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
if (out2 != null) {
out2.close();
}
@ -588,25 +590,25 @@ public class Compute1HrNeighborList {
int day = 0;
int i, j, k;
int num_disagg_stations = Disagg6Hr.num_disagg_stations;
int[] temp = new int[num_disagg_stations * dqc.mpe_dqc_max_precip_neighbors];
BufferedWriter out = disagg_log_fd;
int[] temp = new int[num_disagg_stations * mpe_dqc_max_precip_neighbors];
BufferedWriter out = Disagg6Hr.getDisagg_log_fd();
disagg_station_6hr = Disagg6Hr.disagg_station_6hr;
int qc_days = DailyQcUtils.qcDays;
try {
// out = new BufferedWriter(new FileWriter(disagg_log_fd));
out.write(" Reading 1hr Precip Gage Values \n");
sorted_list_1hr = new int[num_disagg_stations
* dqc.mpe_dqc_max_precip_neighbors];
* mpe_dqc_max_precip_neighbors];
/* sorted_list_1hr array is array of indexes of 1hr gages */
/* defined in compute_1hr_station_list function */
for (i = 0; i < num_disagg_stations * dqc.mpe_dqc_max_precip_neighbors; i++) {
for (i = 0; i < num_disagg_stations * mpe_dqc_max_precip_neighbors; i++) {
sorted_list_1hr[i] = -1;
}
for (i = 0; i < num_disagg_stations; i++) {
for (j = 0; j < dqc.mpe_dqc_max_precip_neighbors; j++) {
sorted_list_1hr[dqc.mpe_dqc_max_precip_neighbors * i + j] = disagg_station_6hr[i].index[j];
for (j = 0; j < mpe_dqc_max_precip_neighbors; j++) {
sorted_list_1hr[mpe_dqc_max_precip_neighbors * i + j] = disagg_station_6hr[i].index[j];
}
}
@ -631,7 +633,7 @@ public class Compute1HrNeighborList {
.format(" number of non-duplicate 1hr nearest-neighbor stations = %d\n",
sorted_array_size));
valuesReadIn = new Values_1hr[dqc.qcDays * sorted_array_size];
valuesReadIn = new Values_1hr[qc_days * sorted_array_size];
out.write(String.format(
"endtime_disagg = %10.0f starttime_disagg = %10.0f\n",
@ -665,7 +667,7 @@ public class Compute1HrNeighborList {
.format("precip totalling routines found no data for gage %s and missing data substituted \n",
disagg_station_1hr[sorted_list_1hr[i]].hb5));
end_time_temp = endtime_disagg;
for (k = 0; k < dqc.qcDays; k++) {
for (k = 0; k < qc_days; k++) {
valuesReadIn[k * sorted_array_size + i].index_in_1hr_list = sorted_list_1hr[i];
valuesReadIn[k * sorted_array_size + i].ID = disagg_station_1hr[sorted_list_1hr[i]].hb5;
for (j = 0; j < 24; j++) {
@ -691,7 +693,7 @@ public class Compute1HrNeighborList {
end_time_temp = endtime_disagg;
Calendar nt = Calendar.getInstance(TimeZone
.getTimeZone("GMT"));
for (k = 0; k < dqc.qcDays; k++) {
for (k = 0; k < qc_days; k++) {
valuesReadIn[k * sorted_array_size + i].ID = disagg_station_1hr[sorted_list_1hr[i]].hb5;
for (j = 0; j < 24; j++) {
@ -720,17 +722,8 @@ public class Compute1HrNeighborList {
} /* end for (i=0 ... */
out.flush();
out.close();
} catch (IOException e) {
return;
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}

View file

@ -91,7 +91,7 @@ public class DailyQcUtils {
private Date selDate;
public int qcDays;
public static int qcDays;
public int firstTok = 1;
@ -185,7 +185,7 @@ public class DailyQcUtils {
private String mpe_dqc_warningpopup_val = "";
public String mpe_gridmasks;
public static String mpe_gridmasks;
public String mpe_rfc_name;
@ -225,15 +225,15 @@ public class DailyQcUtils {
public String mpe_dev_temperature_dir;
public String mpe_station_list_dir;
public static String mpe_station_list_dir;
public String mpe_climo_list_dir;
public String mpe_prism_dir;
public int mpe_dqc_max_precip_neighbors;
public static int mpe_dqc_max_precip_neighbors;
public int mpe_dqc_max_temp_neighbors;
public static int mpe_dqc_max_temp_neighbors;
public float mpe_dqc_precip_deviation;
@ -301,13 +301,13 @@ public class DailyQcUtils {
public int pid = newPid();
public int emonth;
public static int emonth;
public int smonth;
public static int smonth;
private int max_basins;
public Calendar btime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
public static Calendar btime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
/* Define timefile file extensions. */
public String timefile[][] = {

View file

@ -70,6 +70,7 @@ import com.raytheon.viz.mpe.util.Disagg6Hr.Values_6hr;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 1, 2011 snaples Initial creation
* Mar 2, 2015 15660 snaples Fixed issues with null pointer on writing to closed file.
*
* </pre>
*
@ -79,15 +80,13 @@ import com.raytheon.viz.mpe.util.Disagg6Hr.Values_6hr;
public class Delete1hrDisaggValues {
DailyQcUtils dqc = DailyQcUtils.getInstance();
public void delete1hrDisaggValues() {
Values_1hr[] disaggValues = Disagg6Hr.disaggValues;
BufferedWriter disagg_log_fd = Disagg6Hr.disagg_log_fd;
BufferedWriter disagg_log_fd = Disagg6Hr.getDisagg_log_fd();
String[] obsdate = Disagg6Hr.obsdate;
Date[] obsdate_date_t = Disagg6Hr.obsdate_date_t;
Values_6hr[] values6hr = Disagg6Hr.values6hr;
// int num_days_to_qc = dqc.qcDays;
int num_days_to_qc = DailyQcUtils.qcDays;
int num_disagg_stations = Disagg6Hr.num_disagg_stations;
String ts = "";
@ -102,8 +101,6 @@ public class Delete1hrDisaggValues {
ts = "PZ";
try {
// out = new BufferedWriter(new FileWriter(disagg_log_fd));
/*-----------------------------------------*/
/* populate the HourlyPP structure */
/*-----------------------------------------*/
@ -123,14 +120,14 @@ public class Delete1hrDisaggValues {
out.write("\nIn delete1hrDisaggValues\n");
for (j = 0; j < dqc.qcDays + 1; j++) {
for (j = 0; j < num_days_to_qc + 1; j++) {
out.write("\n");
out.write(String.format(" \t Day %d\n", j));
hourlyPPId.setObsdate(obsdate_date_t[j]);
jj = j;
if (j == dqc.qcDays) {
if (j == num_days_to_qc) {
jj = jj - 1;
}
@ -184,7 +181,6 @@ public class Delete1hrDisaggValues {
out.write("\n");
/* update record */
GagePPWrite.update_gage_rec(hourlyPP);
} else if (j == jj) {
@ -230,7 +226,6 @@ public class Delete1hrDisaggValues {
out.write("\n");
/* update record */
GagePPWrite.update_gage_rec(hourlyPP);
}
@ -240,18 +235,6 @@ public class Delete1hrDisaggValues {
} catch (IOException e) {
return;
}
// finally {
// try {
// if (out != null) {
// out.close();
// }
//
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
}
public int deleteHourlyPP(String where) {

View file

@ -58,6 +58,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 20, 2009 snaples Initial creation
* Mar 2, 2015 15660 snaples Fixed the disagg logging and corrected the procedure.
*
* </pre>
*
@ -114,7 +115,7 @@ public class Disagg6Hr {
public static int disagg_maxx, disagg_maxy;
Calendar station_list_time_stamp_6hr;
Date station_list_time_stamp_6hr;
public static int ret_neighbors = -1;
@ -143,9 +144,9 @@ public class Disagg6Hr {
public static Date end_time_temp;
// int num_days_to_qc;
int num_days_to_qc;
Date btim = dqc.btime.getTime();
Date btim = DailyQcUtils.btime.getTime();
Values_1hr valuesReadIn;
@ -155,7 +156,7 @@ public class Disagg6Hr {
static int first = 0;
int mpe_dqc_max_precip_neighbors = dqc.mpe_dqc_max_precip_neighbors;
int mpe_dqc_max_precip_neighbors = DailyQcUtils.mpe_dqc_max_precip_neighbors;
DisaggGridMethod dgm = new DisaggGridMethod();
@ -228,34 +229,36 @@ public class Disagg6Hr {
}
}
public void disagg6hr() {
public void disagg6hr() throws IOException {
long start_time, end_time;
String logdir;
String station_list_dir = dqc.mpe_station_list_dir;
String station_list_dir = DailyQcUtils.mpe_station_list_dir;
String disagg_log_file;
String gridmask_dir = dqc.mpe_gridmasks;
String gridmask_dir = DailyQcUtils.mpe_gridmasks;
String station_list_file;
String mpe_disagg_execute;
// char buf[] = new char[10];
String buf = "";
String cval6hr = "";
station_list_time_stamp_6hr = SimulatedTime.getSystemTime().getTime();
Date currentTime = SimulatedTime.getSystemTime().getTime();
String datestring = "";
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
final SimpleDateFormat ddf = new SimpleDateFormat("yyyyMMddHHMM");
ddf.setTimeZone(TimeZone.getTimeZone("GMT"));
int max_stations = dqc.precip_stations.size();
int max_stations = DailyQcUtils.precip_stations.size();
ArrayList<Station> station = new ArrayList<Station>();
station = DailyQcUtils.precip_stations;
num_days_to_qc = DailyQcUtils.qcDays;
int ier, k = 0, j, i, ii;
int emonth = dqc.emonth;
int smonth = dqc.smonth;
int emonth = DailyQcUtils.emonth;
int smonth = DailyQcUtils.smonth;
MeanMonthlyPrecip mmp = new MeanMonthlyPrecip();
Isoh isoh = mmp.getIsoh();
String area_val_local = dqc.currentQcArea;
Pdata pdata[] = dqc.pdata;
String area_val_local = DailyQcUtils.currentQcArea;
Pdata pdata[] = DailyQcUtils.pdata;
AppsDefaults appsDefaults = AppsDefaults.getInstance();
QCHRAP hrap_point = new QCHRAP();
@ -265,9 +268,7 @@ public class Disagg6Hr {
start_time = tt.getTime();
// num_days_to_qc = DailyQcUtils.qcDays;
// station = DailyQcUtils.precip_stations;
currentTime.getTime();
datestring = ddf.format(currentTime);
@ -281,6 +282,10 @@ public class Disagg6Hr {
neighbor_list_file = String.format("%s/%s_disagg_1hr_neighbors",
gridmask_dir, area_val_local);
disagg_stations_fd = station_list_file;
BufferedReader in = null;
BufferedWriter out = null;
FileWriter fd_log = null;
/*---------------------------------------------*/
/* First time only: */
@ -309,27 +314,43 @@ public class Disagg6Hr {
disagg_log_file = String
.format("%s/disagg_%sz", logdir, datestring);
// BufferedWriter disagg_log_fd = null;
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(disagg_stations_fd));
disagg_log_fd = new BufferedWriter(new FileWriter(
disagg_log_file));
fd_log = new FileWriter(disagg_log_file);
out = new BufferedWriter(fd_log);
disagg_log_fd = out;
disagg_log_fd.write("\t\t-- 6hr to 1hr Disaggregation -- \n");
disagg_log_fd.write("\t\t-- Version AWIPS II 11.9.0-1 -- \n");
disagg_log_fd.write("hydrologic day = 12z - 12z\n");
first = 1;
disagg_method = appsDefaults.getToken("mpe_disagg_method");
} catch (IOException e) {
statusHandler.handle(Priority.WARN,
"Warning: Could not open disagg log file...\n"
+ "exiting from disagg routine..mpe_editor continuing...\n",
e);
e.printStackTrace();
return;
}
} // first block
logdir = appsDefaults.getToken("mpe_editor_logs_dir");
disagg_log_file = String.format("%s/disagg_%sz", logdir, datestring);
disagg_method = appsDefaults.getToken("mpe_disagg_method");
delete_values = appsDefaults.getToken("mpe_disagg_delete_1hr");
if(delete_values == null){
delete_values = "on";
}
disagg_log_fd.write(String.format(
"6hr disagg station list file name: %s\n",
station_list_file));
try {
disagg_log_fd.write(String.format(
"6hr disagg station list file name: %s\n",
station_list_file));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
xor = (int) MPEDataManager.getInstance().getHRAPExtent()
.getMinX();
@ -345,15 +366,23 @@ public class Disagg6Hr {
endtime_disagg = btim;
Calendar nt = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
nt.setTime(endtime_disagg);
nt.add(Calendar.SECOND, -(dqc.qcDays * 86400));
nt.add(Calendar.SECOND, -(num_days_to_qc * 86400));
starttime_disagg = nt.getTime();
end_time_temp = endtime_disagg;
disagg_log_fd.write(String.format(
" endtime = %10.0f starttime = %10.0f\n",
(float) endtime_disagg.getTime(),
(float) starttime_disagg.getTime()));
try {
disagg_log_fd.write(String.format(
" endtime = %10.0f starttime = %10.0f\n",
(float) endtime_disagg.getTime(),
(float) starttime_disagg.getTime()));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(in == null){
in = new BufferedReader(new FileReader(disagg_stations_fd));
}
buf = in.readLine();
num_disagg_stations = Integer.parseInt(buf);
if (num_disagg_stations <= 0) {
@ -363,11 +392,11 @@ public class Disagg6Hr {
return;
}
disagg_station_6hr = new Station[(dqc.qcDays * num_disagg_stations)];
disaggValues = new Values_1hr[(dqc.qcDays * num_disagg_stations)];
values6hr = new Values_6hr[(dqc.qcDays * num_disagg_stations)];
disagg_station_6hr = new Station[(num_days_to_qc * num_disagg_stations)];
disaggValues = new Values_1hr[(num_days_to_qc * num_disagg_stations)];
values6hr = new Values_6hr[(num_days_to_qc * num_disagg_stations)];
for (int z = 0; z < (dqc.qcDays * num_disagg_stations); z++) {
for (int z = 0; z < (num_days_to_qc * num_disagg_stations); z++) {
disagg_station_6hr[z] = dqc.new Station();
disaggValues[z] = new Values_1hr();
values6hr[z] = new Values_6hr();
@ -378,12 +407,12 @@ public class Disagg6Hr {
dist_6hr_to_1hr[z] = new Dist();
}
obsdate = new String[(dqc.qcDays + 1)];
obsdate_date_t = new Date[dqc.qcDays + 1];
obsdate = new String[(num_days_to_qc + 1)];
obsdate_date_t = new Date[num_days_to_qc + 1];
disagg_log_fd.write(" 6hr Disagg Station List\n");
for (j = 0; j < dqc.qcDays; j++) {
for (j = 0; j < num_days_to_qc; j++) {
for (i = 0; i < num_disagg_stations; i++) {
index = (j * num_disagg_stations) + i;
@ -405,15 +434,9 @@ public class Disagg6Hr {
disagg_station_6hr[index].parm = "";
disagg_station_6hr[index].cparm = "";
// char[] kbuf = new char[200];
if (j == 0) {
// int p = in.read(kbuf, 0, 80);
//
// if (p <= 0) {
if (in.ready()) {
buf = in.readLine();
// break;
// }
}
Scanner s = new Scanner(buf);
@ -432,7 +455,7 @@ public class Disagg6Hr {
ll);
Coordinate gridCell = null;
try {
try {
// try {
gridCell = rc
.asGridCell(
com.raytheon.uf.common.hydro.spatial.HRAP
@ -445,8 +468,7 @@ public class Disagg6Hr {
} catch (FactoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (Exception e) {
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@ -476,17 +498,17 @@ public class Disagg6Hr {
}
if ((((int) hrap_point.x - xor) < maxx)
&& (((int) hrap_point.y - yor) < maxy)
&& (((int) hrap_point.x - xor) >= 0)
&& (((int) hrap_point.y - yor) >= 0)) {
if ((((int) hrap_point.x) < maxx)
&& (((int) hrap_point.y) < maxy)
&& (((int) hrap_point.x >= xor))
&& (((int) hrap_point.y >= yor))) {
disagg_station_6hr[i].isoh[k] = isoh.value[k][(int) hrap_point.y
- yor][(int) hrap_point.x - xor];
}
}
s.close();
} else {
values6hr[index].hrapx_local = values6hr[i].hrapx_local;
values6hr[index].hrapy_local = values6hr[i].hrapy_local;
@ -558,16 +580,16 @@ public class Disagg6Hr {
}
obsdate[dqc.qcDays] = "";
obsdate[num_days_to_qc] = "";
// note that end_time_temp is not being decremented
// as in the above loop because it will be decremented
// one extra time in the loop already.
obsdate[dqc.qcDays] = sdf.format(end_time_temp);
obsdate[num_days_to_qc] = sdf.format(end_time_temp);
disagg_log_fd.write(String.format(
"datestring for disagg day %d = %s\n", dqc.qcDays,
obsdate[dqc.qcDays]));
obsdate_date_t[dqc.qcDays] = end_time_temp;
"datestring for disagg day %d = %s\n", num_days_to_qc,
obsdate[num_days_to_qc]));
obsdate_date_t[num_days_to_qc] = end_time_temp;
/* print 6hr values to log */
disagg_log_fd.write("\n");
@ -577,7 +599,7 @@ public class Disagg6Hr {
index = -1;
for (i = 0; i < num_disagg_stations; i++) {
for (j = 0; j < dqc.qcDays; j++) {
for (j = 0; j < num_days_to_qc; j++) {
index = (j * num_disagg_stations) + i;
if (values6hr[index].ID
@ -665,18 +687,13 @@ public class Disagg6Hr {
long stm = st.lastModified();
Date std = SimulatedTime.getSystemTime().getTime();
std.setTime(stm);
station_list_time_stamp_6hr.setTime(std);
station_list_time_stamp_6hr.setTime(std.getTime());
st = new File(neighbor_list_file);
ret_neighbors = (int) st.lastModified();
// disagg_log_fd.close();
c1n.compute1hrStationList();
c1n.read1hrGageVals();
}
// disagg_log_fd = new BufferedWriter(new FileWriter(
// disagg_log_file));
disagg_log_fd.write("---------------------\n");
// disagg_log_fd.close();
/*---------------------------------------------*/
/* disagg 6hr to 1hr values */
@ -727,31 +744,9 @@ public class Disagg6Hr {
disagg_log_fd.close();
in.close();
// return;
} catch (IOException e) {
statusHandler
.handle(Priority.WARN,
"Warning: Could not open disagg log file...\n"
+ "exiting from disagg routine..mpe_editor continuing...\n",
e);
e.printStackTrace();
return;
} finally {
try {
if (disagg_log_fd != null) {
disagg_log_fd.close();
}
if (in != null) {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
// here
}
public static BufferedWriter getDisagg_log_fd() {
return disagg_log_fd;
} // here
}

View file

@ -71,7 +71,7 @@ public class DisaggPointMethod {
double[][] totals_1hr;
int mpe_dqc_max_precip_neighbors = dqc.mpe_dqc_max_precip_neighbors;
int mpe_dqc_max_precip_neighbors = DailyQcUtils.mpe_dqc_max_precip_neighbors;
Dist[] dist_6hr_to_1hr = Disagg6Hr.dist_6hr_to_1hr;
@ -99,7 +99,7 @@ public class DisaggPointMethod {
float stotal = 0.f;
int num_missing_periods = 0;
int num_disagg_stations = Disagg6Hr.num_disagg_stations;
int num_days_to_qc = dqc.qcDays;
int num_days_to_qc = DailyQcUtils.qcDays;
// int num_1hrs_reported = 0;
boolean go_to_next_neighbor = false;
boolean next_6hr_station = false;

View file

@ -36,6 +36,7 @@ import com.raytheon.viz.mpe.util.DailyQcUtils.Station;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 23, 2009 snaples Initial creation
* Mar 2, 2015 15660 snaples Fixed issue with if statement testing CPARM and checking for both values to be true, broken logic.
*
* </pre>
*
@ -133,8 +134,8 @@ public class InitPrecipClimo {
continue;
}
if (tokens[1].equalsIgnoreCase("PPMPBCM")
&& tokens[1].equalsIgnoreCase("PPMRZCM")) {
if (!(tokens[1].equalsIgnoreCase("PPMPBCM"))
&& !(tokens[1].equalsIgnoreCase("PPMRZCM"))) {
line = in.readLine();
++record_count;
continue;

View file

@ -44,6 +44,7 @@ import com.raytheon.viz.mpe.core.MPEDataManager;
* ------------ ---------- ----------- --------------------------
* Feb 24, 2009 snaples Initial creation
* April , 2012 8672 lbousaidi fixed the reading of the PRISM data.
* Mar 2, 2015 15660 snaples Fixed problem with color scale using wrong values. Causing grids to be all zeros.
* </pre>
*
* @author snaples
@ -90,9 +91,8 @@ public class MeanMonthlyPrecip {
displayUnit = NonSI.INCH;
dataUnit = SI.MILLIMETER;
cmc.setDisplayUnit(displayUnit);
cmc.setColorMapUnit(SI.MILLIMETER);
cmc.setDataUnit(dataUnit);
UnitConverter dataToImage = cmc.getColorMapToDisplayConverter();//cmc.getDataToImageConverter();
UnitConverter dataToImage = cmc.getDataToImageConverter();
/*
* Loop over the months. Determine for which months PRISM data are

View file

@ -38,6 +38,7 @@ import com.raytheon.viz.mpe.util.Disagg6Hr.Values_6hr;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 22, 2009 snaples Initial creation
* Mar 2, 2015 15660 snaples Fixed issue with writing to file after stream was closed.
*
* </pre>
*
@ -47,16 +48,14 @@ import com.raytheon.viz.mpe.util.Disagg6Hr.Values_6hr;
public class Write1hrVals6HrGages {
private DailyQcUtils dqc = DailyQcUtils.getInstance();
public void write1hrValuesFor6hrGages() {
Values_1hr[] disaggValues = Disagg6Hr.disaggValues;
BufferedWriter disagg_log_fd = Disagg6Hr.disagg_log_fd;
BufferedWriter disagg_log_fd = Disagg6Hr.getDisagg_log_fd();
String[] obsdate = Disagg6Hr.obsdate;
Date[] obsdate_date_t = Disagg6Hr.obsdate_date_t;
Values_6hr[] values6hr = Disagg6Hr.values6hr;
int num_days_to_qc = dqc.qcDays;
int num_days_to_qc = DailyQcUtils.qcDays;
int num_disagg_stations = Disagg6Hr.num_disagg_stations;
String ts = "";
@ -71,8 +70,6 @@ public class Write1hrVals6HrGages {
ts = "PZ";
try {
// out = new BufferedWriter(new FileWriter(disagg_log_fd));
/*-----------------------------------------*/
/* populate the HourlyPP structure */
/*-----------------------------------------*/
@ -273,20 +270,8 @@ public class Write1hrVals6HrGages {
} /* end for (i=0;i<num_disagg_stations;i++) */
} /* end for (j=0;j<num_days_to_qc+1;j++) */
// out.close();
} catch (IOException e) {
return;
}
// finally {
// try {
// if (out != null) {
// out.close();
// }
//
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
}
}

View file

@ -63,16 +63,16 @@ public class WriteQPFGrids {
// fprintf(fp,"%d %d %d %d %d\n",hrap_grid->hrap_minx,hrap_grid->hrap_miny,hrap_grid->maxi
// ,hrap_grid->maxj,iflag);
StringBuffer sb = new StringBuffer();
sb.append(String.format("%d %d %d %d %d", dqc.getHrap_grid().hrap_minx,
dqc.getHrap_grid().hrap_miny, dqc.getHrap_grid().maxi, dqc.getHrap_grid().maxj, iflag));
sb.append(String.format("%d %d %d %d %d", DailyQcUtils.getHrap_grid().hrap_minx,
DailyQcUtils.getHrap_grid().hrap_miny, DailyQcUtils.getHrap_grid().maxi, DailyQcUtils.getHrap_grid().maxj, iflag));
out.write(sb.toString());
out.newLine();
// for (j = hrap_grid.maxj - hrap_grid.hrap_miny - 1; j >= 0; j--) {
for (i = 0; i < dqc.getHrap_grid().maxi; i++) {
for (i = 0; i < DailyQcUtils.getHrap_grid().maxi; i++) {
sb.setLength(0);
for (j = 0; j < dqc.getHrap_grid().maxj; j++) {
sb.append(String.format(" %5d", dqc.pcp.value[i][j]));
for (j = 0; j < DailyQcUtils.getHrap_grid().maxj; j++) {
sb.append(String.format(" %5d", DailyQcUtils.pcp.value[i][j]));
}
out.write(sb.toString());
out.newLine();

View file

@ -51,7 +51,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 20, 2014 3353 rferrel Initial creation
*
* Feb 26, 2015 3353 rjpeter Make modal optional.
* </pre>
*
* @author rferrel
@ -71,9 +71,10 @@ public class GenerateGeoDataSetDialog extends CaveSWTDialog {
* @param parentShell
* @param site
* @param gmd
* @param modal
*/
protected GenerateGeoDataSetDialog(Shell parentShell, String site,
GeospatialMetadata gmd) {
GeospatialMetadata gmd, boolean modal) {
/*
* This needs to be a blocking dialog. The return value is used to
* placed an entry in WarngenLayer's siteMap. Several layers of calls in
@ -84,7 +85,8 @@ public class GenerateGeoDataSetDialog extends CaveSWTDialog {
* way of being informed when the siteMap is updated. Also synchronize
* on siteMap become more complicated.
*/
super(parentShell, SWT.PRIMARY_MODAL | SWT.BORDER, CAVE.NONE);
super(parentShell, (modal ? SWT.PRIMARY_MODAL : 0) | SWT.BORDER,
CAVE.NONE);
this.site = site;
this.gmd = gmd;
}

View file

@ -121,18 +121,18 @@ import com.vividsolutions.jts.geom.Polygon;
* Apr 27, 2011 #9250 bkowal getStyle and getName are now used to
* get the style and name associated with
* a FontData object.
* Apr 16, 2012 #14515 Qinglu Lin Added return at the beginning of changeTemplate()
* Apr 16, 2012 #14515 Qinglu Lin Added return at the beginning of changeTemplate()
* if the newly selected product is same as current one.
* Jul 10, 2012 #15099 Qinglu Lin Add updatePolygon() and apply it in xxxSelected methods.
* Jul 10, 2012 #15099 Qinglu Lin Add updatePolygon() and apply it in xxxSelected methods.
* Jul 26, 2012 #15227 Qinglu Lin Added removeDuplicateVertices(), removeOverlaidSegments(),
* adjustLatLon(), etc.
* Sep 05, 2012 DR 15261 D. Friedman Prevent additional counties from being selected for EXPs
* Sep 27, 2012 #1196 rferrel Refactored to use non-blocking dialogs
* Oct 03, 2012 DR 15426 Qinglu Lin Unlock WarnGen GUI for COR, implemented in corSelected();
* but lock immediate cause, implemented in individual template.
* Nov 02, 2012 DR 15455 Qinglu Lin Added warngenLayer.setWarningAction() in resetPressed()
* Nov 02, 2012 DR 15455 Qinglu Lin Added warngenLayer.setWarningAction() in resetPressed()
* and in updateListSelected().
* Dec 20, 2012 DR 15537 Qinglu Lin Changed the assigned value to trackEditable from false
* Dec 20, 2012 DR 15537 Qinglu Lin Changed the assigned value to trackEditable from false
* to true in boxSelected().
* Jan 24, 2013 DR 15723 Qinglu Lin Invoked WarngenLayer's initRemovedGids().
* Feb 7, 2013 DR 15799 Qinglu Lin Added setPolygonLocked(false) to conSelected(), newSelected(); added
@ -158,6 +158,7 @@ import com.vividsolutions.jts.geom.Polygon;
* May 09, 2014 DR16694 m.gamazaychikov Fixed disabled duration menu after creating text for a COR SVS.
* Jul 01, 2014 DR 17450 D. Friedman Use list of templates from backup site.
* Jul 21, 2014 3419 jsanchez Created a hidden button to make recreating polygons easier.
* Feb 26, 2015 3353 rjpeter Fixed NPE on clear.
* </pre>
*
* @author chammack
@ -172,7 +173,7 @@ public class WarngenDialog extends CaveSWTDialog implements
* This flag allows a hidden button to appear to help recreating warning
* polygons that had issues in the feed.
*/
private boolean debug = false;
private final boolean debug = false;
private static final int BULLET_WIDTH = 390;
@ -181,7 +182,7 @@ public class WarngenDialog extends CaveSWTDialog implements
private static final int FONT_HEIGHT = 9;
private class TemplateRunnerInitJob extends Job {
private String site;
private final String site;
public TemplateRunnerInitJob() {
super("Template Runner Initialization");
@ -1132,16 +1133,18 @@ public class WarngenDialog extends CaveSWTDialog implements
if ((followupData != null)
&& (WarningAction.valueOf(followupData.getAct()) == WarningAction.NEW)) {
if (!redrawFromWarned())
if (!redrawFromWarned()) {
return;
}
}
if (((followupData == null) || ((WarningAction.valueOf(followupData
.getAct()) == WarningAction.CON) && warngenLayer
.conWarnAreaChanged(followupData)))
&& !polygonLocked && !trackLocked) {
if (!redrawFromWarned())
if (!redrawFromWarned()) {
return;
}
}
// Need to check again because redraw may have failed.
@ -1313,7 +1316,8 @@ public class WarngenDialog extends CaveSWTDialog implements
warngenLayer.resetState();
warngenLayer.getStormTrackState().duration = ((DurationData) durationList
.getData(durationList.getItem(durationList.getSelectionIndex()))).minutes;
durationList.setEnabled(warngenLayer.getConfiguration().isEnableDuration());
durationList.setEnabled(warngenLayer.getConfiguration()
.isEnableDuration());
if (lineOfStorms.getSelection()) {
selectLineOfStorms();
} else {
@ -1587,7 +1591,9 @@ public class WarngenDialog extends CaveSWTDialog implements
warngenLayer.setOldWarningPolygon(null);
warngenLayer.resetInitialFrame();
warngenLayer.setTemplateName(templateName);
warngenLayer.state.followupData = null;
if (warngenLayer.state != null) {
warngenLayer.state.followupData = null;
}
warngenLayer.getStormTrackState().endTime = null;
damBreakInstruct = null;
extEndTime = null;

View file

@ -154,24 +154,24 @@ import com.vividsolutions.jts.io.WKTReader;
* 02/01/2012 DR 14491 D. Friedman Load/unload only the maps not already loaded
* 02/28/2012 DR 13596 Qinglu Lin Call GisUtil.restoreAlaskaLon() in figurePoint().
* 03/19/2012 DR 14690 Qinglu Lin While newHatchedArea==null, handle the polygon differently
* for initial warning and followup (CON); and
* for initial warning and followup (CON); and
* convert ratio to percentage while doing comparison.
* 10/29/2012 DR 15479 Qinglu Lin Added code to call removeDuplicateCoordinate()
* 10/29/2012 DR 15479 Qinglu Lin Added code to call removeDuplicateCoordinate()
* in redrawBoxFromHatched().
* 11/02/2012 DR 15455 Qinglu Lin Added setWarningAction(), called redrawBoxFromTrack() while
* warningAction is neither null nor WarningAction.NEW, removed
* some code from redrawBoxFromHatched().
* warningAction is neither null nor WarningAction.NEW, removed
* some code from redrawBoxFromHatched().
* 11/15/2012 DR 15430 D. Friedman Use correct county/zone in createGeometryForWatches.
* 11/29/2012 DR 15571 Qinglu Lin Called compuateCurrentStormCenter() in getStormLocations();
* For CON, CAN, and COR, calculate Coordinate array, cc, specifically in
* For CON, CAN, and COR, calculate Coordinate array, cc, specifically in
* getStormLocations().
* 12/10/2012 DR 15571 Qinglu Lin Change warningAction's initialization from null to WarningAction.NEW, and add code
* in getStormLocations() for handling case when warningAction equals WarningAction.NEW;
* 12/13/2012 DR 15559 Qinglu Lin Added code to call WarngenUIState's adjustPolygon().
* 12/17/2012 DR 15571 Qinglu Lin For hydro products,futurePoints is null. Resolved an issue caused by trying to get
* 12/17/2012 DR 15571 Qinglu Lin For hydro products,futurePoints is null. Resolved an issue caused by trying to get
* Coordinate[] from futurePoints.
* 12/18/2012 DR 15571 Qinglu Lin Resolved coordinate issue in TML line caused by clicking Restart button.
* 01/24/2013 DR 15723 Qinglu Lin Added initRemovedGids() and updated updateWarnedAreas() to prevent the removed
* 01/24/2013 DR 15723 Qinglu Lin Added initRemovedGids() and updated updateWarnedAreas() to prevent the removed
* counties from being re-hatched.
* 03/06/2013 DR 15831 D. Friedman Use area inclusion filter in followups.
* 03/28/2013 DR 15973 Qinglu Lin Added adjustVertex() and applied it invalid polygon.
@ -207,12 +207,12 @@ import com.vividsolutions.jts.io.WKTReader;
* 12/17/2013 DR 16567 Qinglu Lin Added findLargestGeometry() and findLargestQuadrant(), and updated
* populateStrings() and paintText().
* 01/09/2014 DR 16974 D. Friedman Improve followup redraw-from-hatched-area polygons.
* 02/07/2014 DR16090 m.gamazaychikov Added GeomMetaDataUpdateNotificationObserver class to get notification
* 02/07/2014 DR16090 m.gamazaychikov Added GeomMetaDataUpdateNotificationObserver class to get notification
* when geometry file get updated to re-read them in.
* 02/19/2014 2819 randerso Removed unnecessary .clone() call
* 03/17/2014 DR 16309 Qinglu Lin Updated getWarningAreaFromPolygon(); changed searchCountyGeospatialDataAccessor) to
* 03/17/2014 DR 16309 Qinglu Lin Updated getWarningAreaFromPolygon(); changed searchCountyGeospatialDataAccessor) to
* searchGeospatialDataAccessor() and updated it; changed getCountyGeospatialDataAcessor()
* to getGeospatialDataAcessor(); changed getAllCountyUgcs() to getAllUgcs(); changed
* to getGeospatialDataAcessor(); changed getAllCountyUgcs() to getAllUgcs(); changed
* getUgcsForWatches() to getUgcsForCountyWatches().
* 04/15/2014 DR 17247 D. Friedman Rework error handling in AreaHatcher.
* 04/23/2014 DR 16356 Qinglu Lin Updated initializeState() and added reset().
@ -221,7 +221,7 @@ import com.vividsolutions.jts.io.WKTReader;
* 06/23/2014 DR16322 m.gamazaychikov Fix Warngen unloading previously loaded maps.
* 07/01/2014 DR 17450 D. Friedman Use list of templates from backup site.
* 07/24/2014 3429 mapeters Updated deprecated drawLine() calls.
* 07/28/2014 DR 17475 Qinglu Lin Updated populateStrings() and findLargestQuadrant(), removed findLargestGeometry(),
* 07/28/2014 DR 17475 Qinglu Lin Updated populateStrings() and findLargestQuadrant(), removed findLargestGeometry(),
* added createAreaAndCentroidMaps() and movePopulatePt(), updated paintText() to center W.
* 08/01/2014 3471 mapeters Updated deprecated createShadedShape() calls.
* 08/20/2014 3353 rferrel Generating Geo Spatial data set no longer on the UI thread.
@ -234,6 +234,7 @@ import com.vividsolutions.jts.io.WKTReader;
* any of them is missing.
* 11/03/2014 3353 rferrel Ignore GeoSpatialData notification when this is the instance layer will do an update.
* 02/09/2015 3954 dlovely Only draw "W" if the county is displayed.
* 02/25/2014 3353 rjpeter Fix synchronized use case, updated to not create dialog before init is finished.
* </pre>
*
* @author mschenke
@ -289,9 +290,13 @@ public class WarngenLayer extends AbstractStormTrackResource {
public GeospatialDataAccessor(GeospatialDataList geoData,
AreaSourceConfiguration areaConfig) {
if ((geoData == null) || (areaConfig == null)) {
if (geoData == null) {
throw new IllegalArgumentException(
"GeospatialDataAccessor must not be null");
"GeospatialDataAccessor must have geospatial data, geoData is null.");
}
if (areaConfig == null) {
throw new IllegalArgumentException(
"GeospatialDataAccessor must have area source configuration, areaConfig is null.");
}
this.geoData = geoData;
this.areaConfig = areaConfig;
@ -389,7 +394,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
private class CustomMaps extends Job {
private Set<String> customMaps = new HashSet<String>();
private final Set<String> customMaps = new HashSet<>();
private Set<String> mapsToLoad;
@ -483,7 +488,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
this.warningArea = this.warningPolygon = null;
}
if (warningArea != null && warningPolygon != null) {
if ((warningArea != null) && (warningPolygon != null)) {
Polygon inputWarningPolygon = warningPolygon;
Polygon outputHatchedArea = null;
Geometry outputHatchedWarningArea = null;
@ -522,7 +527,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
adjustPolygon_counter += 1;
}
int counter = 0;
if (!outputHatchedArea.isValid() && counter < 2) {
if (!outputHatchedArea.isValid() && (counter < 2)) {
System.out
.println("calling adjustVertex & alterVertexes: loop #"
+ counter);
@ -545,7 +550,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
int inner_counter = 0;
System.out.println("");
while (!outputHatchedArea.isValid()
&& inner_counter < 5) {
&& (inner_counter < 5)) {
System.out
.println(" Calling alterVertexes #"
+ inner_counter);
@ -674,14 +679,11 @@ public class WarngenLayer extends AbstractStormTrackResource {
Object payload = message.getMessagePayload();
if (payload instanceof GenerateGeospatialDataResult) {
GenerateGeospatialDataResult result = (GenerateGeospatialDataResult) payload;
synchronized (warngenLayer.ignoreNotifications) {
synchronized (siteMap) {
String curKey = result.getArea() + "."
+ result.getSite();
if (warngenLayer.ignoreNotifications
.contains(curKey)) {
warngenLayer.ignoreNotifications.remove(curKey);
} else {
if (warngenLayer.ignoreNotifications.remove(curKey) == false) {
siteMap.remove(curKey);
initWarngen = true;
}
@ -1295,20 +1297,24 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (dataSet != null) {
updateGeoData(gData, dataSet, gmd, currKey, tq0);
} else {
// This makes sure dialog exists and is open
createDialog();
/*
* Add to list prior to opening the genDialog. That
* way if the notfication arrives prior to or after
* closing the genDialog the notfication will be
* ignored.
*/
synchronized (ignoreNotifications) {
ignoreNotifications.add(currKey);
ignoreNotifications.add(currKey);
GenerateGeoDataSetDialog genDialog = null;
if (dialog != null && dialog.isDisposed() == false) {
genDialog = new GenerateGeoDataSetDialog(
dialog.getShell(), site, gmd, true);
} else {
genDialog = new GenerateGeoDataSetDialog(
PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getShell(), site, gmd, false);
}
GenerateGeoDataSetDialog genDialog = new GenerateGeoDataSetDialog(
dialog.getShell(), site, gmd);
// Assume this is a blocking dialog.
genDialog.open();
@ -1520,7 +1526,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
"Unable to load local WarnGen configuration.", e);
}
}
if (dc != null && dialogConfig != null) {
if ((dc != null) && (dialogConfig != null)) {
dialogConfig.setDefaultTemplate(dc.getDefaultTemplate());
dialogConfig.setMainWarngenProducts(dc.getMainWarngenProducts());
dialogConfig.setOtherWarngenProducts(dc.getOtherWarngenProducts());
@ -1530,12 +1536,12 @@ public class WarngenLayer extends AbstractStormTrackResource {
boolean shortTag = false;
boolean locTag = false;
String infoType = null;
if (backupOfficeShort == null
|| backupOfficeShort.trim().length() == 0) {
if ((backupOfficeShort == null)
|| (backupOfficeShort.trim().isEmpty())) {
shortTag = true;
}
if (backupOfficeLoc == null
|| backupOfficeLoc.trim().length() == 0) {
if ((backupOfficeLoc == null)
|| (backupOfficeLoc.trim().isEmpty())) {
locTag = true;
}
if (shortTag && locTag) {
@ -1661,8 +1667,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
throws Exception {
Set<String> ugcs = new HashSet<String>();
GeospatialDataAccessor gda = getGeospatialDataAcessor(type);
for (String fips : gda.getAllFipsInArea(gda.buildArea(polygon)))
for (String fips : gda.getAllFipsInArea(gda.buildArea(polygon))) {
ugcs.add(FipsUtil.getUgcFromFips(fips));
}
return ugcs;
}
@ -1689,13 +1696,14 @@ public class WarngenLayer extends AbstractStormTrackResource {
* changed again? A ticket should be opened for this to be resolved.
*/
String templateName;
if (type == GeoFeatureType.COUNTY)
if (type == GeoFeatureType.COUNTY) {
templateName = "tornadoWarning";
else if (type == GeoFeatureType.MARINE)
} else if (type == GeoFeatureType.MARINE) {
templateName = "specialMarineWarning";
else
} else {
throw new IllegalArgumentException(
"Unsupported geo feature type " + type);
}
WarngenConfiguration config = WarngenConfiguration.loadConfig(
templateName, getLocalizedSite(), null);
loadGeodataForConfiguration(config);
@ -3376,7 +3384,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
areaM = warningAreaM.getArea();
geomIndex = i;
while (i + 1 < geomNum) {
while ((i + 1) < geomNum) {
warningAreaN = warningArea.getGeometryN(i + 1);
prefixN = GeometryUtil.getPrefix(warningAreaN.getUserData());
if (prefixN.equals(prefixM)) {
@ -3418,7 +3426,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
geomN = gd.getGeometry();
CountyUserData cud = (CountyUserData) geomN.getUserData();
prefixN = cud.gid;
if (prefixN.length() > 0 && prefixM.length() > 0
if ((prefixN.length() > 0) && (prefixM.length() > 0)
&& !prefixN.equals(prefixM)) {
if (GeometryUtil.contains(geomN, populatePtGeom)) {
// W is inside a county. Use default centroid of a
@ -3431,7 +3439,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
loop = 1;
while (GeometryUtil.contains(geomN, populatePtGeom)
&& loop < maxLoop) {
&& (loop < maxLoop)) {
// W is still inside a county, move W to the largest
// quadrant
warningAreaM = findLargestQuadrant(gf, warningAreaM);
@ -3750,9 +3758,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
;
}
}
if (null != intersections[index] && intersections[index].isValid())
if ((null != intersections[index]) && intersections[index].isValid()) {
return intersections[index];
else {
} else {
return geom;
}
}

View file

@ -4,130 +4,152 @@
<property file="${basedir}/edex/common.properties" />
<property file="${basedir}/edex/developer.properties" />
<condition property="wa.enabled">
<not><equals arg1="${wa.to.deploy}" arg2="" /></not>
<not>
<equals arg1="${wa.to.deploy}" arg2="" />
</not>
</condition>
<dirname property="antfile.dir" file="${ant.file}" />
<echo message="ANT FILE DIR:${antfile.dir}"/>
<echo message="ANT FILE DIR:${antfile.dir}" />
<dirname property="base.dir" file="${antfile.dir}" />
<echo message="BASE DIR:${base.dir}"/>
<echo message="BASE DIR:${base.dir}" />
<dirname property="repo.dir" file="${base.dir}" />
<echo message="REPO DIR:${repo.dir}"/>
<basename property="base.name" file="${base.dir}"/>
<echo message="BASE NAME:${base.name}"/>
<basename property="base.name" file="${base.dir}" />
<echo message="BASE NAME:${base.name}" />
<if>
<equals arg1="${base.name}" arg2="edexOsgi" />
<then>
<!-- we are in the distributed development environment -->
<echo message="BUILDING: in distributed development environment"/>
<echo message="BUILDING: in distributed development environment" />
<dirname property="awips.baseline.directory" file="${base.dir}" />
<dirname property="git.directory" file="${awips.baseline.directory}" />
<echo message="GIT.DIRECTORY:${git.directory}"/>
<var name="repository.directories"
value="${awips.baseline.directory}" />
<echo message="GIT.DIRECTORY:${git.directory}" />
<var name="repository.directories" value="${awips.baseline.directory}" />
<for list="${core.repositories}" param="repo.directory">
<sequential>
<var name="repository.directories"
value="${repository.directories},${git.directory}${file.separator}@{repo.directory}" />
<var name="repository.directories" value="${repository.directories},${git.directory}${file.separator}@{repo.directory}" />
</sequential>
</for>
<property name="tab" value=" "/>
<echo level="info" message=" "/>
<echo level="info" message="Deploy checks the following directories for source:"/>
<echo level="info" message=" "/>
<for list="${repository.directories}" param="repository.directory">
<sequential>
<echo level="info" message="${tab}@{repository.directory}" />
<if>
<not>
<available file="@{repository.directory}" type="dir" />
</not>
<then>
<echo level="error" message="${tab}@{repository.directory} does not exist!"/>
<property name="missingDir"
value="true" />
</then>
</if>
</sequential>
</for>
<if>
<isset property="missingDir" />
<then>
<echo level="error" message=" "/>
<echo level="error" message="Edit core.repositories=${core.repositories} in common.properties, rename source directories or create a symlink!"/>
<echo level="error" message=" "/>
<fail message="Unable to locate source directories."/>
</then>
</if>
<echo level="info" message=" "/>
<echo message="${optional.repositories}"/>
<for list="${optional.repositories}" param="repo.directory">
<sequential>
<if>
<isset property="optional.directories" />
<then>
<var name="optional.directories" value="${optional.directories},${git.directory}${file.separator}@{repo.directory}" />
</then>
<else>
<var name="optional.directories" value="${git.directory}${file.separator}@{repo.directory}" />
</else>
</if>
</sequential>
</for>
<property name="tab" value=" " />
<echo level="info" message=" " />
<echo level="info" message="Deploy checks the following directories for source:" />
<echo level="info" message=" " />
<for list="${repository.directories}" param="repository.directory">
<sequential>
<echo level="info" message="${tab}@{repository.directory}" />
<if>
<not>
<available file="@{repository.directory}" type="dir" />
</not>
<then>
<echo level="error" message="${tab}@{repository.directory} does not exist!" />
<property name="missingDir" value="true" />
</then>
</if>
</sequential>
</for>
<if>
<isset property="missingDir" />
<then>
<echo level="error" message=" " />
<echo level="error" message="Edit core.repositories=${core.repositories} in common.properties, rename source directories or create a symlink!" />
<echo level="error" message=" " />
<fail message="Unable to locate source directories." />
</then>
</if>
<echo level="info" message=" " />
</then>
<else>
<!-- all of the projects are in the workspace or one single directory -->
<echo message="BUILDING: in workspace or flattened directory structure"/>
<var name="awips.baseline.directory"
value="${base.dir}" />
<var name="repository.directories"
value="${base.dir}" />
<echo message="BUILDING: in workspace or flattened directory structure" />
<var name="awips.baseline.directory" value="${base.dir}" />
<var name="repository.directories" value="${base.dir}" />
</else>
</if>
<echo message="AWIPS.BASELINE.DIRECTORY:${awips.baseline.directory}"/>
<echo message="REPOSITORY.DIRECTORIES:${repository.directories}"/>
<echo message="AWIPS.BASELINE.DIRECTORY:${awips.baseline.directory}" />
<echo message="REPOSITORY.DIRECTORIES:${repository.directories}" />
<!-- construct the list of "basedirectories" -->
<propertyselector property="baseline.variables"
delimiter="${path.separator}"
match="dir.([0-9][0-9])"
select="\1"
casesensitive="true" />
<var name="basedirectories"
value="${awips.baseline.directory}" />
<for list="${baseline.variables}" param="index"
delimiter="${path.separator}">
<sequential>
<propertycopy property="variable.name"
override="true"
from="dir.@{index}" />
<for list="${repository.directories}" param="repo.directory">
<sequential>
<var name="base.directory"
value="@{repo.directory}/${variable.name}" />
<if>
<available file="${base.directory}" type="dir" />
<then>
<echo message="BASE.DIRECTORY:${base.directory}"/>
<var name="basedirectories"
value="${base.directory};${basedirectories}" />
</then>
</if>
</sequential>
</for>
<!-- Loop through the WA directories, if they exist. -->
<if>
<isset property="wa.enabled" />
<then>
<for list="${wa.to.deploy}" param="wa"
delimiter="${path.separator}">
<sequential>
<var name="wa.base.directory"
value="@{wa}/${variable.name}" />
<if>
<available file="${wa.base.directory}"
type="dir" />
<then>
<var name="basedirectories"
value="${wa.base.directory};${basedirectories}" />
</then>
</if>
</sequential>
</for>
</then>
</if>
</sequential>
</for>
<propertyselector property="baseline.variables" delimiter="${path.separator}" match="dir.([0-9][0-9])" select="\1" casesensitive="true" />
<var name="basedirectories" value="${awips.baseline.directory}" />
<for list="${baseline.variables}" param="index" delimiter="${path.separator}">
<sequential>
<propertycopy property="variable.name" override="true" from="dir.@{index}" />
<for list="${repository.directories}" param="repo.directory">
<sequential>
<var name="base.directory" value="@{repo.directory}/${variable.name}" />
<if>
<available file="${base.directory}" type="dir" />
<then>
<echo message="BASE.DIRECTORY:${base.directory}" />
<var name="basedirectories" value="${base.directory};${basedirectories}" />
</then>
</if>
</sequential>
</for>
<for list="${optional.directories}" param="repo.directory">
<sequential>
<var name="optional.directory" value="@{repo.directory}/${variable.name}" />
<if>
<available file="${optional.directory}" type="dir" />
<then>
<echo message="OPTIONAL.DIRECTORY:${optional.directory}" />
<if>
<isset property="optionaldirectories"/>
<then>
<var name="optionaldirectories" value="${optional.directory};${optionaldirectories}" />
</then>
<else>
<var name="optionaldirectories" value="${optional.directory}" />
</else>
</if>
</then>
</if>
</sequential>
</for>
<!-- Loop through the WA directories, if they exist. -->
<if>
<isset property="wa.enabled" />
<then>
<for list="${wa.to.deploy}" param="wa" delimiter="${path.separator}">
<sequential>
<var name="wa.base.directory" value="@{wa}/${variable.name}" />
<if>
<available file="${wa.base.directory}" type="dir" />
<then>
<var name="basedirectories" value="${wa.base.directory};${basedirectories}" />
</then>
</if>
</sequential>
</for>
</then>
</if>
</sequential>
</for>
</target>
</project>

View file

@ -49,7 +49,7 @@
<sequential>
<var name="plugin.path" value="" />
<!-- first we need to find the plugin -->
<for list="${basedirectories}" param="directory"
<for list="@{plugin.directories}" param="directory"
delimiter=";">
<sequential>
<if>

View file

@ -3,15 +3,15 @@
<import file="${basedir}/deploy-common/deploy-init.xml" />
<import file="${basedir}/deploy-common/deploy-setup.xml" />
<import file="${basedir}/deploy-common/plugin-methods.xml" />
<!-- public static final -->
<path id="ant.classpath">
<fileset dir="${basedir}/lib/ant">
<include name="*.jar" />
</fileset>
</path>
<path id="ant.classpath">
<fileset dir="${basedir}/lib/ant">
<include name="*.jar" />
</fileset>
</path>
<target name="main" depends="init, setup">
<property name="esb.directory" value="${repo.dir}/build/deploy.edex.awips2/esb" />
<!-- deploy esb {optionally: data, web} -->
@ -34,40 +34,35 @@
Find the feature associated with
Work Assignments.
-->
<var name="feature.to.find"
value="${wa.edex.feature}" />
<var name="feature.to.find" value="${wa.edex.feature}" />
</then>
<else>
<!--
Find the standard AWIPS II
Baseline feature.
-->
<var name="feature.to.find"
value="${edex.feature}" />
<var name="feature.to.find" value="${edex.feature}" />
</else>
</if>
<var name="feature" value="" />
<!--
find the feature file: we may deploy multiple features
if multiple Work Assignment directories have been
specified.
-->
<for list="${basedirectories}" param="directory"
delimiter=";">
<sequential>
<if>
<available file="@{directory}/${feature.to.find}" />
<then>
<var name="feature"
value="@{directory}/${feature.to.find}" />
<deploy.feature
feature="${feature}" />
</then>
</if>
</sequential>
</for>
<for list="${basedirectories}" param="directory" delimiter=";">
<sequential>
<if>
<available file="@{directory}/${feature.to.find}" />
<then>
<var name="feature" value="@{directory}/${feature.to.find}" />
<deploy.feature feature="${feature}" />
</then>
</if>
</sequential>
</for>
<!-- optionally: deploy raytheon python -->
<if>
<equals arg1="${deploy.python}" arg2="true" />
@ -92,36 +87,30 @@
<if>
<isset property="wa.enabled" />
<then>
<for list="${wa.to.deploy}" param="wa"
delimiter="${path.separator}">
<for list="${wa.to.deploy}" param="wa" delimiter="${path.separator}">
<sequential>
<basename property="wa.name" file="@{wa}" />
<if>
<available file="@{wa}/edex/deploy-${wa.name}/wa-deploy.xml"
type="file" />
<available file="@{wa}/edex/deploy-${wa.name}/wa-deploy.xml" type="file" />
<then>
<ant
antfile="@{wa}/edex/deploy-${wa.name}/wa-deploy.xml"
inheritall="true" inheritrefs="true"
useNativeBasedir="true" />
<ant antfile="@{wa}/edex/deploy-${wa.name}/wa-deploy.xml" inheritall="true" inheritrefs="true" useNativeBasedir="true" />
</then>
</if>
</sequential>
</for>
</then>
</then>
</if>
<tstamp>
<format property="TIMESTAMP_COMPLETE" pattern="d-MMM-yyyy h:mm:ss a"
locale="en,US" />
</tstamp>
<echo message="Deploy Complete: ${TIMESTAMP_COMPLETE}" />
<tstamp>
<format property="TIMESTAMP_COMPLETE" pattern="d-MMM-yyyy h:mm:ss a" locale="en,US" />
</tstamp>
<echo message="Deploy Complete: ${TIMESTAMP_COMPLETE}" />
</target>
<!-- public -->
<!-- Targets specific to the developer deployment. -->
<macrodef name="deploy.feature">
<attribute name="feature" />
<sequential>
<!-- prepare to run includegen -->
<var name="includes.directory" value="${basedir}/tmp/includes" />
@ -129,151 +118,136 @@
<available file="${includes.directory}" type="dir" />
<then>
<delete verbose="true" includeemptydirs="true">
<fileset dir="${includes.directory}"
includes="*/**" />
<fileset dir="${includes.directory}" includes="*/**" />
</delete>
</then>
</if>
<mkdir dir="${includes.directory}" />
<!-- run includegen -->
<echo message="Generating deployment list for feature: ${feature}" />
<echo message="Generating deployment list for feature: ${feature}" />
<!--
TODO: need to update the includegen ant task to recognize
plugin architecture restrictions. Plugins that should only
be deployed for a 64-bit system should not be deployed for
a 32-bit system, etc.
-->
<includegen providerfilter="${includegen.filter}"
basedirectories="${basedirectories}"
featurefile="${feature}"
cotsout="${includes.directory}/cots.includes"
plugsout="${includes.directory}/plugins.includes"
coreout="${includes.directory}/core.includes" />
<var name="destination.directory"
value="${edex.root.directory}/lib/plugins" />
<echo message="${feature}" />
<echo message="${includes.directory}/cots.includes" />
<echo message="${includes.directory}/core.includes" />
<includegen providerfilter="${includegen.filter}" basedirectories="${basedirectories}" optionaldirectories="${optionaldirectories}" featurefile="${feature}" cotsout="${includes.directory}/cots.includes" plugsout="${includes.directory}/plugins.includes" coreout="${includes.directory}/core.includes" />
<var name="destination.directory" value="${edex.root.directory}/lib/plugins" />
<mkdir dir="${destination.directory}" />
<processPlugins
includes.file="${includes.directory}/plugins.includes"
plugin.type="plugins"
plugin.directories="${basedirectories}"
destination.directory="${destination.directory}" />
<processPlugins
includes.file="${includes.directory}/core.includes"
plugin.type="core"
plugin.directories="${basedirectories}"
destination.directory="${destination.directory}" />
<var name="destination.directory"
value="${edex.root.directory}/lib/dependencies" />
<if>
<isset property="optionaldirectories" />
<then>
<var name="allDir" value="${basedirectories};${optionaldirectories}" />
<processPlugins includes.file="${includes.directory}/plugins.includes" plugin.type="plugins" plugin.directories="${allDir}" destination.directory="${destination.directory}" />
<processPlugins includes.file="${includes.directory}/core.includes" plugin.type="core" plugin.directories="${allDir}" destination.directory="${destination.directory}" />
</then>
<else>
<processPlugins includes.file="${includes.directory}/plugins.includes" plugin.type="plugins" plugin.directories="${basedirectories}" destination.directory="${destination.directory}" />
<processPlugins includes.file="${includes.directory}/core.includes" plugin.type="core" plugin.directories="${basedirectories}" destination.directory="${destination.directory}" />
</else>
</if>
<var name="destination.directory" value="${edex.root.directory}/lib/dependencies" />
<mkdir dir="${destination.directory}" />
<processPlugins
includes.file="${includes.directory}/cots.includes"
plugin.type="cots"
plugin.directories="${basedirectories}"
destination.directory="${destination.directory}" />
<if>
<isset property="optionaldirectories" />
<then>
<var name="allDir" value="${basedirectories};${optionaldirectories}" />
<processPlugins includes.file="${includes.directory}/cots.includes" plugin.type="cots" plugin.directories="${allDir}" destination.directory="${destination.directory}" />
</then>
<else>
<processPlugins includes.file="${includes.directory}/cots.includes" plugin.type="cots" plugin.directories="${basedirectories}" destination.directory="${destination.directory}" />
</else>
</if>
<!-- cleanup the temporary directories -->
<if>
<available file="${basedir}/tmp"
type="dir" />
<available file="${basedir}/tmp" type="dir" />
<then>
<delete includeemptydirs="true">
<fileset dir="${basedir}"
includes="tmp/**" />
<fileset dir="${basedir}" includes="tmp/**" />
</delete>
</then>
</if>
</sequential>
</macrodef>
<target name="deploy.python">
<property name="site-package.directory"
value="${python.root.directory}/lib/${python.version.dir}/site-packages" />
<property name="site-package.directory" value="${python.root.directory}/lib/${python.version.dir}/site-packages" />
<echo message="Deploying the Raytheon python site-packages." />
<deploy.python.site-package
site.package="ufpy" />
<deploy.python.site-package
site.package="dynamicserialize" />
<deploy.python.site-package
site.package="pypies" />
<deploy.python.site-package site.package="ufpy" />
<deploy.python.site-package site.package="dynamicserialize" />
<deploy.python.site-package site.package="pypies" />
</target>
<target name="deploy.localization">
<for list="${localization.sites}" param="site"
delimiter="${path.separator}">
<sequential>
<echo message="Deploying localization for site: @{site}" />
<for list="${localization.sites}" param="site" delimiter="${path.separator}">
<sequential>
<echo message="Deploying localization for site: @{site}" />
<!-- determine which directory the localization
project should be in. -->
<var name="localization.path" value="" />
<var name="localization.path" value="" />
<if>
<available file="${awips.baseline.directory}/localization.@{site}"
type="dir" />
<available file="${awips.baseline.directory}/localization.@{site}" type="dir" />
<then>
<var name="localization.path"
value="${awips.baseline.directory}/localization.@{site}" />
<var name="localization.path" value="${awips.baseline.directory}/localization.@{site}" />
</then>
<else>
<var name="localization.path"
value="${awips.baseline.directory}/${localization.directory}/localization.@{site}" />
<var name="localization.path" value="${awips.baseline.directory}/${localization.directory}/localization.@{site}" />
</else>
</if>
<!-- copy the localization files. -->
<copy todir="${edex.root.directory}/data/utility"
overwrite="true">
<fileset dir="${localization.path}/utility"
includes="*/**" />
</copy>
</sequential>
</for>
<!-- copy the localization files. -->
<copy todir="${edex.root.directory}/data/utility" overwrite="true">
<fileset dir="${localization.path}/utility" includes="*/**" />
</copy>
</sequential>
</for>
</target>
<!-- private -->
<macrodef name="deploy.python.site-package">
<attribute name="site.package" />
<sequential>
<echo message="Deploying @{site.package} ..." />
<if>
<available file="${site-package.directory}/@{site.package}"
type="dir" />
<available file="${site-package.directory}/@{site.package}" type="dir" />
<then>
<delete dir="${site-package.directory}/@{site.package}"
includeemptydirs="true">
<fileset dir="${site-package.directory}"
includes="@{site.package}/**" />
<delete dir="${site-package.directory}/@{site.package}" includeemptydirs="true">
<fileset dir="${site-package.directory}" includes="@{site.package}/**" />
</delete>
</then>
</if>
<if>
<equals arg1="@{site.package}" arg2="pypies" />
<then>
<!-- custom rule for pypies due to alternate directory layout -->
<copy todir="${site-package.directory}">
<fileset dir="${awips.baseline.directory}/pythonPackages/pypies"
includes="@{site.package}/**" />
<fileset dir="${awips.baseline.directory}/pythonPackages/pypies" includes="@{site.package}/**" />
</copy>
</then>
<else>
<copy todir="${site-package.directory}">
<fileset dir="${awips.baseline.directory}/pythonPackages"
includes="@{site.package}/**" />
<fileset dir="${awips.baseline.directory}/pythonPackages" includes="@{site.package}/**" />
</copy>
</else>
</if>
</sequential>
</macrodef>
<!-- static -->
<taskdef name="includegen"
classname="com.raytheon.uf.anttasks.includesgen.GenerateIncludesFromFeature"
classpathref="ant.classpath" />
<taskdef resource="net/sf/antcontrib/antlib.xml"
classpath="${basedir}/lib/ant/ant-contrib-1.0b3.jar" />
<taskdef name="includegen" classname="com.raytheon.uf.anttasks.includesgen.GenerateIncludesFromFeature" classpathref="ant.classpath" />
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${basedir}/lib/ant/ant-contrib-1.0b3.jar" />
</project>

View file

@ -1,14 +1,19 @@
edex.root.directory=/awips2/edex
architecture=x86_64
includegen.filter=raytheon|noaa\.nws|noaa\.gsd|gov\.nasa\.msfc|edu\.wisc\.ssec\.cimss
includegen.filter=raytheon|noaa\.nws|gov.nasa.msfc|noaa\.gsd|edu\.wisc\.ssec\.cimss
# AWIPSII core repositories required for build
core.repo=ufcore
core-foss.repo=ufcore-foss
awips2-foss.repo=AWIPS2_foss
awips2-ncep.repo=AWIPS2_NCEP
awips2-cimss.repo=AWIPS2_CIMSS
awips2-gsd.repo=AWIPS2_GSD
core.repositories=${core.repo},${core-foss.repo},${awips2-foss.repo}
optional.repositories=${awips2-ncep.repo},${awips2-cimss.repo},${awips2-gsd.repo}
# Note: currently, there is a limit of 99 plugin directories.
dir.01=cave

View file

@ -140,8 +140,4 @@
id="gov.nasa.msfc.sport.edex.sportlma.feature"
version="0.0.0"/>
<includes
id="edu.wisc.ssec.cimss.edex.convectprob.feature"
version="0.0.0"/>
</feature>

View file

@ -27,10 +27,6 @@
<constructor-arg ref="gfeDbPluginProperties"/>
</bean>
<bean id="gfeSiteActivation" class="com.raytheon.edex.plugin.gfe.config.GFESiteActivation" factory-method="getInstance"
depends-on="commonTimeRegistered, gfeDbRegistered, levelFactoryInitialized">
</bean>
<bean id="ifpServer" class="com.raytheon.edex.plugin.gfe.server.IFPServer.Wrapper"/>
<camelContext id="gfe-common-camel" xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="errorHandler">

View file

@ -3,6 +3,11 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="gfeSiteActivation" class="com.raytheon.edex.plugin.gfe.config.GFESiteActivation"
depends-on="commonTimeRegistered, gfeDbRegistered, levelFactoryInitialized">
<constructor-arg ref="fetchATSrv" />
</bean>
<bean id="gfeSitesActiveRequest" factory-bean="siteAwareRegistry" factory-method="register">
<constructor-arg ref="gfeSiteActivation"/>
</bean>
@ -235,7 +240,6 @@
<property name="provider" ref="brokerConnectionsProvider" />
</bean>
<!-- Service Backup Handlers -->
<bean id="GetPrimarySiteHandler" class="com.raytheon.uf.edex.site.handlers.GetPrimarySiteHandler"/>
@ -583,4 +587,23 @@
<bean factory-bean="contextManager" factory-method="registerClusteredContext">
<constructor-arg ref="clusteredGfeIscRoutes"/>
</bean>
<!-- Active Table Sharing Definitions -->
<bean id="fetchATSrv" class="com.raytheon.edex.plugin.gfe.isc.FetchActiveTableSrv" />
<bean factory-bean="contextManager" factory-method="registerContextStateProcessor">
<constructor-arg ref="activeTableSharingRoutes"/>
<constructor-arg ref="fetchATSrv"/>
</bean>
<camelContext id="activeTableSharingRoutes" xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler">
<route id="activateFetchATSrv">
<from uri="timer://activateActiveTableSharing?repeatCount=1"/>
<bean ref="fetchATSrv" method="activateService"/>
</route>
</camelContext>
<bean factory-bean="contextManager" factory-method="registerClusteredContext">
<constructor-arg ref="activeTableSharingRoutes"/>
</bean>
</beans>

View file

@ -6,6 +6,9 @@
<constructor-arg value="smartInit" />
<constructor-arg value="smartInit.*" />
</bean>
<bean id="gfeSiteActivation" class="com.raytheon.edex.plugin.gfe.config.GFESiteActivation"
depends-on="commonTimeRegistered, gfeDbRegistered, levelFactoryInitialized" />
<bean id="smartInitQueue" class="com.raytheon.edex.plugin.gfe.smartinit.SmartInitQueue" factory-method="createQueue"/>

View file

@ -14,5 +14,5 @@ purge.svcbu.logs.cron=0+30+0+*+*+?
purge.gfe.products.isc.cron=0+45+0+*+*+?
purge.gfe.products.atbl.cron=0+50+0+*+*+?
# Interval at which the gfe orphaned locks are cleared
# Interval at which gfe orphaned locks are cleared
clear.gfe.orphaned.locks.cron = 0+0/10+*+*+*+?

View file

@ -35,6 +35,7 @@ import jep.JepException;
import com.google.common.util.concurrent.MoreExecutors;
import com.raytheon.edex.plugin.gfe.exception.GfeConfigurationException;
import com.raytheon.edex.plugin.gfe.exception.GfeMissingConfigurationException;
import com.raytheon.edex.plugin.gfe.isc.FetchActiveTableSrv;
import com.raytheon.edex.plugin.gfe.isc.IRTManager;
import com.raytheon.edex.plugin.gfe.server.IFPServer;
import com.raytheon.edex.site.SiteUtil;
@ -92,6 +93,7 @@ import com.raytheon.uf.edex.site.notify.SendSiteActivationNotifications;
* Sent activation failure message to alertViz
* Oct 07, 2014 #3684 randerso Restructured IFPServer start up
* Dec 10, 2014 #4953 randerso Added requestTCVFiles call at site activation
* Feb 25, 2015 #4128 dgilling Simplify activation of active table sharing.
*
* </pre>
*
@ -109,25 +111,33 @@ public class GFESiteActivation implements ISiteActivationListener {
private static final int LOCK_TASK_TIMEOUT = 180000;
private static GFESiteActivation instance = new GFESiteActivation();
private boolean intialized;
private boolean intialized = false;
private final ExecutorService postActivationTaskExecutor;
private final ExecutorService postActivationTaskExecutor = MoreExecutors
.getExitingExecutorService((ThreadPoolExecutor) Executors
.newCachedThreadPool());
private final FetchActiveTableSrv fetchAtSrv;
/**
* @return the singleton instance
* Default constructor. Builds a GFESiteActivation instance with no
* associated {@code FetchActiveTableSrv} instance.
*/
public static GFESiteActivation getInstance() {
return instance;
public GFESiteActivation() {
this(null);
}
/**
* private constructor for singleton class
* Builds a GFESiteActivation instance with an associated
* {@code FetchActiveTableSrv} instance. Should only be used on request JVM.
*
* @param fetchAtSrv
* {@code FetchActiveTableSrv} instance
*/
private GFESiteActivation() {
public GFESiteActivation(final FetchActiveTableSrv fetchAtSrv) {
this.intialized = false;
this.postActivationTaskExecutor = MoreExecutors
.getExitingExecutorService((ThreadPoolExecutor) Executors
.newCachedThreadPool());
this.fetchAtSrv = fetchAtSrv;
}
@Override
@ -322,7 +332,6 @@ public class GFESiteActivation implements ISiteActivationListener {
// Doesn't need to be cluster locked
statusHandler.info("Checking ISC configuration...");
boolean isIscActivated = false;
if (config.requestISC()) {
String host = InetAddress.getLocalHost().getCanonicalHostName();
String gfeHost = config.getServerHost();
@ -337,14 +346,27 @@ public class GFESiteActivation implements ISiteActivationListener {
statusHandler.info("Enabling ISC...");
try {
IRTManager.getInstance().enableISC(siteID, config);
isIscActivated = true;
// wait until EDEX is up and running to request TCV files
final IFPServerConfig configRef = config;
if (configRef.tableFetchTime() > 0) {
Runnable activateTableSharing = new Runnable() {
@Override
public void run() {
EDEXUtil.waitForRunning();
fetchAtSrv.activateSite(siteID, configRef);
}
};
postActivationTaskExecutor.submit(activateTableSharing);
}
Runnable requestTCV = new Runnable() {
@Override
public void run() {
// wait until EDEX is up and running to request TCV
// files
EDEXUtil.waitForRunning();
requestTCVFiles(siteID, configRef);
@ -367,45 +389,6 @@ public class GFESiteActivation implements ISiteActivationListener {
statusHandler.info("ISC is not enabled.");
}
// doesn't need to be cluster locked
final IFPServerConfig configRef = config;
if ((config.tableFetchTime() > 0) && isIscActivated) {
Runnable activateFetchAT = new Runnable() {
@Override
public void run() {
EDEXUtil.waitForRunning();
Map<String, Object> fetchATConfig = new HashMap<String, Object>();
fetchATConfig.put("siteId", configRef.getSiteID().get(0));
fetchATConfig.put("interval", configRef.tableFetchTime());
fetchATConfig.put("ancf", configRef
.iscRoutingTableAddress().get("ANCF"));
fetchATConfig.put("bncf", configRef
.iscRoutingTableAddress().get("BNCF"));
fetchATConfig.put("serverHost", configRef.getServerHost());
fetchATConfig.put("port", configRef.getRpcPort());
fetchATConfig.put("protocolV",
configRef.getProtocolVersion());
fetchATConfig.put("mhsid", configRef.getMhsid());
fetchATConfig.put("transmitScript",
configRef.transmitScript());
try {
EDEXUtil.getMessageProducer().sendAsyncUri(
"jms-generic:queue:gfeSiteActivated",
fetchATConfig);
} catch (EdexException e) {
statusHandler.handle(Priority.PROBLEM,
"Could not activate active table sharing for site: "
+ siteID, e);
}
}
};
postActivationTaskExecutor.submit(activateFetchAT);
}
statusHandler.info("Adding " + siteID + " to active sites list.");
IFPServerConfigManager.addActiveSite(siteID);
statusHandler.info(siteID + " successfully activated");

View file

@ -34,6 +34,7 @@ import org.hibernate.StatelessSession;
import org.hibernate.Transaction;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
//import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
import com.raytheon.uf.common.dataplugin.gfe.server.lock.Lock;
import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable;
import com.raytheon.uf.common.message.WsId;
@ -53,7 +54,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
* 04/19/13 #1949 rjpeter Normalized GFE Database.
* 06/20/13 #2127 rjpeter Set session to read only.
* 10/16/2014 3454 bphillip Upgrading to Hibernate 4
* 01/07/15 629 mgamazaychikov Add getAllLocks method.
* 03/03/15 629 mgamazaychikov Add getAllLocks method.
* </pre>
*
* @author bphillip
@ -195,8 +196,8 @@ public class GFELockDao extends CoreDao {
}
@SuppressWarnings("unchecked")
public Map<ParmID, LockTable> getAllLocks() throws DataAccessLayerException{
Map<ParmID, LockTable> lockMap = new HashMap<ParmID, LockTable>();
public List<Lock> getAllLocks(final String siteId)
throws DataAccessLayerException {
Session sess = null;
Transaction tx = null;
@ -204,24 +205,12 @@ public class GFELockDao extends CoreDao {
sess = getSession();
sess.setDefaultReadOnly(true);
tx = sess.beginTransaction();
Query query = sess
.createQuery("FROM Lock");
.createQuery("FROM Lock WHERE parmId in (SELECT id FROM ParmID WHERE dbId in (SELECT id FROM DatabaseID WHERE siteId = ?))");
query.setParameter(0, siteId);
List<Lock> locks = query.list();
tx.commit();
// populate Lock table
for (Lock lock : locks) {
WsId wid = lock.getWsId();
ParmID pid = lock.getParmId();
LockTable lockTable = lockMap.get(pid);
if (lockTable == null) {
lockTable = new LockTable(pid, new ArrayList<Lock>(), wid);
lockMap.put(pid, lockTable);
}
lockTable.addLock(lock);
}
return lockMap;
return locks;
} catch (Exception e) {
if (tx != null) {
try {
@ -230,16 +219,13 @@ public class GFELockDao extends CoreDao {
logger.error("Error occurred rolling back transaction", e1);
}
}
throw new DataAccessLayerException(
"Unable to look up locks ", e);
throw new DataAccessLayerException("Unable to look up locks for site " + siteId, e);
} finally {
if (sess != null) {
try {
sess.close();
} catch (Exception e) {
logger.error(
"Error occurred closing database session", e);
logger.error("Error occurred closing database session", e);
}
}
}

View file

@ -0,0 +1,335 @@
/**
* 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.edex.plugin.gfe.isc;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfig;
import com.raytheon.edex.plugin.gfe.server.IFPServer;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.RunProcess;
import com.raytheon.uf.edex.core.IContextStateProcessor;
/**
* Service that fetches neighboring sites' active table entries that are
* relevant to this site using requestAT.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 28, 2013 dgilling Initial creation
* Feb 20, 2014 #2824 randerso Changed log level of message when activating FetchAT
* Registered with SiteAwareRegistry so we can stop
* fetching when site is deactivated.
* Feb 26, 2015 #4128 dgilling Moved to edex.gfe plugin, rewritten as
* IContextStateProcessor.
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public final class FetchActiveTableSrv implements IContextStateProcessor {
private static final class FetchATJobConfig {
private final String siteId;
private final long interval;
private final String ancfAddress;
private final String bncfAddress;
private final String serverHost;
private final String port;
private final String protocolV;
private final String mhsId;
private final String transmitScript;
public FetchATJobConfig(final String siteId,
final IFPServerConfig gfeConfig) {
this.siteId = siteId;
this.interval = gfeConfig.tableFetchTime();
this.ancfAddress = gfeConfig.iscRoutingTableAddress().get("ANCF");
this.bncfAddress = gfeConfig.iscRoutingTableAddress().get("BNCF");
this.serverHost = gfeConfig.getServerHost();
this.port = Long.toString(gfeConfig.getRpcPort());
this.protocolV = Long.toString(gfeConfig.getProtocolVersion());
this.mhsId = gfeConfig.getMhsid();
this.transmitScript = gfeConfig.transmitScript();
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FetchATJobConfig [siteId=");
builder.append(siteId);
builder.append(", interval=");
builder.append(interval);
builder.append(", ancfAddress=");
builder.append(ancfAddress);
builder.append(", bncfAddress=");
builder.append(bncfAddress);
builder.append(", serverHost=");
builder.append(serverHost);
builder.append(", port=");
builder.append(port);
builder.append(", protocolV=");
builder.append(protocolV);
builder.append(", mhsId=");
builder.append(mhsId);
builder.append(", transmitScript=");
builder.append(transmitScript);
builder.append("]");
return builder.toString();
}
public String getSiteId() {
return siteId;
}
public long getInterval() {
return interval;
}
public String getAncfAddress() {
return ancfAddress;
}
public String getBncfAddress() {
return bncfAddress;
}
public String getServerHost() {
return serverHost;
}
public String getPort() {
return port;
}
public String getProtocolV() {
return protocolV;
}
public String getMhsId() {
return mhsId;
}
public String getTransmitScript() {
return transmitScript;
}
}
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(FetchActiveTableSrv.class);
private final ConcurrentMap<String, ScheduledFuture<?>> siteJobInstanceMap;
private ScheduledExecutorService jobExecutor;
private volatile boolean activeServiceInstance;
/**
* Default constructor.
*/
public FetchActiveTableSrv() {
this.activeServiceInstance = false;
this.siteJobInstanceMap = new ConcurrentHashMap<String, ScheduledFuture<?>>();
}
/**
* Dummy trigger method for the timer in the camel context this bean
* monitors. Ensures this bean properly fails over between cluster members
* as needed.
*/
public void activateService() {
activeServiceInstance = true;
}
/**
* Removes a site's active table sharing job from the job pool.
*
* @param siteID
* Site identifier for the site's job to stop.
*/
public void deactivateSite(final String siteID) {
ScheduledFuture<?> siteJob = siteJobInstanceMap.remove(siteID);
if (siteJob != null) {
statusHandler.info("Deactivating FetchAT for " + siteID);
siteJob.cancel(false);
}
}
/**
* Adds a site's active table sharing job to the job pool.
*
* @param siteID
* Site identifier for the site's job to add to job pool.
* @param gfeConfig
* {@code IFPServerConfig} for the site.
*/
public void activateSite(final String siteID,
final IFPServerConfig gfeConfig) {
if (activeServiceInstance && (!siteJobInstanceMap.containsKey(siteID))) {
FetchATJobConfig jobConfig = new FetchATJobConfig(siteID, gfeConfig);
statusHandler.info("Activating FetchAT for " + siteID);
statusHandler.debug("Site: " + siteID + " config: " + jobConfig);
Runnable job = constructJob(jobConfig);
try {
ScheduledFuture<?> jobInstance = jobExecutor
.scheduleWithFixedDelay(job, 10,
jobConfig.getInterval(), TimeUnit.SECONDS);
siteJobInstanceMap.put(siteID, jobInstance);
} catch (RejectedExecutionException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to submit fetchAT job for execution:", e);
siteJobInstanceMap.remove(siteID);
}
}
}
private Runnable constructJob(final FetchATJobConfig jobConfig) {
Runnable job = new Runnable() {
@Override
public void run() {
statusHandler.info("Starting requestAT process for site: "
+ jobConfig.getSiteId());
/*
* requestAT -H ourHost -P ourPort -L ourServerProto -M mhsid -S
* ourSite -t irtWebAddr -x transmitScript
*/
List<String> args = new ArrayList<String>(17);
args.add("requestAT");
args.add("-H");
args.add(jobConfig.getServerHost());
args.add("-P");
args.add(jobConfig.getPort());
args.add("-L");
args.add(jobConfig.getProtocolV());
args.add("-M");
args.add(jobConfig.getMhsId());
args.add("-S");
args.add(jobConfig.getSiteId());
args.add("-a");
args.add(jobConfig.getAncfAddress());
args.add("-b");
args.add(jobConfig.getBncfAddress());
args.add("-x");
args.add(jobConfig.getTransmitScript());
try {
/*
* We'll wait for requestAT to finish execution so that we
* can't accidentally overlap running instances if the user
* configures the run interval too low.
*/
ProcessBuilder command = new ProcessBuilder(args);
RunProcess proc = RunProcess.getRunProcess();
proc.setProcess(command.start());
proc.waitFor();
} catch (Throwable t) {
statusHandler.error(
"Unhandled exception thrown during requestAT: ", t);
}
}
};
return job;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.core.IContextStateProcessor#preStart()
*/
@Override
public void preStart() {
statusHandler.info("Initializing FetchATSrv...");
activeServiceInstance = true;
jobExecutor = Executors.newScheduledThreadPool(1);
for (IFPServer ifpServer : IFPServer.getActiveServers()) {
IFPServerConfig config = ifpServer.getConfig();
if ((config.requestISC()) && (config.tableFetchTime() > 0)) {
activateSite(ifpServer.getSiteId(), config);
}
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.core.IContextStateProcessor#postStart()
*/
@Override
public void postStart() {
// no op
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.core.IContextStateProcessor#preStop()
*/
@Override
public void preStop() {
statusHandler.info("Shutting down FetchATSrv...");
activeServiceInstance = false;
jobExecutor.shutdown();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.core.IContextStateProcessor#postStop()
*/
@Override
public void postStop() {
jobExecutor = null;
siteJobInstanceMap.clear();
}
}

View file

@ -29,7 +29,6 @@ import java.util.Map;
import jep.JepException;
import com.raytheon.edex.plugin.gfe.config.GFESiteActivation;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfig;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfigManager;
import com.raytheon.edex.plugin.gfe.exception.GfeConfigurationException;
@ -59,6 +58,8 @@ import com.raytheon.uf.edex.core.EdexTimerBasedThread;
* ------------ ---------- ----------- --------------------------
* Oct 20, 2011 dgilling Initial creation
* May 19, 2014 2726 rjpeter Integrate IscSendJob for graceful shutdown.
* Feb 26, 2015 4128 dgilling Switch to IFPServer.getActiveSites().
*
* </pre>
*
* @author dgilling
@ -128,8 +129,7 @@ public class SendIscSrv extends EdexTimerBasedThread {
String xmlDest = request.getXmlDest();
String siteId = id.getDbId().getSiteId();
if (!GFESiteActivation.getInstance().getActiveSites()
.contains(siteId)) {
if (!IFPServer.getActiveSites().contains(siteId)) {
statusHandler.warn("Attempted to send " + id
+ " for deactivated site " + siteId + ".");
return;

View file

@ -25,7 +25,7 @@ import java.util.Map;
import jep.JepException;
import com.raytheon.edex.plugin.gfe.config.GFESiteActivation;
import com.raytheon.edex.plugin.gfe.server.IFPServer;
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
@ -45,6 +45,7 @@ import com.raytheon.uf.common.python.PythonScript;
* ------------ ---------- ----------- --------------------------
* Jul 26, 2011 bphillip Initial creation
* Sep 05, 2013 #2307 dgilling Use better PythonScript constructor.
* Feb 26, 2015 #4128 dgilling Switch to IFPServer.getActiveSites().
*
* </pre>
*
@ -62,7 +63,7 @@ public class LogPurger {
public void purge() throws JepException {
for (String siteID : GFESiteActivation.getInstance().getActiveSites()) {
for (String siteID : IFPServer.getActiveSites()) {
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext cx = pathMgr.getContext(
LocalizationType.EDEX_STATIC, LocalizationLevel.BASE);

View file

@ -23,8 +23,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.raytheon.edex.plugin.gfe.config.GFESiteActivation;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfigManager;
import com.raytheon.edex.plugin.gfe.server.IFPServer;
import com.raytheon.uf.common.dataplugin.gfe.request.GetSiteTimeZoneInfoRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
@ -39,6 +39,7 @@ import com.raytheon.uf.common.serialization.comm.IRequestHandler;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 19, 2011 dgilling Initial creation
* Feb 26, 2015 #4128 dgilling Switch to IFPServer.getActiveSites().
*
* </pre>
*
@ -61,7 +62,7 @@ public class GetSiteTimeZoneInfoRequestHandler implements
GetSiteTimeZoneInfoRequest request) throws Exception {
ServerResponse<Map<String, String>> sr = new ServerResponse<Map<String, String>>();
Set<String> sites = GFESiteActivation.getInstance().getActiveSites();
Set<String> sites = IFPServer.getActiveSites();
Map<String, String> siteWithTimeZone = new HashMap<String, String>();
for (String site : sites) {
// getTimeZones() seems to only ever return a 1 sized List

View file

@ -22,21 +22,22 @@ package com.raytheon.edex.plugin.gfe.server.lock;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import com.raytheon.edex.plugin.gfe.server.IFPServer;
import com.raytheon.edex.plugin.gfe.server.lock.LockManager;
import com.raytheon.edex.plugin.gfe.util.SendNotifications;
import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException;
import com.raytheon.uf.common.dataplugin.gfe.server.lock.Lock;
import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable;
import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable.LockMode;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.dataplugin.gfe.server.notify.GfeNotification;
import com.raytheon.uf.common.dataplugin.gfe.server.notify.LockNotification;
import com.raytheon.uf.common.dataplugin.gfe.server.request.LockRequest;
import com.raytheon.uf.common.message.WsId;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.esb.camel.jms.IBrokerConnectionsProvider;
/**
@ -50,7 +51,7 @@ import com.raytheon.uf.edex.esb.camel.jms.IBrokerConnectionsProvider;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 07, 2015 629 mgamazaychikov Initial creation
* Mar 03, 2015 629 mgamazaychikov Initial creation
*
* </pre>
*
@ -62,148 +63,90 @@ public class ClearGfeOrphanedLocks {
private static IBrokerConnectionsProvider provider;
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ClearGfeOrphanedLocks.class);
public final String CAVE = "CAVE";
public static void setProvider(IBrokerConnectionsProvider provider) {
ClearGfeOrphanedLocks.provider = provider;
}
private Set<String> breakAllLocks(List<LockTable> lockTables,
LockManager lockMgr) {
Set<String> inactives = new HashSet<String>();
for (LockTable lockTable : lockTables) {
for (Lock lock : lockTable.getLocks()) {
TimeRange tr = lock.getTimeRange();
List<LockRequest> lreq = new ArrayList<LockRequest>();
lreq.add(new LockRequest(lock.getParmId(), tr,
private void breakLocks(Set<String> clients, List<Lock> lockList,
LockManager lockMgr, String siteId) {
boolean foundOrpanedLocks = false;
List<LockRequest> lreq = new ArrayList<LockRequest>();
StringBuilder sb = new StringBuilder();
for (Lock lock : lockList) {
String lockWsid = lock.getWsId().toString();
if (!clients.contains(lockWsid)) {
foundOrpanedLocks = true;
List<Lock> lst = new ArrayList<Lock>();
lst.add(lock);
// Inactive clients found
lreq.add(new LockRequest(lock.getParmId(), lock.getTimeRange(),
LockMode.BREAK_LOCK));
lockMgr.requestLockChange(lreq, lock.getWsId());
if (!inactives.contains(lock.getWsId().toPrettyString())
&& !inactives.contains(lock.getParmId().toString())) {
String message = " Breaking orphaned lock on "
+ lock.getParmId().toString() + " owned by "
+ lock.getWsId().toPrettyString() + ".";
inactives.add(message);
}
sb.append(" Breaking orphaned lock for site " + siteId + " on "
+ lock.getParmId().toString() + " owned by "
+ lock.getWsId().toPrettyString() + ".");
}
}
return inactives;
}
private Set<String> breakLocks(Set<String> clients,
List<LockTable> lockTables, LockManager lockMgr) {
Set<String> inactives = new HashSet<String>();
for (LockTable lockTable : lockTables) {
for (Lock lock : lockTable.getLocks()) {
String lockedWsid = lock.getWsId().toString();
for (String client : clients) {
if (!lockedWsid.equals(client)) {
// Inactive CAVE clients found - break its lock
List<LockRequest> lreq = new ArrayList<LockRequest>();
lreq.add(new LockRequest(lock.getParmId(), lock
.getTimeRange(), LockMode.BREAK_LOCK));
lockMgr.requestLockChange(lreq, lock.getWsId());
if (!inactives
.contains(lock.getWsId().toPrettyString())
&& !inactives.contains(lock.getParmId()
.toString())) {
String message = " Breaking orphaned lock on "
+ lock.getParmId().toString()
+ " owned by "
+ lock.getWsId().toPrettyString() + ".";
inactives.add(message);
}
if (foundOrpanedLocks) {
statusHandler.info(sb.toString());
WsId requestor = new WsId(null, null, "ClearGfeOrphanedLocks");
ServerResponse<List<LockTable>> sr = lockMgr.requestLockChange(
lreq, requestor);
if (sr.isOkay()) {
try {
List<LockTable> lockTables = sr.getPayload();
List<GfeNotification> notes = new ArrayList<GfeNotification>(
lockTables.size());
for (LockTable table : lockTables) {
notes.add(new LockNotification(table, siteId));
}
ServerResponse<?> notifyResponse = SendNotifications
.send(notes);
if (!notifyResponse.isOkay()) {
statusHandler.error(notifyResponse.message());
}
// send out grid update notifications
notifyResponse = SendNotifications.send(sr.getNotifications());
if (!notifyResponse.isOkay()) {
statusHandler.error(notifyResponse.message());
}
} catch (Exception e) {
statusHandler.error("Error sending lock notification", e);
}
}
} else {
statusHandler.error(sr.message());
}
return;
} else {
statusHandler.info(" No orphaned locks found for site " + siteId
+ ".");
return;
}
return inactives;
}
@SuppressWarnings("unchecked")
public void clearLocksCron() throws Exception {
Date executionTime = new Date(System.currentTimeMillis());
if (statusHandler.isPriorityEnabled(Priority.INFO)) {
String msg = "Started at " + executionTime;
statusHandler.info(msg);
}
statusHandler
.info("Started at " + new Date(System.currentTimeMillis()));
Set<String> clients = new HashSet<String>(provider.getConnections());
Set<String> inactives = new HashSet<String>();
String siteId = EDEXUtil.getEdexSite();
IFPServer ifpServer = IFPServer.getActiveServer(siteId);
if (ifpServer == null) {
if (statusHandler.isPriorityEnabled(Priority.INFO)) {
String msg = "No active IFPServer for site " + siteId;
statusHandler.info(msg);
return;
}
if (IFPServer.getActiveServers().size() == 0) {
statusHandler.info("No active IFPServer found.");
return;
}
LockManager lockMgr = ifpServer.getLockMgr();
List<LockTable> lockTables = (List<LockTable>) lockMgr.getAllLocks()
.getPayload();
/*
* There are no locks in the db.
*/
if (lockTables.size() == 0) {
if (statusHandler.isPriorityEnabled(Priority.INFO)) {
String msg = "No locks found for site " + siteId;
statusHandler.info(msg);
return;
}
}
/*
* Filter out non-CAVE clients.
*/
for (Iterator<String> iterator = clients.iterator(); iterator.hasNext();) {
String client = iterator.next();
if (!client.contains(CAVE)) {
iterator.remove();
}
}
/*
* If there are no active CAVE clients but the locks exist, they all
* must be orphaned -> break the locks.
*/
if (clients.isEmpty() && lockTables.size() > 0) {
inactives = breakAllLocks(lockTables, lockMgr);
if (statusHandler.isPriorityEnabled(Priority.INFO)) {
StringBuilder sb = new StringBuilder();
for (String in : inactives) {
sb.append(in);
}
statusHandler.info(sb.toString());
return;
}
}
/*
* There are active CAVE clients, find orphaned locks and break the
* locks.
*/
inactives = breakLocks(clients, lockTables, lockMgr);
if (inactives.isEmpty()) {
if (statusHandler.isPriorityEnabled(Priority.INFO)) {
String msg = "No orphaned locks found for site " + siteId;
statusHandler.info(msg);
return;
}
} else {
if (statusHandler.isPriorityEnabled(Priority.INFO)) {
StringBuilder sb = new StringBuilder();
for (String in : inactives) {
sb.append(in);
}
statusHandler.info(sb.toString());
List<IFPServer> ifpServers = IFPServer.getActiveServers();
for (IFPServer ifps : ifpServers) {
LockManager lockMgr = ifps.getLockMgr();
String siteId = ifps.getSiteId();
List<Lock> lockList;
try {
lockList = (List<Lock>) lockMgr.getAllLocks(siteId);
// find orphaned locks and break them
breakLocks(clients, lockList, lockMgr, siteId);
return;
} catch (GfeException e) {
statusHandler.error("Error retrieving all locks", e);
}
}
}

View file

@ -68,7 +68,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
* 06/13/13 #2044 randerso Converted from singleton to instance per
* site managed by IFPServer
* 10/07/2014 #3684 randerso Restructured IFPServer start up
* 01/07/15 629 mgamazaychikov Add getAllLocks method.
* 03/03/15 629 mgamazaychikov Add getAllLocks method.
* </pre>
*
* @author bphillip
@ -909,19 +909,15 @@ public class LockManager {
}
}
public ServerResponse <?> getAllLocks() {
ServerResponse<List<LockTable>> sr = new ServerResponse<List<LockTable>>();
public List<Lock> getAllLocks(String siteId) throws GfeException {
List<Lock> lt = new ArrayList<Lock>();
try {
List<LockTable> payLoad = null;
Map<ParmID, LockTable> lockMap = dao.getAllLocks();
payLoad = new ArrayList<LockTable>(lockMap.size());
payLoad.addAll(lockMap.values());
sr.setPayload(payLoad);
lt = dao.getAllLocks(siteId);
} catch (Exception e) {
sr.addMessage("Error getting lock tables for");
sr.setPayload(new ArrayList<LockTable>(0));
throw new GfeException("Error getting lock tables for site "
+ this.siteId + ": " + e.getMessage());
}
return sr;
return lt;
}
}

View file

@ -11,7 +11,7 @@
200:200:Significant Tornado probability:%:SIGTRNDPROB
201:201:Significant Hail probability:%:SIGHAILPROB
202:202:Significant Wind probability:%:SIGWINDPROB
203:203:Categorical Lightning:categorical:CLGHT
203:203:Categorical Lightning:categorical:CLGTN
204:204:Number of mixed layers next to surface:integer:MIXLY
205:205:Flight Category::FLGHT
206:206:Confidence - Ceiling::CICEL
@ -28,7 +28,7 @@
217:217:Supercooled Large Droplet Icing:mm:SIPD
218:218:Radiative emissivity:mm:EPSR
219:219:Turbulence Potential Forecast Index::TPFI
220:220:Categorical Servre Thunderstorm::SVRTS
220:220:Categorical Severe Thunderstorm::SVRTS
221:221:Probability of Convection:%:PROCON
222:222:Categorical Convection :categorical:CONVP
223:223:Cumulonimbus Horizontal Exten:%:CBHE

View file

@ -18,4 +18,4 @@
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
<DerivedParameter abbreviation="CONVP2hr" name="2hr Convection potential" unit="%"/>
<DerivedParameter abbreviation="CONVP2hr" name="2hr Convection potential" unit=""/>

View file

@ -78,23 +78,4 @@
<constructor-arg value="com.raytheon.uf.common.activetable.request.UnlockAndSetNextEtnRequest"/>
<constructor-arg ref="setAndUnlockEtnHandler"/>
</bean>
<bean id="fetchATSrv" class="com.raytheon.uf.edex.activetable.vtecsharing.FetchActiveTableSrv"/>
<camelContext id="activeTableSharingRoutes" xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler">
<route id="activeSiteForFetchATSrv">
<from uri="jms-generic:queue:gfeSiteActivated"/>
<doTry>
<bean ref="fetchATSrv" method="addSite"/>
<doCatch>
<exception>java.lang.Throwable</exception>
<to uri="log:fetchATSrv?level=ERROR"/>
</doCatch>
</doTry>
</route>
</camelContext>
<bean factory-bean="contextManager" factory-method="registerClusteredContext">
<constructor-arg ref="activeTableSharingRoutes"/>
</bean>
</beans>

View file

@ -1,208 +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.uf.edex.activetable.vtecsharing;
import java.util.Map;
/**
* Configuration information for a given site's vtec active table fetching.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 28, 2013 dgilling Initial creation
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public class FetchATJobConfig {
private String siteId;
private long interval;
private String ancfAddress;
private String bncfAddress;
private String serverHost;
private String port;
private String protocolV;
private String mhsId;
private String transmitScript;
public FetchATJobConfig(Map<String, Object> configMap) {
siteId = configMap.get("siteId").toString();
interval = ((Number) configMap.get("interval")).longValue();
ancfAddress = configMap.get("ancf").toString();
bncfAddress = configMap.get("bncf").toString();
serverHost = configMap.get("serverHost").toString();
port = configMap.get("port").toString();
protocolV = configMap.get("protocolV").toString();
mhsId = configMap.get("mhsid").toString();
transmitScript = configMap.get("transmitScript").toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
FetchATJobConfig other = (FetchATJobConfig) obj;
if (ancfAddress == null) {
if (other.ancfAddress != null) {
return false;
}
} else if (!ancfAddress.equals(other.ancfAddress)) {
return false;
}
if (bncfAddress == null) {
if (other.bncfAddress != null) {
return false;
}
} else if (!bncfAddress.equals(other.bncfAddress)) {
return false;
}
if (interval != other.interval) {
return false;
}
if (mhsId == null) {
if (other.mhsId != null) {
return false;
}
} else if (!mhsId.equals(other.mhsId)) {
return false;
}
if (port == null) {
if (other.port != null) {
return false;
}
} else if (!port.equals(other.port)) {
return false;
}
if (protocolV == null) {
if (other.protocolV != null) {
return false;
}
} else if (!protocolV.equals(other.protocolV)) {
return false;
}
if (serverHost == null) {
if (other.serverHost != null) {
return false;
}
} else if (!serverHost.equals(other.serverHost)) {
return false;
}
if (siteId == null) {
if (other.siteId != null) {
return false;
}
} else if (!siteId.equals(other.siteId)) {
return false;
}
if (transmitScript == null) {
if (other.transmitScript != null) {
return false;
}
} else if (!transmitScript.equals(other.transmitScript)) {
return false;
}
return true;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FetchATJobConfig [siteId=");
builder.append(siteId);
builder.append(", interval=");
builder.append(interval);
builder.append(", ancfAddress=");
builder.append(ancfAddress);
builder.append(", bncfAddress=");
builder.append(bncfAddress);
builder.append(", serverHost=");
builder.append(serverHost);
builder.append(", port=");
builder.append(port);
builder.append(", protocolV=");
builder.append(protocolV);
builder.append(", mhsId=");
builder.append(mhsId);
builder.append(", transmitScript=");
builder.append(transmitScript);
builder.append("]");
return builder.toString();
}
public String getSiteId() {
return siteId;
}
public long getInterval() {
return interval;
}
public String getAncfAddress() {
return ancfAddress;
}
public String getBncfAddress() {
return bncfAddress;
}
public String getServerHost() {
return serverHost;
}
public String getPort() {
return port;
}
public String getProtocolV() {
return protocolV;
}
public String getMhsId() {
return mhsId;
}
public String getTransmitScript() {
return transmitScript;
}
}

View file

@ -1,218 +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.uf.edex.activetable.vtecsharing;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import com.google.common.util.concurrent.MoreExecutors;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.registry.RegistryException;
import com.raytheon.uf.edex.site.ISiteActivationListener;
import com.raytheon.uf.edex.site.SiteAwareRegistry;
/**
* Service that fetches neighboring sites' active table entries that are
* relevant to this site using requestAT.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 28, 2013 dgilling Initial creation
* Feb 20, 2014 #2824 randerso Changed log level of message when activating FetchAT
* Registered with SiteAwareRegistry so we can stop
* fetching when site is deactivated.
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public class FetchActiveTableSrv implements ISiteActivationListener {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(FetchActiveTableSrv.class);
private final Map<String, FetchATJobConfig> siteConfigMap;
private final Map<String, ScheduledFuture<?>> siteJobInstanceMap;
private final ScheduledExecutorService jobExecutor;
public FetchActiveTableSrv() {
siteConfigMap = new ConcurrentHashMap<String, FetchATJobConfig>();
siteJobInstanceMap = new ConcurrentHashMap<String, ScheduledFuture<?>>();
jobExecutor = MoreExecutors
.getExitingScheduledExecutorService((ScheduledThreadPoolExecutor) Executors
.newScheduledThreadPool(1));
try {
SiteAwareRegistry.getInstance().register(this);
} catch (RegistryException e) {
statusHandler.handle(Priority.PROBLEM,
"Error registering with SiteAwareRegistry", e);
}
}
public void addSite(Map<String, Object> configData) {
FetchATJobConfig config = new FetchATJobConfig(configData);
final String site = config.getSiteId();
statusHandler.info("Activating FetchAT for " + site);
statusHandler.debug("Site: " + site + " config: " + config);
if ((siteConfigMap.containsKey(site))
&& siteConfigMap.get(site).equals(config)) {
return;
}
Runnable job = new Runnable() {
@Override
public void run() {
statusHandler.info("Starting requestAT process for site: "
+ site);
// requestAT -H ourHost -P ourPort -L ourServerProto -M mhsid
// -S ourSite -t irtWebAddr -x transmitScript
FetchATJobConfig jobConfig = siteConfigMap.get(site);
List<String> args = new ArrayList<String>(17);
args.add("requestAT");
args.add("-H");
args.add(jobConfig.getServerHost());
args.add("-P");
args.add(jobConfig.getPort());
args.add("-L");
args.add(jobConfig.getProtocolV());
args.add("-M");
args.add(jobConfig.getMhsId());
args.add("-S");
args.add(jobConfig.getSiteId());
args.add("-a");
args.add(jobConfig.getAncfAddress());
args.add("-b");
args.add(jobConfig.getBncfAddress());
args.add("-x");
args.add(jobConfig.getTransmitScript());
// String msg = Joiner.on(' ').join(args);
// statusHandler.debug("Running command: " + msg);
try {
ProcessBuilder command = new ProcessBuilder(args);
command.start();
} catch (IOException e) {
statusHandler.handle(Priority.PROBLEM,
"Error executing requestAT: ", e);
}
}
};
try {
siteConfigMap.put(site, config);
ScheduledFuture<?> jobInstance = jobExecutor.scheduleAtFixedRate(
job, 10, config.getInterval(), TimeUnit.SECONDS);
siteJobInstanceMap.put(site, jobInstance);
} catch (RejectedExecutionException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to submit fetchAT job for execution:", e);
siteConfigMap.remove(site);
siteJobInstanceMap.remove(site);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.site.ISiteActivationListener#deactivateSite(java
* .lang.String)
*/
@Override
public void deactivateSite(String siteID) throws Exception {
ScheduledFuture<?> siteJob = siteJobInstanceMap.remove(siteID);
if (siteJob != null) {
statusHandler.info("Deactivating FetchAT for " + siteID);
siteJob.cancel(false);
}
siteConfigMap.remove(siteID);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.site.ISiteActivationListener#activateSite(java.lang
* .String)
*/
@Override
public void activateSite(String siteID) throws Exception {
return;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.site.ISiteActivationListener#getActiveSites()
*/
@Override
public Set<String> getActiveSites() {
return Collections.emptySet();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.site.ISiteActivationListener#validateConfig(java
* .lang.String)
*/
@Override
public String validateConfig(String siteID) {
return "";
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.site.ISiteActivationListener#registered()
*/
@Override
public void registered() {
return;
}
}

View file

@ -84,12 +84,6 @@
version="0.0.0"
unpack="false"/>
<plugin
id="gov.nasa.gsfc.fits"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="ucar.nc2.bufrsplitter"
download-size="0"

View file

@ -7,3 +7,4 @@ Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.apache.ant;bundle-version="1.7.1",
com.raytheon.uf.featureexplorer;bundle-version="1.0.0"
Import-Package: com.raytheon.uf.featureexplorer

View file

@ -1,11 +1,13 @@
package com.raytheon.uf.anttasks.includesgen;
import java.io.File;
import java.io.FileFilter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.TimeZone;
import java.util.regex.Matcher;
@ -28,6 +30,7 @@ import com.raytheon.uf.featureexplorer.FeatureExplorer;
* 28Jan2009 1930 MW Fegan Added provider and plugin filtering.
* Feb 4, 2013 #1577 bkowal Remove component-deploy.xml suffixes for
* core and plugins; remove jar wildcard for cots
* Feb 25, 2015 #3299 garmendariz Process a list of included features
* </pre>
*
* @author bclement
@ -36,319 +39,367 @@ import com.raytheon.uf.featureexplorer.FeatureExplorer;
public class GenerateIncludesFromFeature extends Task {
protected String baseDirectories;
protected String baseDirectories;
protected File baseDirectory;
protected File baseDirectory;
protected File featureFile;
protected File featureFile;
protected File cotsOut;
protected File cotsOut;
protected File plugsOut;
protected File plugsOut;
protected File coreOut;
protected File coreOut;
protected File allOut;
protected File allOut;
/* attributes for filtering */
private static final String PATTERN = "^.*(%s).*$";
protected String optionalDirectories;
protected String provider = "raytheon";
/* attributes for filtering */
private static final String PATTERN = "^.*(%s).*$";
private Pattern providerPattern = Pattern.compile(String.format(PATTERN,
provider));
protected String provider = "raytheon";
protected String plugin = "plugin";
private Pattern providerPattern = Pattern.compile(String.format(PATTERN,
provider));
private Pattern pluginPattern = Pattern.compile(String.format(PATTERN,
plugin));
protected String plugin = "plugin";
/**
* @return the baseDirectories
*/
public String getBaseDirectories() {
return baseDirectories;
}
private Pattern pluginPattern = Pattern.compile(String.format(PATTERN,
plugin));
/**
* @param baseDirectories
* the baseDirectories to set
*/
public void setBaseDirectories(String baseDirectories) {
this.baseDirectories = baseDirectories;
}
/**
* @return the baseDirectories
*/
public String getBaseDirectories() {
return baseDirectories;
}
/**
* Sets the component provider filter. This is a pipe (|) separated string
* of names that identify a component as a non-COTS component. The default
* provider filter is <em>raytheon</em>.
*/
public void setProviderFilter(String filter) {
this.provider = filter;
this.providerPattern = Pattern.compile(String.format("^.*(%s).*$",
filter));
}
/**
* @param baseDirectories
* the baseDirectories to set
*/
public void setBaseDirectories(String baseDirectories) {
this.baseDirectories = baseDirectories;
}
/**
* Sets the plug-in identifier filter. This is a pipe (|) separated string
* of names that identify a component as an EDEX plug-in. The default
* plug-in filter is <em>plugin</em>.
*/
public void setPluginFilter(String filter) {
this.plugin = filter;
this.pluginPattern = Pattern.compile(String
.format("^.*(%s).*$", filter));
}
/**
* @return the optionalDirectories
*/
public String getOptionalDirectories() {
return optionalDirectories;
}
public void setAllOut(File f) {
this.allOut = f;
}
/**
* @param optionalDirectories
* the optionalDirectories to set
*/
public void setOptionalDirectories(String optionalDirectories) {
this.optionalDirectories = optionalDirectories;
}
public void setFeatureFile(File f) {
this.featureFile = f;
}
/**
* Sets the component provider filter. This is a pipe (|) separated string
* of names that identify a component as a non-COTS component. The default
* provider filter is <em>raytheon</em>.
*/
public void setProviderFilter(String filter) {
this.provider = filter;
this.providerPattern = Pattern.compile(String.format("^.*(%s).*$",
filter));
}
public void setCotsOut(File f) {
this.cotsOut = f;
}
/**
* Sets the plug-in identifier filter. This is a pipe (|) separated string
* of names that identify a component as an EDEX plug-in. The default
* plug-in filter is <em>plugin</em>.
*/
public void setPluginFilter(String filter) {
this.plugin = filter;
this.pluginPattern = Pattern.compile(String
.format("^.*(%s).*$", filter));
}
public void setPlugsOut(File f) {
this.plugsOut = f;
}
public void setAllOut(File f) {
this.allOut = f;
}
public void setCoreOut(File f) {
this.coreOut = f;
}
public void setFeatureFile(File f) {
this.featureFile = f;
}
public void setBaseDirectory(File aDir) {
this.baseDirectory = aDir;
}
public void setCotsOut(File f) {
this.cotsOut = f;
}
/**
* Main class called from ant. Tests to see if at least 1 includes file is
* to be generated. Only generates includes that have been specified from
* ant script. Throws BuildException if any error occurs, this halts the ant
* build and displays the error.
*
*/
public void execute() throws BuildException {
public void setPlugsOut(File f) {
this.plugsOut = f;
}
log("provider filter=" + this.providerPattern.toString());
log("plugin filter=" + this.pluginPattern.toString());
public void setCoreOut(File f) {
this.coreOut = f;
}
ArrayList<File> components = getComponents();
if (cotsOut == null && plugsOut == null && coreOut == null
&& allOut == null)
throw new BuildException(
"Must supply destination for at least one includes file");
if (featureFile == null)
throw new BuildException("Must supply a feature.xml file");
if (cotsOut != null)
generateCots(components);
if (plugsOut != null)
generatePlugs(components);
if (coreOut != null)
generateCore(components);
if (allOut != null)
generateAll(components);
}
public void setBaseDirectory(File aDir) {
this.baseDirectory = aDir;
}
/**
* Generates an includes file for all components in the feature. The
* directories in comps will be added to the includes file with a recursive
* reg ex. This means that the director and all of its sub directories and
* files will be included.
*
* @param comps
*/
protected void generateAll(ArrayList<File> comps) {
log("Generating ALL list in " + this.allOut.getPath());
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(allOut));
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
out.println("## Feature includes file generated on "
+ format.format(new Date()));
/**
* Main class called from ant. Tests to see if at least 1 includes file is
* to be generated. Only generates includes that have been specified from
* ant script. Throws BuildException if any error occurs, this halts the ant
* build and displays the error.
*
*/
public void execute() throws BuildException {
for (File f : comps) {
out.println(f.getName() + "/**");
}
log(String.format("Identified %d ALL list entries", comps.size()));
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (out != null) {
out.close();
}
}
log("provider filter=" + this.providerPattern.toString());
log("plugin filter=" + this.pluginPattern.toString());
}
ArrayList<File> components = getComponents();
if (cotsOut == null && plugsOut == null && coreOut == null
&& allOut == null)
throw new BuildException(
"Must supply destination for at least one includes file");
if (featureFile == null)
throw new BuildException("Must supply a feature.xml file");
if (cotsOut != null)
generateCots(components);
if (plugsOut != null)
generatePlugs(components);
if (coreOut != null)
generateCore(components);
if (allOut != null)
generateAll(components);
}
/**
* Populates a list of project directories with one directory for each
* component stated in feature. This list is built based on manifest ids and
* version compared to what is stated in the feature. These can differ
* drastically from the name of project.
*
* @return a populated list of directories based off feature
* @throws BuildException
* if there are any problems accessing feature or finding
* required components from feature.
*/
protected ArrayList<File> getComponents() throws BuildException {
/**
* Generates an includes file for all components in the feature. The
* directories in comps will be added to the includes file with a recursive
* reg ex. This means that the director and all of its sub directories and
* files will be included.
*
* @param comps
*/
protected void generateAll(ArrayList<File> comps) {
log("Generating ALL list in " + this.allOut.getPath());
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(allOut));
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
out.println("## Feature includes file generated on "
+ format.format(new Date()));
ArrayList<File> rval = null;
for (File f : comps) {
out.println(f.getName() + "/**");
}
log(String.format("Identified %d ALL list entries", comps.size()));
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (out != null) {
out.close();
}
}
FeatureExplorer fe = null;
}
// list of directories overrides single directory
if (baseDirectories != null) {
String[] fileNames = baseDirectories.split(";");
ArrayList<File> files = new ArrayList<File>(fileNames.length);
for (String fName : fileNames) {
File file = new File(fName);
files.add(file);
}
fe = new FeatureExplorer(new WorkspaceFeatureSearch(files),
new WorkspacePluginSearch(files));
} else if (baseDirectory != null) {
fe = new FeatureExplorer(baseDirectory, new WorkspaceFeatureSearch(
baseDirectory), new WorkspacePluginSearch(baseDirectory));
} else {
throw new BuildException(
"Did not have a baseDirectory or baseDirectories");
}
/**
* Populates a list of project directories with one directory for each
* component stated in feature. This list is built based on manifest ids and
* version compared to what is stated in the feature. These can differ
* drastically from the name of project.
*
* @return a populated list of directories based off feature
* @throws BuildException
* if there are any problems accessing feature or finding
* required components from feature.
*/
protected ArrayList<File> getComponents() throws BuildException {
try {
rval = fe.getPlugins(featureFile);
} catch (FeatureException e) {
throw new BuildException(e);
}
if (rval.isEmpty()) {
throw new BuildException("Unable to access file " + featureFile);
}
ArrayList<File> rval = null;
return rval;
}
FeatureExplorer fe = null;
/**
* Generates an includes file for all components (comps) having a project
* directory name that does not match the {@link #setProviderFilter(String)
* provider filter}. The project's manifest will be searched for a list of
* jars to specify in the includes file. If the list is not present in the
* manifest, the default is to include all *.jar files in the includes file.
*
* @param comps
* The full list of feature specified components
* @throws BuildException
* if any IOException occurs
*/
protected void generateCots(ArrayList<File> comps) throws BuildException {
log("Generating COTS list in " + this.cotsOut.getPath());
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(cotsOut));
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
out.println("## Cots includes file generated on "
+ format.format(new Date()));
int count = 0;
for (File f : comps) {
Matcher m = providerPattern.matcher(f.getName());
if (!m.matches()) {
out.println(f.getName());
count++;
}
}
log(String.format("Identified %d COTS list entries", count));
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (out != null) {
out.close();
}
}
}
ArrayList<File> files = null;
/**
* Generates an includes file for all components (comps) having a project
* directory name that matches both the {@link #setProviderFilter(String)
* provider filter} and the {@link #setPluginFilter(String) plug-in filter}.
*
* @param comps
* The full list of feature specified components
* @throws BuildException
* if any IOException occurs
*/
protected void generatePlugs(ArrayList<File> comps) throws BuildException {
log("Generating PLUGS list in " + this.plugsOut.getPath());
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(plugsOut));
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
out.println("## Plug-in includes file generated on "
+ format.format(new Date()));
int count = 0;
for (File f : comps) {
Matcher prm = providerPattern.matcher(f.getName());
Matcher plm = pluginPattern.matcher(f.getName());
if (prm.matches() && plm.matches()) {
out.println(f.getName());
count++;
}
}
log(String.format("Identified %d PLUGS list entries", count));
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (out != null) {
out.close();
}
}
}
File[] incFiles = null;
/**
* Generates an includes file for all components (comps) having a project
* directory name that matches the {@link #setProviderFilter(String)
* provider filter} and does not match the {@link #setPluginFilter(String)
* plug-in filter}.
*
* @param comps
* The full list of feature specified components
* @throws BuildException
* if any IOException occurs
*/
protected void generateCore(ArrayList<File> comps) throws BuildException {
log("Generating CORE list in " + this.coreOut.getPath());
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(coreOut));
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
out.println("## Core includes file generated on "
+ format.format(new Date()));
int count = 0;
for (File f : comps) {
Matcher prm = providerPattern.matcher(f.getName());
Matcher plm = pluginPattern.matcher(f.getName());
if (prm.matches() && !plm.matches()) {
out.println(f.getName());
count++;
}
}
log(String.format("Identified %d CORE list entries", count));
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (out != null) {
out.close();
}
}
}
ArrayList<File> includes = null;
// list of directories overrides single directory
if (baseDirectories != null) {
String[] fileNames = baseDirectories.split(";");
files = new ArrayList<File>(fileNames.length);
for (String fName : fileNames) {
File file = new File(fName);
files.add(file);
}
if (optionalDirectories != null) {
fileNames = optionalDirectories.split(";");
includes = new ArrayList<File>();
for (String fName : fileNames) {
File file = new File(fName);
files.add(file);
// iterate through each optional dir to find edex features
final Pattern p = Pattern.compile(".*edex.*feature");
incFiles = file.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return p.matcher(file.getName()).matches();
}
});
if (incFiles != null) {
includes.addAll(Arrays.asList(incFiles));
}
}
}
fe = new FeatureExplorer(new WorkspaceFeatureSearch(files),
new WorkspacePluginSearch(files));
} else if (baseDirectory != null) {
fe = new FeatureExplorer(baseDirectory, new WorkspaceFeatureSearch(
baseDirectory), new WorkspacePluginSearch(baseDirectory));
} else {
throw new BuildException(
"Did not have a baseDirectory or baseDirectories");
}
try {
rval = fe.getPlugins(featureFile, includes);
} catch (FeatureException e) {
throw new BuildException(e);
}
if (rval.isEmpty()) {
throw new BuildException("Unable to access file " + featureFile);
}
return rval;
}
/**
* Generates an includes file for all components (comps) having a project
* directory name that does not match the {@link #setProviderFilter(String)
* provider filter}. The project's manifest will be searched for a list of
* jars to specify in the includes file. If the list is not present in the
* manifest, the default is to include all *.jar files in the includes file.
*
* @param comps
* The full list of feature specified components
* @throws BuildException
* if any IOException occurs
*/
protected void generateCots(ArrayList<File> comps) throws BuildException {
log("Generating COTS list in " + this.cotsOut.getPath());
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(cotsOut));
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
out.println("## Cots includes file generated on "
+ format.format(new Date()));
int count = 0;
for (File f : comps) {
Matcher m = providerPattern.matcher(f.getName());
if (!m.matches()) {
out.println(f.getName());
count++;
}
}
log(String.format("Identified %d COTS list entries", count));
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (out != null) {
out.close();
}
}
}
/**
* Generates an includes file for all components (comps) having a project
* directory name that matches both the {@link #setProviderFilter(String)
* provider filter} and the {@link #setPluginFilter(String) plug-in filter}.
*
* @param comps
* The full list of feature specified components
* @throws BuildException
* if any IOException occurs
*/
protected void generatePlugs(ArrayList<File> comps) throws BuildException {
log("Generating PLUGS list in " + this.plugsOut.getPath());
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(plugsOut));
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
out.println("## Plug-in includes file generated on "
+ format.format(new Date()));
int count = 0;
for (File f : comps) {
Matcher prm = providerPattern.matcher(f.getName());
Matcher plm = pluginPattern.matcher(f.getName());
if (prm.matches() && plm.matches()) {
out.println(f.getName());
count++;
}
}
log(String.format("Identified %d PLUGS list entries", count));
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (out != null) {
out.close();
}
}
}
/**
* Generates an includes file for all components (comps) having a project
* directory name that matches the {@link #setProviderFilter(String)
* provider filter} and does not match the {@link #setPluginFilter(String)
* plug-in filter}.
*
* @param comps
* The full list of feature specified components
* @throws BuildException
* if any IOException occurs
*/
protected void generateCore(ArrayList<File> comps) throws BuildException {
log("Generating CORE list in " + this.coreOut.getPath());
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(coreOut));
SimpleDateFormat format = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
out.println("## Core includes file generated on "
+ format.format(new Date()));
int count = 0;
for (File f : comps) {
Matcher prm = providerPattern.matcher(f.getName());
Matcher plm = pluginPattern.matcher(f.getName());
if (prm.matches() && !plm.matches()) {
out.println(f.getName());
count++;
}
}
log(String.format("Identified %d CORE list entries", count));
} catch (IOException e) {
throw new BuildException(e);
} finally {
if (out != null) {
out.close();
}
}
}
}

View file

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@ -36,253 +37,271 @@ import com.raytheon.uf.featureexplorer.search.IPluginSearch;
* Oct 10, 2008 SP#15 bclement Added static functions for reading manifests
* Feb 4, 2013 #1577 bkowal Verify that a plugin has not been included in more than one feature.
* May 22, 2013 #1927 bkowal Fix improper String comparison
* Feb 25, 2015 #3299 garmendariz Process a list of included features
* </pre>
*
* @author dglazesk
* @version 1.0
*/
public class FeatureExplorer {
/**
* This holds the feature searching object for the class.
*/
protected IFeatureSearch featureSearch;
/**
* This holds the feature searching object for the class.
*/
protected IFeatureSearch featureSearch;
/**
* This holds the plugin searching object for the class.
*/
protected IPluginSearch pluginSearch;
/**
* This holds the plugin searching object for the class.
*/
protected IPluginSearch pluginSearch;
/**
* This holds the feature file object should the user choose to set it.
*/
protected File feature = null;
/**
* This holds the feature file object should the user choose to set it.
*/
protected File feature = null;
private Map<String, File> pluginLookupMap = new HashMap<String, File>();
private Map<String, File> pluginLookupMap = new HashMap<String, File>();
/**
* This constructor allows a user to setup what the feature for this
* instance is. This allows the user to use getPlugins(), though the other
* methods are still available.
*
* @param aFeature
* File object for the feature for this instance
* @param aFeatureSearch
* The object that can search for features
* @param aPluginSearh
* The object that can search for plugins
*/
public FeatureExplorer(File aFeature, IFeatureSearch aFeatureSearch,
IPluginSearch aPluginSearh) {
featureSearch = aFeatureSearch;
pluginSearch = aPluginSearh;
feature = aFeature;
}
/**
* This constructor allows a user to setup what the feature for this
* instance is. This allows the user to use getPlugins(), though the other
* methods are still available.
*
* @param aFeature
* File object for the feature for this instance
* @param aFeatureSearch
* The object that can search for features
* @param aPluginSearh
* The object that can search for plugins
*/
public FeatureExplorer(File aFeature, IFeatureSearch aFeatureSearch,
IPluginSearch aPluginSearh) {
featureSearch = aFeatureSearch;
pluginSearch = aPluginSearh;
feature = aFeature;
}
/**
* This constructor sets up the classes that will be used for searching for
* plugins and features. It is expected that a user will use
* getPlugins(File) or getPlugins(String) later when getting the plugins.
*
* @param aFeatureSearch
* The object that can search for features
* @param aPluginSearh
* The object that can search for plugins
*/
public FeatureExplorer(IFeatureSearch aFeatureSearch,
IPluginSearch aPluginSearh) {
featureSearch = aFeatureSearch;
pluginSearch = aPluginSearh;
}
/**
* This constructor sets up the classes that will be used for searching for
* plugins and features. It is expected that a user will use
* getPlugins(File) or getPlugins(String) later when getting the plugins.
*
* @param aFeatureSearch
* The object that can search for features
* @param aPluginSearh
* The object that can search for plugins
*/
public FeatureExplorer(IFeatureSearch aFeatureSearch,
IPluginSearch aPluginSearh) {
featureSearch = aFeatureSearch;
pluginSearch = aPluginSearh;
}
/**
* This is a convenience method for when the feature file object is set in a
* constructor.
*
* @return The list of files in the feature for this instance
* @throws FeatureException
*/
public ArrayList<File> getPlugins() throws FeatureException {
return getPlugins(feature);
}
/**
* This is a convenience method for when the feature file object is set in a
* constructor.
*
* @return The list of files in the feature for this instance
* @throws FeatureException
*/
public ArrayList<File> getPlugins() throws FeatureException {
return getPlugins(feature, null);
}
/**
* This is just a convenience method for getting plugins from a feature.
* This is equivalent to doing getPlugins(new File(aPath)).
*
* @param aPath
* Path to the feature.xml file to be scanned
* @return The list of file objects for all of the plugins in the feature
* @throws FeatureException
*/
public ArrayList<File> getPlugins(String aPath) throws FeatureException {
File feat = new File(aPath);
return getPlugins(feat);
}
/**
* This is just a convenience method for getting plugins from a feature.
* This is equivalent to doing getPlugins(new File(aPath)).
*
* @param aPath
* Path to the feature.xml file to be scanned
* @return The list of file objects for all of the plugins in the feature
* @throws FeatureException
*/
public ArrayList<File> getPlugins(String aPath, ArrayList<File> incList)
throws FeatureException {
File feat = new File(aPath);
return getPlugins(feat, incList);
}
/**
* This function attempts to find all of the plugins associated with the
* feature. This includes recursing into any included features and grabbing
* their plugins.
*
* @param aFeature
* The file object for the feature to be scanned
* @return The list of file objects for the located plugins
* @throws FeatureException
*/
public ArrayList<File> getPlugins(File aFeature) throws FeatureException {
ArrayList<File> rval = new ArrayList<File>();
/**
* This function attempts to find all of the plugins associated with the
* feature. This includes recursing into any included features and grabbing
* their plugins.
*
* @param aFeature
* The file object for the feature to be scanned
* @param incList
* @return The list of file objects for the located plugins
* @throws FeatureException
*/
public ArrayList<File> getPlugins(File aFeature, ArrayList<File> incList)
throws FeatureException {
ArrayList<File> rval = new ArrayList<File>();
HashMap<String, File> plugins = getFeaturePlugins(aFeature);
rval = new ArrayList<File>(plugins.values());
HashMap<String, File> plugins = getFeaturePlugins(aFeature, incList);
rval = new ArrayList<File>(plugins.values());
return rval;
}
return rval;
}
/**
* This finds all of the plugins listed in a feature and maps their ids to
* their file system locations as file objects. This is the function that
* does the brunt of the work in locating the plugins.
*
* @param aFile
* The feature file that is being scanned
* @return A hash map that links the plugin id to its file system location
* @throws FeatureException
* If there are any problems with JAXB, a feature cannot be
* found, or a plugin cannot be found
*/
protected HashMap<String, File> getFeaturePlugins(File aFile)
throws FeatureException {
HashMap<String, File> rval = new HashMap<String, File>();
if (aFile == null || !aFile.exists() || !aFile.canRead())
return rval;
/**
* This finds all of the plugins listed in a feature and maps their ids to
* their file system locations as file objects. This is the function that
* does the brunt of the work in locating the plugins.
*
* @param aFile
* The feature file that is being scanned
* @param incList
* @return A hash map that links the plugin id to its file system location
* @throws FeatureException
* If there are any problems with JAXB, a feature cannot be
* found, or a plugin cannot be found
*/
protected HashMap<String, File> getFeaturePlugins(File aFile,
ArrayList<File> incList) throws FeatureException {
HashMap<String, File> rval = new HashMap<String, File>();
if (aFile == null || !aFile.exists() || !aFile.canRead())
return rval;
Feature feat = null;
try {
JAXBContext jc = JAXBContext.newInstance(Feature.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
feat = (Feature) unmarshaller.unmarshal(aFile);
} catch (Exception e) {
throw new FeatureException("Unable to unmarshal file " + aFile, e);
}
Feature feat = null;
try {
JAXBContext jc = JAXBContext.newInstance(Feature.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
feat = (Feature) unmarshaller.unmarshal(aFile);
} catch (Exception e) {
throw new FeatureException("Unable to unmarshal file " + aFile, e);
}
for (Includes include : feat.getIncludes()) {
// go through all of the included features and try to find them
List<File> features = featureSearch.findFeature(include.getId(),
include.getVersion());
try {
// get all of the plugin id to file objects and add them
rval.putAll(getFeaturePlugins(features.get(0)));
} catch (IndexOutOfBoundsException e) {
if (!include.getOptional()) {
// this means we received an empty list, no feature found
throw new FeatureException("Could not find feature "
+ include.getId() + " with version greater than "
+ include.getVersion());
}
}
}
// if additional includes are passed in, add them for processing
if (incList != null && feat != null) {
List<Includes> featList = feat.getIncludes();
for (Plugin plugin : feat.getPlugins()) {
// go through all of the mentioned plugins
List<File> plugs = pluginSearch.findPlugin(plugin.getId(),
plugin.getVersion());
try {
if (this.pluginLookupMap.containsKey(plugin.getId())
&& !this.pluginLookupMap.get(plugin.getId()).equals(aFile)) {
StringBuilder stringBuilder = new StringBuilder("Plugin ");
stringBuilder.append(plugin.getId());
stringBuilder.append(" is in Feature ");
stringBuilder.append(this.generateFeatureFileName(
aFile.getParent(), aFile.getName()));
stringBuilder.append(" and Feature ");
stringBuilder
.append(this.generateFeatureFileName(
this.pluginLookupMap.get(plugin.getId())
.getParent(), this.pluginLookupMap
.get(plugin.getId()).getName()));
stringBuilder.append("!");
throw new FeatureException(stringBuilder.toString());
}
for (Iterator<File> iterator = incList.iterator(); iterator
.hasNext();) {
File incFile = (File) iterator.next();
featList.add(new Includes(incFile.getName(), "0.0.0", false));
}
// add the plugin id and its file object to the map
rval.put(plugin.getId(), plugs.get(0));
this.pluginLookupMap.put(plugin.getId(), aFile);
} catch (IndexOutOfBoundsException e) {
// this means we received an empty list, no plugin found
throw new FeatureException("Could not find plugin "
+ plugin.getId() + " with version greater than "
+ plugin.getVersion());
}
}
}
return rval;
}
for (Includes include : feat.getIncludes()) {
// go through all of the included features and try to find them
List<File> features = featureSearch.findFeature(include.getId(),
include.getVersion());
try {
// get all of the plugin id to file objects and add them
rval.putAll(getFeaturePlugins(features.get(0), null));
} catch (IndexOutOfBoundsException e) {
if (!include.getOptional()) {
// this means we received an empty list, no feature found
throw new FeatureException("Could not find feature "
+ include.getId() + " with version greater than "
+ include.getVersion());
}
}
}
private String generateFeatureFileName(String parentPath, String fileName) {
String[] pathElements = parentPath.split(File.separator);
return pathElements[pathElements.length - 1] + File.separator
+ fileName;
}
for (Plugin plugin : feat.getPlugins()) {
// go through all of the mentioned plugins
List<File> plugs = pluginSearch.findPlugin(plugin.getId(),
plugin.getVersion());
try {
if (this.pluginLookupMap.containsKey(plugin.getId())
&& !this.pluginLookupMap.get(plugin.getId()).equals(
aFile)) {
StringBuilder stringBuilder = new StringBuilder("Plugin ");
stringBuilder.append(plugin.getId());
stringBuilder.append(" is in Feature ");
stringBuilder.append(this.generateFeatureFileName(
aFile.getParent(), aFile.getName()));
stringBuilder.append(" and Feature ");
stringBuilder
.append(this.generateFeatureFileName(
this.pluginLookupMap.get(plugin.getId())
.getParent(), this.pluginLookupMap
.get(plugin.getId()).getName()));
stringBuilder.append("!");
throw new FeatureException(stringBuilder.toString());
}
/**
* Searches a project's manifest for a specific attribute. The returned list
* will contain all values for the attribute or empty if not found.
*
* @param projectRoot
* @param attrib
* @return a list of a values for the attribute or an empty list if not
* found
* @throws IOException
*/
public static List<String> readManifest(File projectRoot, String attrib)
throws IOException {
File maniFile = new File(projectRoot, "/META-INF/MANIFEST.MF");
Manifest m = null;
List<String> rval = new ArrayList<String>();
// add the plugin id and its file object to the map
rval.put(plugin.getId(), plugs.get(0));
this.pluginLookupMap.put(plugin.getId(), aFile);
} catch (IndexOutOfBoundsException e) {
// this means we received an empty list, no plugin found
throw new FeatureException("Could not find plugin "
+ plugin.getId() + " with version greater than "
+ plugin.getVersion());
}
}
try {
m = new Manifest();
// we only care if the manifest actually exists
InputStream is = new FileInputStream(maniFile);
m.read(is);
is.close();
return rval;
}
} catch (IOException e) {
throw new IOException(
"IO Error while reading manifest for project: "
+ projectRoot.getName());
}
private String generateFeatureFileName(String parentPath, String fileName) {
String[] pathElements = parentPath.split(File.separator);
return pathElements[pathElements.length - 1] + File.separator
+ fileName;
}
// if we get this far, m shouldn't be null
if (m != null) {
Attributes attribs = m.getMainAttributes();
String deploys = attribs.getValue(attrib);
/**
* Searches a project's manifest for a specific attribute. The returned list
* will contain all values for the attribute or empty if not found.
*
* @param projectRoot
* @param attrib
* @return a list of a values for the attribute or an empty list if not
* found
* @throws IOException
*/
public static List<String> readManifest(File projectRoot, String attrib)
throws IOException {
File maniFile = new File(projectRoot, "/META-INF/MANIFEST.MF");
Manifest m = null;
List<String> rval = new ArrayList<String>();
// manifests that do not have a deploy entry will return a wildcard
if (deploys != null) {
for (String s : deploys.split(",")) {
rval.add(s.trim());
}
}
}
return rval;
}
try {
m = new Manifest();
// we only care if the manifest actually exists
InputStream is = new FileInputStream(maniFile);
m.read(is);
is.close();
/**
* Reads the manifest for the project and returns all values for the
* "Edex-Deploy" attribute. If the attribute could not be found, default to
* returning a wildcard for all jars.
*
* @param projectRoot
* @return a list of jar names or a wildcard for all jars if attribute not
* found
* @throws IOException
*/
public static List<String> getJars(File projectRoot) throws IOException {
List<String> rval = readManifest(projectRoot, "Edex-Deploy");
if (rval.isEmpty()) {
rval.add("*.jar");
}
return rval;
}
} catch (IOException e) {
throw new IOException(
"IO Error while reading manifest for project: "
+ projectRoot.getName());
}
// if we get this far, m shouldn't be null
if (m != null) {
Attributes attribs = m.getMainAttributes();
String deploys = attribs.getValue(attrib);
// manifests that do not have a deploy entry will return a wildcard
if (deploys != null) {
for (String s : deploys.split(",")) {
rval.add(s.trim());
}
}
}
return rval;
}
/**
* Reads the manifest for the project and returns all values for the
* "Edex-Deploy" attribute. If the attribute could not be found, default to
* returning a wildcard for all jars.
*
* @param projectRoot
* @return a list of jar names or a wildcard for all jars if attribute not
* found
* @throws IOException
*/
public static List<String> getJars(File projectRoot) throws IOException {
List<String> rval = readManifest(projectRoot, "Edex-Deploy");
if (rval.isEmpty()) {
rval.add("*.jar");
}
return rval;
}
}