Omaha #4360 DataURI changes for table madis.

Former-commit-id: eeb5cc61ec80cc3685507ed952a6ce069ad0f189
This commit is contained in:
Roger Ferrel 2015-07-21 08:07:42 -05:00
parent 31b96edb14
commit f8a23c43df
2 changed files with 51 additions and 16 deletions

View file

@ -0,0 +1,29 @@
#!/bin/bash
# DR #4360 - this update script will alter the dataURI columns from madis
PSQL="/awips2/psql/bin/psql"
cmdDir=`dirname $0`
source ${cmdDir}/commonFunctions.sh
table=madis
# table and constraint names from MadisRecord.
echo "INFO: Start update of ${table} dataURI columns."
renameConstraint ${table} uk_${table}_datauri_fields
col=provider
echo "Info Update ${table}'s ${col}"
${PSQL} -U awips -d metadata -c "DELETE from ${table} where ${col} is NULL ; "
updateNotNullCol ${table} ${col}
col=subProvider
echo "Info Update ${table}'s ${col}"
# When subProvider missing MadisDecoder already enters the string "null"; therefore should never have a NULL entry.
${PSQL} -U awips -d metadata -c "DELETE from ${table} where ${col} is NULL ; "
updateNotNullCol ${table} ${col}
col=restriction
${PSQL} -U awips -d metadata -c "DELETE from ${table} where ${col} is NULL ; "
updateNotNullCol ${table} ${col}
echo "INFO: ${table} dataURI columns updated successfully"

View file

@ -77,6 +77,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* jan 22, 2014 2713 dhladky Calendar conversion. * jan 22, 2014 2713 dhladky Calendar conversion.
* Mar 21, 2014 2939 dhladky Fixed mismatches in HDF5, DB records. * Mar 21, 2014 2939 dhladky Fixed mismatches in HDF5, DB records.
* Jan 08, 2014 3141 dhladky Bad index for WFS requests. * Jan 08, 2014 3141 dhladky Bad index for WFS requests.
* Jul 21, 2015 4360 rferrel Named unique constraint.
* Made provider, subProvider and restriction not nullable.
* *
* </pre> * </pre>
* *
@ -86,8 +88,9 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
@Entity @Entity
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "madisseq") @SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "madisseq")
@Table(name = "madis", uniqueConstraints = { @UniqueConstraint(columnNames = { @Table(name = "madis", uniqueConstraints = { @UniqueConstraint(name = "uk_madis_datauri_fields", columnNames = {
"latitude", "longitude", "stationId", "refTime", "provider", "subProvider", "restriction" }) }) "latitude", "longitude", "stationId", "refTime", "provider",
"subProvider", "restriction" }) })
@org.hibernate.annotations.Table(appliesTo = "madis", indexes = { @Index(name = "madis_wfsQueryIndex", columnNames = { @org.hibernate.annotations.Table(appliesTo = "madis", indexes = { @Index(name = "madis_wfsQueryIndex", columnNames = {
"insertTime", "location" }), }) "insertTime", "location" }), })
@DynamicSerialize @DynamicSerialize
@ -98,16 +101,17 @@ public class MadisRecord extends PersistablePluginDataObject implements
/** A string denoting the provider network */ /** A string denoting the provider network */
@DynamicSerializeElement @DynamicSerializeElement
@Column @Column(nullable = false)
@DataURI(position = 1) @DataURI(position = 1)
protected String provider; private String provider;
/** A string denoting the sub provider */ /** A string denoting the sub provider */
@DynamicSerializeElement @DynamicSerializeElement
@Column @Column(nullable = false)
@DataURI(position = 2) @DataURI(position = 2)
private String subProvider; private String subProvider;
// TODO Update once SurfaceObsLocation DataURI's are corrected.
@Embedded @Embedded
@DataURI(position = 3, embedded = true) @DataURI(position = 3, embedded = true)
@DynamicSerializeElement @DynamicSerializeElement
@ -120,10 +124,10 @@ public class MadisRecord extends PersistablePluginDataObject implements
/** An integer denoting the restriction level */ /** An integer denoting the restriction level */
@DynamicSerializeElement @DynamicSerializeElement
@Column @Column(nullable = false)
@DataURI(position = 4) @DataURI(position = 4)
private int restriction; private int restriction;
/** A string denoting the time of observation */ /** A string denoting the time of observation */
@DynamicSerializeElement @DynamicSerializeElement
@Transient @Transient
@ -351,7 +355,7 @@ public class MadisRecord extends PersistablePluginDataObject implements
@DynamicSerializeElement @DynamicSerializeElement
@Embedded @Embedded
private PointDataView pointDataView; private PointDataView pointDataView;
public static final String PLUGIN_NAME = "madis"; public static final String PLUGIN_NAME = "madis";
public static final String STATION_ID = "stationId"; public static final String STATION_ID = "stationId";
@ -455,18 +459,19 @@ public class MadisRecord extends PersistablePluginDataObject implements
public static final String RESTRICTION = "RESTRICTION"; public static final String RESTRICTION = "RESTRICTION";
} }
/** /**
* URI constructor * URI constructor
*
* @param string * @param string
*/ */
public MadisRecord(String string) { public MadisRecord(String string) {
super(); super();
} }
//empty constructor // empty constructor
public MadisRecord() { public MadisRecord() {
} }
/** /**
@ -1101,11 +1106,12 @@ public class MadisRecord extends PersistablePluginDataObject implements
public String getPluginName() { public String getPluginName() {
return PLUGIN_NAME; return PLUGIN_NAME;
} }
/** /**
* Allow overwrite of MADIS records * Allow overwrite of MADIS records MADIS records are frequently updated for
* MADIS records are frequently updated for even the same temporal * even the same temporal record. QC value changes will cause record
* record. QC value changes will cause record re-submissions. * re-submissions.
*
* @return * @return
*/ */
public boolean getAllowOverWrite() { public boolean getAllowOverWrite() {