Issue #2581 remove LSR dataURI column

Change-Id: I9d5ddc8346e6b9ac0ec56d09d50b6b19a5bc682f

Former-commit-id: 1d91d67a5b [formerly 6188356e72] [formerly fa674baf89] [formerly 1d91d67a5b [formerly 6188356e72] [formerly fa674baf89] [formerly e037c179fe [formerly fa674baf89 [formerly 88124207249673c3bf29915b6f6318bd2397ecd5]]]]
Former-commit-id: e037c179fe
Former-commit-id: 61e9833351 [formerly 4478983895] [formerly d4f63bdd454d528603209bfccf323090b3ffb746 [formerly 34c1af18a7]]
Former-commit-id: 7568cea11c2e09ab775871667eabd4d94ff75e40 [formerly b5450572f2]
Former-commit-id: e548e47239
This commit is contained in:
Nate Jensen 2013-12-10 18:27:33 -06:00
parent 04b0c4cec1
commit 74476aa385
3 changed files with 57 additions and 62 deletions

View file

@ -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"

View file

@ -30,8 +30,6 @@ import javax.measure.quantity.Velocity;
import javax.measure.unit.NonSI; import javax.measure.unit.NonSI;
import javax.measure.unit.SI; import javax.measure.unit.SI;
import javax.measure.unit.Unit; import javax.measure.unit.Unit;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
import javax.persistence.Entity; import javax.persistence.Entity;
@ -70,6 +68,7 @@ import com.vividsolutions.jts.geom.Geometry;
* PluginDataObject. * PluginDataObject.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Oct 14, 2013 2361 njensen Removed XML annotations and IDecoderGettable * Oct 14, 2013 2361 njensen Removed XML annotations and IDecoderGettable
* Dec 10, 2013 2581 njensen Removed dataURI column
* *
* </pre> * </pre>
* *
@ -78,7 +77,9 @@ import com.vividsolutions.jts.geom.Geometry;
*/ */
@Entity @Entity
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "lsrseq") @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 * Both refTime and forecastTime are included in the refTimeIndex since
* forecastTime is unlikely to be used. * forecastTime is unlikely to be used.
@ -116,13 +117,12 @@ public class LocalStormReport extends PersistablePluginDataObject implements
private LSREventType eventType; private LSREventType eventType;
// Correction indicator from wmo header // Correction indicator from wmo header
@DataURI(position = 2)
@Column @Column
@DynamicSerializeElement @DynamicSerializeElement
private String corIndicator; private String corIndicator;
@Embedded @Embedded
@DataURI(position = 3, embedded = true) @DataURI(position = 2, embedded = true)
@DynamicSerializeElement @DynamicSerializeElement
private SurfaceObsLocation location; private SurfaceObsLocation location;
@ -504,13 +504,6 @@ public class LocalStormReport extends PersistablePluginDataObject implements
return sb.toString(); return sb.toString();
} }
@Override
@Column
@Access(AccessType.PROPERTY)
public String getDataURI() {
return super.getDataURI();
}
@Override @Override
public String getPluginName() { public String getPluginName() {
return "lsr"; return "lsr";

View file

@ -19,15 +19,12 @@
**/ **/
package com.raytheon.uf.edex.plugin.lsr; package com.raytheon.uf.edex.plugin.lsr;
import java.util.List;
import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.lsr.LocalStormReport; import com.raytheon.uf.common.dataplugin.lsr.LocalStormReport;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.pointdata.PointDataPluginDao; import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
/** /**
* * DAO for Local Storm Reports
* *
* <pre> * <pre>
* *
@ -35,7 +32,8 @@ import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 1, 2009 jkorman Initial creation * Oct 01, 2009 jkorman Initial creation
* Dec 10, 2013 2581 njensen Removed unused methods
* *
* </pre> * </pre>
* *
@ -46,51 +44,13 @@ public class LocalStormReportDao extends PointDataPluginDao<LocalStormReport> {
/** /**
* Creates a new ObsStationDao * Creates a new ObsStationDao
*
* @throws PluginException * @throws PluginException
*/ */
public LocalStormReportDao(String pluginName) throws PluginException { public LocalStormReportDao(String pluginName) throws PluginException {
super(pluginName); 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 @Override
public String[] getKeysRequiredForFileName() { public String[] getKeysRequiredForFileName() {
return new String[] { "dataTime.refTime" }; return new String[] { "dataTime.refTime" };