Issue #2581 remove LSR dataURI column
Change-Id: I9d5ddc8346e6b9ac0ec56d09d50b6b19a5bc682f Former-commit-id:1d91d67a5b
[formerly6188356e72
] [formerlyfa674baf89
] [formerlye037c179fe
[formerlyfa674baf89
[formerly 88124207249673c3bf29915b6f6318bd2397ecd5]]] Former-commit-id:e037c179fe
Former-commit-id: d4f63bdd454d528603209bfccf323090b3ffb746 [formerly34c1af18a7
] Former-commit-id:4478983895
This commit is contained in:
parent
35331459c0
commit
61e9833351
3 changed files with 57 additions and 62 deletions
42
deltaScripts/14.2.1/dropLSRdataURI.sh
Normal file
42
deltaScripts/14.2.1/dropLSRdataURI.sh
Normal 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"
|
|
@ -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
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -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";
|
||||
|
|
|
@ -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
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author jkorman
|
||||
* @version 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
public class LocalStormReportDao extends PointDataPluginDao<LocalStormReport> {
|
||||
|
||||
/**
|
||||
* 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" };
|
||||
|
|
Loading…
Add table
Reference in a new issue