Omaha #4500 - Update hydro blind casts to use Number

Change-Id: Ide22b937047d254cb3fb003df630c936d601fe22

Former-commit-id: 877a65681207ae7d93ac385e88dbc213980a49de
This commit is contained in:
Richard Peter 2015-07-21 17:17:13 -05:00
parent 32b5f874cf
commit 7a79834265
26 changed files with 1813 additions and 1668 deletions

View file

@ -76,7 +76,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 29 NOV 2007 373 lvenable Initial creation. * 29 NOV 2007 373 lvenable Initial creation.
* 13 Oct 2009 2256 mpduff Implement the dialog. * 13 Oct 2009 2256 mpduff Implement the dialog.
* 07 Feb 2013 1578 rferrel Changes for non-blocking dialog. * 07 Feb 2013 1578 rferrel Changes for non-blocking dialog.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author lvenable * @author lvenable
@ -218,7 +218,7 @@ public class FlashFloodGuidanceDlg extends CaveSWTDialog {
private Button closeBtn; private Button closeBtn;
/** Bundle variables */ /** Bundle variables */
private Map<String, String> parameters = new HashMap<String, String>(); private final Map<String, String> parameters = new HashMap<String, String>();
/** /**
* The selected RFC. * The selected RFC.
@ -243,12 +243,12 @@ public class FlashFloodGuidanceDlg extends CaveSWTDialog {
/** /**
* Holds the display string and insert time for later use. * Holds the display string and insert time for later use.
*/ */
private Map<String, Date> dataMap = new HashMap<String, Date>(); private final Map<String, Date> dataMap = new HashMap<String, Date>();
/** /**
* Holds the display string and the xmrg File object. * Holds the display string and the xmrg File object.
*/ */
private Map<String, File> fileMap = new HashMap<String, File>(); private final Map<String, File> fileMap = new HashMap<String, File>();
/** /**
* The wait mouse pointer. * The wait mouse pointer.
@ -1073,8 +1073,8 @@ public class FlashFloodGuidanceDlg extends CaveSWTDialog {
for (Object[] oa : rs) { for (Object[] oa : rs) {
Timestamp validTime = (Timestamp) oa[0]; Timestamp validTime = (Timestamp) oa[0];
int shefDur = (Integer) oa[1]; int shefDur = ((Number) oa[1]).intValue();
int dur = shefDur - (shefDur / 1000) * 1000; int dur = shefDur - ((shefDur / 1000) * 1000);
// Dur is FFG03, FFG06, etc // Dur is FFG03, FFG06, etc
// selectedDur is 1hr, 3hr, etc // selectedDur is 1hr, 3hr, etc

View file

@ -23,108 +23,131 @@ package com.raytheon.viz.hydro.pointdatacontrol.data;
* TODO Add Description * TODO Add Description
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 17, 2008 mpduff Initial creation * Nov 17, 2008 mpduff Initial creation
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author mpduff * @author mpduff
* @version 1.0 * @version 1.0
*/ */
public class IngestFilter { public class IngestFilter {
private String lid = null; private String lid = null;
private String pe = null; private String pe = null;
private int dur; private int dur;
private String ts = null; private String ts = null;
private String extremum = null; private String extremum = null;
private int tsRank; private int tsRank;
public IngestFilter() { public IngestFilter() {
} }
public IngestFilter(Object[] data) { public IngestFilter(Object[] data) {
int i = 0; int i = 0;
setLid((String)data[i++]) ; setLid((String) data[i++]);
setPe((String)data[i++]); setPe((String) data[i++]);
setDur((Integer)data[i++]); setDur(((Number) data[i++]).intValue());
setTs((String)data[i++]); setTs((String) data[i++]);
setExtremum((String)data[i++]); setExtremum((String) data[i++]);
setTsRank((Integer)data[i++]); setTsRank(((Number) data[i++]).intValue());
} }
/** /**
* @return the lid * @return the lid
*/ */
public String getLid() { public String getLid() {
return lid; return lid;
} }
/** /**
* @param lid the lid to set * @param lid
* the lid to set
*/ */
public void setLid(String lid) { public void setLid(String lid) {
this.lid = lid; this.lid = lid;
} }
/** /**
* @return the pe * @return the pe
*/ */
public String getPe() { public String getPe() {
return pe; return pe;
} }
/** /**
* @param pe the pe to set * @param pe
* the pe to set
*/ */
public void setPe(String pe) { public void setPe(String pe) {
this.pe = pe; this.pe = pe;
} }
/** /**
* @return the dur * @return the dur
*/ */
public int getDur() { public int getDur() {
return dur; return dur;
} }
/** /**
* @param dur the dur to set * @param dur
* the dur to set
*/ */
public void setDur(int dur) { public void setDur(int dur) {
this.dur = dur; this.dur = dur;
} }
/** /**
* @return the ts * @return the ts
*/ */
public String getTs() { public String getTs() {
return ts; return ts;
} }
/** /**
* @param ts the ts to set * @param ts
* the ts to set
*/ */
public void setTs(String ts) { public void setTs(String ts) {
this.ts = ts; this.ts = ts;
} }
/** /**
* @return the extremum * @return the extremum
*/ */
public String getExtremum() { public String getExtremum() {
return extremum; return extremum;
} }
/** /**
* @param extremum the extremum to set * @param extremum
* the extremum to set
*/ */
public void setExtremum(String extremum) { public void setExtremum(String extremum) {
this.extremum = extremum; this.extremum = extremum;
} }
/** /**
* @return the tsRank * @return the tsRank
*/ */
public int getTsRank() { public int getTsRank() {
return tsRank; return tsRank;
} }
/** /**
* @param tsRank the tsRank to set * @param tsRank
* the tsRank to set
*/ */
public void setTsRank(int tsRank) { public void setTsRank(int tsRank) {
this.tsRank = tsRank; this.tsRank = tsRank;

View file

@ -26,7 +26,8 @@ package com.raytheon.viz.hydro.pointdatacontrol.data;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 24, 2008 mpduff Initial creation * Nov 24, 2008 mpduff Initial creation
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author mpduff * @author mpduff
@ -97,76 +98,76 @@ public class LocPDC {
* Telemetry Type. * Telemetry Type.
*/ */
private String telemType = null; private String telemType = null;
public LocPDC() { public LocPDC() {
} }
public LocPDC(Object[] data) { public LocPDC(Object[] data) {
int i = 0; int i = 0;
if (data[i] != null) { // LID if (data[i] != null) { // LID
setLid((String)data[i]); setLid((String) data[i]);
} }
if (data[++i] != null) { // name if (data[++i] != null) { // name
setName((String)data[i]); setName((String) data[i]);
} }
if (data[++i] != null) { // lat if (data[++i] != null) { // lat
setLat((Double)data[i]); setLat((Double) data[i]);
} }
if (data[++i] != null) { // lon if (data[++i] != null) { // lon
setLon((Double)data[i]); setLon((Double) data[i]);
} }
if (data[++i] != null) { // hsa if (data[++i] != null) { // hsa
setHsa((String)data[i]); setHsa((String) data[i]);
} }
if (data[++i] != null) { // post if (data[++i] != null) { // post
setPost((Integer)data[i]); setPost(((Number) data[i]).intValue());
} }
if (data[++i] != null) { // elev if (data[++i] != null) { // elev
setElev((Double)data[i]); setElev((Double) data[i]);
} }
if (data[++i] != null) { // primary_pe if (data[++i] != null) { // primary_pe
setPrimaryPe((String)data[i]); setPrimaryPe((String) data[i]);
} }
if (data[++i] != null) { // fs if (data[++i] != null) { // fs
setFs((Double)data[i]); setFs((Double) data[i]);
} }
if (data[++i] != null) { // fq if (data[++i] != null) { // fq
setFq((Double)data[i]); setFq((Double) data[i]);
} }
// disp_class, is_dcp, is_observer, telem_type // disp_class, is_dcp, is_observer, telem_type
if (data[++i] != null) { // disp_class if (data[++i] != null) { // disp_class
setDispClass((String)data[i]); setDispClass((String) data[i]);
} }
if (data[++i] != null) { if (data[++i] != null) {
if (((String)data[i]).equalsIgnoreCase("F")) { if (((String) data[i]).equalsIgnoreCase("F")) {
setDcp(false); setDcp(false);
} else { } else {
setDcp(true); setDcp(true);
} }
} }
if (data[++i] != null) { if (data[++i] != null) {
if (((String)data[i]).equalsIgnoreCase("F")) { if (((String) data[i]).equalsIgnoreCase("F")) {
setObserver(false); setObserver(false);
} else { } else {
setObserver(true); setObserver(true);
} }
} }
if (data[++i] != null) { // Telem_type if (data[++i] != null) { // Telem_type
setTelemType((String)data[i]); setTelemType((String) data[i]);
} }
} }

View file

