Omaha #4360 Updates to ACARSRecord and delta scripts.
Change-Id: I170e3a94fc489a739f27323b19cf3193cd258422 Former-commit-id: b504a90fea6a9077bdc8fb5046277a67a441f5a2
This commit is contained in:
parent
09a64ba7e9
commit
3d3492b140
3 changed files with 88 additions and 19 deletions
20
deltaScripts/16.1.2/DR4360/alterAcarsDataURI.sh
Executable file
20
deltaScripts/16.1.2/DR4360/alterAcarsDataURI.sh
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
# DR #4360 - this update script will alter the dataURI column from acars
|
||||
|
||||
PSQL="/awips2/psql/bin/psql"
|
||||
|
||||
cmdDir=`dirname $0`
|
||||
|
||||
source ${cmdDir}/commonFunctions.sh
|
||||
table=acars
|
||||
|
||||
# table and constraint names form ACARSRecord.
|
||||
echo "INFO: Start update of ${table} dataURI columns."
|
||||
renameConstraint ${table} uk_${table}_datauri_fields
|
||||
|
||||
col=tailNumber
|
||||
echo "INFO: Update ${table}' ${col}"
|
||||
${PSQL} -U awips -d metadata -c "DELETE from ${table} where ${col} is NULL ; "
|
||||
updateNotNullCol ${table} ${col}
|
||||
|
||||
echo "INFO: ${table} dataURI columns updated successfully"
|
48
deltaScripts/16.1.2/DR4360/commonFunctions.sh
Normal file
48
deltaScripts/16.1.2/DR4360/commonFunctions.sh
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Common functions intended to be source by other scripts.
|
||||
|
||||
# takes two args: table, new constraint name
|
||||
# will find table's 'unamed' constraint and if only one exists will rename it.
|
||||
#
|
||||
function renameConstraint {
|
||||
cmd="select constraint_name from information_schema.table_constraints
|
||||
where table_catalog = 'metadata' and table_schema='awips' and constraint_type='UNIQUE' and table_name='$1'; "
|
||||
constraint_name=(`${PSQL} -U awips -d metadata -t -c "$cmd"`)
|
||||
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "ERROR: Failed to obtain 'unnamed' unique constraint on table $1"
|
||||
echo "FATAL: The updae has failes."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cnLen=${#constraint_name[@]}
|
||||
if [ ${cnLen} -eq 0 ] ; then
|
||||
echo "INFO: no unnamed UNIQUE constraint found for table $1"
|
||||
elif [ ${cnLen} -gt 1 ] ; then
|
||||
echo "ERROR: More then one unnamed UNIQUE constraint found for table ${1} (${constraint_name[@]})"
|
||||
echo "FATAL: The update has failed."
|
||||
exit 1
|
||||
elif [ ${constraint_name} == ${2} ] ; then
|
||||
echo "INFO: No constraint rename performed; ${2} already exists."
|
||||
else
|
||||
echo "INFO: On $1 renaming constraint: ${constraint_name} to ${2}"
|
||||
${PSQL} -U awips -d metadata -c "ALTER TABLE ${1} RENAME CONSTRAINT ${constraint_name} TO ${2} ;"
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "ERROR: Failed on table $1 to rename unqiue constraint ${constraint_name} to $2."
|
||||
echo "FATAL: The update failed."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# takes to args: table column
|
||||
# Add not null constraint to table's column
|
||||
function updateNotNullCol {
|
||||
${PSQL} -U awips -d metadata -c "ALTER TABLE $1 ALTER COLUMN $2 SET NOT NULL ;"
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "ERROR: Failed on table $1 to add not null constraint on column $2."
|
||||
echo "FATAL: The update failed."
|
||||
exit 1
|
||||
else
|
||||
echo "INFO: Added non null constraint to column $2 on table $1."
|
||||
fi
|
||||
}
|
|
@ -66,6 +66,7 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Jun 11, 2014 2061 bsteffen Remove IDecoderGettable, drop datauri
|
||||
* Jul 22, 2014 3392 nabowle Change Double fields to Float.
|
||||
* Jul 16, 2015 4360 rferrel tailNumber no longer nullable and unique constraints named.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -75,14 +76,13 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "acarsseq")
|
||||
@Table(name = "acars", uniqueConstraints = { @UniqueConstraint(columnNames = {
|
||||
@Table(name = "acars", uniqueConstraints = { @UniqueConstraint(name = "uk_acars_datauri_fields", columnNames = {
|
||||
"refTime", "tailNumber", "flightLevel", "latitude", "longitude" }) })
|
||||
/*
|
||||
* Both refTime and forecastTime are included in the refTimeIndex since
|
||||
* forecastTime is unlikely to be used.
|
||||
*/
|
||||
@org.hibernate.annotations.Table(appliesTo = "acars", indexes = { @Index(name = "acars_refTimeIndex", columnNames = {
|
||||
"refTime" }) })
|
||||
@org.hibernate.annotations.Table(appliesTo = "acars", indexes = { @Index(name = "acars_refTimeIndex", columnNames = { "refTime" }) })
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
|
@ -104,11 +104,12 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
private String wmoHeader;
|
||||
|
||||
@DataURI(position = 1)
|
||||
@Column(length = 32)
|
||||
@Column(length = 32, nullable = false)
|
||||
@DynamicSerializeElement
|
||||
@XmlElement
|
||||
private String tailNumber;
|
||||
|
||||
// TODO Update once AircraftObsLocation DataURI's are corrected.
|
||||
@Embedded
|
||||
@DataURI(position = 2, embedded = true)
|
||||
@XmlElement
|
||||
|
@ -224,7 +225,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
/**
|
||||
* Constructor for DataURI construction through base class. This is used by
|
||||
* the notification service.
|
||||
*
|
||||
*
|
||||
* @param uri
|
||||
* A data uri applicable to this class.
|
||||
*/
|
||||
|
@ -286,7 +287,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public AircraftObsLocation getLocation() {
|
||||
|
@ -294,7 +295,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param location
|
||||
*/
|
||||
public void setLocation(AircraftObsLocation location) {
|
||||
|
@ -303,7 +304,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
|
||||
/**
|
||||
* Get this observation's geometry.
|
||||
*
|
||||
*
|
||||
* @return The geometry for this observation.
|
||||
*/
|
||||
public Geometry getGeometry() {
|
||||
|
@ -312,7 +313,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
|
||||
/**
|
||||
* Get the geometry latitude.
|
||||
*
|
||||
*
|
||||
* @return The geometry latitude.
|
||||
*/
|
||||
public double getLatitude() {
|
||||
|
@ -321,7 +322,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
|
||||
/**
|
||||
* Get the geometry longitude.
|
||||
*
|
||||
*
|
||||
* @return The geometry longitude.
|
||||
*/
|
||||
public double getLongitude() {
|
||||
|
@ -330,7 +331,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
|
||||
/**
|
||||
* Get the elevation, in meters, of the observing platform or location.
|
||||
*
|
||||
*
|
||||
* @return The observation elevation, in meters.
|
||||
*/
|
||||
public Boolean getLocationDefined() {
|
||||
|
@ -339,7 +340,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
|
||||
/**
|
||||
* Get the elevation, in meters, of the observing platform or location.
|
||||
*
|
||||
*
|
||||
* @return The observation elevation, in meters.
|
||||
*/
|
||||
public Integer getFlightLevel() {
|
||||
|
@ -347,7 +348,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getFlightNumber() {
|
||||
|
@ -356,7 +357,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
|
||||
/**
|
||||
* Get the receiving station.
|
||||
*
|
||||
*
|
||||
* @return the receiver
|
||||
*/
|
||||
public String getReceiver() {
|
||||
|
@ -365,7 +366,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
|
||||
/**
|
||||
* Set the receiving station.
|
||||
*
|
||||
*
|
||||
* @param receiver
|
||||
* the receiver to set
|
||||
*/
|
||||
|
@ -584,7 +585,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return the rollAngleQuality
|
||||
*/
|
||||
public Integer getRollAngleQuality() {
|
||||
|
@ -592,7 +593,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param rollAngleQuality
|
||||
* the rollAngleQuality to set
|
||||
*/
|
||||
|
@ -617,7 +618,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
|
@ -633,7 +634,7 @@ public class ACARSRecord extends PluginDataObject implements ISpatialEnabled,
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue