Merge branch 'omaha_16.1.1' into omaha_16.2.1

Former-commit-id: b7c8b89efdfc63fb24117a985723e7a09c900eeb
This commit is contained in:
Steve Harris 2015-07-22 07:51:43 -05:00
commit b36e10b33e
34 changed files with 1870 additions and 1717 deletions

View file

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -51,7 +50,6 @@ import com.raytheon.uf.common.dataquery.db.QueryResult;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.util.WorldWrapCorrector;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.Pair;
import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
@ -150,15 +148,12 @@ public class ZoneSelectorResource extends DbMapResource {
String query;
List<String> columns;
Request(IGraphicsTarget target, IMapDescriptor descriptor,
ZoneSelectorResource rsc, String query, List<String> columns) {
ZoneSelectorResource rsc, String query) {
this.target = target;
this.descriptor = descriptor;
this.rsc = rsc;
this.query = query;
this.columns = columns;
}
}
@ -196,12 +191,11 @@ public class ZoneSelectorResource extends DbMapResource {
}
public void request(IGraphicsTarget target, IMapDescriptor descriptor,
ZoneSelectorResource rsc, String query, List<String> columns) {
ZoneSelectorResource rsc, String query) {
if (requestQueue.size() == QUEUE_LIMIT) {
requestQueue.poll();
}
requestQueue.add(new Request(target, descriptor, rsc, query,
columns));
requestQueue.add(new Request(target, descriptor, rsc, query));
this.cancel();
this.schedule();
@ -229,10 +223,6 @@ public class ZoneSelectorResource extends DbMapResource {
QueryResult mappedResult = DirectDbQuery
.executeMappedQuery(req.query, "maps",
QueryLanguage.SQL);
int index = 0;
for (String column : req.columns) {
mappedResult.addColumnName(column, index++);
}
// long t1 = System.currentTimeMillis();
// System.out.println("Maps DB query took: " + (t1 - t0)
@ -727,10 +717,8 @@ public class ZoneSelectorResource extends DbMapResource {
clipToProjExtent(screenExtent).getEnvelope())) {
if (!paintProps.isZooming()) {
PixelExtent clippedExtent = clipToProjExtent(screenExtent);
Pair<String, List<String>> queryPair = buildQuery(
clippedExtent, simpLev);
queryJob.request(aTarget, descriptor, this,
queryPair.getFirst(), queryPair.getSecond());
String query = buildQuery(clippedExtent, simpLev);
queryJob.request(aTarget, descriptor, this, query);
lastExtent = clippedExtent;
lastSimpLev = simpLev;
}
@ -841,8 +829,7 @@ public class ZoneSelectorResource extends DbMapResource {
}
}
protected Pair<String, List<String>> buildQuery(PixelExtent extent,
double simpLev) {
protected String buildQuery(PixelExtent extent, double simpLev) {
DecimalFormat df = new DecimalFormat("0.######");
String suffix = "_"
@ -851,19 +838,16 @@ public class ZoneSelectorResource extends DbMapResource {
String geometryField = resourceData.getGeomField() + suffix;
// get the geometry field
List<String> columns = new LinkedList<>();
StringBuilder query = new StringBuilder("SELECT AsBinary(");
query.append(geometryField);
query.append(") as ");
query.append(geometryField);
columns.add(geometryField);
// add any additional columns
if (resourceData.getColumns() != null) {
for (ColumnDefinition column : resourceData.getColumns()) {
query.append(", ");
query.append(column);
columns.add(column.toString());
}
}
@ -880,7 +864,7 @@ public class ZoneSelectorResource extends DbMapResource {
query.append(';');
return new Pair<>(query.toString(), columns);
return query.toString();
}
/**

View file

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

View file

@ -23,108 +23,131 @@ package com.raytheon.viz.hydro.pointdatacontrol.data;
* TODO Add Description
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* 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>
*
*
* @author mpduff
* @version 1.0
* @version 1.0
*/
public class IngestFilter {
private String lid = null;
private String pe = null;
private int dur;
private String ts = null;
private String extremum = null;
private int tsRank;
public IngestFilter() {
}
public IngestFilter(Object[] data) {
int i = 0;
setLid((String)data[i++]) ;
setPe((String)data[i++]);
setDur((Integer)data[i++]);
setTs((String)data[i++]);
setExtremum((String)data[i++]);
setTsRank((Integer)data[i++]);
setLid((String) data[i++]);
setPe((String) data[i++]);
setDur(((Number) data[i++]).intValue());
setTs((String) data[i++]);
setExtremum((String) data[i++]);
setTsRank(((Number) data[i++]).intValue());
}
/**
* @return the lid
*/
public String getLid() {
return lid;
}
/**
* @param lid the lid to set
* @param lid
* the lid to set
*/
public void setLid(String lid) {
this.lid = lid;
}
/**
* @return the pe
*/
public String getPe() {
return pe;
}
/**
* @param pe the pe to set
* @param pe
* the pe to set
*/
public void setPe(String pe) {
this.pe = pe;
}
/**
* @return the dur
*/
public int getDur() {
return dur;
}
/**
* @param dur the dur to set
* @param dur
* the dur to set
*/
public void setDur(int dur) {
this.dur = dur;
}
/**
* @return the ts
*/
public String getTs() {
return ts;
}
/**
* @param ts the ts to set
* @param ts
* the ts to set
*/
public void setTs(String ts) {
this.ts = ts;
}
/**
* @return the extremum
*/
public String getExtremum() {
return extremum;
}
/**
* @param extremum the extremum to set
* @param extremum
* the extremum to set
*/
public void setExtremum(String extremum) {
this.extremum = extremum;
}
/**
* @return the tsRank
*/
public int getTsRank() {
return tsRank;
}
/**
* @param tsRank the tsRank to set
* @param tsRank
* the tsRank to set
*/
public void setTsRank(int tsRank) {
this.tsRank = tsRank;

View file

@ -26,7 +26,8 @@ package com.raytheon.viz.hydro.pointdatacontrol.data;
* SOFTWARE HISTORY
* 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>
*
* @author mpduff
@ -97,76 +98,76 @@ public class LocPDC {
* Telemetry Type.
*/
private String telemType = null;
public LocPDC() {
}
public LocPDC(Object[] data) {
int i = 0;
if (data[i] != null) { // LID
setLid((String)data[i]);
if (data[i] != null) { // LID
setLid((String) data[i]);
}
if (data[++i] != null) { // name
setName((String)data[i]);
if (data[++i] != null) { // name
setName((String) data[i]);
}
if (data[++i] != null) { // lat
setLat((Double)data[i]);
if (data[++i] != null) { // lat
setLat((Double) data[i]);
}
if (data[++i] != null) { // lon
setLon((Double)data[i]);
if (data[++i] != null) { // lon
setLon((Double) data[i]);
}
if (data[++i] != null) { // hsa
setHsa((String)data[i]);
if (data[++i] != null) { // hsa
setHsa((String) data[i]);
}
if (data[++i] != null) { // post
setPost((Integer)data[i]);
if (data[++i] != null) { // post
setPost(((Number) data[i]).intValue());
}
if (data[++i] != null) { // elev
setElev((Double)data[i]);
if (data[++i] != null) { // elev
setElev((Double) data[i]);
}
if (data[++i] != null) { // primary_pe
setPrimaryPe((String)data[i]);
if (data[++i] != null) { // primary_pe
setPrimaryPe((String) data[i]);
}
if (data[++i] != null) { // fs
setFs((Double)data[i]);
if (data[++i] != null) { // fs
setFs((Double) data[i]);
}
if (data[++i] != null) { // fq
setFq((Double)data[i]);
if (data[++i] != null) { // fq
setFq((Double) data[i]);
}
// disp_class, is_dcp, is_observer, telem_type
if (data[++i] != null) { // disp_class
setDispClass((String)data[i]);
// disp_class, is_dcp, is_observer, telem_type
if (data[++i] != null) { // disp_class
setDispClass((String) data[i]);
}
if (data[++i] != null) {
if (((String)data[i]).equalsIgnoreCase("F")) {
if (((String) data[i]).equalsIgnoreCase("F")) {
setDcp(false);
} else {
setDcp(true);
}
}
if (data[++i] != null) {
if (((String)data[i]).equalsIgnoreCase("F")) {
if (((String) data[i]).equalsIgnoreCase("F")) {
setObserver(false);
} else {
setObserver(true);
}
}
if (data[++i] != null) { // Telem_type
setTelemType((String)data[i]);
if (data[++i] != null) { // Telem_type
setTelemType((String) data[i]);
}
}

View file

@ -62,15 +62,17 @@ import com.raytheon.viz.hydrocommon.whfslib.PrecipUtil;
* SOFTWARE HISTORY
* 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>
*
* @author mpduff
* @version 1.0
*/
public class PDCDataManager extends HydroDataManager {
private static PDCDataManager instance = null;
private static Map<String, String> peMap = null;
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, RiverStat> riverStatMap = null;
/**
* Private constructor.
*/
private PDCDataManager() {
}
public static synchronized PDCDataManager getInstance() {
if (instance == null) {
instance = new PDCDataManager();
}
return instance;
}
@ -109,17 +111,18 @@ public class PDCDataManager extends HydroDataManager {
}
return result;
}
public String[] getIngestFilterPE() throws VizException {
ArrayList<String> peList = new ArrayList<String>();
String query = "select distinct(pe) from ingestfilter";
List<Object[]> rs = DirectDbQuery.executeQuery(query, HydroConstants.IHFS, QueryLanguage.SQL);
for (Object[] oa: rs) {
peList.add((String)oa[0]);
List<Object[]> rs = DirectDbQuery.executeQuery(query,
HydroConstants.IHFS, QueryLanguage.SQL);
for (Object[] oa : rs) {
peList.add((String) oa[0]);
}
return peList.toArray(new String[peList.size()]);
}
@ -153,7 +156,7 @@ public class PDCDataManager extends HydroDataManager {
PointDataPreset pdp = new PointDataPreset();
pdp.setPresetId((String) oa[0]);
pdp.setDescription((String) oa[1]);
pdp.setPresetRank((Integer) oa[2]);
pdp.setPresetRank(((Number) oa[2]).intValue());
pdp.setPresetString((String) oa[3]);
presetList.add(pdp);
}
@ -203,9 +206,7 @@ public class PDCDataManager extends HydroDataManager {
"insert into pointdatapresets (preset_id, descr, preset_rank, preset_string) ");
sql.append("values ('" + node.getPresetId() + "', '"
+ node.getDescription() + "', ");
sql
.append(node.getPresetRank() + ", '" + node.getPresetString()
+ "')");
sql.append(node.getPresetRank() + ", '" + node.getPresetString() + "')");
runStatement(sql.toString());
}
@ -355,7 +356,7 @@ public class PDCDataManager extends HydroDataManager {
for (Object[] oa : results) {
lid = (String) oa[0];
if (!lid.equalsIgnoreCase(prevLid)) {
ingestFilterMap.put(prevLid, filterList);
ingestFilterMap.put(prevLid, filterList);
prevLid = lid;
filterList = new ArrayList<IngestFilter>();
}
@ -417,7 +418,8 @@ public class PDCDataManager extends HydroDataManager {
* observed or forecast, or can be any designated type-source.
*/
public void getRiverData(PDCOptions pcOptions) {
PointDataControlManager pdcManager = PointDataControlManager.getInstance();
PointDataControlManager pdcManager = PointDataControlManager
.getInstance();
String where = null;
/*
@ -514,7 +516,8 @@ public class PDCDataManager extends HydroDataManager {
* Get the PC and/or PP rain data.
*/
public void getRainData() {
PointDataControlManager pdcManager = PointDataControlManager.getInstance();
PointDataControlManager pdcManager = PointDataControlManager
.getInstance();
PDCOptionData pcOptions = PDCOptionData.getInstance();
PrecipUtil precipUtil = PrecipUtil.getInstance();
List<String> typeSourceArray = null;
@ -524,7 +527,7 @@ public class PDCDataManager extends HydroDataManager {
ArrayList<Object[]> ppList = null;
ArrayList<Curpc> pcObjectList = new ArrayList<Curpc>();
ArrayList<Curpp> ppObjectList = new ArrayList<Curpp>();
/* Empty out the data lists */
pdcManager.setPpList(null);
pdcManager.setPcList(null);
@ -573,7 +576,7 @@ public class PDCDataManager extends HydroDataManager {
typeSourceArray, HydroConstants.PhysicalElement.PP);
}
}
/* Save the data to the PointDataControlManager */
if (pcList != null) {
/*
@ -591,11 +594,11 @@ public class PDCDataManager extends HydroDataManager {
id.setExtremum((String) oa[4]);
id.setObstime((Date) oa[12]);
pc.setPe((String) oa[1]);
pc.setDur(((Integer)oa[2]).shortValue());
pc.setDur(((Number) oa[2]).shortValue());
pc.setValue((Double) oa[5]);
pc.setShefQualCode((String) oa[6]);
pc.setQualityCode((Integer) oa[7]);
pc.setRevision(((Integer)(oa[8])).shortValue());
pc.setQualityCode(((Number) oa[7]).intValue());
pc.setRevision(((Number) (oa[8])).shortValue());
pc.setProductId((String) oa[9]);
pc.setProducttime((Date) oa[10]);
pc.setPostingtime((Date) oa[11]);
@ -619,15 +622,15 @@ public class PDCDataManager extends HydroDataManager {
Curpp pp = new Curpp();
CurppId id = new CurppId();
id.setLid((String) oa[0]);
id.setDur(((Integer) oa[2]).shortValue());
id.setDur(((Number) oa[2]).shortValue());
id.setTs((String) oa[3]);
id.setExtremum((String) oa[4]);
id.setObstime((Date) oa[12]);
pp.setPe((String) oa[1]);
pp.setValue((Double) oa[5]);
pp.setShefQualCode((String) oa[6]);
pp.setQualityCode((Integer) oa[7]);
pp.setRevision(((Integer) oa[8]).shortValue());
pp.setQualityCode(((Number) oa[7]).intValue());
pp.setRevision(((Number) oa[8]).shortValue());
pp.setProductId((String) oa[9]);
pp.setProducttime((Date) oa[10]);
pp.setPostingtime((Date) oa[11]);
@ -640,7 +643,8 @@ public class PDCDataManager extends HydroDataManager {
}
public void getSnowTempOtherData() {
PointDataControlManager pdcManager = PointDataControlManager.getInstance();
PointDataControlManager pdcManager = PointDataControlManager
.getInstance();
PDCOptionData pcOptions = PDCOptionData.getInstance();
String typeSource = null;
String tablename = null;
@ -684,8 +688,8 @@ public class PDCDataManager extends HydroDataManager {
typeSource = pcOptions.getTypeSourceChosenList().get(0);
tablename = DbUtils.getTableName(pcOptions
.getSelectedAdHocElementString(), typeSource);
tablename = DbUtils.getTableName(
pcOptions.getSelectedAdHocElementString(), typeSource);
obsResult = getObservationData(tablename, where);
}
@ -700,13 +704,13 @@ public class PDCDataManager extends HydroDataManager {
}
for (Object[] oa : obsResult) {
// if (oa.length == 11) {
// Observation obs = new Observation(oa);
// obsList.add(obs);
// } else {
Observation obs = new Observation(oa);
obsList.add(obs);
// }
// if (oa.length == 11) {
// Observation obs = new Observation(oa);
// obsList.add(obs);
// } else {
Observation obs = new Observation(oa);
obsList.add(obs);
// }
}
pdcManager.setObservationList(obsList);
@ -758,8 +762,7 @@ public class PDCDataManager extends HydroDataManager {
Map<String, LocPDC> returnMap = new HashMap<String, LocPDC>();
StringBuilder sql = new StringBuilder();
sql
.append("Select lid, name, lat, lon, hsa, post, elev, primary_pe, fs, fq, ");
sql.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");
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
* save to tokenized directory
* 03/14/2013 1790 rferrel Changes for non-blocking dialog.
*
*
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre>
*
* @author lvenable
@ -180,7 +179,7 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
/**
* Selected Durations.
*/
private int[] selectedDurations = new int[durationValues.length];
private final int[] selectedDurations = new int[durationValues.length];
/**
* Durations.
@ -250,7 +249,7 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
/**
* 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.
@ -544,13 +543,13 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
// durList has the pa_options.duration_set of values (indirectly)
durList = new List(durComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
durList.setLayoutData(gd);
durList.add(((Integer) durationValues[0]).toString() + " Hour");
durList.add(((Integer) durationValues[1]).toString() + " Hour");
durList.add(((Integer) durationValues[2]).toString() + " Hour");
durList.add(((Integer) durationValues[3]).toString() + " Hour");
durList.add(((Integer) durationValues[4]).toString() + " Hour");
durList.add(((Integer) durationValues[5]).toString() + " Hour");
durList.add(((Integer) durationValues[6]).toString() + " Hour");
durList.add(((Number) durationValues[0]).toString() + " Hour");
durList.add(((Number) durationValues[1]).toString() + " Hour");
durList.add(((Number) durationValues[2]).toString() + " Hour");
durList.add(((Number) durationValues[3]).toString() + " Hour");
durList.add(((Number) durationValues[4]).toString() + " Hour");
durList.add(((Number) durationValues[5]).toString() + " Hour");
durList.add(((Number) durationValues[6]).toString() + " Hour");
durList.add("Other");
durList.setFont(font);
durList.setSelection(4);
@ -980,8 +979,8 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
// Determine the length (i.e., NUMDURATIONS) of the new durations array
int NUMDURATIONS = 0;
for (int i = 0; i < selectedDurations.length; i++) {
if (selectedDurations[i] == 9999) {
for (int selectedDuration : selectedDurations) {
if (selectedDuration == 9999) {
break;
} else {
NUMDURATIONS++;
@ -1263,9 +1262,9 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
int index = hdr.indexOf("<duration>");
index += 10;
for (int i = 0; i < durations.length; i++) {
hdr.insert(index, durations[i]);
index += Integer.toString(durations[i]).length();
for (int duration : durations) {
hdr.insert(index, duration);
index += Integer.toString(duration).length();
hdr.insert(index, ",");
index++;
hdr.insert(index, " ");
@ -1298,13 +1297,13 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
hdr.append("\n");
hdr.append(String.format(FMT_DUR_HD_TR, "Location", "Name", "PE", "TS"));
for (int i = 0; i < durations.length; i++) {
hdr.append(String.format(FMT_DUR, durations[i], "hr"));
for (int duration : durations) {
hdr.append(String.format(FMT_DUR, duration, "hr"));
}
hdr.append("\n");
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, "===", "=="));
}
@ -1675,11 +1674,11 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
Point dpi = printer.getDPI();
leftMargin = dpi.x + trim.x; // one inch from left 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
topMargin = dpi.y + trim.y;
// 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. */
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();
}
}
@ -1769,7 +1768,7 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
if (wordBuffer.length() > 0) {
String word = wordBuffer.toString();
int wordWidth = gc.stringExtent(word).x;
if (x + wordWidth > rightMargin) {
if ((x + wordWidth) > rightMargin) {
/* word doesn't fit on current line, so wrap */
newline();
}
@ -1785,9 +1784,9 @@ public class PointPrecipAccumDlg extends CaveSWTDialog {
private void newline() {
x = leftMargin;
y += lineHeight;
if (y + lineHeight > bottomMargin) {
if ((y + lineHeight) > bottomMargin) {
printer.endPage();
if (index + 1 < end) {
if ((index + 1) < end) {
y = topMargin;
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.datamanager.HydroDataManager;
/**
* Class for managing database query calls. PointPrecipDataManager.java
*
@ -47,8 +46,8 @@ import com.raytheon.viz.hydrocommon.datamanager.HydroDataManager;
* 03Sept2008 #1509 dhladky Initial Creation.
* 31Aug2009 #2257 mpduff Adding data access methods.
* 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>
*
* @author dhladky
@ -57,24 +56,24 @@ import com.raytheon.viz.hydrocommon.datamanager.HydroDataManager;
public class PointPrecipDataManager extends HydroDataManager {
private static final String QUERY = "select lid,obstime,lid from latestobsvalue";
private static int adjustedPCStartTime = HydroConstants.MISSING_VALUE;
private static PointPrecipDataManager instance = null;
/** Private constructor */
private PointPrecipDataManager() {
}
public static synchronized PointPrecipDataManager getInstance() {
if (instance == null) {
instance = new PointPrecipDataManager();
}
return instance;
}
/**
* Get tabularDisplayData from the DB
*
@ -85,11 +84,11 @@ public class PointPrecipDataManager extends HydroDataManager {
ArrayList<Object[]> data;
data = runQuery(QUERY);
if (data != null) {
return data.get(0);
}
return null;
}
@ -103,7 +102,7 @@ public class PointPrecipDataManager extends HydroDataManager {
"select distinct locclass.hsa from locclass order by locclass.hsa asc");
ArrayList<Object[]> hsaData;
List<String> items = new ArrayList<String>();
// ---------------------------------------------------------
// 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()]);
}
// ---------------------------------------------------------------
// Query 'ingestfilter' table in ihfs database for selected fields
// 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");
ArrayList<Object[]> PCData;
List<String> items = new ArrayList<String>();
// ------------------------------------------------------------
// Query the IngestFilter Table in the IHFS database using SQL.
// ------------------------------------------------------------
@ -134,10 +132,10 @@ public class PointPrecipDataManager extends HydroDataManager {
for (Object[] rowData : PCData) {
items.add((String) rowData[0]);
}
return items.toArray(new String[items.size()]);
}
// ---------------------------------------------------------------
// Query 'ingestfilter' table in ihfs database for selected fields
// using SQL.
@ -155,7 +153,7 @@ public class PointPrecipDataManager extends HydroDataManager {
for (Object[] rowData : PPData) {
items.add((String) rowData[0]);
}
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
// using SQL.
// ---------------------------------------------------------------
public ArrayList<Curpc> queryCurPc(Date queryBeginTime,
Date queryEndTime, String lid, List<String> pTs) {
public ArrayList<Curpc> queryCurPc(Date queryBeginTime, Date queryEndTime,
String lid, List<String> pTs) {
ArrayList<Object[]> pcData;
String tsClause = null;
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
* periods, retrieve more wider data for gages, use token
* adjust_PC_startingtime to specify the PC data retrieval starting point
* periods, retrieve more wider data for gages, use token
* adjust_PC_startingtime to specify the PC data retrieval starting
* point
*/
if (adjustedPCStartTime == HydroConstants.MISSING_VALUE) {
AppsDefaults ad = AppsDefaults.getInstance();
String tokenString = ad.getToken("adjust_PC_startingtime");
if ((tokenString != null) && (tokenString.length() > 0)) {
adjustedPCStartTime = Integer.parseInt(tokenString);
if (adjustedPCStartTime < 0) {
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
}
}
AppsDefaults ad = AppsDefaults.getInstance();
String tokenString = ad.getToken("adjust_PC_startingtime");
if ((tokenString != null) && (tokenString.length() > 0)) {
adjustedPCStartTime = Integer.parseInt(tokenString);
if (adjustedPCStartTime < 0) {
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
}
}
} else {
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
}
// Adjust the start hours
Calendar adjustedBeginTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
Calendar adjustedBeginTime = Calendar.getInstance(TimeZone
.getTimeZone("GMT"));
adjustedBeginTime.setTimeInMillis(queryBeginTime.getTime());
adjustedBeginTime.add(Calendar.HOUR, adjustedPCStartTime * -1);
@ -199,23 +199,26 @@ public class PointPrecipDataManager extends HydroDataManager {
return null;
}
}
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(String.format(" obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime())));
where.append(String.format(" obstime <= '%s' ",
where.append(String.format(" obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime
.getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(queryEndTime)));
where.append("AND value IS NOT NULL AND ");
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) {
where.append(String.format(" WHERE %s ", tsClause));
where.append(" AND value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime())));
where.append(String.format(" obstime <= '%s' ",
where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime
.getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(queryEndTime)));
where.append("AND value IS NOT NULL AND ");
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(" AND value != '-9999.0' 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' ",
HydroConstants.DATE_FORMAT.format(queryEndTime)));
where.append("AND value IS NOT NULL AND ");
@ -233,64 +237,66 @@ public class PointPrecipDataManager extends HydroDataManager {
} else {
where.append(" WHERE value != '-9999.0' 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' ",
HydroConstants.DATE_FORMAT.format(queryEndTime)));
where.append("AND value IS NOT NULL AND ");
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");
}
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());
int i = 0;
for (Object[] rowData : pcData) {
Curpc curpc = new Curpc();
curpc.getId().setLid((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().setExtremum((String) rowData[++i]);
curpc.getId().setObstime((Date) rowData[++i]);
curpc.setValue((Double) rowData[++i]);
curpc.setShefQualCode((String) rowData[++i]);
curpc.setRevision((Short) rowData[++i]);
curpc.setRevision(((Number) rowData[++i]).shortValue());
curpc.setProductId((String) rowData[++i]);
curpc.setProducttime((Date) rowData[++i]);
curpc.setPostingtime((Date) rowData[++i]);
i = 0;
data.add(curpc);
}
return data;
}
/**
* Get the lat, lon, and name from location.
*
* @param lid
* The lid to query on
* @return
* Object[] - 0 = lat, 1 = lon, 2 = name
* The lid to query on
* @return Object[] - 0 = lat, 1 = lon, 2 = name
*/
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;
ArrayList<Object[]> rs = runQuery(query);
if ((rs!=null) && (rs.size() > 0)) {
return rs.get(0);
if ((rs != null) && (rs.size() > 0)) {
return rs.get(0);
} 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;
StringBuilder where = new StringBuilder();
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
* periods, retrieve more wider data for gages, use token
* adjust_PC_startingtime to specify the PC data retrieval starting point
* periods, retrieve more wider data for gages, use token
* adjust_PC_startingtime to specify the PC data retrieval starting
* point
*/
if (adjustedPCStartTime == HydroConstants.MISSING_VALUE) {
AppsDefaults ad = AppsDefaults.getInstance();
String tokenString = ad.getToken("adjust_PC_startingtime");
if ((tokenString != null) && (tokenString.length() > 0)) {
adjustedPCStartTime = Integer.parseInt(tokenString);
if (adjustedPCStartTime <= 0) {
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
}
}
} else {
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 (adjustedPCStartTime == HydroConstants.MISSING_VALUE) {
AppsDefaults ad = AppsDefaults.getInstance();
String tokenString = ad.getToken("adjust_PC_startingtime");
if ((tokenString != null) && (tokenString.length() > 0)) {
adjustedPCStartTime = Integer.parseInt(tokenString);
if (adjustedPCStartTime <= 0) {
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
}
}
} else {
adjustedPCStartTime = PointPrecipConstants.DEFAULT_ADJUSTED_STARTTIME_HRS;
}
if (tsList.size() > 0) {
tsClause = build_ts_clause(tsList);
if (tsClause == null) {
return null;
}
}
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 ");
where.append(String.format(" obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime)));
where.append("AND value IS NOT NULL AND ");
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));
where.append(" AND value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime)));
where.append("AND value IS NOT NULL AND ");
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
where.append(" NOT LIKE 'R%%' ORDER BY lid ASC, obstime DESC");
} else if (lid.length() > 0) {
where.append(String.format(" WHERE lid = '%s' ", lid));
where.append(" AND value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime)));
where.append("AND value IS NOT NULL AND ");
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
where.append(" NOT LIKE 'R%%' ORDER BY ts ASC, obstime DESC");
} else {
where.append(" WHERE value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime.getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime)));
where.append("AND value IS NOT NULL AND ");
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");
}
/* get the data */
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 curpc";
pcData = runQuery(query + where.toString());
if ((pcData != null) && (pcData.size() > 0)) {
int i = 0;
for (Object[] oa: pcData) {
Rawpc rawpc = new Rawpc();
RawpcId id = new RawpcId();
rawpc.setId(id);
rawpc.getId().setLid((String) oa[i]);
rawpc.setPe((String) oa[++i]);
rawpc.setDur(((Integer) oa[++i]).shortValue());
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((Integer) oa[++i]);
rawpc.setRevision(((Integer) oa[++i]).shortValue());
rawpc.setProductId((String) oa[++i]);
rawpc.setProducttime((Date) oa[++i]);
rawpc.setPostingtime((Date) oa[++i]);
i = 0;
pRawPc.add(rawpc);
}
}
} else {
// Get rawpc
String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, quality_code, revision, product_id, producttime, postingtime from rawpc";
pcData = runQuery(query + where.toString());
if ((pcData != null) && (pcData.size() > 0)) {
int i = 0;
for (Object[] oa: pcData) {
Rawpc rawpc = new Rawpc();
rawpc.getId().setLid((String) oa[i]);
rawpc.setPe((String) oa[++i]);
rawpc.setDur((Short) oa[++i]);
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((Integer) oa[++i]);
rawpc.setRevision((Short) oa[++i]);
rawpc.setProductId((String) oa[++i]);
rawpc.setProducttime((Date) oa[++i]);
rawpc.setPostingtime((Date) oa[++i]);
i = 0;
pRawPc.add(rawpc);
}
}
}
return pRawPc;
// 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) {
tsClause = build_ts_clause(tsList);
if (tsClause == null) {
return null;
}
}
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 ");
where.append(String.format(" obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime
.getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime)));
where.append("AND value IS NOT NULL AND ");
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));
where.append(" AND value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime
.getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime)));
where.append("AND value IS NOT NULL AND ");
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
where.append(" NOT LIKE 'R%%' ORDER BY lid ASC, obstime DESC");
} else if (lid.length() > 0) {
where.append(String.format(" WHERE lid = '%s' ", lid));
where.append(" AND value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime
.getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime)));
where.append("AND value IS NOT NULL AND ");
where.append(" shef_qual_code NOT LIKE 'B%%' AND shef_qual_code ");
where.append(" NOT LIKE 'R%%' ORDER BY ts ASC, obstime DESC");
} else {
where.append(" WHERE value != '-9999.0' AND ");
where.append(String.format("obstime >= '%s' AND ",
HydroConstants.DATE_FORMAT.format(adjustedBeginTime
.getTime())));
where.append(String.format(" obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime)));
where.append("AND value IS NOT NULL AND ");
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");
}
/* get the data */
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 curpc";
pcData = runQuery(query + where.toString());
if ((pcData != null) && (pcData.size() > 0)) {
int i = 0;
for (Object[] oa : pcData) {
Rawpc rawpc = new Rawpc();
RawpcId id = new RawpcId();
rawpc.setId(id);
rawpc.getId().setLid((String) oa[i]);
rawpc.setPe((String) oa[++i]);
rawpc.setDur(((Number) oa[++i]).shortValue());
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);
}
}
} else {
// Get rawpc
String query = "select lid, pe, dur, ts, extremum, obstime, value, shef_qual_code, quality_code, revision, product_id, producttime, postingtime from rawpc";
pcData = runQuery(query + where.toString());
if ((pcData != null) && (pcData.size() > 0)) {
int i = 0;
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());
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();
String tsClause = null;
ArrayList<Object[]> pcData;
@ -449,24 +461,26 @@ public class PointPrecipDataManager extends HydroDataManager {
/* Only retrieve valid PP data. */
String qcWhere = buildQCWhere(PointPrecipConstants.QC_NOT_FAILED);
if (tsList.size() > 0) {
tsClause = build_ts_clause(tsList);
if (tsClause == null) {
return null;
}
}
if ((lid.length() > 0) && (tsList.size() > 0)) {
where.append(String.format(" WHERE lid = '%s' AND %s ", lid, tsClause));
where.append(String.format(" AND value != '-9999.0' AND obstime >= '%s' ",
where.append(String.format(" WHERE lid = '%s' AND %s ", lid,
tsClause));
where.append(String.format(
" AND value != '-9999.0' AND obstime >= '%s' ",
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)));
where.append(qcWhere + " order by dur desc, obstime desc");
} else if (tsList.size() > 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)));
where.append(String.format(" AND obstime <= '%s' ",
HydroConstants.DATE_FORMAT.format(endTime)));
@ -479,8 +493,7 @@ public class PointPrecipDataManager extends HydroDataManager {
where.append(String.format(" obstime <= '%s' AND %s ",
HydroConstants.DATE_FORMAT.format(endTime), qcWhere));
where.append(" ORDER BY ts ASC, DUR DESC, obstime DESC");
} else {
where.append(" WHERE value != '-9999.0' 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 ",
HydroConstants.DATE_FORMAT.format(endTime), qcWhere));
where.append(" ORDER BY lid ASC, ts ASC, dur DESC, obstime DESC");
}
/* get the data */
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";
pcData = runQuery(query + where.toString());
if ((pcData != null) && (pcData.size() > 0)) {
int i = 0;
for (Object[] oa: pcData) {
for (Object[] oa : pcData) {
Rawpp rawpp = new Rawpp();
RawppId id = new RawppId();
rawpp.setId(id);
rawpp.getId().setLid((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().setExtremum((String) oa[++i]);
rawpp.getId().setObstime((Date) oa[++i]);
rawpp.setValue((Double) oa[++i]);
rawpp.setShefQualCode((String) oa[++i]);
rawpp.setQualityCode((Integer) oa[++i]);
rawpp.setRevision(((Integer) oa[++i]).shortValue());
rawpp.setQualityCode(((Number) oa[++i]).intValue());
rawpp.setRevision(((Number) oa[++i]).shortValue());
rawpp.setProductId((String) oa[++i]);
rawpp.setProducttime((Date) oa[++i]);
rawpp.setPostingtime((Date) oa[++i]);
@ -523,19 +536,19 @@ public class PointPrecipDataManager extends HydroDataManager {
// get 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());
int i = 0;
for (Object[] oa: pcData) {
for (Object[] oa : pcData) {
Rawpp rawpp = new Rawpp();
rawpp.getId().setLid((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().setExtremum((String) oa[++i]);
rawpp.getId().setObstime((Date) oa[++i]);
rawpp.setValue((Double) oa[++i]);
rawpp.setShefQualCode((String) oa[++i]);
rawpp.setRevision((Short) oa[++i]);
rawpp.setRevision(((Number) oa[++i]).shortValue());
rawpp.setProductId((String) oa[++i]);
rawpp.setProducttime((Date) oa[++i]);
rawpp.setPostingtime((Date) oa[++i]);
@ -543,79 +556,93 @@ public class PointPrecipDataManager extends HydroDataManager {
pRawPp.add(rawpp);
}
}
return pRawPp;
}
private String buildQCWhere(int request) {
String where = null;
/* The data value is valid as per all checks. */
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) {
/* 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) {
/* The data value is invalid because it failed at least one
certainty check */
where = "quality_code < " + PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD;
/*
* The data value is invalid because it failed at least one
* certainty check
*/
where = "quality_code < "
+ PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD;
} else if (request == PointPrecipConstants.QC_QUESTIONABLE) {
/* The data value is questionable. It passed all certainty checks
but failed at least one quality check. */
where = "quality_code BETWEEN " + PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD +
" and " + (PointPrecipConstants.GOOD_QUESTIONABLE_THRESHOLD - 1);
/*
* The data value is questionable. It passed all certainty checks
* but failed at least one quality check.
*/
where = "quality_code BETWEEN "
+ PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD + " and "
+ (PointPrecipConstants.GOOD_QUESTIONABLE_THRESHOLD - 1);
} else if (request == PointPrecipConstants.QC_NOT_FAILED) {
/* The data is deemed full valid or is questionable, but it is
not deemed bad with certainty. */
where = "quality_code >= " + PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD;
/*
* The data is deemed full valid or is questionable, but it is not
* deemed bad with certainty.
*/
where = "quality_code >= "
+ PointPrecipConstants.QUESTIONABLE_BAD_THRESHOLD;
}
return where;
}
/**
* Check if the given lid is an ALERT station.
*
* @param lid
* The lid to check
* @return
* true if alert station, false if not
* The lid to check
* @return true if alert station, false if not
*/
public boolean isAlertStation(String lid) {
boolean alert = false;
String query = "select type from telem where lid = '" + lid + "'";
ArrayList<Object[]> rs = runQuery(query);
if ((rs != null) && (rs.size() > 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;
}
}
return alert;
}
public ArrayList<IngestFilter> getIngestTsInfo(String lid) {
ArrayList<Object[]> rs = null;
ArrayList<IngestFilter> filterList = null;
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);
if ((rs != null) && (rs.size() > 0)) {
filterList = new ArrayList<IngestFilter>();
for (Object[] oa: rs) {
for (Object[] oa : rs) {
IngestFilter filter = new IngestFilter(oa);
filterList.add(filter);
}
}
return filterList;
}
public String build_ts_clause(List<String> ts) {
if ((ts == null) || ts.isEmpty()) {
return "";
@ -638,17 +665,17 @@ public class PointPrecipDataManager extends HydroDataManager {
return tsClause.toString();
}
public String getDur(short dur) {
String query = "select name from shefdur where dur = " + dur + " ";
ArrayList<Object[]> rs = runQuery(query);
String durStr = null;
if ((rs != null) && (rs.size() > 0)) {
Object[] oa = rs.get(0);
durStr = (String) oa[0];
}
return durStr;
}
}

View file

@ -49,7 +49,7 @@ import com.raytheon.viz.hydrocommon.HydroDataCache;
* 04Sept2008 1509 dhladky abstraction.
* 13Oct2008 1580 askripsky Refactored
* 21 Feb 2010 2915 mpduff Fixed Time Zone problem.
*
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre>
*
* @author ebabin
@ -66,7 +66,7 @@ public class StationReportingDataManager {
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 = " ";
@ -127,8 +127,9 @@ public class StationReportingDataManager {
List<Object[]> data;
try {
data = DirectDbQuery.executeQuery(LATEST_OBS_FOR_LID_QUERY.replace(
":lid", lid), HydroConstants.IHFS, QueryLanguage.SQL);
data = DirectDbQuery.executeQuery(
LATEST_OBS_FOR_LID_QUERY.replace(":lid", lid),
HydroConstants.IHFS, QueryLanguage.SQL);
for (Object[] rowData : data) {
retVal.add(convertObsToDataRecord(rowData));
}
@ -142,7 +143,7 @@ public class StationReportingDataManager {
public StationReportingTimingData getTimingData(String lid) {
if (stationTime == null) {
loadTimingData();
if (stationTime != null) {
return stationTime.get(lid);
}
@ -162,7 +163,8 @@ public class StationReportingDataManager {
StationReportingConstants.Duration duration, int durationHours)
throws VizException {
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"));
previousWhere = "";
@ -182,17 +184,16 @@ public class StationReportingDataManager {
+ " FROM latestobsvalue WHERE obstime > '" + obsTimeString
+ "')");
} else if (listType == ListType.NEVER) {
where
.append(" WHERE lid = 'X-N/A-X' "
+ "UNION "
+ "SELECT lid, "
+ " '', 0, '', '', "
+ " '1-1-1 00:00:00', "
+ " 0.0, 0, '', 0,'', "
+ " '1-1-1 00:00:00', "
+ " '1-1-1 00:00:00' "
+ " FROM location "
+ " WHERE lid NOT IN (SELECT DISTINCT lid FROM latestobsvalue) ");
where.append(" WHERE lid = 'X-N/A-X' "
+ "UNION "
+ "SELECT lid, "
+ " '', 0, '', '', "
+ " '1-1-1 00:00:00', "
+ " 0.0, 0, '', 0,'', "
+ " '1-1-1 00:00:00', "
+ " '1-1-1 00:00:00' "
+ " FROM location "
+ " WHERE lid NOT IN (SELECT DISTINCT lid FROM latestobsvalue) ");
}
/* define the sort order */
@ -243,17 +244,20 @@ public class StationReportingDataManager {
StationReportingData srd = new StationReportingData(
lid, hydroCache.getLocationMap().get(lid));
srd.setPe((String) oa[1]);
srd.setDur(((Integer) oa[2]).shortValue());
srd.setDur(((Number) oa[2]).shortValue());
srd.setTs((String) oa[3]);
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.setRevision(((Integer) oa[7]).shortValue());
srd.setRevision(((Number) oa[7]).shortValue());
srd.setShefQualCode((String) oa[8]);
srd.setQualityCode((Integer) oa[9]);
srd.setQualityCode(((Number) oa[9]).intValue());
srd.setProductId((String) oa[10]);
srd.setProducttime(currentTimeFormat.format((Date) oa[11]));
srd.setPostingtime(currentTimeFormat.format((Date) oa[12]));
srd.setProducttime(currentTimeFormat
.format((Date) oa[11]));
srd.setPostingtime(currentTimeFormat
.format((Date) oa[12]));
rval.add(srd);
lidList.add(lid);
@ -267,7 +271,7 @@ public class StationReportingDataManager {
return null;
}
}
return rval;
}
@ -286,7 +290,7 @@ public class StationReportingDataManager {
retVal.setPe(dataRow[1].toString());
if (dataRow[2] != null) {
retVal.setDur(((Integer) dataRow[2]).shortValue());
retVal.setDur(((Number) dataRow[2]).shortValue());
}
retVal.setTs(dataRow[3].toString());
@ -299,11 +303,11 @@ public class StationReportingDataManager {
retVal.setShefQualCode(dataRow[7].toString());
if (dataRow[8] != null) {
retVal.setQualityCode((Integer) dataRow[8]);
retVal.setQualityCode(((Number) dataRow[8]).intValue());
}
if (dataRow[9] != null) {
retVal.setRevision(((Integer) dataRow[9]).shortValue());
retVal.setRevision(((Number) dataRow[9]).shortValue());
}
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.
* 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 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre>
*
* @author lvenable
@ -1033,7 +1033,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
reviewSendScriptBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (sendConfigDlg == null || sendConfigDlg.isDisposed()) {
if ((sendConfigDlg == null) || sendConfigDlg.isDisposed()) {
sendConfigDlg = new SendConfigDlg(shell);
sendConfigDlg.open();
} else {
@ -1883,8 +1883,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
StringBuilder sb = new StringBuilder();
ArrayList<DataRecord> dataRecordList = new ArrayList<DataRecord>();
for (int i = 0; i < selectionIndices.length; i++) {
TabularData td = tabularDataList.get(selectionIndices[i]);
for (int selectionIndice : selectionIndices) {
TabularData td = tabularDataList.get(selectionIndice);
/* set the update structure with data which doesn't change */
dr = new DataRecord();
@ -1997,8 +1997,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
/* Loop through the data values selected and delete each one */
int[] selectionIndices = bottomListControl.getSelectionIndices();
for (int i = 0; i < selectionIndices.length; i++) {
TabularData td = tabularDataList.get(selectionIndices[i]);
for (int selectionIndice : selectionIndices) {
TabularData td = tabularDataList.get(selectionIndice);
// SiteInfo si = tabInfo.getSiteInfo(topDataList
// .getSelectionIndex());
DataRecord dr = new DataRecord();
@ -2134,8 +2134,8 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
DataRecord dr = new DataRecord();
/* code to update an observation qc info */
for (int i = 0; i < selectionIndices.length; i++) {
TabularData td = tabularDataList.get(selectionIndices[i]);
for (int selectionIndice : selectionIndices) {
TabularData td = tabularDataList.get(selectionIndice);
/* set the update structure with data which doesn't change */
dr.setLid(lid);
@ -2325,11 +2325,11 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
// one inch from left side of paper
leftMargin = dpi.x + trim.x;
// 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
topMargin = dpi.y + trim.y;
// 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.
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();
}
wordBuffer = null;
@ -2554,7 +2554,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
if (wordBuffer.length() > 0) {
String word = wordBuffer.toString();
int wordWidth = gc.stringExtent(word).x;
if (x + wordWidth > rightMargin) {
if ((x + wordWidth) > rightMargin) {
// word doesn't fit on current line, so wrap
newline();
}
@ -2570,9 +2570,9 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
private void newline() {
x = leftMargin;
y += lineHeight;
if (y + lineHeight > bottomMargin) {
if ((y + lineHeight) > bottomMargin) {
printer.endPage();
if (index + 1 < end) {
if ((index + 1) < end) {
y = topMargin;
printer.startPage();
}
@ -2715,7 +2715,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
}
/* 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);
String floodStage = "0.0";
String floodFlow = "0";
@ -2785,7 +2785,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
FcstheightId fhid = new FcstheightId();
fhid.setLid(si.getLid());
fhid.setPe(si.getPe());
fhid.setDur(((Integer) si.getDur()).shortValue());
fhid.setDur((short) si.getDur());
fhid.setExtremum(si.getExt());
fcstRow.setPostingtime(postingTime);
@ -2928,7 +2928,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
BufferedWriter out = new BufferedWriter(new FileWriter(
shefFileName, true));
int[] indices = bottomListControl.getSelectionIndices();
for (int i = 0; i < indices.length; i++) {
for (int indice : indices) {
String data = topDataList.getItem(topDataList
.getSelectionIndex());
@ -2957,7 +2957,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
endingTime, basisTime, forecast);
/* 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")) {
fmtType = ".AR";
}
@ -3027,7 +3027,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
if ((shefFileName != null) && (shefFileName.length() > 0)) {
File shefFile = new File(shefFileName);
if (shefFile.exists()) {
if (editor == null || editor.isDisposed()) {
if ((editor == null) || editor.isDisposed()) {
editor = new TextEditorDlg(shell, false, shefFile);
editor.open();
} else {

View file

@ -72,9 +72,9 @@ import com.raytheon.viz.hydrocommon.util.DbUtils;
* Feb 22 2013 14676 lbousaidi check when producttime is null
* 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.
* Dec 14, 2014 16388 xwei updated the insertion of rejecteddata table.
*
</pre>
* Dec 14, 2014 16388 xwei updated the insertion of rejecteddata table.
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre>
*
* @author dhladky
* @version 1.0
@ -251,7 +251,7 @@ public class TimeSeriesDataManager extends HydroDataManager {
SiteInfo si = new SiteInfo();
si.setLid((String) oa[0]);
si.setPe((String) oa[1]);
si.setDur((Integer) oa[2]);
si.setDur(((Number) oa[2]).intValue());
si.setTs((String) oa[3]);
si.setExt((String) oa[4]);
returnData.add(si);
@ -561,15 +561,15 @@ public class TimeSeriesDataManager extends HydroDataManager {
td.setLid((String) oa[0]);
td.setObsTime((Date) oa[1]);
td.setValue((Double) oa[2]);
td.setRevision((Integer) oa[3]);
td.setRevision(((Number) oa[3]).intValue());
td.setShefQualCode((String) oa[4]);
td.setQualityCode((Integer) oa[5]);
td.setQualityCode(((Number) oa[5]).intValue());
td.setProductId((String) oa[6]);
td.setProductTime((Date) oa[7]);
td.setPostingTime((Date) oa[8]);
if (forecastData) {
td.setValidTime((Date) oa[9]);
td.setProbability((Float) oa[10]);
td.setProbability(((Number) oa[10]).floatValue());
}
tabularData.add(td);
}
@ -612,7 +612,7 @@ public class TimeSeriesDataManager extends HydroDataManager {
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 {
sqlResult = (DirectDbQuery.executeQuery(sql.toString(),
HydroConstants.IHFS, QueryLanguage.SQL));
if (sqlResult != null && sqlResult.size() > 0
&& sqlResult.get(0)[0] != null) {
if ((sqlResult != null) && (sqlResult.size() > 0)
&& (sqlResult.get(0)[0] != null)) {
return sqlResult.get(0)[0];
}
} catch (VizException e) {
@ -949,8 +949,9 @@ public class TimeSeriesDataManager extends HydroDataManager {
int probability = -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;
}
@ -1302,18 +1303,18 @@ public class TimeSeriesDataManager extends HydroDataManager {
FcstheightId fhid = new FcstheightId();
fhid.setLid((String) item[i++]);
fhid.setPe((String) item[i++]);
Integer in = (Integer) item[i++];
Number in = (Number) item[i++];
fhid.setDur(in.shortValue());
fhid.setTs((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.setBasistime((Date) item[i++]);
fh.setId(fhid);
fh.setValue((Double) item[i++]);
fh.setShefQualCode((String) item[i++]);
fh.setQualityCode((Integer) item[i++]);
in = (Integer) item[i++];
fh.setQualityCode(((Number) item[i++]).intValue());
in = (Number) item[i++];
fh.setRevision(in.shortValue());
fh.setProductId((String) 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 Jun 2013 2076 mpduff Fix station list selection and graph button enabling.
* 0 Jun 2013 15980 wkwock Fix selected station not update
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre>
*
* @author lvenable
@ -490,7 +491,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
*/
public final static TimeSeriesDlg getInstance() {
// Independent shell must be recreated after closing.
if (instance == null || !instance.isOpen()) {
if ((instance == null) || !instance.isOpen()) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
instance = new TimeSeriesDlg(shell);
@ -528,12 +529,12 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
this.standaloneMode = true;
// 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
IPathManager pm = PathManagerFactory.getPathManager();
groupConfigFile = pm.getStaticFile(HydroConstants.GROUP_DEFINITION);
if (groupConfigFile == null || !groupConfigFile.exists()) {
if ((groupConfigFile == null) || !groupConfigFile.exists()) {
String name = HydroConstants.GROUP_DEFINITION;
if (name.startsWith("/")) {
name = name.substring(1);
@ -1527,7 +1528,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
si.setPe((String) row[1]);
si.setTs((String) row[2]);
si.setExt((String) row[3]);
si.setDur((Integer) row[4]);
si.setDur(((Number) row[4]).intValue());
if (si.getPe().startsWith("H")) {
if (!si.getPe().equals(prevPE)) {
@ -1692,8 +1693,9 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
if (values.length > 1) {
if ((values[0] != null)
&& values[0].equalsIgnoreCase(NAME)) {
if (values[1] != null)
if (values[1] != null) {
groupInfo.setGroupName(values[1]);
}
groupDataList.add(groupInfo.getGroupName());
} else if (values[0].equalsIgnoreCase(DESCRIPT)) {
groupInfo.setDescription(values[1]);
@ -1788,10 +1790,11 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} else if (values[0]
.equalsIgnoreCase(HydroConstants.PC)) {
td.setPc(values[1]);
if (showpp_flag == true)
if (showpp_flag == true) {
graphData.setShowpp(true);
else
} else {
graphData.setShowpp(false);
}
} else if (values[0].equalsIgnoreCase(COLOR)) {
td.setColorName(values[1]);
}
@ -1959,9 +1962,9 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
}
String[] dataString2 = bottomDataList.getSelection();
for (int i = 0; i < dataString2.length; i++) {
for (String element : dataString2) {
LIDData tmpLidData = new LIDData();
tmpLidData.setData(dataString2[i]);
tmpLidData.setData(element);
check1 = lidCheck(prevLidData, tmpLidData);
check2 = lidCheck(currLidData, tmpLidData);
@ -2182,12 +2185,12 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
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
* needed
*/
String selection = bottomDataList.getItem(indices[i]);
String selection = bottomDataList.getItem(indice);
String[] pieces2 = selection.split("\\s+");
LIDData lidData = new LIDData();
@ -2301,7 +2304,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
GroupInfo groupInfo = groupList.get(groupDataList
.getSelectionIndex());
if (prevGroupInfo == null || !prevGroupInfo.equals(groupInfo)) {
if ((prevGroupInfo == null) || !prevGroupInfo.equals(groupInfo)) {
int pastHours = groupInfo.getPastHours();
int futureHours = groupInfo.getFutureHours();
beginCal = Calendar
@ -2344,7 +2347,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
private boolean validateForm() {
boolean valid = true;
if (modeCbo.getText().equals(STATION_SELECTION)) {
if (endCal.getTimeInMillis() - beginCal.getTimeInMillis() < 0) {
if ((endCal.getTimeInMillis() - beginCal.getTimeInMillis()) < 0) {
MessageDialog.openWarning(shell, "Invalid Date Selection",
"Ending Time is prior to Beginning Time");
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
*/
public void updateFromDisplayManager() {
HydroDisplayManager hdm = HydroDisplayManager.getInstance();
String newLid=hdm.getCurrentLid();
if (newLid!=null && !newLid.equalsIgnoreCase(currentLid)) {
updateAndOpen(newLid, this.displayGraph);
openGraph();
String newLid = hdm.getCurrentLid();
if ((newLid != null) && !newLid.equalsIgnoreCase(currentLid)) {
updateAndOpen(newLid, this.displayGraph);
openGraph();
}
}

View file

@ -48,9 +48,9 @@ import com.raytheon.viz.hydrocommon.whfslib.IHFSDbGenerated;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 31, 2009 mpduff Initial creation.
* Nov 06, 2009 2639 mpduff Added getRiverStat method.
*
* Mar 31, 2009 mpduff Initial creation.
* Nov 06, 2009 2639 mpduff Added getRiverStat method.
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre>
*
* @author mpduff
@ -62,11 +62,12 @@ public class HydroData {
* Get Rpfparams data.
*
* @param where
* The where clause to use
* The where clause to use
* @return list of Rpfparams data
* @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>();
String query = null;
if ((where == null) || (where.length() == 0)) {
@ -78,19 +79,21 @@ public class HydroData {
+ com.raytheon.uf.common.dataplugin.shef.tables.Rpfparams.class
.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) {
returnList.add((Rpfparams) item[0]);
}
return returnList;
}
public static ArrayList<Forecast> bldTsFcstRiv(String lid, String pe, String tsFilter,
boolean useLatest, Date basisTime) {
String useTs = null;;
public static ArrayList<Forecast> bldTsFcstRiv(String lid, String pe,
String tsFilter, boolean useLatest, Date basisTime) {
String useTs = null;
;
ArrayList<Forecast> fcstList = null;
String where = null;
String qcwhere = null;
@ -100,81 +103,82 @@ public class HydroData {
int keepCnt = 0;
try {
/* 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;
useTs = getBestTs(lid, pe, "F%", ordinal);
/*
* 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;
useTs = getBestTs(lid, pe, "F%", ordinal);
} else {
useTs = tsFilter;
useTs = tsFilter;
}
/* 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 */
tablename = DbUtils.getTableName(pe, useTs);
/* convert the times for the where clause */
String basisTimeStr = HydroConstants.DATE_FORMAT.format(basisTime);
/* get current system time */
Date now = SimulatedTime.getSystemTime().getTime();
/* convert the local current time to ansi time in GMT format */
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,
and with some limited basis time ago */
where = "WHERE lid = '" + lid + "' and pe ='" + pe + "' " +
"and ts = '" + useTs + "' and probability < 0.0 and " +
"validtime >= '" + currentTime + "' and " +
"basistime >= '" + basisTimeStr + "' and " +
"value != " + HydroConstants.MISSING_VALUE +
" and " + qcwhere + " ORDER BY basistime DESC ";
ArrayList<String[]> uniqueResults = loadUnique("basistime", tablename, where);
/*
* retrieve a list of unique basis times; use descending sort. only
* consider forecast data before some ending time, and with some
* limited basis time ago
*/
where = "WHERE lid = '" + lid + "' and pe ='" + pe + "' "
+ "and ts = '" + useTs + "' and probability < 0.0 and "
+ "validtime >= '" + currentTime + "' and "
+ "basistime >= '" + basisTimeStr + "' and " + "value != "
+ HydroConstants.MISSING_VALUE + " and " + qcwhere
+ " ORDER BY basistime DESC ";
ArrayList<String[]> uniqueResults = loadUnique("basistime",
tablename, where);
if (uniqueResults.size() <= 0) {
return null;
}
/* retrieve the data; the ordering by validtime is important.
as before, limit the forecast time valid time window
and as needed, the age of the forecast (basistime). */
/*
* retrieve the data; the ordering by validtime is important. as
* before, limit the forecast time valid time window and as needed,
* the age of the forecast (basistime).
*/
if (useLatest || (uniqueResults.size() == 1)) {
where = String.format(" WHERE lid = '%s' AND pe = '%s' AND " +
" ts = '%s' AND " +
" probability < 0.0 AND " +
" validtime >= '%s' AND basistime = '%s' AND " +
" value != %d AND %s " +
" ORDER BY validtime ASC",
lid, pe, useTs, currentTime, uniqueResults.get(0)[0],
HydroConstants.MISSING_VALUE, qcwhere);
where = String.format(" WHERE lid = '%s' AND pe = '%s' AND "
+ " ts = '%s' AND " + " probability < 0.0 AND "
+ " validtime >= '%s' AND basistime = '%s' AND "
+ " value != %d AND %s " + " ORDER BY validtime ASC",
lid, pe, useTs, currentTime, uniqueResults.get(0)[0],
HydroConstants.MISSING_VALUE, qcwhere);
} else {
where = String.format(" WHERE lid = '%s' AND pe = '%s' AND " +
" ts = '%s' AND " +
" probability < 0.0 AND " +
" validtime >= '%s' AND basistime >= '%s' AND " +
" value != %d AND %s" +
" ORDER BY validtime ASC",
lid, pe, useTs, currentTime, basisTimeStr,
HydroConstants.MISSING_VALUE, qcwhere);
where = String.format(" WHERE lid = '%s' AND pe = '%s' AND "
+ " ts = '%s' AND " + " probability < 0.0 AND "
+ " validtime >= '%s' AND basistime >= '%s' AND "
+ " value != %d AND %s" + " ORDER BY validtime ASC",
lid, pe, useTs, currentTime, basisTimeStr,
HydroConstants.MISSING_VALUE, qcwhere);
}
fcstList = getForecast(where, tablename);
/*
* if only getting the latest basis time's data
* or only one basis time was found, then consider all;
* otherwise, need to adjoin/butt the time series together
* for the multiple basis times.
/*
* if only getting the latest basis time's data or only one basis
* time was found, then consider all; otherwise, need to adjoin/butt
* the time series together for the multiple basis times.
*/
doKeep = new boolean[fcstList.size()];
if (useLatest || (uniqueResults.size() <= 1)) {
@ -184,10 +188,12 @@ public class HydroData {
} else {
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
the count of the number of values to keep and allocate the data */
/*
* now load the values and info to return, knowing which items to
* 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++) {
if (doKeep[i]) {
keepCnt++;
@ -199,50 +205,47 @@ public class HydroData {
fcstList.remove(i);
}
}
} catch (VizException ve) {
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
* 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.
* 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
* 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
* The location id
* The location id
* @param pe
* The physical element
* The physical element
* @param tsPrefix
* One character string, R for observed and F for forecast
* One character string, R for observed and F for forecast
* @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
*/
public static String getBestTs(String lid, String pe, String tsPrefix,
@ -251,46 +254,53 @@ public class HydroData {
String where = null;
List<Ingestfilter> ingestFilterList = null;
Ingestfilter ingestPtr;
/* get the ingest filter entries for this location. note that the
retrieval is ordered so that if multiple best ranks exist, there
is 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);
ingestFilterList = IHFSDbGenerated.GetIngestFilter(where);
if ((ingestFilterList != null) && (ingestFilterList.size() > 0)) {
/* if no specific ordinal number was requested, return with
the highest rank. */
if (ordinal <= 0) {
tsFound = ingestFilterList.get(0).getId().getTs();
}
} else { /* if a specific ordinal number was requested. */
/* if a specific ordinal number was requested. */
/* get a count of the number of matching ts entries.
if the requested ordinal number is greater than
the number available then return with a not found status. */
if (ordinal <= ingestFilterList.size()) {
ingestPtr = ingestFilterList.get(ordinal);
tsFound = ingestPtr.getId().getTs();
}
}
return tsFound;
/*
* get the ingest filter entries for this location. note that the
* retrieval is ordered so that if multiple best ranks exist, there is
* 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);
ingestFilterList = IHFSDbGenerated.GetIngestFilter(where);
if ((ingestFilterList != null) && (ingestFilterList.size() > 0)) {
/*
* if no specific ordinal number was requested, return with the
* highest rank.
*/
if (ordinal <= 0) {
tsFound = ingestFilterList.get(0).getId().getTs();
}
} else { /* if a specific ordinal number was requested. */
/* if a specific ordinal number was requested. */
/*
* get a count of the number of matching ts entries. if the
* requested ordinal number is greater than the number available
* then return with a not found status.
*/
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[]>();
StringBuilder sql = new StringBuilder("SELECT DISTINCT ");
if (field.contains("||")) {
String[] fields = field.split("\\|\\|");
sql.append(fields[0]);
@ -301,40 +311,44 @@ public class HydroData {
} else {
sql.append(field);
}
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++) {
Object[] oa = results.get(i);
ArrayList<String> al = new ArrayList<String>();
for (Object o: oa) {
for (Object o : oa) {
if (o instanceof java.sql.Timestamp) {
al.add(HydroConstants.DATE_FORMAT.format((java.sql.Timestamp) o));
} else if (o instanceof Integer){
al.add(((Integer) o).toString());
al.add(HydroConstants.DATE_FORMAT
.format((java.sql.Timestamp) o));
} else if (o instanceof Number) {
al.add(((Number) o).toString());
} else {
al.add((String) o);
}
}
returnList.add(al.toArray(new String[al.size()]));
}
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<Object[]> result = null;
if (tablename.equalsIgnoreCase("fcstheight")) {
String query = "from "
+ com.raytheon.uf.common.dataplugin.shef.tables.Fcstheight.class
.getName() + " " + where;
result = DirectDbQuery.executeQuery(query, HydroConstants.IHFS, QueryLanguage.HQL);
+ com.raytheon.uf.common.dataplugin.shef.tables.Fcstheight.class
.getName() + " " + where;
result = DirectDbQuery.executeQuery(query, HydroConstants.IHFS,
QueryLanguage.HQL);
/* Convert to Forecast object */
for (Object[] item : result) {
Fcstheight fh = (Fcstheight) item[0];
@ -357,72 +371,79 @@ public class HydroData {
fcstList.add(f);
}
}
return (ArrayList<Forecast>) fcstList;
}
/**
* Determine which items in the forecast time series to keep,
* as there may be overlap due to multiple time_series.
* Determine which items in the forecast time series to keep, as there may
* be overlap due to multiple time_series.
*
* @param uniqueResults
* List of results from the unique query
* List of results from the unique query
* @param fcstList
* List of Forecast data
* List of Forecast data
* @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
*/
private static boolean[] setFcstKeep(ArrayList<String[]> uniqueResults, ArrayList<Forecast> fcstList, boolean[] doKeep) {
/* get counts of linked lists, one for the forecast values themselves
and one for the number of unique basis times */
private static boolean[] setFcstKeep(ArrayList<String[]> uniqueResults,
ArrayList<Forecast> fcstList, boolean[] doKeep) {
/*
* 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()];
int[] basisIndex = new int[fcstList.size()];
Date[] tsStartTime = new Date[fcstList.size()];
Date[] tsEndTime = new Date[fcstList.size()];
Date[] tsBasisTime = new Date[fcstList.size()];
String basisTimeStr = null;
for (int i = 0; i < uniqueResults.size(); i++) {
tsFirstChk[i] = false;
}
Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime();
/* allocate arrays for each basis time */
for (int i = 0; i < fcstList.size(); i++) {
tsStartTime[i] = now;
}
for (int i = 0; i < fcstList.size(); i++) {
tsEndTime[i] = now;
}
for (int i = 0; i < fcstList.size(); i++) {
tsBasisTime[i] = now;
}
/* now loop thru the retrieved time series data values and get the
start and end times for each of the basis times found. */
/*
* now loop thru the retrieved time series data values and get the start
* and end times for each of the basis times found.
*/
for (int i = 0; i < fcstList.size(); i++) {
/* find out which basis time's time series this value belongs to */
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++) {
if (uniqueResults.get(j)[0].equalsIgnoreCase(basisTimeStr)) {
basisIndex[i] = j;
}
}
if (basisIndex[i] == HydroConstants.MISSING_VALUE) {
// 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();
if (tsFirstChk[basisIndex[i]]) {
if (validTime.before(tsStartTime[basisIndex[i]])) {
@ -436,10 +457,11 @@ public class HydroData {
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
function. */
/*
* for each of the unique basis times, assign the basis time in a
* convenient array for use in the adjust_startend function.
*/
for (int j = 0; j < uniqueResults.size(); j++) {
String bTimeStr = uniqueResults.get(j)[0];
Date bTime;
@ -449,62 +471,68 @@ public class HydroData {
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/* knowing the actual start and end times for the multiple
time series, loop thru the time series and adjust the start
and end times so that they reflect the time span to use;
i.e. there is no overlap. THIS IS THE KEY STEP IN THE
PROCESS OF DEFINING AN AGGREGATE VIRTUAL TIME SERIES!!! */
adjustStartEnd(uniqueResults.size(), tsBasisTime, tsStartTime, tsEndTime);
/*
* knowing the actual start and end times for the multiple time series,
* loop thru the time series and adjust the start and end times so that
* they reflect the time span to use; i.e. there is no overlap. THIS IS
* THE KEY STEP IN THE PROCESS OF DEFINING AN AGGREGATE VIRTUAL TIME
* SERIES!!!
*/
adjustStartEnd(uniqueResults.size(), tsBasisTime, tsStartTime,
tsEndTime);
return doKeep;
}
/**
* This method uses the time series with the latest basis time first,
* and uses it in its entirety. Then the time series with the next
* latest basis time is used. If it overlaps portions of the already
* saved time series, then only that portion which doesn't
* overlap is used. This process continues until all time series
* have been considered. In essences, this method adjoins adjacent
* time series.
* This method uses the time series with the latest basis time first, and
* uses it in its entirety. Then the time series with the next latest basis
* time is used. If it overlaps portions of the already saved time series,
* then only that portion which doesn't overlap is used. This process
* continues until all time series have been considered. In essences, this
* method adjoins adjacent time series.
*
* @param basisTime
* Date[] of basis times
* Date[] of basis times
* @param startValidTime
* Date[] of starting valid times
* Date[] of starting valid times
* @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];
Date tmpTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime();
Date tmpTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"))
.getTime();
int curIndex = 0;
Date fullStartValidTime;
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++) {
basisOrder[i] = -1;
}
/*
* find the order of the time series by their latest basis time.
* if two time series have the same basis time, use the one that
* has the earlier starting time. note that the order is such
* that the latest basis time is last in the resulting order array.
/*
* find the order of the time series by their latest basis time. if two
* time series have the same basis time, use the one that has the
* earlier starting time. note that the order is such that the latest
* basis time is last in the resulting order array.
*/
for (int i = 0; i < ulCount; i++) {
curIndex = 0;
boolean found = false;
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;
for (int k = 0; k < i; k++) {
if (j == basisOrder[k]) {
@ -526,96 +554,114 @@ public class HydroData {
}
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
time series and adjust their start and end times as necessary
so that they do not overlap the time limits of the
being-built aggregate time series. */
/*
* do NOT adjust the start and end time of the time series with the
* latest ending time. loop through all the other time series and adjust
* their start and end times as necessary so that they do not overlap
* the time limits of the being-built aggregate time series.
*/
curIndex = basisOrder[0];
fullStartValidTime = startValidTime[curIndex];
fullEndValidTime = endValidTime[curIndex];
for (int i = 1; i < ulCount; i++) {
curIndex = basisOrder[i];
/* each additional time series being considered is checked to
see if it falls outside the time window already encompassed
by the 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 (startValidTime[curIndex].after(fullStartValidTime) && endValidTime[curIndex].before(fullEndValidTime)) {
/*
* each additional time series being considered is checked to see if
* it falls outside the time window already encompassed by the
* 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 (startValidTime[curIndex].after(fullStartValidTime)
&& endValidTime[curIndex].before(fullEndValidTime)) {
startValidTime[curIndex].setTime(0);
endValidTime[curIndex].setTime(0);
}
else if (startValidTime[curIndex].before(fullStartValidTime) && 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
that is before the time series. it is not desirable to use
both the before and after portion (this results in a
non-contiguous time-series that is weird), and given a choice
it is better to use the forecast data early on than the
later forecast data, so use the before portion */
}
else if (startValidTime[curIndex].before(fullStartValidTime)
&& 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 that is before the time series. it is not desirable to use
* both the before and after portion (this results in a
* non-contiguous time-series that is weird), and given a choice
* 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);
endValidTime[curIndex] = fullStartValidTime;
fullStartValidTime = startValidTime[curIndex];
} else if (startValidTime[curIndex].before(fullStartValidTime) && endValidTime[curIndex].before(fullEndValidTime)) {
/* 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. */
} else if (startValidTime[curIndex].before(fullStartValidTime)
&& endValidTime[curIndex].before(fullEndValidTime)) {
/*
* 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);
endValidTime[curIndex] = fullStartValidTime;
fullStartValidTime = startValidTime[curIndex];
} else if (startValidTime[curIndex].after(fullStartValidTime) && endValidTime[curIndex].after(fullEndValidTime)) {
/* 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. */
} else if (startValidTime[curIndex].after(fullStartValidTime)
&& endValidTime[curIndex].after(fullEndValidTime)) {
/*
* 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);
startValidTime[curIndex] = fullEndValidTime;
fullEndValidTime = endValidTime[curIndex];
}
}
}
/**
* Loads the max fcst info into the RiverStatus table for the
* current location and pe.
* Loads the max fcst info into the RiverStatus table for the current
* location and pe.
*
* @param record
* Forecast record to load
* Forecast record to load
*/
public static void loadRiverStatus(Forecast record) throws VizException {
Riverstatus rstatus = new Riverstatus();
RiverstatusId rsid = new RiverstatusId();
/* update the value in the RiverStatus table. if no record
currently in the table, then insert/put a new record.
first build the record to update/insert */
/*
* update the value in the RiverStatus table. if no record currently in
* the table, then insert/put a new record. first build the record to
* update/insert
*/
rsid.setLid(record.getLid());
rsid.setPe(record.getPe());
rsid.setTs(record.getTs());
rstatus.setId(rsid);
rstatus.setBasistime(record.getBasistime());
rstatus.setDur((short)record.getDur());
rstatus.setDur((short) record.getDur());
rstatus.setExtremum(record.getExtremum());
rstatus.setProbability((float)record.getProbability());
rstatus.setProbability((float) record.getProbability());
rstatus.setValidtime(record.getValidtime());
rstatus.setValue(record.getValue());
DirectDbQuery.saveOrUpdate(rstatus, HydroConstants.IHFS);
}
public static void deleteRiverStatus(String lid, String pe, String ts) throws VizException {
String where = String.format(" WHERE lid='%s' AND pe='%s' AND ts='%s' ",
lid, pe, ts);
public static void deleteRiverStatus(String lid, String pe, String ts)
throws VizException {
String where = String.format(
" WHERE lid='%s' AND pe='%s' AND ts='%s' ", lid, pe, ts);
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
* Oct 27, 2011 11267 lbousaidi change showNoPost initial value to false
* to match AWIPS I default setting
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre>
*
* @author askripsky
@ -66,7 +67,7 @@ public class HydroStationDataManager {
private boolean showPost = true;
private boolean showNoPost = false;
private IGetSortType sortType;
/**
@ -103,7 +104,7 @@ public class HydroStationDataManager {
public ArrayList<HydroStationData> getStationData(IGetSortType sortType) {
ArrayList<HydroStationData> rval = new ArrayList<HydroStationData>();
this.sortType = sortType;
// Verify data is empty
if (stationData == null) {
stationData = new ArrayList<HydroStationData>();
@ -123,8 +124,8 @@ public class HydroStationDataManager {
hydroStationQuery.append(getWhereClause());
try {
List<Object[]> data = DirectDbQuery.executeQuery(hydroStationQuery
.toString(), HydroConstants.IHFS,
List<Object[]> data = DirectDbQuery.executeQuery(
hydroStationQuery.toString(), HydroConstants.IHFS,
DirectDbQuery.QueryLanguage.SQL);
for (Object[] currData : data) {
@ -141,10 +142,11 @@ public class HydroStationDataManager {
StringBuffer rval = new StringBuffer();
if (showPost) {
if (showNoPost)
if (showNoPost) {
rval.append(" WHERE post IS NOT NULL ");
else
} else {
rval.append(" WHERE post = 1 ");
}
} else if (showNoPost) {
rval.append(" WHERE post = 0 ");
} else {
@ -176,15 +178,12 @@ public class HydroStationDataManager {
/* specify the lat-lon filter if it is enabled */
if (filterByLatLon) {
rval
.append(String
.format(
" AND ((lat > %f) AND (lat < %f)) AND ((lon > %f) AND (lon < %f)) ",
latCenter - latOffset, latCenter
+ latOffset, lonCenter - lonOffset,
lonCenter + lonOffset));
rval.append(String
.format(" AND ((lat > %f) AND (lat < %f)) AND ((lon > %f) AND (lon < %f)) ",
latCenter - latOffset, latCenter + latOffset,
lonCenter - lonOffset, lonCenter + lonOffset));
}
/* Determine sort selection criteria */
String sort = sortType.getSortType();
if (sort.compareTo("State,County") == 0) {
@ -195,40 +194,40 @@ public class HydroStationDataManager {
{
rval.append(" order by lid");
}
return rval.toString();
}
/**
* Check if the lid passed in is a river site or not.
*
* @param lid
* The lid to check
* @return
* True if site is a river site
* The lid to check
* @return True if site is a river site
*/
public boolean isRiverSite(String lid) {
boolean riverSite = false;
String query = "select count(*) from riverstat where lid = '" + lid + "'";
String query = "select count(*) from riverstat where lid = '" + lid
+ "'";
List<Object[]> rs;
try {
rs = DirectDbQuery.executeQuery(query, HydroConstants.IHFS, QueryLanguage.SQL);
rs = DirectDbQuery.executeQuery(query, HydroConstants.IHFS,
QueryLanguage.SQL);
if ((rs != null) && (rs.size() > 0)) {
long num = (Long) rs.get(0)[0];
long num = ((Number) rs.get(0)[0]).longValue();
if (num > 0) {
riverSite = true;
}
}
} catch (VizException e) {
System.err.println("Error querying riverstat table");
}
}
return riverSite;
}
/**
* @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.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 {
protected static final String HARDCODED = "HARDCODED";
@ -121,8 +136,7 @@ public abstract class ColorManager {
rval.add(data);
ColorThreshold[] thresholds = arr.getThresholds();
for (int i = 0; i < thresholds.length; ++i) {
ColorThreshold ct = thresholds[i];
for (ColorThreshold ct : thresholds) {
double tmpVal = ct.getValue();
data = new ColorScaleData();
// 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();
} else if (description.equals(entry.getValue()
.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;
}
}
@ -201,10 +215,11 @@ public abstract class ColorManager {
rval = entry.getValue().getColor_use_display_string();
break;
}
} else if (dataType.equals(entry.getValue().getColor_use_display_string())) {
// if the display string is passed in just return it
rval = dataType;
break;
} else if (dataType.equals(entry.getValue()
.getColor_use_display_string())) {
// if the display string is passed in just return it
rval = dataType;
break;
}
}
@ -391,7 +406,7 @@ public abstract class ColorManager {
colorValue.setUserID((String) oa[0]);
colorValue.setApplicationName((String) oa[1]);
colorValue.setColorUseName((String) oa[2]);
colorValue.setDuration(((Integer) oa[3]) / 3600);
colorValue.setDuration(((Number) oa[3]).intValue() / 3600);
colorValue.setThresholdValue((Double) oa[4]);
colorValue.setThresholdUnit((String) oa[5]);
colorValue.setColorName((String) oa[6]);

View file

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

View file

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

View file

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

View file

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

View file

@ -32,7 +32,7 @@ import com.raytheon.viz.hydrocommon.HydroConstants;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 14, 2008 1697 askripsky Initial creation
*
* Jul 21, 2015 4500 rjpeter Use Number in blind cast.
* </pre>
*
* @author askripsky
@ -112,7 +112,8 @@ public class LowWaterStatementData {
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) {
setStatement((String) data.getColumn(dataMap.get("statement")));

View file

@ -25,17 +25,17 @@ import java.util.Date;
* TODO Add Description
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* 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>
*
*
* @author mpduff
* @version 1.0
* @version 1.0
*/
public class Observation {
@ -68,12 +68,12 @@ public class Observation {
* Obstime
*/
private Date obstime;
/**
* Basistime
*/
private Date basisTime;
/**
* Data value
*/
@ -98,29 +98,29 @@ public class Observation {
* Product ID
*/
private String productId;
public Observation() {
}
public Observation(Object[] oa) {
setLid((String)oa[0]);
setPe((String)oa[1]);
setDur((Integer)oa[2]);
setTs((String)oa[3]);
setExtremum((String)oa[4]);
setObstime((Date)oa[5]);
setValue((Double)oa[6]);
setLid((String) oa[0]);
setPe((String) oa[1]);
setDur(((Number) oa[2]).intValue());
setTs((String) oa[3]);
setExtremum((String) oa[4]);
setObstime((Date) oa[5]);
setValue((Double) oa[6]);
if (oa[7] != null) {
setShefQualCode((String)oa[7]);
setShefQualCode((String) oa[7]);
}
if (oa[8] != null) {
setQualityCode((Integer)oa[8]);
setQualityCode(((Number) oa[8]).intValue());
}
if (oa[9] != null) {
setRevision((Integer)oa[9]);
setRevision(((Number) oa[9]).intValue());
}
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
this.productId = productId;
}
/**
* @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) {
this.basisTime = basisTime;
@ -306,7 +318,7 @@ public class Observation {
sb.append("Value = " + getValue() + "\n");
sb.append("Obstime = " + getObstime() + "\n");
sb.append("Quality Code = " + getQualityCode() + "\n");
return sb.toString();
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -59,7 +59,7 @@
</property>
<property
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>
</product>
</extension>

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.common.dataplugin.redbook;
import java.io.File;
import java.util.HashMap;
import javax.xml.bind.JAXB;
@ -28,6 +27,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
/**
@ -41,6 +43,8 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
* Nov 04, 2013 2361 njensen Use JAXB instead of SerializationUtil
* Jun 25, 2015 4512 mapeters Refactored from viz.redbook, made mapping
* private, added getValue() and addEntry()
* Jul 21, 2015 4512 mapeters Check for redbookMapping.xml in common_static.configured,
* then cave_static.base
*
* </pre>
*
@ -51,6 +55,9 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
@XmlAccessorType(XmlAccessType.FIELD)
public class RedbookWMOMap {
private static final String FILE_PATH = "redbook" + IPathManager.SEPARATOR
+ "redbookMapping.xml";
@XmlAccessorType(XmlAccessType.FIELD)
public static class Info {
public String name;
@ -70,9 +77,26 @@ public class RedbookWMOMap {
}
public static RedbookWMOMap load() {
File file = PathManagerFactory.getPathManager().getStaticFile(
"redbook/redbookMapping.xml");
RedbookWMOMap map = JAXB.unmarshal(file, RedbookWMOMap.class);
IPathManager pathMgr = PathManagerFactory.getPathManager();
/*
* Check common_static.configured first, as it is now being saved there.
* If not found, check cave_static.base, where it used to be stored (in
* the future cave_static should no longer need to be checked).
*/
LocalizationContext context = pathMgr.getContext(
LocalizationContext.LocalizationType.COMMON_STATIC,
LocalizationContext.LocalizationLevel.CONFIGURED);
LocalizationFile locFile = pathMgr.getLocalizationFile(context,
FILE_PATH);
if (locFile == null || !locFile.exists()) {
context = pathMgr.getContext(
LocalizationContext.LocalizationType.CAVE_STATIC,
LocalizationContext.LocalizationLevel.BASE);
locFile = pathMgr.getLocalizationFile(context, FILE_PATH);
}
RedbookWMOMap map = JAXB.unmarshal(locFile.getFile(),
RedbookWMOMap.class);
// add ability for comma separated values in xml file
RedbookWMOMap secondMap = new RedbookWMOMap();

View file

@ -396,10 +396,10 @@ THIS IS A TEST MESSAGE. ##
######## GENERATE PATHCAST OR CITIES LIST #########
###################################################
#if(${stormType} == "line")
#set($pathcastLead = "severe thunderstorms")
#set($pathcastLead = "Severe thunderstorms")
#set($otherLead = "these severe thunderstorms")
#else
#set($pathcastLead = "this severe thunderstorm")
#set($pathcastLead = "This severe thunderstorm")
#set($otherLead = "this severe thunderstorm")
#end
#if(${list.contains(${bullets}, "pathcast")})

View file

@ -47,12 +47,12 @@
#set($reportType1 = "severe thunderstorms were")
#set($reportType2 = "these storms were")
#set($reportType = "severe thunderstorms are")
#set($pathcastLead = "these severe storms")
#set($pathcastLead = "These severe storms")
#else
#set($reportType1 = "a severe thunderstorm was")
#set($reportType2 = "this storm was")
#set($reportType = "a severe thunderstorm is")
#set($pathcastLead = "this severe storm")
#set($pathcastLead = "This severe storm")
#end
#elseif(${phenomena}=="TO")
#set($eventType = "TORNADO")
@ -65,12 +65,12 @@
#set($reportType = "a tornado was reported")
#set($reportType1 = "line of tornado producing storms")
#set($reportType2 = "these tornado producing storms were")
#set($pathcastLead = "these tornadic storms")
#set($pathcastLead = "These tornadic storms")
#else
#set($reportType = "a line of tornado producing storms was reported")
#set($reportType1 = "tornado")
#set($reportType2 = "this tornadic storm was")
#set($pathcastLead = "this tornado")
#set($pathcastLead = "This tornado")
#end
#end
######################################################
@ -395,7 +395,7 @@ ${dateUtil.format(${now}, ${timeFormat.header}, ${localtimezone})}
#end
#if(${action}=="CANCON" || ${action}=="CON" || ${action}=="COR" || ${CORCAN}=="true")
...A ${eventType} WARNING REMAINS IN EFFECT UNTIL #headlineExpire(${dateUtil},${expire},${timeFormat},${localtimezone},${secondtimezone}) for ##
...A ${eventType} WARNING REMAINS IN EFFECT UNTIL #headlineExpire(${dateUtil},${expire},${timeFormat},${localtimezone},${secondtimezone}) FOR ##
#headlineLocList(${areas} true true true false "ALL")...
########### END NEW HEADLINE CODE ####################
#set($reportType = "!** BASIS FOR WARNING **!")
@ -406,16 +406,16 @@ ${dateUtil.format(${now}, ${timeFormat.header}, ${localtimezone})}
#if(${stormType} == "line")
#set($reportType = "severe thunderstorms capable of producing tornadoes were")
#set($reportType2 = "these dangerous storms were")
#set($pathcastLead = "these dangerous storms")
#set($pathcastLead = "These dangerous storms")
#else
#set($reportType = "a severe thunderstorm capable of producing a tornado was")
#set($reportType2 = "this dangerous storm was")
#set($pathcastLead = "this dangerous storm")
#set($pathcastLead = "This dangerous storm")
#end
#elseif(${list.contains(${bullets}, "dopplerSquallTOR")})
#set($reportType = "a severe squall line capable of producing both tornadoes and extensive straight line wind damage was")
#set($reportType2 = "these dangerous storms were")
#set($pathcastLead = "these dangerous storms")
#set($pathcastLead = "These dangerous storms")
#elseif(${list.contains(${bullets}, "confirmedDopplerTOR")})
#set($torTag = "observed")
#set($torHazard = "damaging tornado")
@ -483,11 +483,11 @@ ${dateUtil.format(${now}, ${timeFormat.header}, ${localtimezone})}
#if(${stormType} == "line")
#set($reportType = "severe thunderstorms capable of producing a tornado were")
#set($reportType2 = "a tornado may develop at any time. these dangerous storms were")
#set($pathcastLead = "these dangerous storms")
#set($pathcastLead = "These dangerous storms")
#else
#set($reportType = "a severe thunderstorm capable of producing a tornado was")
#set($reportType2 = "a tornado may develop at any time. This dangerous storm was")
#set($pathcastLead = "this dangerous storm")
#set($pathcastLead = "This dangerous storm")
#end
#elseif(${list.contains(${bullets}, "dopplerSVR")})
#set($reportType = "${reportType1}")
@ -528,10 +528,10 @@ ${dateUtil.format(${now}, ${timeFormat.header}, ${localtimezone})}
#set($torThreat = "<L>TORNADO DAMAGE THREAT...CONSIDERABLE</L>")
#set($pdstor = "This is a PARTICULARLY DANGEROUS SITUATION.")
#if(${stormType} == "line")
#set($pathcastLead = "these tornadic storms")
#set($pathcastLead = "These tornadic storms")
#set($moveLead = " Doppler radar showed these tornadic storms moving")
#else
#set($pathcastLead = "the tornado")
#set($pathcastLead = "The tornado")
#set($moveLead = " Doppler radar showed this tornado moving")
#end
#set($preAmbleTOR = "To repeat, a large, extremely dangerous and potentially deadly tornado is ${torground}. To protect your life, ")
@ -548,10 +548,10 @@ ${dateUtil.format(${now}, ${timeFormat.header}, ${localtimezone})}
#set($reportType = "a confirmed large and destructive tornado was")
#set($pdstor = "TORNADO EMERGENCY for !** EDIT LOCATION(S) **!. Take cover now! This is a PARTICULARLY DANGEROUS SITUATION.")
#if(${stormType} == "line")
#set($pathcastLead = "these tornadic storms")
#set($pathcastLead = "These tornadic storms")
#set($moveLead = " doppler radar showed these tornadic storms moving")
#else
#set($pathcastLead = "the tornado")
#set($pathcastLead = "The tornado")
#set($moveLead = " Doppler radar showed this tornado moving")
#end
#if(${list.contains(${bullets}, "dopplerTOR")})
@ -866,7 +866,7 @@ ${dateUtil.format(${now}, ${timeFormat.header}, ${localtimezone})}
THIS IS A TEST MESSAGE. ##
#end
#thirdBullet(${dateUtil},${event},${timeFormat},${localtimezone},${secondtimezone})...##
#thirdBullet(${dateUtil},${event},${timeFormat},${localtimezone},${secondtimezone}), #
${reportType} located ##
##Many of the variables passed below are controlled by config.vm
#if(${stormType} == "line")

View file

@ -211,7 +211,7 @@ ${area.name}...
## Section for end of warning statements. Replaced default wording with
## a better defined reason for the end to the warning.
#######################################################################
#set($canwarning = "The ${eventType} !** WEAKENED / MOVED OUT OF THE WARNED AREA **! and no longer ${pose} a significant threat to boaters.")
#set($canwarning = "The ${eventType} !** weakened / moved out of the warned area **! and no longer ${pose} a significant threat to boaters.")
#if(${list.contains(${bullets}, "weakenedWarnEnd")})
#set($canwarning = "The ${eventType} weakened and no longer ${pose} a significant threat to boaters.")
#end

View file

@ -272,10 +272,10 @@ This is a test message. ##
#set($torHazard = "damaging tornado")
#set($confirmed = "confirmed ")
#if(${stormType} == "line")
#set($pathcastLead = "these tornadic storms")
#set($pathcastLead = "These tornadic storms")
#set($moveLead = " doppler radar showed these tornadic storms moving")
#else
#set($pathcastLead = "the tornado")
#set($pathcastLead = "The tornado")
#set($moveLead = " doppler radar showed this tornado moving")
#end
#set($preAmble = "to repeat, a large, extremely dangerous and potentially deadly tornado is on the ground. to protect your life, ")

View file

@ -158,7 +158,7 @@ ${dateUtil.format(${now}, ${timeFormat.header}, ${localtimezone})}
## Section to produce areas affected by statement
#######################################################################
#if(${list.contains(${bullets}, "noHead")})
A MARINE WEATHER STATEMENT HAS BEEN ISSUED FOR THE FOLLOWING AREAS...
A Marine Weather Statement has been issued for the following areas...
#else
#capitalize(${headerType1} "ALL")

View file

@ -97,7 +97,7 @@ THIS IS A TEST MESSAGE. ##
#end
#if(${list.contains(${bullets}, "leadingRain")})
#set($eventType = "the leading edge of an area of rain")
#set($pathcastLead = "the rain will begin at ")
#set($pathcastLead = "The rain will begin at ")
#set($otherLead = "the rain")
#set($reportType2 = "${otherLead} was")
#end