@ -62,15 +62,17 @@ import com.raytheon.viz.hydrocommon.whfslib.PrecipUtil;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 22, 2008 mpduff Initial creation * Oct 22, 2008 mpduff Initial creation
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
*
* @author mpduff * @author mpduff
* @version 1.0 * @version 1.0
*/ */
public class PDCDataManager extends HydroDataManager { public class PDCDataManager extends HydroDataManager {
private static PDCDataManager instance = null; private static PDCDataManager instance = null;
private static Map<String, String> peMap = null; private static Map<String, String> peMap = null;
private static final String obsQueryHead = "select lid, pe, dur, ts, extremum, obstime, " private static final String obsQueryHead = "select lid, pe, dur, ts, extremum, obstime, "
@ -79,19 +81,19 @@ public class PDCDataManager extends HydroDataManager {
private static Map<String, List<IngestFilter>> ingestFilterMap = null; private static Map<String, List<IngestFilter>> ingestFilterMap = null;
private static Map<String, RiverStat> riverStatMap = null; private static Map<String, RiverStat> riverStatMap = null;
/** /**
* Private constructor. * Private constructor.
*/ */
private PDCDataManager() { private PDCDataManager() {
} }
public static synchronized PDCDataManager getInstance() { public static synchronized PDCDataManager getInstance() {
if (instance == null) { if (instance == null) {
instance = new PDCDataManager(); instance = new PDCDataManager();
} }
return instance; return instance;
} }
@ -109,17 +111,18 @@ public class PDCDataManager extends HydroDataManager {
} }
return result; return result;
} }
public String[] getIngestFilterPE() throws VizException { public String[] getIngestFilterPE() throws VizException {
ArrayList<String> peList = new ArrayList<String>(); ArrayList<String> peList = new ArrayList<String>();
String query = "select distinct(pe) from ingestfilter"; String query = "select distinct(pe) from ingestfilter";
List<Object[]> rs = DirectDbQuery.executeQuery(query, HydroConstants.IHFS, QueryLanguage.SQL); List<Object[]> rs = DirectDbQuery.executeQuery(query,
HydroConstants.IHFS, QueryLanguage.SQL);
for (Object[] oa: rs) {
peList.add((String)oa[0]); for (Object[] oa : rs) {
peList.add((String) oa[0]);
} }
return peList.toArray(new String[peList.size()]); return peList.toArray(new String[peList.size()]);
} }
@ -153,7 +156,7 @@ public class PDCDataManager extends HydroDataManager {
PointDataPreset pdp = new PointDataPreset(); PointDataPreset pdp = new PointDataPreset();
pdp.setPresetId((String) oa[0]); pdp.setPresetId((String) oa[0]);
pdp.setDescription((String) oa[1]); pdp.setDescription((String) oa[1]);
pdp.setPresetRank((Integer) oa[2]); pdp.setPresetRank(((Number) oa[2]).intValue());
pdp.setPresetString((String) oa[3]); pdp.setPresetString((String) oa[3]);
presetList.add(pdp); presetList.add(pdp);
} }
@ -203,9 +206,7 @@ public class PDCDataManager extends HydroDataManager {
"insert into pointdatapresets (preset_id, descr, preset_rank, preset_string) "); "insert into pointdatapresets (preset_id, descr, preset_rank, preset_string) ");
sql.append("values ('" + node.getPresetId() + "', '" sql.append("values ('" + node.getPresetId() + "', '"
+ node.getDescription() + "', "); + node.getDescription() + "', ");
sql sql.append(node.getPresetRank() + ", '" + node.getPresetString() + "')");
.append(node.getPresetRank() + ", '" + node.getPresetString()
+ "')");
runStatement(sql.toString()); runStatement(sql.toString());
} }
@ -355,7 +356,7 @@ public class PDCDataManager extends HydroDataManager {
for (Object[] oa : results) { for (Object[] oa : results) {
lid = (String) oa[0]; lid = (String) oa[0];
if (!lid.equalsIgnoreCase(prevLid)) { if (!lid.equalsIgnoreCase(prevLid)) {
ingestFilterMap.put(prevLid, filterList); ingestFilterMap.put(prevLid, filterList);
prevLid = lid; prevLid = lid;
filterList = new ArrayList<IngestFilter>(); filterList = new ArrayList<IngestFilter>();
} }
@ -417,7 +418,8 @@ public class PDCDataManager extends HydroDataManager {
* observed or forecast, or can be any designated type-source. * observed or forecast, or can be any designated type-source.
*/ */
public void getRiverData(PDCOptions pcOptions) { public void getRiverData(PDCOptions pcOptions) {
PointDataControlManager pdcManager = PointDataControlManager.getInstance(); PointDataControlManager pdcManager = PointDataControlManager
.getInstance();
String where = null; String where = null;
/* /*
@ -514,7 +516,8 @@ public class PDCDataManager extends HydroDataManager {
* Get the PC and/or PP rain data. * Get the PC and/or PP rain data.
*/ */
public void getRainData() { public void getRainData() {
PointDataControlManager pdcManager = PointDataControlManager.getInstance(); PointDataControlManager pdcManager = PointDataControlManager
.getInstance();
PDCOptionData pcOptions = PDCOptionData.getInstance(); PDCOptionData pcOptions = PDCOptionData.getInstance();
PrecipUtil precipUtil = PrecipUtil.getInstance(); PrecipUtil precipUtil = PrecipUtil.getInstance();
List<String> typeSourceArray = null; List<String> typeSourceArray = null;
@ -524,7 +527,7 @@ public class PDCDataManager extends HydroDataManager {
ArrayList<Object[]> ppList = null; ArrayList<Object[]> ppList = null;
ArrayList<Curpc> pcObjectList = new ArrayList<Curpc>(); ArrayList<Curpc> pcObjectList = new ArrayList<Curpc>();
ArrayList<Curpp> ppObjectList = new ArrayList<Curpp>(); ArrayList<Curpp> ppObjectList = new ArrayList<Curpp>();
/* Empty out the data lists */ /* Empty out the data lists */
pdcManager.setPpList(null); pdcManager.setPpList(null);
pdcManager.setPcList(null); pdcManager.setPcList(null);
@ -573,7 +576,7 @@ public class PDCDataManager extends HydroDataManager {
typeSourceArray, HydroConstants.PhysicalElement.PP); typeSourceArray, HydroConstants.PhysicalElement.PP);
} }
} }
/* Save the data to the PointDataControlManager */ /* Save the data to the PointDataControlManager */
if (pcList != null) { if (pcList != null) {
/* /*
@ -591,11 +594,11 @@ public class PDCDataManager extends HydroDataManager {
id.setExtremum((String) oa[4]); id.setExtremum((String) oa[4]);
id.setObstime((Date) oa[12]); id.setObstime((Date) oa[12]);
pc.setPe((String) oa[1]); pc.setPe((String) oa[1]);
pc.setDur(((Integer)oa[2]).shortValue()); pc.setDur(((Number) oa[2]).shortValue());
pc.setValue((Double) oa[5]); pc.setValue((Double) oa[5]);
pc.setShefQualCode((String) oa[6]); pc.setShefQualCode((String) oa[6]);
pc.setQualityCode((Integer) oa[7]); pc.setQualityCode(((Number) oa[7]).intValue());
pc.setRevision(((Integer)(oa[8])).shortValue()); pc.setRevision(((Number) (oa[8])).shortValue());
pc.setProductId((String) oa[9]); pc.setProductId((String) oa[9]);
pc.setProducttime((Date) oa[10]); pc.setProducttime((Date) oa[10]);
pc.setPostingtime((Date) oa[11]); pc.setPostingtime((Date) oa[11]);
@ -619,15 +622,15 @@ public class PDCDataManager extends HydroDataManager {
Curpp pp = new Curpp(); Curpp pp = new Curpp();
CurppId id = new CurppId(); CurppId id = new CurppId();
id.setLid((String) oa[0]); id.setLid((String) oa[0]);
id.setDur(((Integer) oa[2]).shortValue()); id.setDur(((Number) oa[2]).shortValue());
id.setTs((String) oa[3]); id.setTs((String) oa[3]);
id.setExtremum((String) oa[4]); id.setExtremum((String) oa[4]);
id.setObstime((Date) oa[12]); id.setObstime((Date) oa[12]);
pp.setPe((String) oa[1]); pp.setPe((String) oa[1]);
pp.setValue((Double) oa[5]); pp.setValue((Double) oa[5]);
pp.setShefQualCode((String) oa[6]); pp.setShefQualCode((String) oa[6]);
pp.setQualityCode((Integer) oa[7]); pp.setQualityCode(((Number) oa[7]).intValue());
pp.setRevision(((Integer) oa[8]).shortValue()); pp.setRevision(((Number) oa[8]).shortValue());
pp.setProductId((String) oa[9]); pp.setProductId((String) oa[9]);
pp.setProducttime((Date) oa[10]); pp.setProducttime((Date) oa[10]);
pp.setPostingtime((Date) oa[11]); pp.setPostingtime((Date) oa[11]);
@ -640,7 +643,8 @@ public class PDCDataManager extends HydroDataManager {
} }
public void getSnowTempOtherData() { public void getSnowTempOtherData() {
PointDataControlManager pdcManager = PointDataControlManager.getInstance(); PointDataControlManager pdcManager = PointDataControlManager
.getInstance();
PDCOptionData pcOptions = PDCOptionData.getInstance(); PDCOptionData pcOptions = PDCOptionData.getInstance();
String typeSource = null; String typeSource = null;
String tablename = null; String tablename = null;
@ -684,8 +688,8 @@ public class PDCDataManager extends HydroDataManager {
typeSource = pcOptions.getTypeSourceChosenList().get(0); typeSource = pcOptions.getTypeSourceChosenList().get(0);
tablename = DbUtils.getTableName(pcOptions tablename = DbUtils.getTableName(
.getSelectedAdHocElementString(), typeSource); pcOptions.getSelectedAdHocElementString(), typeSource);
obsResult = getObservationData(tablename, where); obsResult = getObservationData(tablename, where);
} }
@ -700,13 +704,13 @@ public class PDCDataManager extends HydroDataManager {
} }
for (Object[] oa : obsResult) { for (Object[] oa : obsResult) {
// if (oa.length == 11) { // if (oa.length == 11) {
// Observation obs = new Observation(oa); // Observation obs = new Observation(oa);
// obsList.add(obs); // obsList.add(obs);
// } else { // } else {
Observation obs = new Observation(oa); Observation obs = new Observation(oa);
obsList.add(obs); obsList.add(obs);
// } // }
} }
pdcManager.setObservationList(obsList); pdcManager.setObservationList(obsList);
@ -758,8 +762,7 @@ public class PDCDataManager extends HydroDataManager {
Map<String, LocPDC> returnMap = new HashMap<String, LocPDC>(); Map<String, LocPDC> returnMap = new HashMap<String, LocPDC>();
StringBuilder sql = new StringBuilder(); StringBuilder sql = new StringBuilder();
sql sql.append("Select lid, name, lat, lon, hsa, post, elev, primary_pe, fs, fq, ");
.append("Select lid, name, lat, lon, hsa, post, elev, primary_pe, fs, fq, ");
sql.append("disp_class, is_dcp, is_observer, telem_type from locPDC"); sql.append("disp_class, is_dcp, is_observer, telem_type from locPDC");
ArrayList<Object[]> results = runQuery(sql.toString()); ArrayList<Object[]> results = runQuery(sql.toString());

View file

@ -104,8 +104,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 09/29/2010 4384 lbousaidi Fixed PC/PP display and make Save button * 09/29/2010 4384 lbousaidi Fixed PC/PP display and make Save button
* save to tokenized directory * save to tokenized directory
* 03/14/2013 1790 rferrel Changes for non-blocking dialog. * 03/14/2013 1790 rferrel Changes for non-blocking dialog.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
*
* </pre> * </pre>
* *
* @author lvenable * @author lvenable
@ -180,7 +179,7 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
/** /**
* Selected Durations. * Selected Durations.
*/ */
private int[] selectedDurations = new int[durationValues.length]; private final int[] selectedDurations = new int[durationValues.length];
/** /**
* Durations. * Durations.
@ -250,7 +249,7 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
/** /**
* List of PTS values. * List of PTS values.
*/ */
private java.util.List<String> pTs = new ArrayList<String>(); private final java.util.List<String> pTs = new ArrayList<String>();
/** /**
* Sort combo box. * Sort combo box.
@ -544,13 +543,13 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
// durList has the pa_options.duration_set of values (indirectly) // durList has the pa_options.duration_set of values (indirectly)
durList = new List(durComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); durList = new List(durComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
durList.setLayoutData(gd); durList.setLayoutData(gd);
durList.add(((Integer) durationValues[0]).toString() + " Hour"); durList.add(((Number) durationValues[0]).toString() + " Hour");
durList.add(((Integer) durationValues[1]).toString() + " Hour"); durList.add(((Number) durationValues[1]).toString() + " Hour");
durList.add(((Integer) durationValues[2]).toString() + " Hour"); durList.add(((Number) durationValues[2]).toString() + " Hour");
durList.add(((Integer) durationValues[3]).toString() + " Hour"); durList.add(((Number) durationValues[3]).toString() + " Hour");
durList.add(((Integer) durationValues[4]).toString() + " Hour"); durList.add(((Number) durationValues[4]).toString() + " Hour");
durList.add(((Integer) durationValues[5]).toString() + " Hour"); durList.add(((Number) durationValues[5]).toString() + " Hour");
durList.add(((Integer) durationValues[6]).toString() + " Hour"); durList.add(((Number) durationValues[6]).toString() + " Hour");
durList.add("Other"); durList.add("Other");
durList.setFont(font); durList.setFont(font);
durList.setSelection(4); durList.setSelection(4);
@ -980,8 +979,8 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
// Determine the length (i.e., NUMDURATIONS) of the new durations array // Determine the length (i.e., NUMDURATIONS) of the new durations array
int NUMDURATIONS = 0; int NUMDURATIONS = 0;
for (int i = 0; i < selectedDurations.length; i++) { for (int selectedDuration : selectedDurations) {
if (selectedDurations[i] == 9999) { if (selectedDuration == 9999) {
break; break;
} else { } else {
NUMDURATIONS++; NUMDURATIONS++;
@ -1263,9 +1262,9 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
int index = hdr.indexOf("<duration>"); int index = hdr.indexOf("<duration>");
index += 10; index += 10;
for (int i = 0; i < durations.length; i++) { for (int duration : durations) {
hdr.insert(index, durations[i]); hdr.insert(index, duration);
index += Integer.toString(durations[i]).length(); index += Integer.toString(duration).length();
hdr.insert(index, ","); hdr.insert(index, ",");
index++; index++;
hdr.insert(index, " "); hdr.insert(index, " ");
@ -1298,13 +1297,13 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
hdr.append("\n"); hdr.append("\n");
hdr.append(String.format(FMT_DUR_HD_TR, "Location", "Name", "PE", "TS")); hdr.append(String.format(FMT_DUR_HD_TR, "Location", "Name", "PE", "TS"));
for (int i = 0; i < durations.length; i++) { for (int duration : durations) {
hdr.append(String.format(FMT_DUR, durations[i], "hr")); hdr.append(String.format(FMT_DUR, duration, "hr"));
} }
hdr.append("\n"); hdr.append("\n");
hdr.append(String.format(FMT_DUR_HD_TR, "========", "====", "==", "==")); hdr.append(String.format(FMT_DUR_HD_TR, "========", "====", "==", "=="));
for (int i = 0; i < durations.length; i++) { for (int duration : durations) {
hdr.append(String.format(FMT_DUR_TR, "===", "==")); hdr.append(String.format(FMT_DUR_TR, "===", "=="));
} }
@ -1675,11 +1674,11 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
Point dpi = printer.getDPI(); Point dpi = printer.getDPI();
leftMargin = dpi.x + trim.x; // one inch from left side of paper leftMargin = dpi.x + trim.x; // one inch from left side of paper
// one inch from right side of paper // one inch from right side of paper
rightMargin = clientArea.width - dpi.x + trim.x + trim.width; rightMargin = (clientArea.width - dpi.x) + trim.x + trim.width;
// one inch from top edge of paper // one inch from top edge of paper
topMargin = dpi.y + trim.y; topMargin = dpi.y + trim.y;
// one inch from bottom edge of paper // one inch from bottom edge of paper
bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; bottomMargin = (clientArea.height - dpi.y) + trim.y + trim.height;
/* Create a buffer for computing tab width. */ /* Create a buffer for computing tab width. */
int tabSize = 4; // is tab width a user setting in your UI? int tabSize = 4; // is tab width a user setting in your UI?
@ -1757,7 +1756,7 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
} }
} }
} }
if (y + lineHeight <= bottomMargin) { if ((y + lineHeight) <= bottomMargin) {
printer.endPage(); printer.endPage();
} }
} }
@ -1769,7 +1768,7 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
if (wordBuffer.length() > 0) { if (wordBuffer.length() > 0) {
String word = wordBuffer.toString(); String word = wordBuffer.toString();
int wordWidth = gc.stringExtent(word).x; int wordWidth = gc.stringExtent(word).x;
if (x + wordWidth > rightMargin) { if ((x + wordWidth) > rightMargin) {
/* word doesn't fit on current line, so wrap */ /* word doesn't fit on current line, so wrap */
newline(); newline();
} }
@ -1785,9 +1784,9 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
private void newline() { private void newline() {
x = leftMargin; x = leftMargin;
y += lineHeight; y += lineHeight;
if (y + lineHeight > bottomMargin) { if ((y + lineHeight) > bottomMargin) {
printer.endPage(); printer.endPage();
if (index + 1 < end) { if ((index + 1) < end) {
y = topMargin; y = topMargin;
printer.startPage(); printer.startPage();
} }

View file

@ -36,7 +36,6 @@ import com.raytheon.viz.hydro.pointprecipitation.PointPrecipConstants.RawPrecipT
import com.raytheon.viz.hydrocommon.HydroConstants; import com.raytheon.viz.hydrocommon.HydroConstants;
import com.raytheon.viz.hydrocommon.datamanager.HydroDataManager; import com.raytheon.viz.hydrocommon.datamanager.HydroDataManager;
/** /**
* Class for managing database query calls. PointPrecipDataManager.java * Class for managing database query calls. PointPrecipDataManager.java
* *
@ -47,8 +46,8 @@ import com.raytheon.viz.hydrocommon.datamanager.HydroDataManager;
* 03Sept2008 #1509 dhladky Initial Creation. * 03Sept2008 #1509 dhladky Initial Creation.
* 31Aug2009 #2257 mpduff Adding data access methods. * 31Aug2009 #2257 mpduff Adding data access methods.
* sep292010 #4384 lbousaidi Fixed quality_code and change name of table * sep292010 #4384 lbousaidi Fixed quality_code and change name of table
* that retrieves PC data from rawpp to rawpc * that retrieves PC data from rawpp to rawpc
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author dhladky * @author dhladky
@ -57,24 +56,24 @@ import com.raytheon.viz.hydrocommon.datamanager.HydroDataManager;
public class PointPrecipDataManager extends HydroDataManager { public class PointPrecipDataManager extends HydroDataManager {
private static final String QUERY = "select lid,obstime,lid from latestobsvalue"; private static final String QUERY = "select lid,obstime,lid from latestobsvalue";
private static int adjustedPCStartTime = HydroConstants.MISSING_VALUE; private static int adjustedPCStartTime = HydroConstants.MISSING_VALUE;
private static PointPrecipDataManager instance = null; private static PointPrecipDataManager instance = null;
/** Private constructor */ /** Private constructor */
private PointPrecipDataManager() { private PointPrecipDataManager() {
} }
public static synchronized PointPrecipDataManager getInstance() { public static synchronized PointPrecipDataManager getInstance() {
if (instance == null) { if (instance == null) {
instance = new PointPrecipDataManager(); instance = new PointPrecipDataManager();
} }
return instance; return instance;
} }
/** /**
* Get tabularDisplayData from the DB * Get tabularDisplayData from the DB
* *
@ -85,11 +84,11 @@ public class PointPrecipDataManager extends HydroDataManager {
ArrayList<Object[]> data; ArrayList<Object[]> data;
data = runQuery(QUERY); data = runQuery(QUERY);
if (data != null) { if (data != null) {
return data.get(0); return data.get(0);
} }
return null; return null;
} }
@ -103,7 +102,7 @@ public class PointPrecipDataManager extends HydroDataManager {
"select distinct locclass.hsa from locclass order by locclass.hsa asc"); "select distinct locclass.hsa from locclass order by locclass.hsa asc");
ArrayList<Object[]> hsaData; ArrayList<Object[]> hsaData;
List<String> items = new ArrayList<String>(); List<String> items = new ArrayList<String>();
// --------------------------------------------------------- // ---------------------------------------------------------
// Query the HSA in LOCCLASS in the IHFS database using SQL. // Query the HSA in LOCCLASS in the IHFS database using SQL.
// --------------------------------------------------------- // ---------------------------------------------------------
@ -115,7 +114,6 @@ public class PointPrecipDataManager extends HydroDataManager {
return items.toArray(new String[items.size()]); return items.toArray(new String[items.size()]);
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Query 'ingestfilter' table in ihfs database for selected fields // Query 'ingestfilter' table in ihfs database for selected fields
// using SQL. // using SQL.
@ -126,7 +124,7 @@ public class PointPrecipDataManager extends HydroDataManager {
"select distinct ing.ts from ingestfilter ing where pe = 'PC' and ing.ts like 'R%' order by 1"); "select distinct ing.ts from ingestfilter ing where pe = 'PC' and ing.ts like 'R%' order by 1");
ArrayList<Object[]> PCData; ArrayList<Object[]> PCData;
List<String> items = new ArrayList<String>(); List<String> items = new ArrayList<String>();
// ------------------------------------------------------------ // ------------------------------------------------------------
// Query the IngestFilter Table in the IHFS database using SQL. // Query the IngestFilter Table in the IHFS database using SQL.
// ------------------------------------------------------------ // ------------------------------------------------------------
@ -134,10 +132,10 @@ public class PointPrecipDataManager extends HydroDataManager {
for (Object[] rowData : PCData) { for (Object[] rowData : PCData) {
items.add((String) rowData[0]); items.add((String) rowData[0]);
} }
return items.toArray(new String[items.size()]); return items.toArray(new String[items.size()]);
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Query 'ingestfilter' table in ihfs database for selected fields // Query 'ingestfilter' table in ihfs database for selected fields
// using SQL. // using SQL.
@ -155,7 +153,7 @@ public class PointPrecipDataManager extends HydroDataManager {
for (Object[] rowData : PPData) { for (Object[] rowData : PPData) {
items.add((String) rowData[0]); items.add((String) rowData[0]);
} }
return items.toArray(new String[items.size()]); return items.toArray(new String[items.size()]);
} }
@ -163,33 +161,35 @@ public class PointPrecipDataManager extends HydroDataManager {
// Query 'curpc' table in ihfs database for selected fields // Query 'curpc' table in ihfs database for selected fields
// using SQL. // using SQL.
// --------------------------------------------------------------- // ---------------------------------------------------------------
public ArrayList<Curpc> queryCurPc(Date queryBeginTime, public ArrayList<Curpc> queryCurPc(Date queryBeginTime, Date queryEndTime,
Date queryEndTime, String lid, List<String> pTs) { String lid, List<String> pTs) {
ArrayList<Object[]> pcData; ArrayList<Object[]> pcData;
String tsClause = null; String tsClause = null;
StringBuilder where = new StringBuilder(); StringBuilder where = new StringBuilder();
ArrayList<Curpc> data = new ArrayList<Curpc>(); ArrayList<Curpc> data = new ArrayList<Curpc>();
/* /*
* In order to consider cases that there is no PC data during dry * In order to consider cases that there is no PC data during dry
* periods, retrieve more wider data for gages, use token * periods, retrieve more wider data for gages, use token
* adjust_PC_startingtime to specify the PC data retrieval starting point * adjust_PC_startingtime to specify the PC data retrieval starting
* point
*/ */
if (adjustedPCStartTime == HydroConstants.MISSING_VALUE) { if (adjustedPCStartTime == HydroConstants.MISSING_VALUE) {
AppsDefaults ad = AppsDefaults.getInstance(); AppsDefaults ad = AppsDefaults.getInstance();
String tokenString = ad.getToken("adjust_PC_startingtime"); String tokenString = ad.getToken("adjust_PC_startingtime");
if ((tokenString != null) && (tokenString.length() > 0)) { if ((tokenString != null) && (tokenString.length() > 0)) {
adjustedPCStartTime = Integer.parseInt(tokenString); adjustedPCStartTime = Integer.parseInt(tokenString);
if (adjustedPCStartTime < 0) { if (adjustedPCStartTime < 0) {
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS; adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
} }
} }
} else { } else {
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS; adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
} }
// Adjust the start hours // Adjust the start hours
Calendar adjustedBeginTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")); Calendar adjustedBeginTime = Calendar.getInstance(TimeZone
.getTimeZone("GMT"));
adjustedBeginTime.setTimeInMillis(queryBeginTime.getTime()); adjustedBeginTime.setTimeInMillis(queryBeginTime.getTime());
adjustedBeginTime.add(Calendar.HOUR, adjustedPCStartTime * -1); adjustedBeginTime.add(Calendar.HOUR, adjustedPCStartTime * -1);
@ -199,23 +199,26 @@ public class PointPrecipDataManager extends HydroDataManager {
return null; return null;
} }
} }
if ((lid.length() > 0) && (pTs.size() > 0)) { if ((lid.length() > 0) && (pTs.size() > 0)) {
where.append(String.format(" where lid = '%s' and %s ", lid, tsClause)); where.append(String.format(" where lid = '%s' and %s ", lid,
tsClause));
where.append(" AND value != '-9999.0' AND "); where.append(" AND value != '-9999.0' AND ");
where.append(String.format(" obstime >= '%s' AND ", where.append(String.format(" obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime()))); HydroConstants.DATE_FORMAT.format(adjustedBeginTime
where.append(String.format(" obstime <= '%s' ", .getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(queryEndTime))); HydroConstants.DATE_FORMAT.format(queryEndTime)));
where.append("AND value IS NOT NULL AND "); where.append("AND value IS NOT NULL AND ");
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code "); where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
where.append(" NOT LIKE 'R%%' ORDER BY obstime DESC "); where.append(" NOT LIKE 'R%%' ORDER BY obstime DESC ");
} else if (pTs.size() > 0) { } else if (pTs.size() > 0) {
where.append(String.format(" WHERE %s ", tsClause)); where.append(String.format(" WHERE %s ", tsClause));
where.append(" AND value != '-9999.0' AND "); where.append(" AND value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ", where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime()))); HydroConstants.DATE_FORMAT.format(adjustedBeginTime
where.append(String.format(" obstime <= '%s' ", .getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(queryEndTime))); HydroConstants.DATE_FORMAT.format(queryEndTime)));
where.append("AND value IS NOT NULL AND "); where.append("AND value IS NOT NULL AND ");
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code "); where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
@ -224,7 +227,8 @@ public class PointPrecipDataManager extends HydroDataManager {
where.append(String.format(" WHERE lid = '%s' ", lid)); where.append(String.format(" WHERE lid = '%s' ", lid));
where.append(" AND value != '-9999.0' AND "); where.append(" AND value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ", where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime()))); HydroConstants.DATE_FORMAT.format(adjustedBeginTime
.getTime())));
where.append(String.format(" obstime <= '%s' ", where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(queryEndTime))); HydroConstants.DATE_FORMAT.format(queryEndTime)));
where.append("AND value IS NOT NULL AND "); where.append("AND value IS NOT NULL AND ");
@ -233,64 +237,66 @@ public class PointPrecipDataManager extends HydroDataManager {
} else { } else {
where.append(" WHERE value != '-9999.0' AND "); where.append(" WHERE value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ", where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime()))); HydroConstants.DATE_FORMAT.format(adjustedBeginTime
.getTime())));
where.append(String.format(" obstime <= '%s' ", where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(queryEndTime))); HydroConstants.DATE_FORMAT.format(queryEndTime)));
where.append("AND value IS NOT NULL AND "); where.append("AND value IS NOT NULL AND ");
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code "); where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
where.append(" NOT LIKE 'R%%' ORDER BY lid ASC, ts ASC, obstime DESC"); where.append(" NOT LIKE 'R%%' ORDER BY lid ASC, ts ASC, obstime DESC");
} }
String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, revision, product_id, producttime, postingtime from curpc"; String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, revision, product_id, producttime, postingtime from curpc";
pcData = runQuery(query + where.toString()); pcData = runQuery(query + where.toString());
int i = 0; int i = 0;
for (Object[] rowData : pcData) { for (Object[] rowData : pcData) {
Curpc curpc = new Curpc(); Curpc curpc = new Curpc();
curpc.getId().setLid((String) rowData[i]); curpc.getId().setLid((String) rowData[i]);
curpc.setPe((String) rowData[++i]); curpc.setPe((String) rowData[++i]);
curpc.setDur((Short) rowData[++i]); curpc.setDur(((Number) rowData[++i]).shortValue());
curpc.getId().setTs((String) rowData[++i]); curpc.getId().setTs((String) rowData[++i]);
curpc.getId().setExtremum((String) rowData[++i]); curpc.getId().setExtremum((String) rowData[++i]);
curpc.getId().setObstime((Date) rowData[++i]); curpc.getId().setObstime((Date) rowData[++i]);
curpc.setValue((Double) rowData[++i]); curpc.setValue((Double) rowData[++i]);
curpc.setShefQualCode((String) rowData[++i]); curpc.setShefQualCode((String) rowData[++i]);
curpc.setRevision((Short) rowData[++i]); curpc.setRevision(((Number) rowData[++i]).shortValue());
curpc.setProductId((String) rowData[++i]); curpc.setProductId((String) rowData[++i]);
curpc.setProducttime((Date) rowData[++i]); curpc.setProducttime((Date) rowData[++i]);
curpc.setPostingtime((Date) rowData[++i]); curpc.setPostingtime((Date) rowData[++i]);
i = 0; i = 0;
data.add(curpc); data.add(curpc);
} }
return data; return data;
} }
/** /**
* Get the lat, lon, and name from location. * Get the lat, lon, and name from location.
* *
* @param lid * @param lid
* The lid to query on * The lid to query on
* @return * @return Object[] - 0 = lat, 1 = lon, 2 = name
* Object[] - 0 = lat, 1 = lon, 2 = name
*/ */
public Object[] getLocInfo(String lid) { public Object[] getLocInfo(String lid) {
String query = "select lat, lon, name from location where lid = '" + lid + "'"; String query = "select lat, lon, name from location where lid = '"
+ lid + "'";
Object[] result = null; Object[] result = null;
ArrayList<Object[]> rs = runQuery(query); ArrayList<Object[]> rs = runQuery(query);
if ((rs!=null) && (rs.size() > 0)) { if ((rs != null) && (rs.size() > 0)) {
return rs.get(0); return rs.get(0);
} else { } else {
return result; return result;
} }
} }
public ArrayList<Rawpc> loadPcRaw(Date beginTime, Date endTime, String lid, List<String> tsList, RawPrecipTable table) { public ArrayList<Rawpc> loadPcRaw(Date beginTime, Date endTime, String lid,
List<String> tsList, RawPrecipTable table) {
String tsClause = null; String tsClause = null;
StringBuilder where = new StringBuilder(); StringBuilder where = new StringBuilder();
ArrayList<Object[]> pcData; ArrayList<Object[]> pcData;
@ -301,144 +307,150 @@ public class PointPrecipDataManager extends HydroDataManager {
/* /*
* In order to consider cases that there is no PC data during dry * In order to consider cases that there is no PC data during dry
* periods, retrieve more wider data for gages, use token * periods, retrieve more wider data for gages, use token
* adjust_PC_startingtime to specify the PC data retrieval starting point * adjust_PC_startingtime to specify the PC data retrieval starting
* point
*/ */
if (adjustedPCStartTime == HydroConstants.MISSING_VALUE) { if (adjustedPCStartTime == HydroConstants.MISSING_VALUE) {
AppsDefaults ad = AppsDefaults.getInstance(); AppsDefaults ad = AppsDefaults.getInstance();
String tokenString = ad.getToken("adjust_PC_startingtime"); String tokenString = ad.getToken("adjust_PC_startingtime");
if ((tokenString != null) && (tokenString.length() > 0)) { if ((tokenString != null) && (tokenString.length() > 0)) {
adjustedPCStartTime = Integer.parseInt(tokenString); adjustedPCStartTime = Integer.parseInt(tokenString);
if (adjustedPCStartTime <= 0) { if (adjustedPCStartTime <= 0) {
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS; adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
} }
} }
} else { } else {
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS; adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
} }
// Adjust the start hours
Calendar adjustedBeginTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
adjustedBeginTime.setTimeInMillis(beginTime.getTime());
/*if (adjustedPCStartTime != -9999) {
adjustedBeginTime.add(Calendar.HOUR, adjustedPCStartTime * -1);
}*/
adjustedBeginTime.add(Calendar.HOUR_OF_DAY, adjustedPCStartTime * -1);
if (tsList.size() > 0) { // Adjust the start hours
tsClause = build_ts_clause(tsList); Calendar adjustedBeginTime = Calendar.getInstance(TimeZone
if (tsClause == null) { .getTimeZone("GMT"));
return null; adjustedBeginTime.setTimeInMillis(beginTime.getTime());
} /*
} * if (adjustedPCStartTime != -9999) {
* adjustedBeginTime.add(Calendar.HOUR, adjustedPCStartTime * -1); }
if ((lid.length() > 0) && (tsList.size() > 0)) { */
where.append(String.format(" where lid = '%s' and %s ", lid, tsClause));
where.append(" AND value != '-9999.0' AND "); adjustedBeginTime.add(Calendar.HOUR_OF_DAY, adjustedPCStartTime * -1);
where.append(String.format(" obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime()))); if (tsList.size() > 0) {
where.append(String.format(" obstime <= '%s' ", tsClause = build_ts_clause(tsList);
HydroConstants.DATE_FORMAT.format(endTime))); if (tsClause == null) {
where.append("AND value IS NOT NULL AND "); return null;
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code "); }
where.append(" NOT LIKE 'R%%' ORDER BY obstime DESC "); }
} else if (tsList.size() > 0) {
where.append(String.format(" WHERE %s ", tsClause)); if ((lid.length() > 0) && (tsList.size() > 0)) {
where.append(" AND value != '-9999.0' AND "); where.append(String.format(" where lid = '%s' and %s ", lid,
where.append(String.format("obstime >= '%s' AND ", tsClause));
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime()))); where.append(" AND value != '-9999.0' AND ");
where.append(String.format(" obstime <= '%s' ", where.append(String.format(" obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(endTime))); HydroConstants.DATE_FORMAT.format(adjustedBeginTime
where.append("AND value IS NOT NULL AND "); .getTime())));
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code "); where.append(String.format(" obstime <= '%s' ",
where.append(" NOT LIKE 'R%%' ORDER BY lid ASC, obstime DESC"); HydroConstants.DATE_FORMAT.format(endTime)));
} else if (lid.length() > 0) { where.append("AND value IS NOT NULL AND ");
where.append(String.format(" WHERE lid = '%s' ", lid)); where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
where.append(" AND value != '-9999.0' AND "); where.append(" NOT LIKE 'R%%' ORDER BY obstime DESC ");
where.append(String.format("obstime >= '%s' AND ", } else if (tsList.size() > 0) {
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime()))); where.append(String.format(" WHERE %s ", tsClause));
where.append(String.format(" obstime <= '%s' ", where.append(" AND value != '-9999.0' AND ");
HydroConstants.DATE_FORMAT.format(endTime))); where.append(String.format("obstime >= '%s' AND ",
where.append("AND value IS NOT NULL AND "); HydroConstants.DATE_FORMAT.format(adjustedBeginTime
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code "); .getTime())));
where.append(" NOT LIKE 'R%%' ORDER BY ts ASC, obstime DESC"); where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime)));
} else { where.append("AND value IS NOT NULL AND ");
where.append(" WHERE value != '-9999.0' AND "); where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
where.append(String.format("obstime >= '%s' AND ", where.append(" NOT LIKE 'R%%' ORDER BY lid ASC, obstime DESC");
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime()))); } else if (lid.length() > 0) {
where.append(String.format(" obstime <= '%s' ", where.append(String.format(" WHERE lid = '%s' ", lid));
HydroConstants.DATE_FORMAT.format(endTime))); where.append(" AND value != '-9999.0' AND ");
where.append("AND value IS NOT NULL AND "); where.append(String.format("obstime >= '%s' AND ",
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code "); HydroConstants.DATE_FORMAT.format(adjustedBeginTime
where.append(" NOT LIKE 'R%%' ORDER BY lid ASC, ts ASC, obstime DESC"); .getTime())));
where.append(String.format(" obstime <= '%s' ",
} HydroConstants.DATE_FORMAT.format(endTime)));
where.append("AND value IS NOT NULL AND ");
/* get the data */ where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
if (table == RawPrecipTable.CurRawPrecip) { where.append(" NOT LIKE 'R%%' ORDER BY ts ASC, obstime DESC");
String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, quality_code, revision, product_id, producttime, postingtime from curpc";
pcData = runQuery(query + where.toString()); } else {
where.append(" WHERE value != '-9999.0' AND ");
if ((pcData != null) && (pcData.size() > 0)) { where.append(String.format("obstime >= '%s' AND ",
int i = 0; HydroConstants.DATE_FORMAT.format(adjustedBeginTime
for (Object[] oa: pcData) { .getTime())));
Rawpc rawpc = new Rawpc(); where.append(String.format(" obstime <= '%s' ",
RawpcId id = new RawpcId(); HydroConstants.DATE_FORMAT.format(endTime)));
rawpc.setId(id); where.append("AND value IS NOT NULL AND ");
rawpc.getId().setLid((String) oa[i]); where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
rawpc.setPe((String) oa[++i]); where.append(" NOT LIKE 'R%%' ORDER BY lid ASC, ts ASC, obstime DESC");
rawpc.setDur(((Integer) oa[++i]).shortValue());
rawpc.getId().setTs((String) oa[++i]); }
rawpc.getId().setExtremum((String) oa[++i]);
rawpc.getId().setObstime((Date) oa[++i]); /* get the data */
rawpc.setValue((Double) oa[++i]); if (table == RawPrecipTable.CurRawPrecip) {
rawpc.setShefQualCode((String) oa[++i]); String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, quality_code, revision, product_id, producttime, postingtime from curpc";
rawpc.setQualityCode((Integer) oa[++i]); pcData = runQuery(query + where.toString());
rawpc.setRevision(((Integer) oa[++i]).shortValue());
rawpc.setProductId((String) oa[++i]); if ((pcData != null) && (pcData.size() > 0)) {
rawpc.setProducttime((Date) oa[++i]); int i = 0;
rawpc.setPostingtime((Date) oa[++i]); for (Object[] oa : pcData) {
i = 0; Rawpc rawpc = new Rawpc();
pRawPc.add(rawpc); RawpcId id = new RawpcId();
} rawpc.setId(id);
} rawpc.getId().setLid((String) oa[i]);
} else { rawpc.setPe((String) oa[++i]);
// Get rawpc rawpc.setDur(((Number) oa[++i]).shortValue());
String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, quality_code, revision, product_id, producttime, postingtime from rawpc"; rawpc.getId().setTs((String) oa[++i]);
pcData = runQuery(query + where.toString()); rawpc.getId().setExtremum((String) oa[++i]);
rawpc.getId().setObstime((Date) oa[++i]);
if ((pcData != null) && (pcData.size() > 0)) { rawpc.setValue((Double) oa[++i]);
int i = 0; rawpc.setShefQualCode((String) oa[++i]);
for (Object[] oa: pcData) { rawpc.setQualityCode(((Number) oa[++i]).intValue());
Rawpc rawpc = new Rawpc(); rawpc.setRevision(((Number) oa[++i]).shortValue());
rawpc.getId().setLid((String) oa[i]); rawpc.setProductId((String) oa[++i]);
rawpc.setPe((String) oa[++i]); rawpc.setProducttime((Date) oa[++i]);
rawpc.setDur((Short) oa[++i]); rawpc.setPostingtime((Date) oa[++i]);
rawpc.getId().setTs((String) oa[++i]); i = 0;
rawpc.getId().setExtremum((String) oa[++i]); pRawPc.add(rawpc);
rawpc.getId().setObstime((Date) oa[++i]); }
rawpc.setValue((Double) oa[++i]); }
rawpc.setShefQualCode((String) oa[++i]); } else {
rawpc.setQualityCode((Integer) oa[++i]); // Get rawpc
rawpc.setRevision((Short) oa[++i]); String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, quality_code, revision, product_id, producttime, postingtime from rawpc";
rawpc.setProductId((String) oa[++i]); pcData = runQuery(query + where.toString());
rawpc.setProducttime((Date) oa[++i]);
rawpc.setPostingtime((Date) oa[++i]); if ((pcData != null) && (pcData.size() > 0)) {
i = 0; int i = 0;
pRawPc.add(rawpc); for (Object[] oa : pcData) {
} Rawpc rawpc = new Rawpc();
} rawpc.getId().setLid((String) oa[i]);
} rawpc.setPe((String) oa[++i]);
rawpc.setDur(((Number) oa[++i]).shortValue());
return pRawPc; rawpc.getId().setTs((String) oa[++i]);
rawpc.getId().setExtremum((String) oa[++i]);
rawpc.getId().setObstime((Date) oa[++i]);
rawpc.setValue((Double) oa[++i]);
rawpc.setShefQualCode((String) oa[++i]);
rawpc.setQualityCode(((Number) oa[++i]).intValue());
rawpc.setRevision(((Number) oa[++i]).shortValue());
rawpc.setProductId((String) oa[++i]);
rawpc.setProducttime((Date) oa[++i]);
rawpc.setPostingtime((Date) oa[++i]);
i = 0;
pRawPc.add(rawpc);
}
}
}
return pRawPc;
} }
public ArrayList<Rawpp> loadPpRaw(Date beginTime, Date endTime, String lid, List<String> tsList, RawPrecipTable table) { public ArrayList<Rawpp> loadPpRaw(Date beginTime, Date endTime, String lid,
List<String> tsList, RawPrecipTable table) {
StringBuilder where = new StringBuilder(); StringBuilder where = new StringBuilder();
String tsClause = null; String tsClause = null;
ArrayList<Object[]> pcData; ArrayList<Object[]> pcData;
@ -449,24 +461,26 @@ public class PointPrecipDataManager extends HydroDataManager {
/* Only retrieve valid PP data. */ /* Only retrieve valid PP data. */
String qcWhere = buildQCWhere(PointPrecipConstants.QC_NOT_FAILED); String qcWhere = buildQCWhere(PointPrecipConstants.QC_NOT_FAILED);
if (tsList.size() > 0) { if (tsList.size() > 0) {
tsClause = build_ts_clause(tsList); tsClause = build_ts_clause(tsList);
if (tsClause == null) { if (tsClause == null) {
return null; return null;
} }
} }
if ((lid.length() > 0) && (tsList.size() > 0)) { if ((lid.length() > 0) && (tsList.size() > 0)) {
where.append(String.format(" WHERE lid = '%s' AND %s ", lid, tsClause)); where.append(String.format(" WHERE lid = '%s' AND %s ", lid,
where.append(String.format(" AND value != '-9999.0' AND obstime >= '%s' ", tsClause));
where.append(String.format(
" AND value != '-9999.0' AND obstime >= '%s' ",
HydroConstants.DATE_FORMAT.format(beginTime))); HydroConstants.DATE_FORMAT.format(beginTime)));
where.append(String.format(" AND obstime <= '%s' AND", where.append(String.format(" AND obstime <= '%s' AND",
HydroConstants.DATE_FORMAT.format(endTime))); HydroConstants.DATE_FORMAT.format(endTime)));
where.append(qcWhere + " order by dur desc, obstime desc"); where.append(qcWhere + " order by dur desc, obstime desc");
} else if (tsList.size() > 0) { } else if (tsList.size() > 0) {
where.append(" where " + tsClause + " and value != '-9999.0' "); where.append(" where " + tsClause + " and value != '-9999.0' ");
where.append(String.format("AND obstime >= '%s' ", where.append(String.format("AND obstime >= '%s' ",
HydroConstants.DATE_FORMAT.format(beginTime))); HydroConstants.DATE_FORMAT.format(beginTime)));
where.append(String.format(" AND obstime <= '%s' ", where.append(String.format(" AND obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime))); HydroConstants.DATE_FORMAT.format(endTime)));
@ -479,8 +493,7 @@ public class PointPrecipDataManager extends HydroDataManager {
where.append(String.format(" obstime <= '%s' AND %s ", where.append(String.format(" obstime <= '%s' AND %s ",
HydroConstants.DATE_FORMAT.format(endTime), qcWhere)); HydroConstants.DATE_FORMAT.format(endTime), qcWhere));
where.append(" ORDER BY ts ASC, DUR DESC, obstime DESC"); where.append(" ORDER BY ts ASC, DUR DESC, obstime DESC");
} else { } else {
where.append(" WHERE value != '-9999.0' AND "); where.append(" WHERE value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ", where.append(String.format("obstime >= '%s' AND ",
@ -488,30 +501,30 @@ public class PointPrecipDataManager extends HydroDataManager {
where.append(String.format("obstime <= '%s' AND %s ", where.append(String.format("obstime <= '%s' AND %s ",
HydroConstants.DATE_FORMAT.format(endTime), qcWhere)); HydroConstants.DATE_FORMAT.format(endTime), qcWhere));
where.append(" ORDER BY lid ASC, ts ASC, dur DESC, obstime DESC"); where.append(" ORDER BY lid ASC, ts ASC, dur DESC, obstime DESC");
} }
/* get the data */ /* get the data */
if (table == RawPrecipTable.CurRawPrecip) { if (table == RawPrecipTable.CurRawPrecip) {
String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, quality_code, revision, product_id, producttime, postingtime from curpp"; String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, quality_code, revision, product_id, producttime, postingtime from curpp";
pcData = runQuery(query + where.toString()); pcData = runQuery(query + where.toString());
if ((pcData != null) && (pcData.size() > 0)) { if ((pcData != null) && (pcData.size() > 0)) {
int i = 0; int i = 0;
for (Object[] oa: pcData) { for (Object[] oa : pcData) {
Rawpp rawpp = new Rawpp(); Rawpp rawpp = new Rawpp();
RawppId id = new RawppId(); RawppId id = new RawppId();
rawpp.setId(id); rawpp.setId(id);
rawpp.getId().setLid((String) oa[i]); rawpp.getId().setLid((String) oa[i]);
rawpp.setPe((String) oa[++i]); rawpp.setPe((String) oa[++i]);
rawpp.getId().setDur(((Integer) oa[++i]).shortValue()); rawpp.getId().setDur(((Number) oa[++i]).shortValue());
rawpp.getId().setTs((String) oa[++i]); rawpp.getId().setTs((String) oa[++i]);
rawpp.getId().setExtremum((String) oa[++i]); rawpp.getId().setExtremum((String) oa[++i]);
rawpp.getId().setObstime((Date) oa[++i]); rawpp.getId().setObstime((Date) oa[++i]);
rawpp.setValue((Double) oa[++i]); rawpp.setValue((Double) oa[++i]);
rawpp.setShefQualCode((String) oa[++i]); rawpp.setShefQualCode((String) oa[++i]);
rawpp.setQualityCode((Integer) oa[++i]); rawpp.setQualityCode(((Number) oa[++i]).intValue());
rawpp.setRevision(((Integer) oa[++i]).shortValue()); rawpp.setRevision(((Number) oa[++i]).shortValue());
rawpp.setProductId((String) oa[++i]); rawpp.setProductId((String) oa[++i]);
rawpp.setProducttime((Date) oa[++i]); rawpp.setProducttime((Date) oa[++i]);
rawpp.setPostingtime((Date) oa[++i]); rawpp.setPostingtime((Date) oa[++i]);
@ -523,19 +536,19 @@ public class PointPrecipDataManager extends HydroDataManager {
// get rawpp // get rawpp
String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, quality_code, revision, product_id, producttime, postingtime from rawpp"; String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, quality_code, revision, product_id, producttime, postingtime from rawpp";
pcData = runQuery(query + where.toString()); pcData = runQuery(query + where.toString());
int i = 0; int i = 0;
for (Object[] oa: pcData) { for (Object[] oa : pcData) {
Rawpp rawpp = new Rawpp(); Rawpp rawpp = new Rawpp();
rawpp.getId().setLid((String) oa[i]); rawpp.getId().setLid((String) oa[i]);
rawpp.setPe((String) oa[++i]); rawpp.setPe((String) oa[++i]);
rawpp.getId().setDur((Short) oa[++i]); rawpp.getId().setDur(((Number) oa[++i]).shortValue());
rawpp.getId().setTs((String) oa[++i]); rawpp.getId().setTs((String) oa[++i]);
rawpp.getId().setExtremum((String) oa[++i]); rawpp.getId().setExtremum((String) oa[++i]);
rawpp.getId().setObstime((Date) oa[++i]); rawpp.getId().setObstime((Date) oa[++i]);
rawpp.setValue((Double) oa[++i]); rawpp.setValue((Double) oa[++i]);
rawpp.setShefQualCode((String) oa[++i]); rawpp.setShefQualCode((String) oa[++i]);
rawpp.setRevision((Short) oa[++i]); rawpp.setRevision(((Number) oa[++i]).shortValue());
rawpp.setProductId((String) oa[++i]); rawpp.setProductId((String) oa[++i]);
rawpp.setProducttime((Date) oa[++i]); rawpp.setProducttime((Date) oa[++i]);
rawpp.setPostingtime((Date) oa[++i]); rawpp.setPostingtime((Date) oa[++i]);
@ -543,79 +556,93 @@ public class PointPrecipDataManager extends HydroDataManager {
pRawPp.add(rawpp); pRawPp.add(rawpp);
} }
} }
return pRawPp; return pRawPp;
} }
private String buildQCWhere(int request) { private String buildQCWhere(int request) {
String where = null; String where = null;
/* The data value is valid as per all checks. */ /* The data value is valid as per all checks. */
if (request == PointPrecipConstants.QC_PASSED) { if (request == PointPrecipConstants.QC_PASSED) {
where = "quality_code >= " + PointPrecipConstants.GOOD_QUESTIONABLE_THRESHOLD; where = "quality_code >= "
+ PointPrecipConstants.GOOD_QUESTIONABLE_THRESHOLD;
} else if (request == PointPrecipConstants.QC_NOT_PASSED) { } else if (request == PointPrecipConstants.QC_NOT_PASSED) {
/* The gross range certainty check did not pass. The data is not usable. */ /*
where = "quality_code < " + PointPrecipConstants.GOOD_QUESTIONABLE_THRESHOLD; * The gross range certainty check did not pass. The data is not
* usable.
*/
where = "quality_code < "
+ PointPrecipConstants.GOOD_QUESTIONABLE_THRESHOLD;
} else if (request == PointPrecipConstants.QC_FAILED) { } else if (request == PointPrecipConstants.QC_FAILED) {
/* The data value is invalid because it failed at least one /*
certainty check */ * The data value is invalid because it failed at least one
where = "quality_code < " + PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD; * certainty check
*/
where = "quality_code < "
+ PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD;
} else if (request == PointPrecipConstants.QC_QUESTIONABLE) { } else if (request == PointPrecipConstants.QC_QUESTIONABLE) {
/* The data value is questionable. It passed all certainty checks /*
but failed at least one quality check. */ * The data value is questionable. It passed all certainty checks
where = "quality_code BETWEEN " + PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD + * but failed at least one quality check.
" and " + (PointPrecipConstants.GOOD_QUESTIONABLE_THRESHOLD - 1); */
where = "quality_code BETWEEN "
+ PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD + " and "
+ (PointPrecipConstants.GOOD_QUESTIONABLE_THRESHOLD - 1);
} else if (request == PointPrecipConstants.QC_NOT_FAILED) { } else if (request == PointPrecipConstants.QC_NOT_FAILED) {
/* The data is deemed full valid or is questionable, but it is /*
not deemed bad with certainty. */ * The data is deemed full valid or is questionable, but it is not
where = "quality_code >= " + PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD; * deemed bad with certainty.
*/
where = "quality_code >= "
+ PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD;
} }
return where; return where;
} }
/** /**
* Check if the given lid is an ALERT station. * Check if the given lid is an ALERT station.
* *
* @param lid * @param lid
* The lid to check * The lid to check
* @return * @return true if alert station, false if not
* true if alert station, false if not
*/ */
public boolean isAlertStation(String lid) { public boolean isAlertStation(String lid) {
boolean alert = false; boolean alert = false;
String query = "select type from telem where lid = '" + lid + "'"; String query = "select type from telem where lid = '" + lid + "'";
ArrayList<Object[]> rs = runQuery(query); ArrayList<Object[]> rs = runQuery(query);
if ((rs != null) && (rs.size() > 0)) { if ((rs != null) && (rs.size() > 0)) {
Object[] oa = rs.get(0); Object[] oa = rs.get(0);
if (oa[0] != null && ((String) oa[0]).equalsIgnoreCase("ALERT")) { if ((oa[0] != null) && ((String) oa[0]).equalsIgnoreCase("ALERT")) {
alert = true; alert = true;
} }
} }
return alert; return alert;
} }
public ArrayList<IngestFilter> getIngestTsInfo(String lid) { public ArrayList<IngestFilter> getIngestTsInfo(String lid) {
ArrayList<Object[]> rs = null; ArrayList<Object[]> rs = null;
ArrayList<IngestFilter> filterList = null; ArrayList<IngestFilter> filterList = null;
String query = "select lid, pe, duration, ts, extremum, ts_rank from ingestFilter"; String query = "select lid, pe, duration, ts, extremum, ts_rank from ingestFilter";
String where = " where lid = '" + lid + "' and ingest = 'T' order by ts asc"; String where = " where lid = '" + lid
+ "' and ingest = 'T' order by ts asc";
rs = runQuery(query + where); rs = runQuery(query + where);
if ((rs != null) && (rs.size() > 0)) { if ((rs != null) && (rs.size() > 0)) {
filterList = new ArrayList<IngestFilter>(); filterList = new ArrayList<IngestFilter>();
for (Object[] oa: rs) { for (Object[] oa : rs) {
IngestFilter filter = new IngestFilter(oa); IngestFilter filter = new IngestFilter(oa);
filterList.add(filter); filterList.add(filter);
} }
} }
return filterList; return filterList;
} }
public String build_ts_clause(List<String> ts) { public String build_ts_clause(List<String> ts) {
if ((ts == null) || ts.isEmpty()) { if ((ts == null) || ts.isEmpty()) {
return ""; return "";
@ -638,17 +665,17 @@ public class PointPrecipDataManager extends HydroDataManager {
return tsClause.toString(); return tsClause.toString();
} }
public String getDur(short dur) { public String getDur(short dur) {
String query = "select name from shefdur where dur = " + dur + " "; String query = "select name from shefdur where dur = " + dur + " ";
ArrayList<Object[]> rs = runQuery(query); ArrayList<Object[]> rs = runQuery(query);
String durStr = null; String durStr = null;
if ((rs != null) && (rs.size() > 0)) { if ((rs != null) && (rs.size() > 0)) {
Object[] oa = rs.get(0); Object[] oa = rs.get(0);
durStr = (String) oa[0]; durStr = (String) oa[0];
} }
return durStr; return durStr;
} }
} }

View file

@ -49,7 +49,7 @@ import com.raytheon.viz.hydrocommon.HydroDataCache;
* 04Sept2008 1509 dhladky abstraction. * 04Sept2008 1509 dhladky abstraction.
* 13Oct2008 1580 askripsky Refactored * 13Oct2008 1580 askripsky Refactored
* 21 Feb 2010 2915 mpduff Fixed Time Zone problem. * 21 Feb 2010 2915 mpduff Fixed Time Zone problem.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author ebabin * @author ebabin
@ -66,7 +66,7 @@ public class StationReportingDataManager {
private HashMap<String, StationReportingTimingData> stationTime; private HashMap<String, StationReportingTimingData> stationTime;
private String LATEST_OBS_FOR_LID_QUERY = "select lid,pe,dur,ts,extremum,obstime,value,shef_Qual_Code,quality_Code,revision,product_Id,producttime,postingtime from latestobsvalue where lid = ':lid' order by obstime desc, pe desc,ts desc,dur desc,extremum desc"; private final String LATEST_OBS_FOR_LID_QUERY = "select lid,pe,dur,ts,extremum,obstime,value,shef_Qual_Code,quality_Code,revision,product_Id,producttime,postingtime from latestobsvalue where lid = ':lid' order by obstime desc, pe desc,ts desc,dur desc,extremum desc";
private String previousWhere = " "; private String previousWhere = " ";
@ -127,8 +127,9 @@ public class StationReportingDataManager {
List<Object[]> data; List<Object[]> data;
try { try {
data = DirectDbQuery.executeQuery(LATEST_OBS_FOR_LID_QUERY.replace( data = DirectDbQuery.executeQuery(
":lid", lid), HydroConstants.IHFS, QueryLanguage.SQL); LATEST_OBS_FOR_LID_QUERY.replace(":lid", lid),
HydroConstants.IHFS, QueryLanguage.SQL);
for (Object[] rowData : data) { for (Object[] rowData : data) {
retVal.add(convertObsToDataRecord(rowData)); retVal.add(convertObsToDataRecord(rowData));
} }
@ -142,7 +143,7 @@ public class StationReportingDataManager {
public StationReportingTimingData getTimingData(String lid) { public StationReportingTimingData getTimingData(String lid) {
if (stationTime == null) { if (stationTime == null) {
loadTimingData(); loadTimingData();
if (stationTime != null) { if (stationTime != null) {
return stationTime.get(lid); return stationTime.get(lid);
} }
@ -162,7 +163,8 @@ public class StationReportingDataManager {
StationReportingConstants.Duration duration, int durationHours) StationReportingConstants.Duration duration, int durationHours)
throws VizException { throws VizException {
HydroDataCache hydroCache = HydroDataCache.getInstance(); HydroDataCache hydroCache = HydroDataCache.getInstance();
SimpleDateFormat currentTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat currentTimeFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
currentTimeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); currentTimeFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
previousWhere = ""; previousWhere = "";
@ -182,17 +184,16 @@ public class StationReportingDataManager {
+ " FROM latestobsvalue WHERE obstime > '" + obsTimeString + " FROM latestobsvalue WHERE obstime > '" + obsTimeString
+ "')"); + "')");
} else if (listType == ListType.NEVER) { } else if (listType == ListType.NEVER) {
where where.append(" WHERE lid = 'X-N/A-X' "
.append(" WHERE lid = 'X-N/A-X' " + "UNION "
+ "UNION " + "SELECT lid, "
+ "SELECT lid, " + " '', 0, '', '', "
+ " '', 0, '', '', " + " '1-1-1 00:00:00', "
+ " '1-1-1 00:00:00', " + " 0.0, 0, '', 0,'', "
+ " 0.0, 0, '', 0,'', " + " '1-1-1 00:00:00', "
+ " '1-1-1 00:00:00', " + " '1-1-1 00:00:00' "
+ " '1-1-1 00:00:00' " + " FROM location "
+ " FROM location " + " WHERE lid NOT IN (SELECT DISTINCT lid FROM latestobsvalue) ");
+ " WHERE lid NOT IN (SELECT DISTINCT lid FROM latestobsvalue) ");
} }
/* define the sort order */ /* define the sort order */
@ -243,17 +244,20 @@ public class StationReportingDataManager {
StationReportingData srd = new StationReportingData( StationReportingData srd = new StationReportingData(
lid, hydroCache.getLocationMap().get(lid)); lid, hydroCache.getLocationMap().get(lid));
srd.setPe((String) oa[1]); srd.setPe((String) oa[1]);
srd.setDur(((Integer) oa[2]).shortValue()); srd.setDur(((Number) oa[2]).shortValue());
srd.setTs((String) oa[3]); srd.setTs((String) oa[3]);
srd.setExtremum((String) oa[4]); srd.setExtremum((String) oa[4]);
srd.setObstime(currentTimeFormat.format((Date) oa[5])); srd.setObstime(currentTimeFormat
.format((Date) oa[5]));
srd.setValue((Double) oa[6]); srd.setValue((Double) oa[6]);
srd.setRevision(((Integer) oa[7]).shortValue()); srd.setRevision(((Number) oa[7]).shortValue());
srd.setShefQualCode((String) oa[8]); srd.setShefQualCode((String) oa[8]);
srd.setQualityCode((Integer) oa[9]); srd.setQualityCode(((Number) oa[9]).intValue());
srd.setProductId((String) oa[10]); srd.setProductId((String) oa[10]);
srd.setProducttime(currentTimeFormat.format((Date) oa[11])); srd.setProducttime(currentTimeFormat
srd.setPostingtime(currentTimeFormat.format((Date) oa[12])); .format((Date) oa[11]));
srd.setPostingtime(currentTimeFormat
.format((Date) oa[12]));
rval.add(srd); rval.add(srd);
lidList.add(lid); lidList.add(lid);
@ -267,7 +271,7 @@ public class StationReportingDataManager {
return null; return null;
} }
} }
return rval; return rval;
} }
@ -286,7 +290,7 @@ public class StationReportingDataManager {
retVal.setPe(dataRow[1].toString()); retVal.setPe(dataRow[1].toString());
if (dataRow[2] != null) { if (dataRow[2] != null) {
retVal.setDur(((Integer) dataRow[2]).shortValue()); retVal.setDur(((Number) dataRow[2]).shortValue());
} }
retVal.setTs(dataRow[3].toString()); retVal.setTs(dataRow[3].toString());
@ -299,11 +303,11 @@ public class StationReportingDataManager {
retVal.setShefQualCode(dataRow[7].toString()); retVal.setShefQualCode(dataRow[7].toString());
if (dataRow[8] != null) { if (dataRow[8] != null) {
retVal.setQualityCode((Integer) dataRow[8]); retVal.setQualityCode(((Number) dataRow[8]).intValue());
} }
if (dataRow[9] != null) { if (dataRow[9] != null) {
retVal.setRevision(((Integer) dataRow[9]).shortValue()); retVal.setRevision(((Number) dataRow[9]).shortValue());
} }
retVal.setProductId(dataRow[10].toString()); retVal.setProductId(dataRow[10].toString());

View file

@ -129,7 +129,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Feb 27,2013 1790 rferrel Bug fix for non-blocking dialogs. * Feb 27,2013 1790 rferrel Bug fix for non-blocking dialogs.
* Jun 07, 2013 1981 mpduff Set user's id on the OUPRequest as it is now protected. * Jun 07, 2013 1981 mpduff Set user's id on the OUPRequest as it is now protected.
* Jul 16, 2013 2088 rferrel Changes for non-blocking TextEditorDlg. * Jul 16, 2013 2088 rferrel Changes for non-blocking TextEditorDlg.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author lvenable * @author lvenable
@ -1033,7 +1033,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
reviewSendScriptBtn.addSelectionListener(new SelectionAdapter() { reviewSendScriptBtn.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
if (sendConfigDlg == null || sendConfigDlg.isDisposed()) { if ((sendConfigDlg == null) || sendConfigDlg.isDisposed()) {
sendConfigDlg = new SendConfigDlg(shell); sendConfigDlg = new SendConfigDlg(shell);
sendConfigDlg.open(); sendConfigDlg.open();
} else { } else {
@ -1883,8 +1883,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
ArrayList<DataRecord> dataRecordList = new ArrayList<DataRecord>(); ArrayList<DataRecord> dataRecordList = new ArrayList<DataRecord>();
for (int i = 0; i < selectionIndices.length; i++) { for (int selectionIndice : selectionIndices) {
TabularData td = tabularDataList.get(selectionIndices[i]); TabularData td = tabularDataList.get(selectionIndice);
/* set the update structure with data which doesn't change */ /* set the update structure with data which doesn't change */
dr = new DataRecord(); dr = new DataRecord();
@ -1997,8 +1997,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
/* Loop through the data values selected and delete each one */ /* Loop through the data values selected and delete each one */
int[] selectionIndices = bottomListControl.getSelectionIndices(); int[] selectionIndices = bottomListControl.getSelectionIndices();
for (int i = 0; i < selectionIndices.length; i++) { for (int selectionIndice : selectionIndices) {
TabularData td = tabularDataList.get(selectionIndices[i]); TabularData td = tabularDataList.get(selectionIndice);
// SiteInfo si = tabInfo.getSiteInfo(topDataList // SiteInfo si = tabInfo.getSiteInfo(topDataList
// .getSelectionIndex()); // .getSelectionIndex());
DataRecord dr = new DataRecord(); DataRecord dr = new DataRecord();
@ -2134,8 +2134,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
DataRecord dr = new DataRecord(); DataRecord dr = new DataRecord();
/* code to update an observation qc info */ /* code to update an observation qc info */
for (int i = 0; i < selectionIndices.length; i++) { for (int selectionIndice : selectionIndices) {
TabularData td = tabularDataList.get(selectionIndices[i]); TabularData td = tabularDataList.get(selectionIndice);
/* set the update structure with data which doesn't change */ /* set the update structure with data which doesn't change */
dr.setLid(lid); dr.setLid(lid);
@ -2325,11 +2325,11 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
// one inch from left side of paper // one inch from left side of paper
leftMargin = dpi.x + trim.x; leftMargin = dpi.x + trim.x;
// one inch from right side of paper // one inch from right side of paper
rightMargin = clientArea.width - dpi.x + trim.x + trim.width; rightMargin = (clientArea.width - dpi.x) + trim.x + trim.width;
// one inch from top edge of paper // one inch from top edge of paper
topMargin = dpi.y + trim.y; topMargin = dpi.y + trim.y;
// one inch from bottom edge of paper // one inch from bottom edge of paper
bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; bottomMargin = (clientArea.height - dpi.y) + trim.y + trim.height;
// Create a buffer for computing tab width. // Create a buffer for computing tab width.
int tabSize = 4; // is tab width a user setting in your UI? int tabSize = 4; // is tab width a user setting in your UI?
@ -2541,7 +2541,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
} }
} }
} }
if (y + lineHeight <= bottomMargin) { if ((y + lineHeight) <= bottomMargin) {
printer.endPage(); printer.endPage();
} }
wordBuffer = null; wordBuffer = null;
@ -2554,7 +2554,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
if (wordBuffer.length() > 0) { if (wordBuffer.length() > 0) {
String word = wordBuffer.toString(); String word = wordBuffer.toString();
int wordWidth = gc.stringExtent(word).x; int wordWidth = gc.stringExtent(word).x;
if (x + wordWidth > rightMargin) { if ((x + wordWidth) > rightMargin) {
// word doesn't fit on current line, so wrap // word doesn't fit on current line, so wrap
newline(); newline();
} }
@ -2570,9 +2570,9 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
private void newline() { private void newline() {
x = leftMargin; x = leftMargin;
y += lineHeight; y += lineHeight;
if (y + lineHeight > bottomMargin) { if ((y + lineHeight) > bottomMargin) {
printer.endPage(); printer.endPage();
if (index + 1 < end) { if ((index + 1) < end) {
y = topMargin; y = topMargin;
printer.startPage(); printer.startPage();
} }
@ -2715,7 +2715,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
} }
/* Should only be one here, lid is primary key */ /* Should only be one here, lid is primary key */
if (floodList != null && floodList.size() > 0) { if ((floodList != null) && (floodList.size() > 0)) {
Object[] oa = floodList.get(0); Object[] oa = floodList.get(0);
String floodStage = "0.0"; String floodStage = "0.0";
String floodFlow = "0"; String floodFlow = "0";
@ -2785,7 +2785,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
FcstheightId fhid = new FcstheightId(); FcstheightId fhid = new FcstheightId();
fhid.setLid(si.getLid()); fhid.setLid(si.getLid());
fhid.setPe(si.getPe()); fhid.setPe(si.getPe());
fhid.setDur(((Integer) si.getDur()).shortValue()); fhid.setDur((short) si.getDur());
fhid.setExtremum(si.getExt()); fhid.setExtremum(si.getExt());
fcstRow.setPostingtime(postingTime); fcstRow.setPostingtime(postingTime);
@ -2928,7 +2928,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
BufferedWriter out = new BufferedWriter(new FileWriter( BufferedWriter out = new BufferedWriter(new FileWriter(
shefFileName, true)); shefFileName, true));
int[] indices = bottomListControl.getSelectionIndices(); int[] indices = bottomListControl.getSelectionIndices();
for (int i = 0; i < indices.length; i++) { for (int indice : indices) {
String data = topDataList.getItem(topDataList String data = topDataList.getItem(topDataList
.getSelectionIndex()); .getSelectionIndex());
@ -2957,7 +2957,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
endingTime, basisTime, forecast); endingTime, basisTime, forecast);
/* if manually edited data then format as .AR message */ /* if manually edited data then format as .AR message */
TabularData td = tabularDataList.get(indices[i]); TabularData td = tabularDataList.get(indice);
if (td.getShefQualCode().startsWith("M")) { if (td.getShefQualCode().startsWith("M")) {
fmtType = ".AR"; fmtType = ".AR";
} }
@ -3027,7 +3027,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
if ((shefFileName != null) && (shefFileName.length() > 0)) { if ((shefFileName != null) && (shefFileName.length() > 0)) {
File shefFile = new File(shefFileName); File shefFile = new File(shefFileName);
if (shefFile.exists()) { if (shefFile.exists()) {
if (editor == null || editor.isDisposed()) { if ((editor == null) || editor.isDisposed()) {
editor = new TextEditorDlg(shell, false, shefFile); editor = new TextEditorDlg(shell, false, shefFile);
editor.open(); editor.open();
} else { } else {

View file

@ -72,9 +72,9 @@ import com.raytheon.viz.hydrocommon.util.DbUtils;
* Feb 22 2013 14676 lbousaidi check when producttime is null * Feb 22 2013 14676 lbousaidi check when producttime is null
* Mar 25, 2013 1781 mpduff Constrain time series table query with a start time. * Mar 25, 2013 1781 mpduff Constrain time series table query with a start time.
* May 12 2014 16705 lbousaidi update revision and shef_qual_code in edit routine. * May 12 2014 16705 lbousaidi update revision and shef_qual_code in edit routine.
* Dec 14, 2014 16388 xwei updated the insertion of rejecteddata table. * Dec 14, 2014 16388 xwei updated the insertion of rejecteddata table.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
</pre> * </pre>
* *
* @author dhladky * @author dhladky
* @version 1.0 * @version 1.0
@ -251,7 +251,7 @@ public class TimeSeriesDataManager extends HydroDataManager {
SiteInfo si = new SiteInfo(); SiteInfo si = new SiteInfo();
si.setLid((String) oa[0]); si.setLid((String) oa[0]);
si.setPe((String) oa[1]); si.setPe((String) oa[1]);
si.setDur((Integer) oa[2]); si.setDur(((Number) oa[2]).intValue());
si.setTs((String) oa[3]); si.setTs((String) oa[3]);
si.setExt((String) oa[4]); si.setExt((String) oa[4]);
returnData.add(si); returnData.add(si);
@ -561,15 +561,15 @@ public class TimeSeriesDataManager extends HydroDataManager {
td.setLid((String) oa[0]); td.setLid((String) oa[0]);
td.setObsTime((Date) oa[1]); td.setObsTime((Date) oa[1]);
td.setValue((Double) oa[2]); td.setValue((Double) oa[2]);
td.setRevision((Integer) oa[3]); td.setRevision(((Number) oa[3]).intValue());
td.setShefQualCode((String) oa[4]); td.setShefQualCode((String) oa[4]);
td.setQualityCode((Integer) oa[5]); td.setQualityCode(((Number) oa[5]).intValue());
td.setProductId((String) oa[6]); td.setProductId((String) oa[6]);
td.setProductTime((Date) oa[7]); td.setProductTime((Date) oa[7]);
td.setPostingTime((Date) oa[8]); td.setPostingTime((Date) oa[8]);
if (forecastData) { if (forecastData) {
td.setValidTime((Date) oa[9]); td.setValidTime((Date) oa[9]);
td.setProbability((Float) oa[10]); td.setProbability(((Number) oa[10]).floatValue());
} }
tabularData.add(td); tabularData.add(td);
} }
@ -612,7 +612,7 @@ public class TimeSeriesDataManager extends HydroDataManager {
return -1; return -1;
} }
return (Long) results.get(0)[0]; return ((Number) results.get(0)[0]).longValue();
} }
/** /**
@ -927,8 +927,8 @@ public class TimeSeriesDataManager extends HydroDataManager {
try { try {
sqlResult = (DirectDbQuery.executeQuery(sql.toString(), sqlResult = (DirectDbQuery.executeQuery(sql.toString(),
HydroConstants.IHFS, QueryLanguage.SQL)); HydroConstants.IHFS, QueryLanguage.SQL));
if (sqlResult != null && sqlResult.size() > 0 if ((sqlResult != null) && (sqlResult.size() > 0)
&& sqlResult.get(0)[0] != null) { && (sqlResult.get(0)[0] != null)) {
return sqlResult.get(0)[0]; return sqlResult.get(0)[0];
} }
} catch (VizException e) { } catch (VizException e) {
@ -949,8 +949,9 @@ public class TimeSeriesDataManager extends HydroDataManager {
int probability = -1; int probability = -1;
int revision = 1; int revision = 1;
if ( dr.getTs().toUpperCase().startsWith("F") || dr.getTs().toUpperCase().startsWith("C") ) { if (dr.getTs().toUpperCase().startsWith("F")
|| dr.getTs().toUpperCase().startsWith("C")) {
probability = 0; probability = 0;
} }
@ -1302,18 +1303,18 @@ public class TimeSeriesDataManager extends HydroDataManager {
FcstheightId fhid = new FcstheightId(); FcstheightId fhid = new FcstheightId();
fhid.setLid((String) item[i++]); fhid.setLid((String) item[i++]);
fhid.setPe((String) item[i++]); fhid.setPe((String) item[i++]);
Integer in = (Integer) item[i++]; Number in = (Number) item[i++];
fhid.setDur(in.shortValue()); fhid.setDur(in.shortValue());
fhid.setTs((String) item[i++]); fhid.setTs((String) item[i++]);
fhid.setExtremum((String) item[i++]); fhid.setExtremum((String) item[i++]);
fhid.setProbability((Float) item[i++]); fhid.setProbability(((Number) item[i++]).floatValue());
fhid.setValidtime((Date) item[i++]); fhid.setValidtime((Date) item[i++]);
fhid.setBasistime((Date) item[i++]); fhid.setBasistime((Date) item[i++]);
fh.setId(fhid); fh.setId(fhid);
fh.setValue((Double) item[i++]); fh.setValue((Double) item[i++]);
fh.setShefQualCode((String) item[i++]); fh.setShefQualCode((String) item[i++]);
fh.setQualityCode((Integer) item[i++]); fh.setQualityCode(((Number) item[i++]).intValue());
in = (Integer) item[i++]; in = (Number) item[i++];
fh.setRevision(in.shortValue()); fh.setRevision(in.shortValue());
fh.setProductId((String) item[i++]); fh.setProductId((String) item[i++]);
fh.setProducttime((Date) item[i++]); fh.setProducttime((Date) item[i++]);

View file

@ -123,6 +123,7 @@ import com.raytheon.viz.hydrocommon.util.StnClassSyncUtil;
* 06 May 2013 1976 mpduff Code cleanup. * 06 May 2013 1976 mpduff Code cleanup.
* 06 Jun 2013 2076 mpduff Fix station list selection and graph button enabling. * 06 Jun 2013 2076 mpduff Fix station list selection and graph button enabling.
* 0 Jun 2013 15980 wkwock Fix selected station not update * 0 Jun 2013 15980 wkwock Fix selected station not update
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author lvenable * @author lvenable
@ -490,7 +491,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
*/ */
public final static TimeSeriesDlg getInstance() { public final static TimeSeriesDlg getInstance() {
// Independent shell must be recreated after closing. // Independent shell must be recreated after closing.
if (instance == null || !instance.isOpen()) { if ((instance == null) || !instance.isOpen()) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell(); .getShell();
instance = new TimeSeriesDlg(shell); instance = new TimeSeriesDlg(shell);
@ -528,12 +529,12 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
this.standaloneMode = true; this.standaloneMode = true;
// Ensure That The Group Configuration File Exists. // Ensure That The Group Configuration File Exists.
if (groupConfigFile == null || !groupConfigFile.exists()) { if ((groupConfigFile == null) || !groupConfigFile.exists()) {
// if it does not, check localization for the file // if it does not, check localization for the file
IPathManager pm = PathManagerFactory.getPathManager(); IPathManager pm = PathManagerFactory.getPathManager();
groupConfigFile = pm.getStaticFile(HydroConstants.GROUP_DEFINITION); groupConfigFile = pm.getStaticFile(HydroConstants.GROUP_DEFINITION);
if (groupConfigFile == null || !groupConfigFile.exists()) { if ((groupConfigFile == null) || !groupConfigFile.exists()) {
String name = HydroConstants.GROUP_DEFINITION; String name = HydroConstants.GROUP_DEFINITION;
if (name.startsWith("/")) { if (name.startsWith("/")) {
name = name.substring(1); name = name.substring(1);
@ -1527,7 +1528,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
si.setPe((String) row[1]); si.setPe((String) row[1]);
si.setTs((String) row[2]); si.setTs((String) row[2]);
si.setExt((String) row[3]); si.setExt((String) row[3]);
si.setDur((Integer) row[4]); si.setDur(((Number) row[4]).intValue());
if (si.getPe().startsWith("H")) { if (si.getPe().startsWith("H")) {
if (!si.getPe().equals(prevPE)) { if (!si.getPe().equals(prevPE)) {
@ -1692,8 +1693,9 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
if (values.length > 1) { if (values.length > 1) {
if ((values[0] != null) if ((values[0] != null)
&& values[0].equalsIgnoreCase(NAME)) { && values[0].equalsIgnoreCase(NAME)) {
if (values[1] != null) if (values[1] != null) {
groupInfo.setGroupName(values[1]); groupInfo.setGroupName(values[1]);
}
groupDataList.add(groupInfo.getGroupName()); groupDataList.add(groupInfo.getGroupName());
} else if (values[0].equalsIgnoreCase(DESCRIPT)) { } else if (values[0].equalsIgnoreCase(DESCRIPT)) {
groupInfo.setDescription(values[1]); groupInfo.setDescription(values[1]);
@ -1788,10 +1790,11 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} else if (values[0] } else if (values[0]
.equalsIgnoreCase(HydroConstants.PC)) { .equalsIgnoreCase(HydroConstants.PC)) {
td.setPc(values[1]); td.setPc(values[1]);
if (showpp_flag == true) if (showpp_flag == true) {
graphData.setShowpp(true); graphData.setShowpp(true);
else } else {
graphData.setShowpp(false); graphData.setShowpp(false);
}
} else if (values[0].equalsIgnoreCase(COLOR)) { } else if (values[0].equalsIgnoreCase(COLOR)) {
td.setColorName(values[1]); td.setColorName(values[1]);
} }
@ -1959,9 +1962,9 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} }
String[] dataString2 = bottomDataList.getSelection(); String[] dataString2 = bottomDataList.getSelection();
for (int i = 0; i < dataString2.length; i++) { for (String element : dataString2) {
LIDData tmpLidData = new LIDData(); LIDData tmpLidData = new LIDData();
tmpLidData.setData(dataString2[i]); tmpLidData.setData(element);
check1 = lidCheck(prevLidData, tmpLidData); check1 = lidCheck(prevLidData, tmpLidData);
check2 = lidCheck(currLidData, tmpLidData); check2 = lidCheck(currLidData, tmpLidData);
@ -2182,12 +2185,12 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
ArrayList<TraceData> dataList = new ArrayList<TraceData>(); ArrayList<TraceData> dataList = new ArrayList<TraceData>();
for (int i = 0; i < indices.length; i++) { for (int indice : indices) {
/* /*
* Check the selections and determine if 1 or 2 graphs are * Check the selections and determine if 1 or 2 graphs are
* needed * needed
*/ */
String selection = bottomDataList.getItem(indices[i]); String selection = bottomDataList.getItem(indice);
String[] pieces2 = selection.split("\\s+"); String[] pieces2 = selection.split("\\s+");
LIDData lidData = new LIDData(); LIDData lidData = new LIDData();
@ -2301,7 +2304,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
GroupInfo groupInfo = groupList.get(groupDataList GroupInfo groupInfo = groupList.get(groupDataList
.getSelectionIndex()); .getSelectionIndex());
if (prevGroupInfo == null || !prevGroupInfo.equals(groupInfo)) { if ((prevGroupInfo == null) || !prevGroupInfo.equals(groupInfo)) {
int pastHours = groupInfo.getPastHours(); int pastHours = groupInfo.getPastHours();
int futureHours = groupInfo.getFutureHours(); int futureHours = groupInfo.getFutureHours();
beginCal = Calendar beginCal = Calendar
@ -2344,7 +2347,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
private boolean validateForm() { private boolean validateForm() {
boolean valid = true; boolean valid = true;
if (modeCbo.getText().equals(STATION_SELECTION)) { if (modeCbo.getText().equals(STATION_SELECTION)) {
if (endCal.getTimeInMillis() - beginCal.getTimeInMillis() < 0) { if ((endCal.getTimeInMillis() - beginCal.getTimeInMillis()) < 0) {
MessageDialog.openWarning(shell, "Invalid Date Selection", MessageDialog.openWarning(shell, "Invalid Date Selection",
"Ending Time is prior to Beginning Time"); "Ending Time is prior to Beginning Time");
valid = false; valid = false;
@ -2615,15 +2618,15 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} }
/** /**
* In case user selected a different station in the Hydro perspective, * In case user selected a different station in the Hydro perspective,
* update currentLid, etc * update currentLid, etc
*/ */
public void updateFromDisplayManager() { public void updateFromDisplayManager() {
HydroDisplayManager hdm = HydroDisplayManager.getInstance(); HydroDisplayManager hdm = HydroDisplayManager.getInstance();
String newLid=hdm.getCurrentLid(); String newLid = hdm.getCurrentLid();
if (newLid!=null && !newLid.equalsIgnoreCase(currentLid)) { if ((newLid != null) && !newLid.equalsIgnoreCase(currentLid)) {
updateAndOpen(newLid, this.displayGraph); updateAndOpen(newLid, this.displayGraph);
openGraph(); openGraph();
} }
} }

View file

@ -48,9 +48,9 @@ import com.raytheon.viz.hydrocommon.whfslib.IHFSDbGenerated;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Mar 31, 2009 mpduff Initial creation. * Mar 31, 2009 mpduff Initial creation.
* Nov 06, 2009 2639 mpduff Added getRiverStat method. * Nov 06, 2009 2639 mpduff Added getRiverStat method.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author mpduff * @author mpduff
@ -62,11 +62,12 @@ public class HydroData {
* Get Rpfparams data. * Get Rpfparams data.
* *
* @param where * @param where
* The where clause to use * The where clause to use
* @return list of Rpfparams data * @return list of Rpfparams data
* @throws VizException * @throws VizException
*/ */
public static List<Rpfparams> getRpfParams(String where) throws VizException { public static List<Rpfparams> getRpfParams(String where)
throws VizException {
ArrayList<Rpfparams> returnList = new ArrayList<Rpfparams>(); ArrayList<Rpfparams> returnList = new ArrayList<Rpfparams>();
String query = null; String query = null;
if ((where == null) || (where.length() == 0)) { if ((where == null) || (where.length() == 0)) {
@ -78,19 +79,21 @@ public class HydroData {
+ com.raytheon.uf.common.dataplugin.shef.tables.Rpfparams.class + com.raytheon.uf.common.dataplugin.shef.tables.Rpfparams.class
.getName() + " " + where; .getName() + " " + where;
} }
List<Object[]> results = DirectDbQuery.executeQuery(query, HydroConstants.IHFS, QueryLanguage.HQL); List<Object[]> results = DirectDbQuery.executeQuery(query,
HydroConstants.IHFS, QueryLanguage.HQL);
for (Object[] item : results) { for (Object[] item : results) {
returnList.add((Rpfparams) item[0]); returnList.add((Rpfparams) item[0]);
} }
return returnList; return returnList;
} }
public static ArrayList<Forecast> bldTsFcstRiv(String lid, String pe, String tsFilter, public static ArrayList<Forecast> bldTsFcstRiv(String lid, String pe,
boolean useLatest, Date basisTime) { String tsFilter, boolean useLatest, Date basisTime) {
String useTs = null;; String useTs = null;
;
ArrayList<Forecast> fcstList = null; ArrayList<Forecast> fcstList = null;
String where = null; String where = null;
String qcwhere = null; String qcwhere = null;
@ -100,81 +103,82 @@ public class HydroData {
int keepCnt = 0; int keepCnt = 0;
try { try {
/* define which typesource code to use, whether it is passed in /*
whether it is determined by the ingestfilter ranks */ * define which typesource code to use, whether it is passed in
* whether it is determined by the ingestfilter ranks
if ((tsFilter == null) || (tsFilter.length() == 0)) */
{
ordinal = 0; if ((tsFilter == null) || (tsFilter.length() == 0)) {
useTs = getBestTs(lid, pe, "F%", ordinal); ordinal = 0;
useTs = getBestTs(lid, pe, "F%", ordinal);
} else { } else {
useTs = tsFilter; useTs = tsFilter;
} }
/* define the qc filter to apply */ /* define the qc filter to apply */
qcwhere = QualityCodeUtil.buildQcWhere(QualityCodeUtil.QC_NOT_FAILED); qcwhere = QualityCodeUtil
.buildQcWhere(QualityCodeUtil.QC_NOT_FAILED);
/* set the tablename to use */ /* set the tablename to use */
tablename = DbUtils.getTableName(pe, useTs); tablename = DbUtils.getTableName(pe, useTs);
/* convert the times for the where clause */ /* convert the times for the where clause */
String basisTimeStr = HydroConstants.DATE_FORMAT.format(basisTime); String basisTimeStr = HydroConstants.DATE_FORMAT.format(basisTime);
/* get current system time */ /* get current system time */
Date now = SimulatedTime.getSystemTime().getTime(); Date now = SimulatedTime.getSystemTime().getTime();
/* convert the local current time to ansi time in GMT format */ /* convert the local current time to ansi time in GMT format */
String currentTime = HydroConstants.DATE_FORMAT.format(now); String currentTime = HydroConstants.DATE_FORMAT.format(now);
/* retrieve a list of unique basis times; use descending sort. /*
only consider forecast data before some ending time, * retrieve a list of unique basis times; use descending sort. only
and with some limited basis time ago */ * consider forecast data before some ending time, and with some
where = "WHERE lid = '" + lid + "' and pe ='" + pe + "' " + * limited basis time ago
"and ts = '" + useTs + "' and probability < 0.0 and " + */
"validtime >= '" + currentTime + "' and " + where = "WHERE lid = '" + lid + "' and pe ='" + pe + "' "
"basistime >= '" + basisTimeStr + "' and " + + "and ts = '" + useTs + "' and probability < 0.0 and "
"value != " + HydroConstants.MISSING_VALUE + + "validtime >= '" + currentTime + "' and "
" and " + qcwhere + " ORDER BY basistime DESC "; + "basistime >= '" + basisTimeStr + "' and " + "value != "
+ HydroConstants.MISSING_VALUE + " and " + qcwhere
ArrayList<String[]> uniqueResults = loadUnique("basistime", tablename, where); + " ORDER BY basistime DESC ";
ArrayList<String[]> uniqueResults = loadUnique("basistime",
tablename, where);
if (uniqueResults.size() <= 0) { if (uniqueResults.size() <= 0) {
return null; return null;
} }
/* retrieve the data; the ordering by validtime is important. /*
as before, limit the forecast time valid time window * retrieve the data; the ordering by validtime is important. as
and as needed, the age of the forecast (basistime). */ * before, limit the forecast time valid time window and as needed,
* the age of the forecast (basistime).
*/
if (useLatest || (uniqueResults.size() == 1)) { if (useLatest || (uniqueResults.size() == 1)) {
where = String.format(" WHERE lid = '%s' AND pe = '%s' AND " + where = String.format(" WHERE lid = '%s' AND pe = '%s' AND "
" ts = '%s' AND " + + " ts = '%s' AND " + " probability < 0.0 AND "
" probability < 0.0 AND " + + " validtime >= '%s' AND basistime = '%s' AND "
" validtime >= '%s' AND basistime = '%s' AND " + + " value != %d AND %s " + " ORDER BY validtime ASC",
" value != %d AND %s " + lid, pe, useTs, currentTime, uniqueResults.get(0)[0],
" ORDER BY validtime ASC", HydroConstants.MISSING_VALUE, qcwhere);
lid, pe, useTs, currentTime, uniqueResults.get(0)[0],
HydroConstants.MISSING_VALUE, qcwhere);
} else { } else {
where = String.format(" WHERE lid = '%s' AND pe = '%s' AND " + where = String.format(" WHERE lid = '%s' AND pe = '%s' AND "
" ts = '%s' AND " + + " ts = '%s' AND " + " probability < 0.0 AND "
" probability < 0.0 AND " + + " validtime >= '%s' AND basistime >= '%s' AND "
" validtime >= '%s' AND basistime >= '%s' AND " + + " value != %d AND %s" + " ORDER BY validtime ASC",
" value != %d AND %s" + lid, pe, useTs, currentTime, basisTimeStr,
" ORDER BY validtime ASC", HydroConstants.MISSING_VALUE, qcwhere);
lid, pe, useTs, currentTime, basisTimeStr,
HydroConstants.MISSING_VALUE, qcwhere);
} }
fcstList = getForecast(where, tablename); fcstList = getForecast(where, tablename);
/* /*
* if only getting the latest basis time's data * if only getting the latest basis time's data or only one basis
* or only one basis time was found, then consider all; * time was found, then consider all; otherwise, need to adjoin/butt
* otherwise, need to adjoin/butt the time series together * the time series together for the multiple basis times.
* for the multiple basis times.
*/ */
doKeep = new boolean[fcstList.size()]; doKeep = new boolean[fcstList.size()];
if (useLatest || (uniqueResults.size() <= 1)) { if (useLatest || (uniqueResults.size() <= 1)) {
@ -184,10 +188,12 @@ public class HydroData {
} else { } else {
setFcstKeep(uniqueResults, fcstList, doKeep); setFcstKeep(uniqueResults, fcstList, doKeep);
} }
/* now load the values and info to return, knowing which items /*
to keep since all the values have been tagged. first get * now load the values and info to return, knowing which items to
the count of the number of values to keep and allocate the data */ * keep since all the values have been tagged. first get the count
* of the number of values to keep and allocate the data
*/
for (int i = 0; i < fcstList.size(); i++) { for (int i = 0; i < fcstList.size(); i++) {
if (doKeep[i]) { if (doKeep[i]) {
keepCnt++; keepCnt++;
@ -199,50 +205,47 @@ public class HydroData {
fcstList.remove(i); fcstList.remove(i);
} }
} }
} catch (VizException ve) { } catch (VizException ve) {
ve.printStackTrace(); ve.printStackTrace();
} }
return fcstList; return fcstList;
} }
/**
For a given location and pe code and type-source prefix, this function
returns the type-source code with the lowest rank in IngestFilter.
Alternatively, if a specific ordinal number is passed, then the
Nth ranking ts is returned. If no (<= 0) ordinal number (i.e. 1st, 2nd)
is requested, then the highest rank (1st) is returned.
The type-source prefix is normally given as a one-character string,
R for observed data and F for forecast data.
The function argument returns a status variable indicating
whether the request was satisfied.
**************************************************************/
/**
*
*/
/** /**
* For a given location and pe code and type-source prefix, this function * For a given location and pe code and type-source prefix, this function
* returns the type-source code with the lowest rank in IngestFilter. * returns the type-source code with the lowest rank in IngestFilter.
* Alternatively, if a specific ordinal number is passed, then the * Alternatively, if a specific ordinal number is passed, then the Nth
* Nth ranking ts is returned. If no (<= 0) ordinal number (i.e. 1st, 2nd) * ranking ts is returned. If no (<= 0) ordinal number (i.e. 1st, 2nd) is
* is requested, then the highest rank (1st) is returned. * requested, then the highest rank (1st) is returned. The type-source
* The type-source prefix is normally given as a one-character string, * prefix is normally given as a one-character string, R for observed data
* R for observed data and F for forecast data. * and F for forecast data.
*
* The function argument returns a status variable indicating whether the
* request was satisfied.
**************************************************************/
/**
*
*/
/**
* For a given location and pe code and type-source prefix, this function
* returns the type-source code with the lowest rank in IngestFilter.
* Alternatively, if a specific ordinal number is passed, then the Nth
* ranking ts is returned. If no (<= 0) ordinal number (i.e. 1st, 2nd) is
* requested, then the highest rank (1st) is returned. The type-source
* prefix is normally given as a one-character string, R for observed data
* and F for forecast data.
* *
* @param lid * @param lid
* The location id * The location id
* @param pe * @param pe
* The physical element * The physical element
* @param tsPrefix * @param tsPrefix
* One character string, R for observed and F for forecast * One character string, R for observed and F for forecast
* @param ordinal * @param ordinal
* the specific ranking to return, if <= 0 return highest ranking * the specific ranking to return, if <= 0 return highest ranking
* @return The ts with the best ranking * @return The ts with the best ranking
*/ */
public static String getBestTs(String lid, String pe, String tsPrefix, public static String getBestTs(String lid, String pe, String tsPrefix,
@ -251,46 +254,53 @@ public class HydroData {
String where = null; String where = null;
List<Ingestfilter> ingestFilterList = null; List<Ingestfilter> ingestFilterList = null;
Ingestfilter ingestPtr; Ingestfilter ingestPtr;
/* get the ingest filter entries for this location. note that the /*
retrieval is ordered so that if multiple best ranks exist, there * get the ingest filter entries for this location. note that the
is some predicatibility for the identified best one. also note that * retrieval is ordered so that if multiple best ranks exist, there is
this approach ignores the duration, extremum, and probabilty code. */ * some predicatibility for the identified best one. also note that this
* approach ignores the duration, extremum, and probabilty code.
where = String.format(" WHERE lid = '%s' AND pe = '%s' AND " + */
" ts LIKE '%s%%' AND ingest = 'T' ORDER BY ts_rank, ts",
lid, pe, tsPrefix); where = String.format(" WHERE lid = '%s' AND pe = '%s' AND "
+ " ts LIKE '%s%%' AND ingest = 'T' ORDER BY ts_rank, ts", lid,
ingestFilterList = IHFSDbGenerated.GetIngestFilter(where); pe, tsPrefix);
if ((ingestFilterList != null) && (ingestFilterList.size() > 0)) { ingestFilterList = IHFSDbGenerated.GetIngestFilter(where);
/* if no specific ordinal number was requested, return with
the highest rank. */ if ((ingestFilterList != null) && (ingestFilterList.size() > 0)) {
/*
if (ordinal <= 0) { * if no specific ordinal number was requested, return with the
tsFound = ingestFilterList.get(0).getId().getTs(); * highest rank.
} */
} else { /* if a specific ordinal number was requested. */ if (ordinal <= 0) {
/* if a specific ordinal number was requested. */ tsFound = ingestFilterList.get(0).getId().getTs();
}
/* get a count of the number of matching ts entries.
if the requested ordinal number is greater than } else { /* if a specific ordinal number was requested. */
the number available then return with a not found status. */ /* if a specific ordinal number was requested. */
if (ordinal <= ingestFilterList.size()) { /*
ingestPtr = ingestFilterList.get(ordinal); * get a count of the number of matching ts entries. if the
tsFound = ingestPtr.getId().getTs(); * requested ordinal number is greater than the number available
} * then return with a not found status.
} */
return tsFound; if (ordinal <= ingestFilterList.size()) {
ingestPtr = ingestFilterList.get(ordinal);
tsFound = ingestPtr.getId().getTs();
}
}
return tsFound;
} }
public static ArrayList<String[]> loadUnique(String field, String table, String where) throws VizException { public static ArrayList<String[]> loadUnique(String field, String table,
String where) throws VizException {
ArrayList<String[]> returnList = new ArrayList<String[]>(); ArrayList<String[]> returnList = new ArrayList<String[]>();
StringBuilder sql = new StringBuilder("SELECT DISTINCT "); StringBuilder sql = new StringBuilder("SELECT DISTINCT ");
if (field.contains("||")) { if (field.contains("||")) {
String[] fields = field.split("\\|\\|"); String[] fields = field.split("\\|\\|");
sql.append(fields[0]); sql.append(fields[0]);
@ -301,40 +311,44 @@ public class HydroData {
} else { } else {
sql.append(field); sql.append(field);
} }
sql.append(" from " + table + " " + where); sql.append(" from " + table + " " + where);
List<Object[]> results = DirectDbQuery.executeQuery(sql.toString(), HydroConstants.IHFS, QueryLanguage.SQL); List<Object[]> results = DirectDbQuery.executeQuery(sql.toString(),
HydroConstants.IHFS, QueryLanguage.SQL);
for (int i = 0; i < results.size(); i++) { for (int i = 0; i < results.size(); i++) {
Object[] oa = results.get(i); Object[] oa = results.get(i);
ArrayList<String> al = new ArrayList<String>(); ArrayList<String> al = new ArrayList<String>();
for (Object o: oa) { for (Object o : oa) {
if (o instanceof java.sql.Timestamp) { if (o instanceof java.sql.Timestamp) {
al.add(HydroConstants.DATE_FORMAT.format((java.sql.Timestamp) o)); al.add(HydroConstants.DATE_FORMAT
} else if (o instanceof Integer){ .format((java.sql.Timestamp) o));
al.add(((Integer) o).toString()); } else if (o instanceof Number) {
al.add(((Number) o).toString());
} else { } else {
al.add((String) o); al.add((String) o);
} }
} }
returnList.add(al.toArray(new String[al.size()])); returnList.add(al.toArray(new String[al.size()]));
} }
return returnList; return returnList;
} }
public static ArrayList<Forecast> getForecast(String where, String tablename) throws VizException { public static ArrayList<Forecast> getForecast(String where, String tablename)
throws VizException {
List<Forecast> fcstList = new ArrayList<Forecast>(); List<Forecast> fcstList = new ArrayList<Forecast>();
List<Object[]> result = null; List<Object[]> result = null;
if (tablename.equalsIgnoreCase("fcstheight")) { if (tablename.equalsIgnoreCase("fcstheight")) {
String query = "from " String query = "from "
+ com.raytheon.uf.common.dataplugin.shef.tables.Fcstheight.class + com.raytheon.uf.common.dataplugin.shef.tables.Fcstheight.class
.getName() + " " + where; .getName() + " " + where;
result = DirectDbQuery.executeQuery(query, HydroConstants.IHFS, QueryLanguage.HQL); result = DirectDbQuery.executeQuery(query, HydroConstants.IHFS,
QueryLanguage.HQL);
/* Convert to Forecast object */ /* Convert to Forecast object */
for (Object[] item : result) { for (Object[] item : result) {
Fcstheight fh = (Fcstheight) item[0]; Fcstheight fh = (Fcstheight) item[0];
@ -357,72 +371,79 @@ public class HydroData {
fcstList.add(f); fcstList.add(f);
} }
} }
return (ArrayList<Forecast>) fcstList; return (ArrayList<Forecast>) fcstList;
} }
/** /**
* Determine which items in the forecast time series to keep, * Determine which items in the forecast time series to keep, as there may
* as there may be overlap due to multiple time_series. * be overlap due to multiple time_series.
* *
* @param uniqueResults * @param uniqueResults
* List of results from the unique query * List of results from the unique query
* @param fcstList * @param fcstList
* List of Forecast data * List of Forecast data
* @param doKeep * @param doKeep
* Array of boolean flags on which to keep * Array of boolean flags on which to keep
* @return array of flags determining which time series to keep * @return array of flags determining which time series to keep
*/ */
private static boolean[] setFcstKeep(ArrayList<String[]> uniqueResults, ArrayList<Forecast> fcstList, boolean[] doKeep) { private static boolean[] setFcstKeep(ArrayList<String[]> uniqueResults,
/* get counts of linked lists, one for the forecast values themselves ArrayList<Forecast> fcstList, boolean[] doKeep) {
and one for the number of unique basis times */ /*
* get counts of linked lists, one for the forecast values themselves
* and one for the number of unique basis times
*/
boolean[] tsFirstChk = new boolean[uniqueResults.size()]; boolean[] tsFirstChk = new boolean[uniqueResults.size()];
int[] basisIndex = new int[fcstList.size()]; int[] basisIndex = new int[fcstList.size()];
Date[] tsStartTime = new Date[fcstList.size()]; Date[] tsStartTime = new Date[fcstList.size()];
Date[] tsEndTime = new Date[fcstList.size()]; Date[] tsEndTime = new Date[fcstList.size()];
Date[] tsBasisTime = new Date[fcstList.size()]; Date[] tsBasisTime = new Date[fcstList.size()];
String basisTimeStr = null; String basisTimeStr = null;
for (int i = 0; i < uniqueResults.size(); i++) { for (int i = 0; i < uniqueResults.size(); i++) {
tsFirstChk[i] = false; tsFirstChk[i] = false;
} }
Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime();
/* allocate arrays for each basis time */ /* allocate arrays for each basis time */
for (int i = 0; i < fcstList.size(); i++) { for (int i = 0; i < fcstList.size(); i++) {
tsStartTime[i] = now; tsStartTime[i] = now;
} }
for (int i = 0; i < fcstList.size(); i++) { for (int i = 0; i < fcstList.size(); i++) {
tsEndTime[i] = now; tsEndTime[i] = now;
} }
for (int i = 0; i < fcstList.size(); i++) { for (int i = 0; i < fcstList.size(); i++) {
tsBasisTime[i] = now; tsBasisTime[i] = now;
} }
/*
/* now loop thru the retrieved time series data values and get the * now loop thru the retrieved time series data values and get the start
start and end times for each of the basis times found. */ * and end times for each of the basis times found.
*/
for (int i = 0; i < fcstList.size(); i++) { for (int i = 0; i < fcstList.size(); i++) {
/* find out which basis time's time series this value belongs to */ /* find out which basis time's time series this value belongs to */
basisIndex[i] = HydroConstants.MISSING_VALUE; basisIndex[i] = HydroConstants.MISSING_VALUE;
basisTimeStr = HydroConstants.DATE_FORMAT.format(fcstList.get(i).getBasistime()); basisTimeStr = HydroConstants.DATE_FORMAT.format(fcstList.get(i)
.getBasistime());
for (int j = 0; ((j < uniqueResults.size()) && (basisIndex[i] == HydroConstants.MISSING_VALUE)); j++) { for (int j = 0; ((j < uniqueResults.size()) && (basisIndex[i] == HydroConstants.MISSING_VALUE)); j++) {
if (uniqueResults.get(j)[0].equalsIgnoreCase(basisTimeStr)) { if (uniqueResults.get(j)[0].equalsIgnoreCase(basisTimeStr)) {
basisIndex[i] = j; basisIndex[i] = j;
} }
} }
if (basisIndex[i] == HydroConstants.MISSING_VALUE) { if (basisIndex[i] == HydroConstants.MISSING_VALUE) {
// TODO error log this message: // TODO error log this message:
// fprintf(stderr, "Unexpected error assigning basis_index for %d\n", i); // fprintf(stderr,
// "Unexpected error assigning basis_index for %d\n", i);
} }
/* check if the values constitute the start or end times /*
for the time series and record these times if they do */ * check if the values constitute the start or end times for the
* time series and record these times if they do
*/
Date validTime = fcstList.get(i).getValidtime(); Date validTime = fcstList.get(i).getValidtime();
if (tsFirstChk[basisIndex[i]]) { if (tsFirstChk[basisIndex[i]]) {
if (validTime.before(tsStartTime[basisIndex[i]])) { if (validTime.before(tsStartTime[basisIndex[i]])) {
@ -436,10 +457,11 @@ public class HydroData {
tsFirstChk[basisIndex[i]] = true; tsFirstChk[basisIndex[i]] = true;
} }
} }
/* for each of the unique basis times, assign the basis time /*
in a convenient array for use in the adjust_startend * for each of the unique basis times, assign the basis time in a
function. */ * convenient array for use in the adjust_startend function.
*/
for (int j = 0; j < uniqueResults.size(); j++) { for (int j = 0; j < uniqueResults.size(); j++) {
String bTimeStr = uniqueResults.get(j)[0]; String bTimeStr = uniqueResults.get(j)[0];
Date bTime; Date bTime;
@ -449,62 +471,68 @@ public class HydroData {
} catch (ParseException e) { } catch (ParseException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
/* knowing the actual start and end times for the multiple /*
time series, loop thru the time series and adjust the start * knowing the actual start and end times for the multiple time series,
and end times so that they reflect the time span to use; * loop thru the time series and adjust the start and end times so that
i.e. there is no overlap. THIS IS THE KEY STEP IN THE * they reflect the time span to use; i.e. there is no overlap. THIS IS
PROCESS OF DEFINING AN AGGREGATE VIRTUAL TIME SERIES!!! */ * THE KEY STEP IN THE PROCESS OF DEFINING AN AGGREGATE VIRTUAL TIME
adjustStartEnd(uniqueResults.size(), tsBasisTime, tsStartTime, tsEndTime); * SERIES!!!
*/
adjustStartEnd(uniqueResults.size(), tsBasisTime, tsStartTime,
tsEndTime);
return doKeep; return doKeep;
} }
/** /**
* This method uses the time series with the latest basis time first, * This method uses the time series with the latest basis time first, and
* and uses it in its entirety. Then the time series with the next * uses it in its entirety. Then the time series with the next latest basis
* latest basis time is used. If it overlaps portions of the already * time is used. If it overlaps portions of the already saved time series,
* saved time series, then only that portion which doesn't * then only that portion which doesn't overlap is used. This process
* overlap is used. This process continues until all time series * continues until all time series have been considered. In essences, this
* have been considered. In essences, this method adjoins adjacent * method adjoins adjacent time series.
* time series.
* *
* @param basisTime * @param basisTime
* Date[] of basis times * Date[] of basis times
* @param startValidTime * @param startValidTime
* Date[] of starting valid times * Date[] of starting valid times
* @param endValidTime * @param endValidTime
* Date[] of ending valid times * Date[] of ending valid times
*/ */
private static void adjustStartEnd(int ulCount, Date[] basisTime, Date[] startValidTime, Date[] endValidTime) { private static void adjustStartEnd(int ulCount, Date[] basisTime,
Date[] startValidTime, Date[] endValidTime) {
int[] basisOrder = new int[ulCount]; int[] basisOrder = new int[ulCount];
Date tmpTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); Date tmpTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"))
.getTime();
int curIndex = 0; int curIndex = 0;
Date fullStartValidTime; Date fullStartValidTime;
Date fullEndValidTime; Date fullEndValidTime;
/* initialize array to keep track of order /*
of the basis time series' */ * initialize array to keep track of order of the basis time series'
*/
for (int i = 0; i < ulCount; i++) { for (int i = 0; i < ulCount; i++) {
basisOrder[i] = -1; basisOrder[i] = -1;
} }
/* /*
* find the order of the time series by their latest basis time. * find the order of the time series by their latest basis time. if two
* if two time series have the same basis time, use the one that * time series have the same basis time, use the one that has the
* has the earlier starting time. note that the order is such * earlier starting time. note that the order is such that the latest
* that the latest basis time is last in the resulting order array. * basis time is last in the resulting order array.
*/ */
for (int i = 0; i < ulCount; i++) { for (int i = 0; i < ulCount; i++) {
curIndex = 0; curIndex = 0;
boolean found = false; boolean found = false;
for (int j = 0; j < ulCount; j++) { for (int j = 0; j < ulCount; j++) {
/* only consider the time series if it hasn't been accounted /*
for in the order array */ * only consider the time series if it hasn't been accounted for
* in the order array
*/
found = false; found = false;
for (int k = 0; k < i; k++) { for (int k = 0; k < i; k++) {
if (j == basisOrder[k]) { if (j == basisOrder[k]) {
@ -526,96 +554,114 @@ public class HydroData {
} }
basisOrder[i] = curIndex; basisOrder[i] = curIndex;
} }
/* do NOT adjust the start and end time of the time series /*
with the latest ending time. loop through all the other * do NOT adjust the start and end time of the time series with the
time series and adjust their start and end times as necessary * latest ending time. loop through all the other time series and adjust
so that they do not overlap the time limits of the * their start and end times as necessary so that they do not overlap
being-built aggregate time series. */ * the time limits of the being-built aggregate time series.
*/
curIndex = basisOrder[0]; curIndex = basisOrder[0];
fullStartValidTime = startValidTime[curIndex]; fullStartValidTime = startValidTime[curIndex];
fullEndValidTime = endValidTime[curIndex]; fullEndValidTime = endValidTime[curIndex];
for (int i = 1; i < ulCount; i++) { for (int i = 1; i < ulCount; i++) {
curIndex = basisOrder[i]; curIndex = basisOrder[i];
/* each additional time series being considered is checked to /*
see if it falls outside the time window already encompassed * each additional time series being considered is checked to see if
by the assembled time series. there are four cases that can * it falls outside the time window already encompassed by the
occur; each is handled below. */ * assembled time series. there are four cases that can occur; each
* is handled below.
/* if the basis time series being considered is fully within the */
time of the already existing time series, then
ignore it completely, and reset its times. */ /*
* if the basis time series being considered is fully within the
if (startValidTime[curIndex].after(fullStartValidTime) && endValidTime[curIndex].before(fullEndValidTime)) { * time of the already existing time series, then ignore it
* completely, and reset its times.
*/
if (startValidTime[curIndex].after(fullStartValidTime)
&& endValidTime[curIndex].before(fullEndValidTime)) {
startValidTime[curIndex].setTime(0); startValidTime[curIndex].setTime(0);
endValidTime[curIndex].setTime(0); endValidTime[curIndex].setTime(0);
} }
else if (startValidTime[curIndex].before(fullStartValidTime)
else if (startValidTime[curIndex].before(fullStartValidTime) && endValidTime[curIndex].after(fullEndValidTime)) { && endValidTime[curIndex].after(fullEndValidTime)) {
/* if the basis time series being considered covers time both before /*
and after the existing time series, use the portion of it * if the basis time series being considered covers time both
that is before the time series. it is not desirable to use * before and after the existing time series, use the portion of
both the before and after portion (this results in a * it that is before the time series. it is not desirable to use
non-contiguous time-series that is weird), and given a choice * both the before and after portion (this results in a
it is better to use the forecast data early on than the * non-contiguous time-series that is weird), and given a choice
later forecast data, so use the before portion */ * it is better to use the forecast data early on than the later
* forecast data, so use the before portion
*/
fullStartValidTime.setTime(fullStartValidTime.getTime() - 1000); fullStartValidTime.setTime(fullStartValidTime.getTime() - 1000);
endValidTime[curIndex] = fullStartValidTime; endValidTime[curIndex] = fullStartValidTime;
fullStartValidTime = startValidTime[curIndex]; fullStartValidTime = startValidTime[curIndex];
} else if (startValidTime[curIndex].before(fullStartValidTime) && endValidTime[curIndex].before(fullEndValidTime)) { } else if (startValidTime[curIndex].before(fullStartValidTime)
/* if the basis time series being considered straddles the beginning && endValidTime[curIndex].before(fullEndValidTime)) {
or is completely before the existing time series, then use the /*
portion of it that is before the time series. */ * if the basis time series being considered straddles the
* beginning or is completely before the existing time series,
* then use the portion of it that is before the time series.
*/
fullStartValidTime.setTime(fullStartValidTime.getTime() - 1000); fullStartValidTime.setTime(fullStartValidTime.getTime() - 1000);
endValidTime[curIndex] = fullStartValidTime; endValidTime[curIndex] = fullStartValidTime;
fullStartValidTime = startValidTime[curIndex]; fullStartValidTime = startValidTime[curIndex];
} else if (startValidTime[curIndex].after(fullStartValidTime) && endValidTime[curIndex].after(fullEndValidTime)) { } else if (startValidTime[curIndex].after(fullStartValidTime)
/* if the basis time series being considered straddles the end && endValidTime[curIndex].after(fullEndValidTime)) {
or is completely after the existing time series, then use the /*
portion of it that is after the time series. */ * if the basis time series being considered straddles the end
* or is completely after the existing time series, then use the
* portion of it that is after the time series.
*/
fullEndValidTime.setTime(fullEndValidTime.getTime() - 1000); fullEndValidTime.setTime(fullEndValidTime.getTime() - 1000);
startValidTime[curIndex] = fullEndValidTime; startValidTime[curIndex] = fullEndValidTime;
fullEndValidTime = endValidTime[curIndex]; fullEndValidTime = endValidTime[curIndex];
} }
} }
} }
/** /**
* Loads the max fcst info into the RiverStatus table for the * Loads the max fcst info into the RiverStatus table for the current
* current location and pe. * location and pe.
* *
* @param record * @param record
* Forecast record to load * Forecast record to load
*/ */
public static void loadRiverStatus(Forecast record) throws VizException { public static void loadRiverStatus(Forecast record) throws VizException {
Riverstatus rstatus = new Riverstatus(); Riverstatus rstatus = new Riverstatus();
RiverstatusId rsid = new RiverstatusId(); RiverstatusId rsid = new RiverstatusId();
/* update the value in the RiverStatus table. if no record /*
currently in the table, then insert/put a new record. * update the value in the RiverStatus table. if no record currently in
first build the record to update/insert */ * the table, then insert/put a new record. first build the record to
* update/insert
*/
rsid.setLid(record.getLid()); rsid.setLid(record.getLid());
rsid.setPe(record.getPe()); rsid.setPe(record.getPe());
rsid.setTs(record.getTs()); rsid.setTs(record.getTs());
rstatus.setId(rsid); rstatus.setId(rsid);
rstatus.setBasistime(record.getBasistime()); rstatus.setBasistime(record.getBasistime());
rstatus.setDur((short)record.getDur()); rstatus.setDur((short) record.getDur());
rstatus.setExtremum(record.getExtremum()); rstatus.setExtremum(record.getExtremum());
rstatus.setProbability((float)record.getProbability()); rstatus.setProbability((float) record.getProbability());
rstatus.setValidtime(record.getValidtime()); rstatus.setValidtime(record.getValidtime());
rstatus.setValue(record.getValue()); rstatus.setValue(record.getValue());
DirectDbQuery.saveOrUpdate(rstatus, HydroConstants.IHFS); DirectDbQuery.saveOrUpdate(rstatus, HydroConstants.IHFS);
} }
public static void deleteRiverStatus(String lid, String pe, String ts) throws VizException { public static void deleteRiverStatus(String lid, String pe, String ts)
String where = String.format(" WHERE lid='%s' AND pe='%s' AND ts='%s' ", throws VizException {
lid, pe, ts); String where = String.format(
" WHERE lid='%s' AND pe='%s' AND ts='%s' ", lid, pe, ts);
String query = "delete from RiverStatus " + where; String query = "delete from RiverStatus " + where;
DirectDbQuery.executeStatement(query, HydroConstants.IHFS, QueryLanguage.SQL); DirectDbQuery.executeStatement(query, HydroConstants.IHFS,
QueryLanguage.SQL);
} }
} }

View file

@ -39,6 +39,7 @@ import com.raytheon.viz.hydrocommon.IGetSortType;
* 16Oct2008 1636 askripsky Initial Creation * 16Oct2008 1636 askripsky Initial Creation
* Oct 27, 2011 11267 lbousaidi change showNoPost initial value to false * Oct 27, 2011 11267 lbousaidi change showNoPost initial value to false
* to match AWIPS I default setting * to match AWIPS I default setting
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author askripsky * @author askripsky
@ -66,7 +67,7 @@ public class HydroStationDataManager {
private boolean showPost = true; private boolean showPost = true;
private boolean showNoPost = false; private boolean showNoPost = false;
private IGetSortType sortType; private IGetSortType sortType;
/** /**
@ -103,7 +104,7 @@ public class HydroStationDataManager {
public ArrayList<HydroStationData> getStationData(IGetSortType sortType) { public ArrayList<HydroStationData> getStationData(IGetSortType sortType) {
ArrayList<HydroStationData> rval = new ArrayList<HydroStationData>(); ArrayList<HydroStationData> rval = new ArrayList<HydroStationData>();
this.sortType = sortType; this.sortType = sortType;
// Verify data is empty // Verify data is empty
if (stationData == null) { if (stationData == null) {
stationData = new ArrayList<HydroStationData>(); stationData = new ArrayList<HydroStationData>();
@ -123,8 +124,8 @@ public class HydroStationDataManager {
hydroStationQuery.append(getWhereClause()); hydroStationQuery.append(getWhereClause());
try { try {
List<Object[]> data = DirectDbQuery.executeQuery(hydroStationQuery List<Object[]> data = DirectDbQuery.executeQuery(
.toString(), HydroConstants.IHFS, hydroStationQuery.toString(), HydroConstants.IHFS,
DirectDbQuery.QueryLanguage.SQL); DirectDbQuery.QueryLanguage.SQL);
for (Object[] currData : data) { for (Object[] currData : data) {
@ -141,10 +142,11 @@ public class HydroStationDataManager {
StringBuffer rval = new StringBuffer(); StringBuffer rval = new StringBuffer();
if (showPost) { if (showPost) {
if (showNoPost) if (showNoPost) {
rval.append(" WHERE post IS NOT NULL "); rval.append(" WHERE post IS NOT NULL ");
else } else {
rval.append(" WHERE post = 1 "); rval.append(" WHERE post = 1 ");
}
} else if (showNoPost) { } else if (showNoPost) {
rval.append(" WHERE post = 0 "); rval.append(" WHERE post = 0 ");
} else { } else {
@ -176,15 +178,12 @@ public class HydroStationDataManager {
/* specify the lat-lon filter if it is enabled */ /* specify the lat-lon filter if it is enabled */
if (filterByLatLon) { if (filterByLatLon) {
rval rval.append(String
.append(String .format(" AND ((lat > %f) AND (lat < %f)) AND ((lon > %f) AND (lon < %f)) ",
.format( latCenter - latOffset, latCenter + latOffset,
" AND ((lat > %f) AND (lat < %f)) AND ((lon > %f) AND (lon < %f)) ", lonCenter - lonOffset, lonCenter + lonOffset));
latCenter - latOffset, latCenter
+ latOffset, lonCenter - lonOffset,
lonCenter + lonOffset));
} }
/* Determine sort selection criteria */ /* Determine sort selection criteria */
String sort = sortType.getSortType(); String sort = sortType.getSortType();
if (sort.compareTo("State,County") == 0) { if (sort.compareTo("State,County") == 0) {
@ -195,40 +194,40 @@ public class HydroStationDataManager {
{ {
rval.append(" order by lid"); rval.append(" order by lid");
} }
return rval.toString(); return rval.toString();
} }
/** /**
* Check if the lid passed in is a river site or not. * Check if the lid passed in is a river site or not.
* *
* @param lid * @param lid
* The lid to check * The lid to check
* @return * @return True if site is a river site
* True if site is a river site
*/ */
public boolean isRiverSite(String lid) { public boolean isRiverSite(String lid) {
boolean riverSite = false; boolean riverSite = false;
String query = "select count(*) from riverstat where lid = '" + lid + "'"; String query = "select count(*) from riverstat where lid = '" + lid
+ "'";
List<Object[]> rs; List<Object[]> rs;
try { try {
rs = DirectDbQuery.executeQuery(query, HydroConstants.IHFS, QueryLanguage.SQL); rs = DirectDbQuery.executeQuery(query, HydroConstants.IHFS,
QueryLanguage.SQL);
if ((rs != null) && (rs.size() > 0)) { if ((rs != null) && (rs.size() > 0)) {
long num = (Long) rs.get(0)[0]; long num = ((Number) rs.get(0)[0]).longValue();
if (num > 0) { if (num > 0) {
riverSite = true; riverSite = true;
} }
} }
} catch (VizException e) { } catch (VizException e) {
System.err.println("Error querying riverstat table"); System.err.println("Error querying riverstat table");
} }
return riverSite; return riverSite;
} }
/** /**
* @return the latCenter * @return the latCenter
*/ */

View file

@ -36,6 +36,21 @@ import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.ColorThreshold;
import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.ColorThresholdArray; import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.ColorThresholdArray;
import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.NamedColorUseSet; import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.NamedColorUseSet;
/**
* Hydro Color Manager
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre>
*
* @author rjpeter
* @version 1.0
*/
public abstract class ColorManager { public abstract class ColorManager {
protected static final String HARDCODED = "HARDCODED"; protected static final String HARDCODED = "HARDCODED";
@ -121,8 +136,7 @@ public abstract class ColorManager {
rval.add(data); rval.add(data);
ColorThreshold[] thresholds = arr.getThresholds(); ColorThreshold[] thresholds = arr.getThresholds();
for (int i = 0; i < thresholds.length; ++i) { for (ColorThreshold ct : thresholds) {
ColorThreshold ct = thresholds[i];
double tmpVal = ct.getValue(); double tmpVal = ct.getValue();
data = new ColorScaleData(); data = new ColorScaleData();
// We already added the default and missing values... replace them? // We already added the default and missing values... replace them?
@ -152,7 +166,7 @@ public abstract class ColorManager {
return entry.getValue().getColor_use_db_name(); return entry.getValue().getColor_use_db_name();
} else if (description.equals(entry.getValue() } else if (description.equals(entry.getValue()
.getColor_use_db_name())) { .getColor_use_db_name())) {
// if passing in the data type name then just return it // if passing in the data type name then just return it
return description; return description;
} }
} }
@ -201,10 +215,11 @@ public abstract class ColorManager {
rval = entry.getValue().getColor_use_display_string(); rval = entry.getValue().getColor_use_display_string();
break; break;
} }
} else if (dataType.equals(entry.getValue().getColor_use_display_string())) { } else if (dataType.equals(entry.getValue()
// if the display string is passed in just return it .getColor_use_display_string())) {
rval = dataType; // if the display string is passed in just return it
break; rval = dataType;
break;
} }
} }
@ -391,7 +406,7 @@ public abstract class ColorManager {
colorValue.setUserID((String) oa[0]); colorValue.setUserID((String) oa[0]);
colorValue.setApplicationName((String) oa[1]); colorValue.setApplicationName((String) oa[1]);
colorValue.setColorUseName((String) oa[2]); colorValue.setColorUseName((String) oa[2]);
colorValue.setDuration(((Integer) oa[3]) / 3600); colorValue.setDuration(((Number) oa[3]).intValue() / 3600);
colorValue.setThresholdValue((Double) oa[4]); colorValue.setThresholdValue((Double) oa[4]);
colorValue.setThresholdUnit((String) oa[5]); colorValue.setThresholdUnit((String) oa[5]);
colorValue.setColorName((String) oa[6]); colorValue.setColorName((String) oa[6]);

View file

@ -36,7 +36,7 @@ import com.raytheon.viz.hydrocommon.HydroConstants;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 02 Sep 2008 lvenable Initial creation. * 02 Sep 2008 lvenable Initial creation.
* 18 Nov 2008 dhladky Made Interactive. * 18 Nov 2008 dhladky Made Interactive.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author lvenable * @author lvenable
@ -82,7 +82,7 @@ public class CrestData implements Comparable<CrestData> {
/** /**
* Flag indicating if the data is record data or not. * Flag indicating if the data is record data or not.
*/ */
private boolean record = false; private final boolean record = false;
/** /**
* Indicator on how to sort the data. * Indicator on how to sort the data.
@ -104,7 +104,7 @@ public class CrestData implements Comparable<CrestData> {
setStage((Double) objects[0]); setStage((Double) objects[0]);
} }
if (objects[1] != null) { if (objects[1] != null) {
setFlow((Integer) objects[1]); setFlow(((Number) objects[1]).intValue());
} }
if (objects[2] != null) { if (objects[2] != null) {
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
@ -255,7 +255,7 @@ public class CrestData implements Comparable<CrestData> {
public String getDateString() { public String getDateString() {
DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
df.setTimeZone(TimeZone.getTimeZone("GMT")); df.setTimeZone(TimeZone.getTimeZone("GMT"));
return df.format(crestDate.getTime()); return df.format(crestDate.getTime());
} }
@ -271,7 +271,7 @@ public class CrestData implements Comparable<CrestData> {
DateFormat df = new SimpleDateFormat("HH:mm"); DateFormat df = new SimpleDateFormat("HH:mm");
df.setTimeZone(TimeZone.getTimeZone("GMT")); df.setTimeZone(TimeZone.getTimeZone("GMT"));
return df.format(crestDate.getTime()); return df.format(crestDate.getTime());
} }
@ -328,22 +328,25 @@ public class CrestData implements Comparable<CrestData> {
} }
if (stage == HydroConstants.MISSING_VALUE) { if (stage == HydroConstants.MISSING_VALUE) {
str = String.format("%10s %8s %10s %10s %-6s", HydroConstants.MISSING_STRING, flow, str = String.format("%10s %8s %10s %10s %-6s",
getDateString(), getTimeString(), crestType); HydroConstants.MISSING_STRING, flow, getDateString(),
} else if (flow == HydroConstants.MISSING_VALUE) { getTimeString(), crestType);
str = String.format(" %8.2f %8s %10s %10s %-6s", stage, HydroConstants.MISSING_STRING, } else if (flow == HydroConstants.MISSING_VALUE) {
getDateString(), getTimeString(), crestType); str = String.format(" %8.2f %8s %10s %10s %-6s", stage,
HydroConstants.MISSING_STRING, getDateString(),
getTimeString(), crestType);
} else { } else {
str = String.format(" %8.2f %8s %10s %10s %-6s", stage, flow, str = String.format(" %8.2f %8s %10s %10s %-6s", stage,
getDateString(), getTimeString(), crestType); flow, getDateString(), getTimeString(), crestType);
} }
return str; return str;
} }
/** /**
* Compare method used to determine what data type to sort on. * Compare method used to determine what data type to sort on.
*/ */
@Override
public int compareTo(CrestData obj) { public int compareTo(CrestData obj) {
CrestData otherObject = obj; CrestData otherObject = obj;

View file

@ -88,7 +88,7 @@ public class DataLimitData extends HydroDBData implements IHydroDBData {
public DataLimitData(Object[] data) { public DataLimitData(Object[] data) {
setPe((String) data[0]); setPe((String) data[0]);
// limitQuery.append("pe,"); // limitQuery.append("pe,");
setDur((Short) data[1]); setDur(((Number) data[1]).shortValue());
// limitQuery.append("dur,"); // limitQuery.append("dur,");
setMonthDayStart((String) data[2]); setMonthDayStart((String) data[2]);
// limitQuery.append("monthdaystart,"); // limitQuery.append("monthdaystart,");

View file

@ -36,7 +36,7 @@ import com.raytheon.viz.hydrocommon.util.QualityCodeUtil;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 28, 2008 1636 askripsky Initial creation * Oct 28, 2008 1636 askripsky Initial creation
* 11/5/2008 1662 grichard Added another constructor. * 11/5/2008 1662 grichard Added another constructor.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author askripsky * @author askripsky
@ -150,7 +150,7 @@ public class HydroData extends HydroDBData {
setLid((String) data[0]); setLid((String) data[0]);
setName((String) data[1]); setName((String) data[1]);
setPe((String) data[2]); setPe((String) data[2]);
setDur((Integer) data[3]); setDur(((Number) data[3]).intValue());
setTs((String) data[4]); setTs((String) data[4]);
setExtremum((String) data[5]); setExtremum((String) data[5]);
setValue(data[6]); setValue(data[6]);
@ -171,7 +171,7 @@ public class HydroData extends HydroDBData {
public HydroData(Object[] data, Object name) { public HydroData(Object[] data, Object name) {
setLid((String) data[0]); setLid((String) data[0]);
setPe((String) data[1]); setPe((String) data[1]);
setDur((Integer) data[2]); setDur(((Number) data[2]).intValue());
setTs((String) data[3]); setTs((String) data[3]);
setExtremum((String) data[4]); setExtremum((String) data[4]);
setValue(data[5]); setValue(data[5]);
@ -187,7 +187,7 @@ public class HydroData extends HydroDBData {
public HydroData(Object[] data, String table) { public HydroData(Object[] data, String table) {
setLid((String) data[0]); setLid((String) data[0]);
setPe((String) data[1]); setPe((String) data[1]);
setDur((Integer) data[2]); setDur(((Number) data[2]).intValue());
setTs((String) data[3]); setTs((String) data[3]);
setExtremum((String) data[4]); setExtremum((String) data[4]);
setObsTime((Date) data[5]); setObsTime((Date) data[5]);
@ -282,8 +282,8 @@ public class HydroData extends HydroDBData {
} }
public void setQualityCode(Object qualityCode) { public void setQualityCode(Object qualityCode) {
this.qualityCode = (qualityCode != null) ? (Integer) qualityCode this.qualityCode = (qualityCode != null) ? ((Number) qualityCode)
: HydroConstants.MISSING_VALUE; .intValue() : HydroConstants.MISSING_VALUE;
} }
public int getRevision() { public int getRevision() {
@ -291,7 +291,7 @@ public class HydroData extends HydroDBData {
} }
public void setRevision(Object revision) { public void setRevision(Object revision) {
this.revision = (revision != null) ? (Integer) revision : 0; this.revision = (revision != null) ? ((Number) revision).intValue() : 0;
} }
public String getProductID() { public String getProductID() {
@ -373,7 +373,8 @@ public class HydroData extends HydroDBData {
} }
/** /**
* @param previousValue the previousValue to set * @param previousValue
* the previousValue to set
*/ */
public void setPreviousValue(double previousValue) { public void setPreviousValue(double previousValue) {
this.previousValue = previousValue; this.previousValue = previousValue;

View file

@ -35,7 +35,7 @@ import com.raytheon.uf.common.dataquery.db.QueryResultRow;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 11, 2008 askripsky Initial creation * Nov 11, 2008 askripsky Initial creation
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author askripsky * @author askripsky
@ -75,7 +75,8 @@ public class LowWaterData {
/** /**
* Date format. * Date format.
*/ */
private SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); private final SimpleDateFormat dateFormat = new SimpleDateFormat(
"MM/dd/yyyy");
/** /**
* Constructor * Constructor
@ -136,7 +137,7 @@ public class LowWaterData {
} }
public void setFlow(Object q) { public void setFlow(Object q) {
flow = (q != null) ? (Integer) q : MISSING_VALUE; flow = (q != null) ? ((Number) q).intValue() : MISSING_VALUE;
} }
public String getRemark() { public String getRemark() {
@ -152,8 +153,8 @@ public class LowWaterData {
return String return String
.format("%-24s %-27s %-12s", .format("%-24s %-27s %-12s",
(stage != MISSING_VALUE_D) ? String.format("%8.2f", (stage != MISSING_VALUE_D) ? String.format("%8.2f",
stage) : "", (flow != MISSING_VALUE) ? String stage) : "",
.format("%8d", flow) : "", dateFormat (flow != MISSING_VALUE) ? String.format("%8d", flow)
.format(lwDate)); : "", dateFormat.format(lwDate));
} }
} }

View file

@ -32,7 +32,7 @@ import com.raytheon.viz.hydrocommon.HydroConstants;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 14, 2008 1697 askripsky Initial creation * Nov 14, 2008 1697 askripsky Initial creation
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author askripsky * @author askripsky
@ -112,7 +112,8 @@ public class LowWaterStatementData {
setUpperValue((Double) data.getColumn(dataMap.get("upper_value"))); setUpperValue((Double) data.getColumn(dataMap.get("upper_value")));
} }
setCriteriaRank((Integer) data.getColumn(dataMap.get("criteria_rank"))); setCriteriaRank(((Number) data.getColumn(dataMap.get("criteria_rank")))
.intValue());
if (data.getColumn(dataMap.get("statement")) != null) { if (data.getColumn(dataMap.get("statement")) != null) {
setStatement((String) data.getColumn(dataMap.get("statement"))); setStatement((String) data.getColumn(dataMap.get("statement")));

View file

@ -25,17 +25,17 @@ import java.util.Date;
* TODO Add Description * TODO Add Description
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 19, 2008 mpduff Initial creation * Nov 19, 2008 mpduff Initial creation
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author mpduff * @author mpduff
* @version 1.0 * @version 1.0
*/ */
public class Observation { public class Observation {
@ -68,12 +68,12 @@ public class Observation {
* Obstime * Obstime
*/ */
private Date obstime; private Date obstime;
/** /**
* Basistime * Basistime
*/ */
private Date basisTime; private Date basisTime;
/** /**
* Data value * Data value
*/ */
@ -98,29 +98,29 @@ public class Observation {
* Product ID * Product ID
*/ */
private String productId; private String productId;
public Observation() { public Observation() {
} }
public Observation(Object[] oa) { public Observation(Object[] oa) {
setLid((String)oa[0]); setLid((String) oa[0]);
setPe((String)oa[1]); setPe((String) oa[1]);
setDur((Integer)oa[2]); setDur(((Number) oa[2]).intValue());
setTs((String)oa[3]); setTs((String) oa[3]);
setExtremum((String)oa[4]); setExtremum((String) oa[4]);
setObstime((Date)oa[5]); setObstime((Date) oa[5]);
setValue((Double)oa[6]); setValue((Double) oa[6]);
if (oa[7] != null) { if (oa[7] != null) {
setShefQualCode((String)oa[7]); setShefQualCode((String) oa[7]);
} }
if (oa[8] != null) { if (oa[8] != null) {
setQualityCode((Integer)oa[8]); setQualityCode(((Number) oa[8]).intValue());
} }
if (oa[9] != null) { if (oa[9] != null) {
setRevision((Integer)oa[9]); setRevision(((Number) oa[9]).intValue());
} }
if (oa[10] != null) { if (oa[10] != null) {
setProductId((String)oa[10]); setProductId((String) oa[10]);
} }
} }
@ -132,7 +132,8 @@ public class Observation {
} }
/** /**
* @param lid the lid to set * @param lid
* the lid to set
*/ */
public void setLid(String lid) { public void setLid(String lid) {
this.lid = lid; this.lid = lid;
@ -146,7 +147,8 @@ public class Observation {
} }
/** /**
* @param pe the pe to set * @param pe
* the pe to set
*/ */
public void setPe(String pe) { public void setPe(String pe) {
this.pe = pe; this.pe = pe;
@ -160,7 +162,8 @@ public class Observation {
} }
/** /**
* @param dur the dur to set * @param dur
* the dur to set
*/ */
public void setDur(int dur) { public void setDur(int dur) {
this.dur = dur; this.dur = dur;
@ -174,7 +177,8 @@ public class Observation {
} }
/** /**
* @param ts the ts to set * @param ts
* the ts to set
*/ */
public void setTs(String ts) { public void setTs(String ts) {
this.ts = ts; this.ts = ts;
@ -188,7 +192,8 @@ public class Observation {
} }
/** /**
* @param extremum the extremum to set * @param extremum
* the extremum to set
*/ */
public void setExtremum(String extremum) { public void setExtremum(String extremum) {
this.extremum = extremum; this.extremum = extremum;
@ -202,7 +207,8 @@ public class Observation {
} }
/** /**
* @param obstime the obstime to set * @param obstime
* the obstime to set
*/ */
public void setObstime(Date obstime) { public void setObstime(Date obstime) {
this.obstime = obstime; this.obstime = obstime;
@ -216,7 +222,8 @@ public class Observation {
} }
/** /**
* @param value the value to set * @param value
* the value to set
*/ */
public void setValue(Double value) { public void setValue(Double value) {
this.value = value; this.value = value;
@ -230,7 +237,8 @@ public class Observation {
} }
/** /**
* @param shefQualCode the shefQualCode to set * @param shefQualCode
* the shefQualCode to set
*/ */
public void setShefQualCode(String shefQualCode) { public void setShefQualCode(String shefQualCode) {
this.shefQualCode = shefQualCode; this.shefQualCode = shefQualCode;
@ -244,7 +252,8 @@ public class Observation {
} }
/** /**
* @param qualityCode the qualityCode to set * @param qualityCode
* the qualityCode to set
*/ */
public void setQualityCode(Integer qualityCode) { public void setQualityCode(Integer qualityCode) {
this.qualityCode = qualityCode; this.qualityCode = qualityCode;
@ -258,7 +267,8 @@ public class Observation {
} }
/** /**
* @param revision the revision to set * @param revision
* the revision to set
*/ */
public void setRevision(int revision) { public void setRevision(int revision) {
this.revision = revision; this.revision = revision;
@ -272,12 +282,13 @@ public class Observation {
} }
/** /**
* @param productId the productId to set * @param productId
* the productId to set
*/ */
public void setProductId(String productId) { public void setProductId(String productId) {
this.productId = productId; this.productId = productId;
} }
/** /**
* @return the basisTime * @return the basisTime
*/ */
@ -286,7 +297,8 @@ public class Observation {
} }
/** /**
* @param basisTime the basisTime to set * @param basisTime
* the basisTime to set
*/ */
public void setBasisTime(Date basisTime) { public void setBasisTime(Date basisTime) {
this.basisTime = basisTime; this.basisTime = basisTime;
@ -306,7 +318,7 @@ public class Observation {
sb.append("Value = " + getValue() + "\n"); sb.append("Value = " + getValue() + "\n");
sb.append("Obstime = " + getObstime() + "\n"); sb.append("Obstime = " + getObstime() + "\n");
sb.append("Quality Code = " + getQualityCode() + "\n"); sb.append("Quality Code = " + getQualityCode() + "\n");
return sb.toString(); return sb.toString();
} }
} }

View file

@ -38,7 +38,7 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils;
* Dec 15, 2008 1787 askripsky Initial Creation * Dec 15, 2008 1787 askripsky Initial Creation
* Apr 18, 2013 1790 rferrel Cleanup method interfaces; * Apr 18, 2013 1790 rferrel Cleanup method interfaces;
* part of non-blocking dialogs. * part of non-blocking dialogs.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author askripsky * @author askripsky
@ -66,7 +66,7 @@ public class DataAdjustFactorDataManager {
manager = new DataAdjustFactorDataManager(); manager = new DataAdjustFactorDataManager();
} }
return (DataAdjustFactorDataManager) manager; return manager;
} }
/** /**
@ -87,8 +87,8 @@ public class DataAdjustFactorDataManager {
for (QueryResultRow currNet : data.getRows()) { for (QueryResultRow currNet : data.getRows()) {
String name = (String) currNet.getColumn(data.getColumnNames() String name = (String) currNet.getColumn(data.getColumnNames()
.get("name")); .get("name"));
int dur = (Integer) currNet.getColumn(data.getColumnNames() int dur = ((Number) currNet.getColumn(data.getColumnNames()
.get("dur")); .get("dur"))).intValue();
rval.add(String.format("%s (%s)", name, dur)); rval.add(String.format("%s (%s)", name, dur));
} }
} }
@ -156,7 +156,7 @@ public class DataAdjustFactorDataManager {
public List<DataAdjustFactorData> getAdjustFactorData(boolean forceLoad) public List<DataAdjustFactorData> getAdjustFactorData(boolean forceLoad)
throws VizException { throws VizException {
if (adjustFactorData == null || forceLoad) { if ((adjustFactorData == null) || forceLoad) {
adjustFactorData = HydroDBDataManager.getInstance().getData( adjustFactorData = HydroDBDataManager.getInstance().getData(
DataAdjustFactorData.class); DataAdjustFactorData.class);
} }

View file

@ -38,8 +38,7 @@ import com.raytheon.viz.hydrocommon.data.DataIngestFilterData;
* Dec 11, 2008 1787 askripsky Initial Creation * Dec 11, 2008 1787 askripsky Initial Creation
* Apr 18, 2013 1790 rferrel Code clean up with non-blocking dialogs. * Apr 18, 2013 1790 rferrel Code clean up with non-blocking dialogs.
* May 1, 2014 17096 xwei Updated the filter list SQL statement * May 1, 2014 17096 xwei Updated the filter list SQL statement
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
*
* </pre> * </pre>
* *
* @author askripsky * @author askripsky
@ -84,8 +83,8 @@ public class DataIngestFilterDataManager {
for (QueryResultRow currNet : data.getRows()) { for (QueryResultRow currNet : data.getRows()) {
String name = (String) currNet.getColumn(data.getColumnNames() String name = (String) currNet.getColumn(data.getColumnNames()
.get("name")); .get("name"));
int dur = (Integer) currNet.getColumn(data.getColumnNames() int dur = ((Number) currNet.getColumn(data.getColumnNames()
.get("dur")); .get("dur"))).intValue();
rval.add(String.format("%s (%s)", name, dur)); rval.add(String.format("%s (%s)", name, dur));
} }
} }
@ -222,7 +221,7 @@ public class DataIngestFilterDataManager {
StringBuffer whereClause = new StringBuffer(); StringBuffer whereClause = new StringBuffer();
if (filterByLocation) { if (filterByLocation) {
whereClause.append( "lid='" + selectedLocation + "'" ); whereClause.append("lid='" + selectedLocation + "'");
} }
if (filterByPE && (selectedPE.size() > 0)) { if (filterByPE && (selectedPE.size() > 0)) {

View file

@ -36,10 +36,10 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 8, 2008 1697 askripsky Initial Creation * Dec 8, 2008 1697 askripsky Initial Creation
* Apr 18,2013 1790 rferrel Cleanup method interfaces; * Apr 18,2013 1790 rferrel Cleanup method interfaces;
* part of non-blocking dialogs. * part of non-blocking dialogs.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author askripsky * @author askripsky
@ -73,7 +73,7 @@ public class QcAlertAlarmLimitsDataManager {
manager = new QcAlertAlarmLimitsDataManager(); manager = new QcAlertAlarmLimitsDataManager();
} }
return (QcAlertAlarmLimitsDataManager) manager; return manager;
} }
/** /**
@ -94,8 +94,8 @@ public class QcAlertAlarmLimitsDataManager {
for (QueryResultRow currNet : data.getRows()) { for (QueryResultRow currNet : data.getRows()) {
String name = (String) currNet.getColumn(data.getColumnNames() String name = (String) currNet.getColumn(data.getColumnNames()
.get("name")); .get("name"));
int dur = (Integer) currNet.getColumn(data.getColumnNames() int dur = ((Number) currNet.getColumn(data.getColumnNames()
.get("dur")); .get("dur"))).intValue();
rval.add(String.format("%s (%s)", name, dur)); rval.add(String.format("%s (%s)", name, dur));
} }
} }
@ -110,7 +110,7 @@ public class QcAlertAlarmLimitsDataManager {
public List<DataLimitData> getDefaultLimits(boolean filterByPE, public List<DataLimitData> getDefaultLimits(boolean filterByPE,
List<String> selectedPE, boolean forceLoad) throws VizException { List<String> selectedPE, boolean forceLoad) throws VizException {
if (defaultData == null || forceLoad) { if ((defaultData == null) || forceLoad) {
defaultData = HydroDBDataManager.getInstance().getData( defaultData = HydroDBDataManager.getInstance().getData(
DataLimitData.class); DataLimitData.class);
} }
@ -198,7 +198,7 @@ public class QcAlertAlarmLimitsDataManager {
public List<LocationDataLimitData> getLocationLimits(boolean filterByLID, public List<LocationDataLimitData> getLocationLimits(boolean filterByLID,
String lidFilter, boolean filterByPE, List<String> selectedPE, String lidFilter, boolean filterByPE, List<String> selectedPE,
boolean forceLoad) throws VizException { boolean forceLoad) throws VizException {
if (locationData == null || forceLoad) { if ((locationData == null) || forceLoad) {
locationData = HydroDBDataManager.getInstance().getData( locationData = HydroDBDataManager.getInstance().getData(
LocationDataLimitData.class); LocationDataLimitData.class);
} }

View file

@ -42,14 +42,14 @@ import com.raytheon.viz.hydrocommon.datamanager.HydroDataManager;
* 24 Nov 2008 1682 dhladky Made interactive. * 24 Nov 2008 1682 dhladky Made interactive.
* 15 Dec 2009 2422 mpduff Added query for rating date and * 15 Dec 2009 2422 mpduff Added query for rating date and
* USGS rating number. * USGS rating number.
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @version 1.0 * @version 1.0
*/ */
public class RatingCurveDataManager extends HydroDataManager { public class RatingCurveDataManager extends HydroDataManager {
private SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); private final SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
public RatingCurveDataManager() { public RatingCurveDataManager() {
sdf.setTimeZone(TimeZone.getTimeZone("GMT")); sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
@ -191,18 +191,21 @@ public class RatingCurveDataManager extends HydroDataManager {
public void insertRatingCurveShift(RatingCurveShiftData rcsd) { public void insertRatingCurveShift(RatingCurveShiftData rcsd) {
if (rcsd.getLid() != null) { if (rcsd.getLid() != null) {
// Check to see if we need to update or insert // Check to see if we need to update or insert
ArrayList<RatingCurveShiftData> dataList = getRatingCurveShift(rcsd.getLid()); ArrayList<RatingCurveShiftData> dataList = getRatingCurveShift(rcsd
.getLid());
boolean doUpdate = false; boolean doUpdate = false;
if (dataList.size() > 0) { if (dataList.size() > 0) {
for (RatingCurveShiftData data: dataList) { for (RatingCurveShiftData data : dataList) {
// if a pk match, then need to update // if a pk match, then need to update
if (data.getLid().equals(rcsd.getLid()) && data.getDate().getTime().equals(rcsd.getDate().getTime())) { if (data.getLid().equals(rcsd.getLid())
&& data.getDate().getTime()
.equals(rcsd.getDate().getTime())) {
doUpdate = true; doUpdate = true;
break; break;
} }
} }
} }
String lid = rcsd.getLid(); String lid = rcsd.getLid();
double value = rcsd.getValue(); double value = rcsd.getValue();
String date = rcsd.getDateString(); String date = rcsd.getDateString();
@ -216,13 +219,21 @@ public class RatingCurveDataManager extends HydroDataManager {
String query = null; String query = null;
if (doUpdate) { if (doUpdate) {
// do an update // do an update
query = "update ratingShift set shift_amount = " + value + ", active = '" + active + "' " query = "update ratingShift set shift_amount = " + value
+ " where lid = '" + lid + "' and date = '" + date + "'"; + ", active = '" + active + "' " + " where lid = '"
+ lid + "' and date = '" + date + "'";
} else { } else {
query = "INSERT INTO ratingshift (lid, date, shift_amount, active) VALUES ('" query = "INSERT INTO ratingshift (lid, date, shift_amount, active) VALUES ('"
+ lid + "', '" + date + "', " + value + ", '" + active + "')"; + lid
+ "', '"
+ date
+ "', "
+ value
+ ", '"
+ active
+ "')";
} }
try { try {
DirectDbQuery.executeStatement(query, HydroConstants.IHFS, DirectDbQuery.executeStatement(query, HydroConstants.IHFS,
QueryLanguage.SQL); QueryLanguage.SQL);
@ -261,37 +272,38 @@ public class RatingCurveDataManager extends HydroDataManager {
public void insertRatingCurveData(RatingCurveData rcd, String lid) { public void insertRatingCurveData(RatingCurveData rcd, String lid) {
if (lid != null) { if (lid != null) {
// Check for update or insert // Check for update or insert
String countQuery = "select count(*) from rating where lid = '" + lid + "'" String countQuery = "select count(*) from rating where lid = '"
+ " and stage = " + rcd.getStage(); + lid + "'" + " and stage = " + rcd.getStage();
try { try {
List<Object[]> rs = DirectDbQuery.executeQuery(countQuery, HydroConstants.IHFS, QueryLanguage.SQL); List<Object[]> rs = DirectDbQuery.executeQuery(countQuery,
HydroConstants.IHFS, QueryLanguage.SQL);
if ((rs != null) && (rs.size() > 0)) { if ((rs != null) && (rs.size() > 0)) {
Object[] oa = rs.get(0); Object[] oa = rs.get(0);
if ((oa != null) && (oa.length > 0)) { if ((oa != null) && (oa.length > 0)) {
long count = (Long) oa[0]; long count = ((Number) oa[0]).longValue();
if (count > 0) { if (count > 0) {
// need to delete, then insert // need to delete, then insert
String query = "delete from rating where lid = '" + lid + "' and stage = " + rcd.getStage(); String query = "delete from rating where lid = '"
DirectDbQuery.executeStatement(query, HydroConstants.IHFS, + lid + "' and stage = " + rcd.getStage();
QueryLanguage.SQL); DirectDbQuery.executeStatement(query,
HydroConstants.IHFS, QueryLanguage.SQL);
} }
// need to do an insert // need to do an insert
String query = "INSERT INTO rating (lid, stage, discharge) VALUES ('" String query = "INSERT INTO rating (lid, stage, discharge) VALUES ('"
+ lid + lid
+ "', " + "', "
+ rcd.getStage() + rcd.getStage()
+ ", " + ", "
+ rcd.getDischarge() + rcd.getDischarge() + ")";
+ ")"; DirectDbQuery.executeStatement(query,
DirectDbQuery.executeStatement(query, HydroConstants.IHFS, HydroConstants.IHFS, QueryLanguage.SQL);
QueryLanguage.SQL);
} else { } else {
throw new Exception("Error accessing Hydor Database"); throw new Exception("Error accessing Hydor Database");
} }
} else { } else {
throw new Exception("Error accessing Hydor Database"); throw new Exception("Error accessing Hydor Database");
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -42,9 +42,9 @@ import com.raytheon.viz.hydrocommon.whfslib.IHFSDbGenerated;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 10, 2008 randerso Initial creation * Nov 10, 2008 randerso Initial creation
* May 27, 2014 3133 njensen Organized imports, fixed == to equals * May 27, 2014 3133 njensen Organized imports, fixed == to equals
* * Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre> * </pre>
* *
* @author randerso * @author randerso
@ -158,7 +158,7 @@ public class GetColorValues {
statusHandler.handle(Priority.PROBLEM, "ERROR in " + method statusHandler.handle(Priority.PROBLEM, "ERROR in " + method
+ " Colors/levels not defined for application " + " Colors/levels not defined for application "
+ application_name + " use_name = " + coloruse_name + application_name + " use_name = " + coloruse_name
+ " user_id = " + user_id); + " user_id = " + user_id);
} }
} }
} }
@ -198,8 +198,8 @@ public class GetColorValues {
application_name, coloruse_name, duration, threshold_unit); application_name, coloruse_name, duration, threshold_unit);
// does the closest one match? // does the closest one match?
if (closest_duration != NO_DURATION_FOUND if ((closest_duration != NO_DURATION_FOUND)
&& duration == closest_duration) { && (duration == closest_duration)) {
cvHead = getColorValueTableEntries(user_id, application_name, cvHead = getColorValueTableEntries(user_id, application_name,
coloruse_name, closest_duration, threshold_unit); coloruse_name, closest_duration, threshold_unit);
} }
@ -347,7 +347,7 @@ public class GetColorValues {
if ((results != null) && (results.size() > 0)) { if ((results != null) && (results.size() > 0)) {
for (Object[] item : results) { for (Object[] item : results) {
duration_value = (Integer) item[0]; duration_value = ((Number) item[0]).intValue();
duration_diff = Math.abs(duration - duration_value); duration_diff = Math.abs(duration - duration_value);
// Is this duration the closest to the original duration // Is this duration the closest to the original duration

View file

@ -59,7 +59,7 @@
</property> </property>
<property <property
name="windowImages" name="windowImages"
value="icons/cave_16x16.gif,icons/cave_32x32.gif"> value="platform:/plugin/com.raytheon.viz.ui.personalities.awips/cave_16x16.png,platform:/plugin/com.raytheon.viz.ui.personalities.awips/cave_32x32.png,platform:/plugin/com.raytheon.viz.ui.personalities.awips/cave_48x48.png,platform:/plugin/com.raytheon.viz.ui.personalities.awips/cave_64x64.png,platform:/plugin/com.raytheon.viz.ui.personalities.awips/cave_128x128.png">
</property> </property>
</product> </product>
</extension> </extension>