From 6f585b897f3071ac6860a969ddcb44ce2cd2ec60 Mon Sep 17 00:00:00 2001 From: Tom Gurney Date: Fri, 5 Feb 2016 11:40:49 -0600 Subject: [PATCH] Omaha #5310 Drop dataURI column from bufrncwf Change-Id: Ic6290db7b3f615fe188b2399d7466d145967ba63 Former-commit-id: ec59ebd66b91d39117b405f01cccf7bfc006dac1 --- .../uf/viz/ncwf/rsc/NcwfMovementResource.java | 30 ++++----- .../uf/viz/ncwf/rsc/NcwfPolygonResource.java | 10 +-- .../DR5310/alter_bufrncwf_drop_datauri.sh | 19 ++++++ .../common/dataplugin/bufrncwf/BUFRncwf.java | 20 +----- .../uf/edex/plugin/bufrncwf/BUFRncwfDao.java | 61 +++---------------- 5 files changed, 48 insertions(+), 92 deletions(-) create mode 100755 deltaScripts/16.2.2/DR5310/alter_bufrncwf_drop_datauri.sh diff --git a/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java b/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java index 3504c84349..f5013b6f81 100644 --- a/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java +++ b/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java @@ -29,8 +29,6 @@ import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.common.dataplugin.bufrncwf.BUFRncwf; import com.raytheon.uf.common.dataplugin.bufrncwf.NCWFFeature; -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; @@ -54,8 +52,9 @@ import com.vividsolutions.jts.geom.Coordinate; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 16, 2009 bsteffen Initial creation - * Jul 24, 2014 3429 mapeters Updated deprecated drawLine() calls. + * Sep 16, 2009 bsteffen Initial creation + * Jul 24, 2014 3429 mapeters Updated deprecated drawLine() calls. + * Feb 04, 2016 5310 tgurney Remove dependency on dataURI * * * @@ -168,7 +167,8 @@ public class NcwfMovementResource extends // Draw the body of the arrow DrawableLine line = new DrawableLine(); line.setCoordinates(centerPixel[0], centerPixel[1], centerPixel[2]); - line.addPoint(or_centerPixel[0], or_centerPixel[1], or_centerPixel[2]); + line.addPoint(or_centerPixel[0], or_centerPixel[1], + or_centerPixel[2]); line.basics.color = color; line.width = 1.5f; lines.add(line); @@ -181,8 +181,8 @@ public class NcwfMovementResource extends } private DrawableLine createArrowHead(IGraphicsTarget target, - double[] center, - Double length, Double dir, RGB color) throws VizException { + double[] center, Double length, Double dir, RGB color) + throws VizException { double[] pointPixel = target.getPointOnCircle(center[0], center[1], center[2], length, dir + 210); @@ -191,8 +191,7 @@ public class NcwfMovementResource extends line.setCoordinates(pointPixel[0], pointPixel[1], pointPixel[2]); line.addPoint(center[0], center[1], center[2]); double[] pointPixel2 = target.getPointOnCircle(center[0], center[1], - center[2], - length, dir + 150); + center[2], length, dir + 150); line.addPoint(pointPixel2[0], pointPixel2[1], pointPixel2[2]); line.basics.color = color; line.width = 1.5f; @@ -209,21 +208,13 @@ public class NcwfMovementResource extends if (!recordsMap.containsKey(displayedDataTime)) { recordsMap.put(displayedDataTime, new ArrayList()); } - RequestConstraint constraint = new RequestConstraint(); - constraint.setConstraintType(ConstraintType.IN); - - for (BUFRncwf r : records) { - - constraint.addToConstraintValueList(r.getDataURI()); - } - Map constraints = new HashMap(); - constraints.put("dataURI", constraint); // Request the point data PointDataContainer pdc = PointDataRequest.requestPointDataAllLevels( displayedDataTime, resourceData.getMetadataMap().get("pluginName") - .getConstraintValue(), parameters, null, constraints); + .getConstraintValue(), parameters, null, + resourceData.getMetadataMap()); for (int uriCounter = 0; uriCounter < pdc.getAllocatedSz(); uriCounter++) { PointDataView pdv = pdc.readRandom(uriCounter); @@ -253,6 +244,7 @@ public class NcwfMovementResource extends this.recordsToParse.get(displayedDataTime).clear(); } + @Override protected void addRecord(BUFRncwf obj) { if (!recordsToParse.containsKey(obj.getDataTime())) { recordsToParse.put(obj.getDataTime(), new ArrayList()); diff --git a/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfPolygonResource.java b/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfPolygonResource.java index 92e2fa5fb4..cb012eb26c 100644 --- a/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfPolygonResource.java +++ b/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfPolygonResource.java @@ -53,7 +53,8 @@ import com.vividsolutions.jts.geom.GeometryFactory; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 16, 2009 bsteffen Initial creation + * Sep 16, 2009 bsteffen Initial creation + * Feb 04, 2016 5310 tgurney Remove dependency on dataURI * * * @@ -175,14 +176,12 @@ public class NcwfPolygonResource extends DataTime dataTime = null; for (BUFRncwf r : records) { - constraint.addToConstraintValueList(r.getDataURI()); dataTime = r.getDataTime(); } - Map constraints = new HashMap(); - constraints.put("dataURI", constraint); PointDataContainer pdc = PointDataRequest.requestPointDataAllLevels( dataTime, resourceData.getMetadataMap().get("pluginName") - .getConstraintValue(), parameters, null, constraints); + .getConstraintValue(), parameters, null, + resourceData.getMetadataMap()); for (int uriCounter = 0; uriCounter < pdc.getAllocatedSz(); uriCounter++) { PointDataView pdv = pdc.readRandom(uriCounter); @@ -206,6 +205,7 @@ public class NcwfPolygonResource extends } + @Override protected void addRecord(BUFRncwf obj) { DataTime time = calculateBinTime(obj.getDataTime()); diff --git a/deltaScripts/16.2.2/DR5310/alter_bufrncwf_drop_datauri.sh b/deltaScripts/16.2.2/DR5310/alter_bufrncwf_drop_datauri.sh new file mode 100755 index 0000000000..2e90ff1203 --- /dev/null +++ b/deltaScripts/16.2.2/DR5310/alter_bufrncwf_drop_datauri.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# DR #5310 - This script drops dataURI column from bufrncwf table and adds a +# new multi-column unique constraint + +TABLE=bufrncwf + +PSQL="/awips2/psql/bin/psql" + +echo "INFO: Altering table ${TABLE}" + +${PSQL} -U awips -d metadata << EOF +begin transaction; +alter table ${TABLE} + drop constraint if exists uk_${TABLE}_datauri_fields, + drop column if exists datauri, + add constraint uk_${TABLE}_datauri_fields unique + (reftime, latitude, longitude, stationid); +commit transaction; +EOF diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.bufrncwf/src/com/raytheon/uf/common/dataplugin/bufrncwf/BUFRncwf.java b/edexOsgi/com.raytheon.uf.common.dataplugin.bufrncwf/src/com/raytheon/uf/common/dataplugin/bufrncwf/BUFRncwf.java index 7975f12d57..e605eb41ce 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.bufrncwf/src/com/raytheon/uf/common/dataplugin/bufrncwf/BUFRncwf.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.bufrncwf/src/com/raytheon/uf/common/dataplugin/bufrncwf/BUFRncwf.java @@ -19,9 +19,6 @@ **/ package com.raytheon.uf.common.dataplugin.bufrncwf; -import javax.persistence.Access; -import javax.persistence.AccessType; -import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.SequenceGenerator; @@ -60,6 +57,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Oct 15, 2013 2361 njensen Remove XML annotations and IDecoderGettable * Jul 23, 2015 4360 rferrel Add name to unique constraint. + * Feb 04, 2016 5310 tgurney Drop dataURI column and update unique constraint. * * * @@ -68,7 +66,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; */ @Entity @SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "bufrncwfseq") -@Table(name = "bufrncwf", uniqueConstraints = { @UniqueConstraint(name = "uk_bufrncwf_datauri_fields", columnNames = { "dataURI" }) }) +@Table(name = "bufrncwf", uniqueConstraints = { @UniqueConstraint(name = "uk_bufrncwf_datauri_fields", columnNames = { + "refTime", "latitude", "longitude", "stationId" }) }) /* * Both refTime and forecastTime are included in the refTimeIndex since * forecastTime is unlikely to be used. @@ -224,29 +223,16 @@ public class BUFRncwf extends PersistablePluginDataObject implements return location; } - /** - * - */ @Override public PointDataView getPointDataView() { return pointDataView; } - /** - * - */ @Override public void setPointDataView(PointDataView pointDataView) { this.pointDataView = pointDataView; } - @Override - @Column - @Access(AccessType.PROPERTY) - public String getDataURI() { - return super.getDataURI(); - } - @Override public String getPluginName() { return "bufrncwf"; diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrncwf/src/com/raytheon/uf/edex/plugin/bufrncwf/BUFRncwfDao.java b/edexOsgi/com.raytheon.uf.edex.plugin.bufrncwf/src/com/raytheon/uf/edex/plugin/bufrncwf/BUFRncwfDao.java index 67672a6b31..8b7096da35 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.bufrncwf/src/com/raytheon/uf/edex/plugin/bufrncwf/BUFRncwfDao.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrncwf/src/com/raytheon/uf/edex/plugin/bufrncwf/BUFRncwfDao.java @@ -19,80 +19,39 @@ **/ package com.raytheon.uf.edex.plugin.bufrncwf; -import java.util.List; - import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.bufrncwf.BUFRncwf; -import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.pointdata.PointDataPluginDao; /** - * TODO Add Description + * DAO for BUFRncwf * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Aug 17, 2009            jkorman     Initial creation
- *
+ * Feb 04, 2016 5310       tgurney     Remove dead code
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class BUFRncwfDao extends PointDataPluginDao { - /** - * Creates a new ReccoDao - * @throws PluginException + * Creates a new BUFRncwfDao + * + * @throws PluginException */ public BUFRncwfDao(String pluginName) throws PluginException { super(pluginName); } - /** - * Retrieves an bufrua report using the datauri . - * - * @param dataURI - * The dataURI to match against. - * @return The report record if it exists. - */ - public BUFRncwf queryByDataURI(String dataURI) { - BUFRncwf report = null; - List obs = null; - try { - obs = queryBySingleCriteria("dataURI", dataURI); - } catch (DataAccessLayerException e) { - e.printStackTrace(); - } - if((obs != null)&&(obs.size() > 0)) { - report = (BUFRncwf) obs.get(0); - } - return report; - } - - /** - * Queries for to determine if a given data uri exists on the bufrua 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.bufrncwfua where datauri='" - + dataUri + "';"; - - Object[] results = executeSQLQuery(sql); - - return results; - } - @Override public String[] getKeysRequiredForFileName() { return new String[] { "dataTime.refTime" };