Omaha #5285 Drop dataURI column on tcs
Also fix NPE in TCSResource.paintInternal() when displaying TCS hourly forecast when no data is available. Change-Id: I1321ca567ae47c71661d8414c3d2f96d8ff2352d Former-commit-id: 3044446a32a7dcc22c1617370e5dea6320b4a4cf
This commit is contained in:
parent
5c0a410248
commit
df06c10573
7 changed files with 44 additions and 90 deletions
|
@ -39,8 +39,6 @@ import com.raytheon.uf.common.dataplugin.tcs.Radius;
|
|||
import com.raytheon.uf.common.dataplugin.tcs.TropicalCycloneSummary;
|
||||
import com.raytheon.uf.common.dataplugin.tcs.util.TCSConstants;
|
||||
import com.raytheon.uf.common.dataplugin.tcs.util.TcsUtil;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.pointdata.PointDataContainer;
|
||||
import com.raytheon.uf.common.pointdata.PointDataView;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
@ -82,6 +80,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Sep 17, 2014 3632 bclement fixed index out of bounds
|
||||
* Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling
|
||||
* Nov 30, 2015 5149 bsteffen Rename TcsUtil, update class javadoc
|
||||
* Jan 27, 2016 5285 tgurney Remove dependency on dataURI
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -149,8 +148,10 @@ public class TCSResource extends
|
|||
/ paintProps.getView().getExtent().getWidth();
|
||||
double scale = (PLOT_WIDTH / 2.0) / screenToWorldRatio;
|
||||
|
||||
DataTime dt = resourceData.isHourlyForecast ? new DataTime(paintProps
|
||||
.getDataTime().getRefTime()) : paintProps.getDataTime();
|
||||
DataTime dt = paintProps.getDataTime();
|
||||
if (resourceData.isHourlyForecast && dt != null) {
|
||||
dt = new DataTime(dt.getRefTime());
|
||||
}
|
||||
Collection<TropicalCycloneSummary> toParse = recordsToParse.get(dt);
|
||||
if (toParse != null && toParse.size() > 0) {
|
||||
updateRecords(dt);
|
||||
|
@ -504,18 +505,10 @@ public class TCSResource extends
|
|||
|
||||
protected void updateRecords(DataTime dataTime) throws VizException {
|
||||
PointDataContainer pdc = null;
|
||||
RequestConstraint constraint = new RequestConstraint();
|
||||
Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
|
||||
|
||||
for (TropicalCycloneSummary record : recordsToParse.get(dataTime)) {
|
||||
constraint.setConstraintType(ConstraintType.IN);
|
||||
constraint.addToConstraintValueList(record.getDataURI());
|
||||
}
|
||||
constraints.put(DATAURI, constraint);
|
||||
// Request the point data
|
||||
pdc = PointDataRequest.requestPointDataAllLevels(dataTime, resourceData
|
||||
.getMetadataMap().get("pluginName").getConstraintValue(),
|
||||
getParameters(), null, constraints);
|
||||
getParameters(), null, resourceData.getMetadataMap());
|
||||
|
||||
if (recordsToDisplay.containsKey(dataTime)) {
|
||||
recordsToDisplay.get(dataTime).combine(pdc);
|
||||
|
|
17
deltaScripts/16.2.2/DR5285/alter_tcs_drop_datauri.sh
Executable file
17
deltaScripts/16.2.2/DR5285/alter_tcs_drop_datauri.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
# DR #5285 - This script drops dataURI column from tcs table and adds a new
|
||||
# multi-column unique constraint
|
||||
|
||||
PSQL="/awips2/psql/bin/psql"
|
||||
|
||||
echo "INFO: Altering table tcs"
|
||||
|
||||
${PSQL} -U awips -d metadata << EOF
|
||||
begin transaction;
|
||||
alter table tcs
|
||||
drop constraint if exists uk_tcs_datauri_fields,
|
||||
drop column if exists datauri,
|
||||
add constraint uk_tcs_datauri_fields unique
|
||||
(reftime, producttype, latitude, longitude, stationid);
|
||||
commit transaction;
|
||||
EOF
|
|
@ -22,8 +22,6 @@ package com.raytheon.uf.common.dataplugin.tcs;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
|
@ -64,6 +62,7 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
* Oct 22, 2013 2361 njensen Remove XML annotations
|
||||
* Jul 23, 2014 3410 bclement location changed to floats
|
||||
* Jul 28, 2015 4360 rferrel Named unique constraint. Made productType non-nullable.
|
||||
* Jan 27, 2016 5285 tgurney Remove dataURI column and update unique constraint.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -72,7 +71,8 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "tcsseq")
|
||||
@Table(name = "tcs", uniqueConstraints = { @UniqueConstraint(name = "uk_tcs_datauri_fields", columnNames = { "dataURI" }) })
|
||||
@Table(name = "tcs", uniqueConstraints = { @UniqueConstraint(name = "uk_tcs_datauri_fields", columnNames = {
|
||||
"refTime", "productType", "latitude", "longitude", "stationId" }) })
|
||||
/*
|
||||
* Both refTime and forecastTime are included in the refTimeIndex since
|
||||
* forecastTime is unlikely to be used.
|
||||
|
@ -177,17 +177,6 @@ public class TropicalCycloneSummary extends PersistablePluginDataObject
|
|||
this.wmoHeader = wmoHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the data uri for this observation.
|
||||
*
|
||||
* @param dataURI
|
||||
*/
|
||||
@Override
|
||||
public void setDataURI(String dataURI) {
|
||||
super.setDataURI(dataURI);
|
||||
identifier = dataURI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SurfaceObsLocation getSpatialObject() {
|
||||
return location;
|
||||
|
@ -321,13 +310,6 @@ public class TropicalCycloneSummary extends PersistablePluginDataObject
|
|||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Column
|
||||
@Access(AccessType.PROPERTY)
|
||||
public String getDataURI() {
|
||||
return super.getDataURI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "tcs";
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
-->
|
||||
<pointDataDescription>
|
||||
<parameter name="wmoHeader" numDims="1" type="STRING" />
|
||||
<parameter name="productType" numDims="1" type="STRING" />
|
||||
<parameter name="name" numDims="1" type="STRING" />
|
||||
<parameter name="pressure" numDims="1" type="INT" unit="mbar"/>
|
||||
<parameter name="size" numDims="1" type="INT" />
|
||||
|
@ -35,11 +34,11 @@
|
|||
<parameter name="isTropical" numDims="2" type="INT"/>
|
||||
|
||||
<!--
|
||||
each radius will be stored as such: xxNE xxSE xxSW xxNW
|
||||
each radius will be stored as such: xxNE xxSE xxSW xxNW
|
||||
-->
|
||||
<parameter name="radius64KT" numDims="2" type="INT" unit="mi" />
|
||||
<parameter name="radius50KT" numDims="2" type="INT" unit="mi" />
|
||||
<parameter name="radius34KT" numDims="2" type="INT" unit="mi" />
|
||||
<parameter name="radius12FT" numDims="2" type="INT" unit="mi" />
|
||||
|
||||
</pointDataDescription>
|
||||
</pointDataDescription>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<pointDataDbDescription>
|
||||
<parameter name="dataURI" queryName="dataURI" type="STRING" />
|
||||
</pointDataDbDescription>
|
||||
<parameter name="productType" queryName="productType" type="STRING" />
|
||||
</pointDataDbDescription>
|
||||
|
|
|
@ -19,74 +19,38 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.plugin.tcs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.dataplugin.tcs.TropicalCycloneSummary;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* DAO for TropicalCycloneSummary (TCS)
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 12, 2009 jsanchez Initial creation
|
||||
*
|
||||
* Jan 27, 2016 5285 tgurney Remove dead code
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author jsanchez
|
||||
* @version 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
public class TropicalCycloneSummaryDao extends PointDataPluginDao<TropicalCycloneSummary> {
|
||||
public class TropicalCycloneSummaryDao extends
|
||||
PointDataPluginDao<TropicalCycloneSummary> {
|
||||
/**
|
||||
* Creates a new TropicalCycloneSummaryDao
|
||||
* @throws PluginException
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
public TropicalCycloneSummaryDao(String pluginName) throws PluginException {
|
||||
super(pluginName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an tcs report using the datauri .
|
||||
*
|
||||
* @param dataURI
|
||||
* The dataURI to match against.
|
||||
* @return The report record if it exists.
|
||||
*/
|
||||
public TropicalCycloneSummary queryByDataURI(String dataURI) {
|
||||
TropicalCycloneSummary report = null;
|
||||
List<?> obs = null;
|
||||
try {
|
||||
obs = queryBySingleCriteria("dataURI", dataURI);
|
||||
} catch (DataAccessLayerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if ((obs != null) && (obs.size() > 0)) {
|
||||
report = (TropicalCycloneSummary) obs.get(0);
|
||||
}
|
||||
return report;
|
||||
}
|
||||
/**
|
||||
* Queries for to determine if a given data uri exists on the tcs table.
|
||||
*
|
||||
* @param dataUri
|
||||
* The DataURI to find.
|
||||
* @return An array of objects. If not null, there should only be a single
|
||||
* element.
|
||||
*/
|
||||
public Object[] queryDataUriColumn(final String dataUri) {
|
||||
|
||||
String sql = "select datauri from awips.tcs where datauri='"
|
||||
+ dataUri + "';";
|
||||
|
||||
Object[] results = executeSQLQuery(sql);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getKeysRequiredForFileName() {
|
||||
|
|
|
@ -146,7 +146,6 @@ public abstract class TCSDataAdapter implements TCSConstants {
|
|||
headReport = report;
|
||||
view = getContainer(report).append();
|
||||
view.setString(WMO_HEADER, report.getWmoHeader());
|
||||
view.setString(TYPE, report.getProductType());
|
||||
view.setString(NAME, report.getName());
|
||||
view.setInt(PRESSURE, report.getPressure());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue