Merge "Omaha #4360 DataURI updates from table derived from NPPSoundingRecord." into omaha_16.2.1
Former-commit-id: a372093e1378b8cd90bb7257477e5ee7956ade6c
This commit is contained in:
commit
713e3d1567
5 changed files with 49 additions and 5 deletions
33
deltaScripts/16.1.2/DR4360/alterNPPSoundingRecordDataURI.sh
Executable file
33
deltaScripts/16.1.2/DR4360/alterNPPSoundingRecordDataURI.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
# DR #4360 - this update script will alter the dataURI column from tables derived from NPPSoundingRecord.
|
||||
|
||||
PSQL="/awips2/psql/bin/psql"
|
||||
|
||||
cmdDir=`dirname $0`
|
||||
|
||||
source ${cmdDir}/commonFunctions.sh
|
||||
|
||||
# table and constraint names from CrimssRecord and NucapsRecord
|
||||
tables=("nucaps" "crimss")
|
||||
|
||||
# columns from NPPSoundingRecord.
|
||||
cols=("latitude" "longitude")
|
||||
|
||||
echo "INFO: Start update of tables derived from NPPSoundingRecord."
|
||||
for table in ${tables[@]} ; do
|
||||
if tableExists ${table} ; then
|
||||
echo "INFO: Start update of ${table} dataURI columns."
|
||||
echo renameConstraint ${table} uk_${table}_datauri_fields
|
||||
|
||||
for col in ${cols[@]} ; do
|
||||
echo "INFO: Update ${table}'s ${col}"
|
||||
echo ${PSQL} -U awips -d metadata -c "DELETE from ${table} where ${col} is NULL ;"
|
||||
echo updateNotNullCol ${table} ${col}
|
||||
done
|
||||
echo "INFO: ${table} dataURI columns updated successfully"
|
||||
else
|
||||
echo "WARNING: The table ${table} does not exist."
|
||||
fi
|
||||
done
|
||||
|
||||
echo "INFO: Tables derived from NPPSoundingRecord updated."
|
|
@ -34,7 +34,7 @@ where table_catalog = 'metadata' and table_schema='awips' and constraint_type='U
|
|||
fi
|
||||
}
|
||||
|
||||
# takes to args: table column
|
||||
# takes two 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 ;"
|
||||
|
@ -46,3 +46,11 @@ function updateNotNullCol {
|
|||
echo "INFO: Added non null constraint to column $2 on table $1."
|
||||
fi
|
||||
}
|
||||
|
||||
# takes one args: table
|
||||
# return 0 status if the table exists.
|
||||
function tableExists {
|
||||
${PSQL} -U awips -d metadata -q \
|
||||
-c "SELECT count(*) from information_schema.tables where table_schema='awips' and table_name='${1}' ; " \
|
||||
2>1 | grep -q '^\s*1$'
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
* PluginDataObject.
|
||||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Oct 14, 2013 2361 njensen Removed XML annotations
|
||||
* Jul 27, 2015 4360 rferrel Named unique constraint.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -54,7 +55,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "crimssseq")
|
||||
@Table(name = "crimss", uniqueConstraints = { @UniqueConstraint(columnNames = { "dataURI" }) })
|
||||
@Table(name = "crimss", uniqueConstraints = { @UniqueConstraint(name = "uk_crimss_datauri_fields", columnNames = { "dataURI" }) })
|
||||
@DynamicSerialize
|
||||
public class CrimssRecord extends NPPSoundingRecord {
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
* PluginDataObject.
|
||||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Oct 14, 2013 2361 njensen Removed XML annotations
|
||||
* Jul 27, 2015 4360 rferrel Named unique constraint.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -54,7 +55,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "nucapsseq")
|
||||
@Table(name = NucapsRecord.PLUGIN_NAME, uniqueConstraints = { @UniqueConstraint(columnNames = { "dataURI" }) })
|
||||
@Table(name = NucapsRecord.PLUGIN_NAME, uniqueConstraints = { @UniqueConstraint(name = "uk_nucaps_datauri_fields", columnNames = { "dataURI" }) })
|
||||
@DynamicSerialize
|
||||
public class NucapsRecord extends NPPSoundingRecord {
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* Mar 02, 2013 1970 bgonzale Added SequenceGenerator and Inheritance Strategy
|
||||
* annotations.
|
||||
* Jun 11, 2014 2061 bsteffen Remove IDecoderGettable
|
||||
* Jul 27, 2016 4360 rferrel Made latitude and longitude non-nullable.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -75,13 +76,13 @@ public abstract class NPPSoundingRecord extends PersistablePluginDataObject
|
|||
private PointDataView pointDataView;
|
||||
|
||||
@DataURI(position = 1)
|
||||
@Column
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private Double latitude;
|
||||
|
||||
@DataURI(position = 2)
|
||||
@Column
|
||||
@Column(nullable = false)
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
private Double longitude;
|
||||
|
|
Loading…
Add table
Reference in a new issue