diff --git a/deltaScripts/14.2.1/dropLSRdataURI.sh b/deltaScripts/14.2.1/dropLSRdataURI.sh new file mode 100644 index 0000000000..fb9bb06d5f --- /dev/null +++ b/deltaScripts/14.2.1/dropLSRdataURI.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# DR #2581 - this update script will drop the dataURI column from the lsr table + +PSQL="/awips2/psql/bin/psql" + +# takes one arg: a table name +# drops the datauri constraint and column if they exist +function dropDatauri { + echo "INFO: Dropping DataURI column from $1" + ${PSQL} -U awips -d metadata -c "ALTER TABLE $1 DROP CONSTRAINT IF EXISTS ${1}_datauri_key;" + ${PSQL} -U awips -d metadata -c "ALTER TABLE $1 DROP COLUMN IF EXISTS datauri;" + if [ $? -ne 0 ]; then + echo "ERROR: Failed to drop dataURI column for $table" + echo "FATAL: The update has failed." + exit 1 + fi +} + + + +# takes three args: table, constraint name, unique columns +# will first drop the constraint if it exists and then adds it back, this is +# fairly inefficient if it does exist but operationally it won't exist and for +# testing this allows the script to be run easily as a noop. +function dropDatauriAndAddConstraint { + dropDatauri $1 + ${PSQL} -U awips -d metadata -c "ALTER TABLE $1 DROP CONSTRAINT IF EXISTS $2;" + ${PSQL} -U awips -d metadata -c "ALTER TABLE $1 ADD CONSTRAINT $2 UNIQUE $3;" + if [ $? -ne 0 ]; then + echo "ERROR: Failed to add new unique constraint for $table" + echo "FATAL: The update has failed." + exit 1 + fi + ${PSQL} -U awips -d metadata -c "VACUUM FULL ANALYZE $1" +} + +echo "INFO: Dropping dataURI columns." + +dropDatauriAndAddConstraint lsr lsr_latitude_longitude_stationId_reftime_forecasttime_eventtype_key "(latitude, longitude, stationId, reftime, forecasttime, eventtype)" + + +echo "INFO: LSR dataURI column dropped successfully" diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.lsr/src/com/raytheon/uf/common/dataplugin/lsr/LocalStormReport.java b/edexOsgi/com.raytheon.uf.common.dataplugin.lsr/src/com/raytheon/uf/common/dataplugin/lsr/LocalStormReport.java index e6eeb3d455..eb2174a557 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.lsr/src/com/raytheon/uf/common/dataplugin/lsr/LocalStormReport.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.lsr/src/com/raytheon/uf/common/dataplugin/lsr/LocalStormReport.java @@ -30,8 +30,6 @@ import javax.measure.quantity.Velocity; import javax.measure.unit.NonSI; import javax.measure.unit.SI; import javax.measure.unit.Unit; -import javax.persistence.Access; -import javax.persistence.AccessType; import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; @@ -70,6 +68,7 @@ import com.vividsolutions.jts.geom.Geometry; * PluginDataObject. * Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Oct 14, 2013 2361 njensen Removed XML annotations and IDecoderGettable + * Dec 10, 2013 2581 njensen Removed dataURI column * * * @@ -78,7 +77,9 @@ import com.vividsolutions.jts.geom.Geometry; */ @Entity @SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "lsrseq") -@Table(name = "lsr", uniqueConstraints = { @UniqueConstraint(columnNames = { "dataURI" }) }) +@Table(name = "lsr", uniqueConstraints = { @UniqueConstraint(columnNames = { + "latitude", "longitude", "stationId", "refTime", "forecastTime", + "eventType" }) }) /* * Both refTime and forecastTime are included in the refTimeIndex since * forecastTime is unlikely to be used. @@ -116,13 +117,12 @@ public class LocalStormReport extends PersistablePluginDataObject implements private LSREventType eventType; // Correction indicator from wmo header - @DataURI(position = 2) @Column @DynamicSerializeElement private String corIndicator; @Embedded - @DataURI(position = 3, embedded = true) + @DataURI(position = 2, embedded = true) @DynamicSerializeElement private SurfaceObsLocation location; @@ -504,13 +504,6 @@ public class LocalStormReport extends PersistablePluginDataObject implements return sb.toString(); } - @Override - @Column - @Access(AccessType.PROPERTY) - public String getDataURI() { - return super.getDataURI(); - } - @Override public String getPluginName() { return "lsr"; diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/LocalStormReportDao.java b/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/LocalStormReportDao.java index 124143ac23..9fb341fd4c 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/LocalStormReportDao.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/LocalStormReportDao.java @@ -19,78 +19,38 @@ **/ package com.raytheon.uf.edex.plugin.lsr; -import java.util.List; - import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.lsr.LocalStormReport; -import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.pointdata.PointDataPluginDao; /** - * + * DAO for Local Storm Reports * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Oct 1, 2009            jkorman     Initial creation
- *
+ * Oct 01, 2009            jkorman     Initial creation
+ * Dec 10, 2013 2581       njensen     Removed unused methods
+ * 
  * 
- * + * * @author jkorman - * @version 1.0 + * @version 1.0 */ public class LocalStormReportDao extends PointDataPluginDao { /** * Creates a new ObsStationDao - * @throws PluginException + * + * @throws PluginException */ public LocalStormReportDao(String pluginName) throws PluginException { super(pluginName); } - /** - * Retrieves an sfcobs report using the datauri . - * - * @param dataURI - * The dataURI to match against. - * @return The report record if it exists. - */ - public LocalStormReport queryByDataURI(String dataURI) { - LocalStormReport report = null; - List obs = null; - try { - obs = queryBySingleCriteria("dataURI", dataURI); - } catch (DataAccessLayerException e) { - e.printStackTrace(); - } - if ((obs != null) && (obs.size() > 0)) { - report = (LocalStormReport) obs.get(0); - } - return report; - } - - /** - * Queries for to determine if a given data uri exists on the sfcobs 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.lsr where datauri='" - + dataUri + "';"; - - Object[] results = executeSQLQuery(sql); - - return results; - } - @Override public String[] getKeysRequiredForFileName() { return new String[] { "dataTime.refTime" };