Merge branch 'ohd_15.1.1' of ssh://vlab.ncep.noaa.gov:29418/AWIPS2_Dev_Baseline into master_15.1.1

Former-commit-id: 366cd07d35f6e9f842ba72d1164a53fbb5fc6838
This commit is contained in:
Fay.Liang 2015-03-19 12:42:35 -04:00
commit 4718a036f1
8 changed files with 302 additions and 58 deletions

View file

@ -19,9 +19,11 @@
**/
package com.raytheon.viz.hydrobase.dialogs;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
import org.eclipse.swt.SWT;
@ -46,6 +48,7 @@ import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.hydrobase.listeners.ICountyStateListener;
import com.raytheon.viz.hydrobase.listeners.IStationListener;
@ -83,6 +86,9 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Changes for non-blocking CoopAgencyOfficeDlg.
* Changes for non-blocking CopyNewLocationDlg.
* Changes for non-blocking CountyStateDlg.
* 08 Jan 2015 15695, 15488 djingtao fix the save/update text field with apostrophe, repleace the single
* apostrophe to two single apostrophe before save/update to database.
* 02 Feb 2015 13372 djingtao change the GMT time to local time for "revise" field
*
*
* </pre>
@ -1800,7 +1806,40 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements
* If station is "Inactive", store an 'I' in the loc.type field.
*/
dataToSave.setType((inactiveChk.getSelection()) ? "I" : "");
/* Check if text fields in dataToSave include single apostrophe, if it do, replace to
two single apostrophe */
AppsDefaults ad = AppsDefaults.getInstance();
boolean debug = ad.getBoolean(HydroConstants.DEBUG_HYDRO_DB_TOKEN, false);
Class<?> c = dataToSave.getClass();
Field fields[] = c.getDeclaredFields();
for (Field f : fields)
{
try
{
if (f.getType().isAssignableFrom(String.class))
{
if (debug)
System.out.println("The field name is " + f.getName());
f.setAccessible(true);
String value = (String) f.get(dataToSave).toString();
if (value.contains("'"))
{
value = value.replace("'", "''");
f.set(dataToSave, value);
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
// Save to DB via DataManager
try {
HydroDBDataManager.getInstance().putData(dataToSave);
@ -1905,9 +1944,14 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements
// If the Revision Checkbox is checked, set the Revision Date to the
// current date
// Else load the date from the database
Calendar now = Calendar.getInstance(Locale.getDefault());
String revise_str = new SimpleDateFormat("MM/dd/yyyy").format(now.getTime());
if (reviseChk.getSelection()) {
reviseTF.setText(locDate.format(Calendar.getInstance(
TimeZone.getTimeZone("GMT")).getTime()));
// reviseTF.setText(locDate.format(Calendar.getInstance(
// TimeZone.getTimeZone("GMT")).getTime()));
reviseTF.setText(revise_str);
} else if (locData != null) {
reviseTF.setText((locData.getReviseDate() != null) ? locDate
.format(locData.getReviseDate()) : "");

View file

@ -23,6 +23,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import org.eclipse.swt.SWT;
@ -77,6 +78,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Apr 16,2012 14797 wkwock Change lat/lon from hour minute sec to decimal.
* Jun 11,2013 2088 rferrel Make dialog non-blocking.
* Changes for non-blocking FcstPointGroupDlg.
* Feb.02, 2015 #13372 djingtao Change from GMT time to local time for "Revise" field
*
* </pre>
*
@ -1531,11 +1533,16 @@ public class RiverGageDlg extends CaveSWTDialog implements
*/
private void updateRevisionDate() {
// If the Revision Checkbox is checked, set the Revision Date to the
// current date
// current date in local time
// Else load the date from the database
Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime();
if (reviseChk.getSelection()) {
dateTF.setText(dateFormat.format(now));
//Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime();
Calendar now = Calendar.getInstance(Locale.getDefault());
String revise_str = new SimpleDateFormat("MM/dd/yyyy").format(now.getTime());
if (reviseChk.getSelection()) {
//dateTF.setText(dateFormat.format(now));
dateTF.setText(revise_str);
} else if (riverGageData != null) {
dateTF.setText((riverGageData.getReviseDate() != null) ? dateFormat
.format(riverGageData.getReviseDate()) : "");

View file

@ -22,6 +22,7 @@ package com.raytheon.viz.hydrocommon.colorscalemgr;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.jface.dialogs.MessageDialog;
@ -54,7 +55,10 @@ 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.viz.core.RGBColors;
import com.raytheon.uf.viz.core.catalog.DirectDbQuery;
import com.raytheon.uf.viz.core.catalog.DirectDbQuery.QueryLanguage;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.hydrocommon.HydroConstants;
import com.raytheon.viz.hydrocommon.data.ColorValueData;
import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@ -74,6 +78,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 01 Jul 2013 2088 rferrel Changes for non-blocking dialogs.
* 06 Sep 2013 #2342 lvenable Fixed color memory leaks and a null point exception.
* 04 Sep 2014 14448 cgobs Make MPE redisplay after save of color settings in ColorScaleMgr
* 26 Feb 2015 16848 cgobs Fix merging of color sets by deleting existing set before saving new set.
* </pre>
*
* @author lvenable
@ -1955,6 +1960,66 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
return true;
}
private void deleteDataFromDb(String applicationName, String colorUseName, String userId, String durationString) {
HydroDBDataManager manager = HydroDBDataManager.getInstance();
String whereClause = " WHERE application_name = '" + applicationName + "' AND " +
"color_use_name = '" + colorUseName + "' AND " +
"userId = '" + userId + "' AND " +
"duration = '" + durationString + "' AND " +
"threshold_unit = 'E' ";
String statement = "delete from colorValue " + whereClause;
try
{
DirectDbQuery.executeStatement(statement,HydroConstants.IHFS, QueryLanguage.SQL);
}
catch (VizException e) {
statusHandler.handle(Priority.ERROR,
"Error deleting Color Value Data: ", e);
}
// 0. Collect data to delete (user, dataType, duration
java.util.List<ColorScaleData> data = editColorData
.getUsedColorScaleDataArray(userId, durationString + "_" + colorUseName);
ColorValueData cvd = new ColorValueData();
cvd.setApplicationName(applicationName);
cvd.setColorUseName(colorUseName);
cvd.setUserId(userId);
cvd.setDuration(durationString);
System.out.println("Attempting to delete data from cvd = " + getStringFromColorValueData(cvd) );
// 1. Delete each record from database
for (ColorScaleData csd : data) {
cvd.setThresholdValue(csd.getDoubleVal().toString());
try {
manager.deleteRecord(cvd);
} catch (VizException e) {
statusHandler.handle(Priority.ERROR,
"Error deleting Color Value Data: ", e);
}
}
}
private String getStringFromColorValueData(ColorValueData cvd)
{
StringBuilder builder = new StringBuilder();
builder.append("appName: " + cvd.getApplicationName() +
" colorUseName: " + cvd.getColorUseName() +
" userId: " + cvd.getUserId() +
" duration: " + cvd.getDuration());
return builder.toString();
}
/**
* save the data to the database
*
@ -1966,6 +2031,69 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
HydroDBDataManager manager = HydroDBDataManager.getInstance();
String userId = user;
String applicationName = colorManager.getApplicationName();
String colorUseName = colorManager.getDataTypeName(saveDataTypeCbo
.getText());
String duration = selectedDurationInSeconds.toString();
deleteDataFromDb(applicationName, colorUseName, userId, duration);
ColorValueData cvd = new ColorValueData();
for (ColorValueLabels cvls : colorValLblArray) {
String threshold = cvls.getValueText();
String colorName = cvls.getColorName();
String thresholdUnit = "E";
if (ColorScaleData.MISSING.equals(threshold)) {
threshold = "-9999";
} else if (ColorScaleData.LESS_THAN_MIN.equals(threshold)) {
threshold = "-8888";
}
cvd.setApplicationName(applicationName);
cvd.setUserId(userId);
cvd.setColorName(colorName);
cvd.setColorUseName(colorUseName);
cvd.setDuration(duration);
cvd.setThresholdUnit(thresholdUnit);
cvd.setThresholdValue(threshold);
try {
manager.putData(cvd);
} catch (VizException e1) {
statusHandler.handle(Priority.ERROR,
"Error saving Color Value Data: ", e1);
}
}
if (sourceCbo.getText().equals(DEFAULT)) {
createDefaultData();
} else {
createColorData(user);
}
updateDurationCombo();
updateColorValueLabelBar();
if (this.saveCallback != null) {
this.saveCallback.execute();
}
setReturnValue(true);
}
/**
* save the data to the database
*
* @param user
* user to save current data as
*/
private void saveDataOrig(String user) {
setSelectedDuration(durationCbo.getText());
HydroDBDataManager manager = HydroDBDataManager.getInstance();
String userId = user;
String applicationName = colorManager.getApplicationName();
String colorUseName = colorManager.getDataTypeName(saveDataTypeCbo
@ -1998,7 +2126,13 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
}
}
//delete all old records
for (ColorValueLabels cvls : usedColorValLblArray) {
System.out.printf(" value = %s, colorName = %s\n", cvls.getValueText(), cvls.getColorName() );
boolean found = false;
for (int i = 0; (i < colorValLblArray.size()) && !found; ++i) {
String val = colorValLblArray.get(i).getValueText();
@ -2006,6 +2140,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog {
found = true;
}
}
System.out.printf("found = %b\n", found);
if (!found) {
cvd.setApplicationName(applicationName);
cvd.setUserId(userId);

View file

@ -48,6 +48,8 @@ import org.eclipse.swt.graphics.RGB;
* 29 NOV 2007 373 lvenable Initial creation
* 18 APR 2013 1790 rferrel Cleanup method interfaces;
* part of non-blocking dialogs.
* 26 Feb 2015 16777 cgobs Fix code so that undo in color manager works
* for missing and lessThanMin color-value pairs
*
* </pre>
*
@ -104,7 +106,11 @@ public class ColorScaleSets {
public void updateMissingColor(RGB rgb) {
for (int i = 0; i < updatedColorSet.size(); ++i) {
if (updatedColorSet.get(i).value.compareTo(ColorScaleData.MISSING) == 0) {
updatedColorSet.get(i).setColor(rgb);
// updatedColorSet.get(i).setColor(rgb);
ColorScaleData newData = new ColorScaleData();
newData.missingScaleData(rgb);
updatedColorSet.set(i, newData);
break;
}
}
@ -120,7 +126,12 @@ public class ColorScaleSets {
for (int i = 0; i < updatedColorSet.size(); ++i) {
if (updatedColorSet.get(i).value
.compareTo(ColorScaleData.LESS_THAN_MIN) == 0) {
updatedColorSet.get(i).setColor(rgb);
//updatedColorSet.get(i).setColor(rgb);
ColorScaleData newData = new ColorScaleData();
newData.lessThanMinScaleData(rgb);
updatedColorSet.set(i, newData);
break;
}
}

View file

@ -59,7 +59,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Sep 10, 2008 lvenable Initial creation
* Feb 13, 2013 15794 wkwock Make Sequence number goes up to 99
* Jul 10, 2013 2088 rferrel Make dialog non-blocking.
*
* Feb 03, 2015 16883 djingtao Contact "New" button causes record to be written to the db
* Feb 03, 2015 14147 djingtao "Sequence" number in Contact
* </pre>
*
* @author lvenable
@ -391,7 +392,8 @@ public class ContactsDlg extends CaveSWTDialog {
newBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
newContactFlag = true;
updateInsertContactData();
// updateInsertContactData();
clearInformationFields();
}
});
@ -419,7 +421,18 @@ public class ContactsDlg extends CaveSWTDialog {
* Clear the informations fields.
*/
private void clearInformationFields() {
seqNumSpnr.setSelection(5);
// get how many contacts in the Contacts List
int contactNum = 0;
try {
contactNum = ContactsDataManager.getInstance().getContactData(locationId).size();
} catch (VizException e) {
statusHandler.handle(Priority.ERROR,
"Unable to determine if contact exits: ", e);
}
//seqNumSpnr.setSelection(1);
seqNumSpnr.setSelection(contactNum + 1);
contactNameTF.setText("");
phoneTF.setText("");
emailTF.setText("");
@ -455,18 +468,13 @@ public class ContactsDlg extends CaveSWTDialog {
* Check if the contact already exists.
*/
if (contactExits == true) {
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
| SWT.OK | SWT.CANCEL);
mb.setText("Insert");
mb.setMessage("The contact you want to insert already exists.\n"
+ "Do you wish to update the existing data?");
int result = mb.open();
if (result == SWT.CANCEL) {
state = false;
} else {
state = updateContact();
}
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR
| SWT.OK);
mb.setText("Error");
mb.setMessage("The contact you want to insert already exists.");
mb.open();
state = false;
} else {
state = insertNewContact();
}
@ -511,7 +519,7 @@ public class ContactsDlg extends CaveSWTDialog {
* @return true when update successful
*/
private boolean updateContact() {
try {
try {
ContactsData data = new ContactsData();
data.setLid(locationId);
data.setContact(contactNameTF.getText().trim());

View file

@ -30,7 +30,8 @@ package com.raytheon.viz.hydrocommon.cresthistory;
* ------------ ---------- ----------- --------------------------
* Dec 11, 2008 1628 dhladky initial
* Nov 04, 2010 5518 lbousaid added all/above/bellow flag to
* getRiverCrestData
* getRiverCrestData
* Jan 09, 2015 16698 JingtaoD Crest History failed validation dialog pops up when OK button clicked
*
* </pre>
*
@ -207,14 +208,17 @@ public class CrestHistoryDataManager {
try {
DirectDbQuery.executeStatement(insertCrest, HydroConstants.IHFS,
QueryLanguage.SQL);
} catch (VizException e) {
/* If this update fails then try an insert */
if (e.getMessage().contains("crest_pk")) {
} catch (VizException e) {
e.printStackTrace();
//exception with duplicate key value is throwed in the 2nd cause
if (e.getCause().getCause().getMessage().contains("crest_pk")) {
executeUpdate = true;
} else {
errMsg = "Error inserting data into database.";
}
e.printStackTrace();
}
}
if (executeUpdate) {

View file

@ -25,6 +25,8 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.dialogs.postanalysis.SummedHourlyMpeDlg;
/**
@ -37,7 +39,7 @@ import com.raytheon.viz.mpe.ui.dialogs.postanalysis.SummedHourlyMpeDlg;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 12, 2011 lvenable Initial creation
*
* Feb 26, 2015 9554 cgobs Enable button based on mpe_post_analysis token and MPE 1-hr vs DQC mode
* </pre>
*
* @author lvenable
@ -60,4 +62,25 @@ public class SummedHourlyMpeAction extends AbstractHandler {
return null;
}
public boolean isEnabled()
{
System.out.println("In SummedHourlyMpeAction.isEnabled()");
AppsDefaults appsDefaults = AppsDefaults.getInstance();
boolean isPostAnalysisOnByToken = appsDefaults.getBoolean("mpe_post_analysis", false);
MPEDisplayManager mgr = MPEDisplayManager.getCurrent();
boolean isDailyQCOn = (mgr.isQpf() || mgr.isZflag() || mgr.isMaxmin());
boolean isPostAnalysisAvailable = isDailyQCOn && isPostAnalysisOnByToken;
return isPostAnalysisAvailable;
}
}

View file

@ -1,34 +1,8 @@
#! /bin/ksh
# purge_mpe_files
# This script purges mpe (Multi-sensor-Precipitation Estimator)files
# History: Deng, Jingtao August 09, 2001
# modified by P. Tilles 4/22/2002
# - removed stage3 directories
# - added jpeg, netCDF, grib directories
# modified by P. Tilles 10/2002
# - added DISAGG_LOG_DIR purge
# modified by P. Tilles 9/2003
# - added LIGHTNING_LOG_DIR purge
# March 9 2004 - added purge of mlmosaic files - pst
# March 25 2004 - added purge of lsatpre files - pst
# - removed delete from satel_precip dir
# March 30 2004 - added purge of state var files
# for local bias corr satellite - pst
# May 5, 2006 - Modified to fix mistakes made in logic
# to purge MAXRMOSAIC, AVGRMOSAIC, and
# P3LMOSAIC fields. Added logic to purge
# GAGETRIANGLES.
# May 5, 2006 - Modified to purge DailyQC files.
# Nov 17, 2006 - Modified to purge sbn grib and sbn qpe directories.
# May 2007 - Added SRG related fields (3 new fields)
# - added "-type f" to all find commands
# - added directories for RFC bias transfer RFC bias fields
# Sep 2007 - removed stray "i" from delete on FREEZEGRID directory
# Nov 2007 - added purge of disagg logs from mpe_editor dir
# - changed purge of mpe_fieldgen logs to purge filenames mpe_*
# Dec 2007 - removed purge of old disagg logs from old disagg app
# Jan 2008 - added purge of DailyQC freezing level preprocessor logs.
# April 2014 - add purge dualpol products
# March 2015 - added purge of localfield directories and auto_dailyqc logs
# This allows you to run this script from outside of ./whfs/bin
RUN_FROM_DIR=`dirname $0`
@ -50,6 +24,7 @@ export PPROC_LOG=$(get_apps_defaults pproc_log)
# Define directories for MPE data.
MPELOGS=$MPE_LOG_DIR
MPEEDITLOGS=$PPROC_LOG/mpe_editor
AUTODQCLOGDIR=$MPEEDITLOGS
RFCBIASLOGS=$PPROC_LOG/process_bias_message
GAQLOGS=$GAQ_LOG_DIR
@ -91,6 +66,10 @@ MPEMLDMOSAIC=$RFCWIDE_OUTPUT_DIR/mldmosaic
MPEAVGRDMOSAIC=$RFCWIDE_OUTPUT_DIR/avgrdmosaic
MPEMAXRDMOSAIC=$RFCWIDE_OUTPUT_DIR/maxrdmosaic
LOCALFIELD1DIR=$RFCWIDE_OUTPUT_DIR/localfield1
LOCALFIELD2DIR=$RFCWIDE_OUTPUT_DIR/localfield2
LOCALFIELD3DIR=$RFCWIDE_OUTPUT_DIR/localfield3
MPERFCBMOSAIC=$RFCWIDE_OUTPUT_DIR/rfcbmosaic
MPERFCMMOSAIC=$RFCWIDE_OUTPUT_DIR/rfcmmosaic
@ -331,6 +310,37 @@ find $MPESRDMOSAIC -name '*z' -type f -mtime +1 -print -exec rm {} \; \
find $MPESRDGMOSAIC -name '*z' -type f -mtime +1 -print -exec rm {} \; \
>> $fnm
# purge LOCALFIELD directories
if [[ -d $LOCALFIELD1DIR ]]
then
find $LOCALFIELD1DIR -name '*z' -type f -mtime +1 -print -exec rm {} \; \
>> $fnm
fi
if [[ -d $LOCALFIELD2DIR ]]
then
find $LOCALFIELD2DIR -name '*z' -type f -mtime +1 -print -exec rm {} \; \
>> $fnm
fi
if [[ -d $LOCALFIELD3DIR ]]
then
find $LOCALFIELD3DIR -name '*z' -type f -mtime +1 -print -exec rm {} \; \
>> $fnm
fi
# purge auto_dailyQC log files
echo " " >> $fnm
echo " auto_dailyqc log files " >> $fnm
if [[ -d $AUTODQCLOGDIR ]]
then
find $AUTODQCLOGDIR -name 'auto_dailyqc*' -type f -mtime +10 -print -exec rm {} \; \
>> $fnm
fi
Dte=`date -u`
echo "End purge_mpe_files at: " $Dte >> $fnm