diff --git a/deltaScripts/16.1.2/DR4360/alterMadisRecordDataURI.sh b/deltaScripts/16.1.2/DR4360/alterMadisRecordDataURI.sh new file mode 100755 index 0000000000..8fe3f70f9c --- /dev/null +++ b/deltaScripts/16.1.2/DR4360/alterMadisRecordDataURI.sh @@ -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" diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.madis/src/com/raytheon/uf/common/dataplugin/madis/MadisRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.madis/src/com/raytheon/uf/common/dataplugin/madis/MadisRecord.java index 01dec9ace1..0c3c3d7d83 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.madis/src/com/raytheon/uf/common/dataplugin/madis/MadisRecord.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.madis/src/com/raytheon/uf/common/dataplugin/madis/MadisRecord.java @@ -77,6 +77,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * jan 22, 2014 2713 dhladky Calendar conversion. * Mar 21, 2014 2939 dhladky Fixed mismatches in HDF5, DB records. * 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. * * * @@ -86,8 +88,9 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @Entity @SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "madisseq") -@Table(name = "madis", uniqueConstraints = { @UniqueConstraint(columnNames = { - "latitude", "longitude", "stationId", "refTime", "provider", "subProvider", "restriction" }) }) +@Table(name = "madis", uniqueConstraints = { @UniqueConstraint(name = "uk_madis_datauri_fields", columnNames = { + "latitude", "longitude", "stationId", "refTime", "provider", + "subProvider", "restriction" }) }) @org.hibernate.annotations.Table(appliesTo = "madis", indexes = { @Index(name = "madis_wfsQueryIndex", columnNames = { "insertTime", "location" }), }) @DynamicSerialize @@ -98,16 +101,17 @@ public class MadisRecord extends PersistablePluginDataObject implements /** A string denoting the provider network */ @DynamicSerializeElement - @Column + @Column(nullable = false) @DataURI(position = 1) - protected String provider; + private String provider; /** A string denoting the sub provider */ @DynamicSerializeElement - @Column + @Column(nullable = false) @DataURI(position = 2) private String subProvider; + // TODO Update once SurfaceObsLocation DataURI's are corrected. @Embedded @DataURI(position = 3, embedded = true) @DynamicSerializeElement @@ -120,10 +124,10 @@ public class MadisRecord extends PersistablePluginDataObject implements /** An integer denoting the restriction level */ @DynamicSerializeElement - @Column + @Column(nullable = false) @DataURI(position = 4) private int restriction; - + /** A string denoting the time of observation */ @DynamicSerializeElement @Transient @@ -351,7 +355,7 @@ public class MadisRecord extends PersistablePluginDataObject implements @DynamicSerializeElement @Embedded private PointDataView pointDataView; - + public static final String PLUGIN_NAME = "madis"; public static final String STATION_ID = "stationId"; @@ -455,18 +459,19 @@ public class MadisRecord extends PersistablePluginDataObject implements public static final String RESTRICTION = "RESTRICTION"; } - + /** * URI constructor + * * @param string */ public MadisRecord(String string) { super(); } - - //empty constructor + + // empty constructor public MadisRecord() { - + } /** @@ -1101,11 +1106,12 @@ public class MadisRecord extends PersistablePluginDataObject implements public String getPluginName() { return PLUGIN_NAME; } - + /** - * Allow overwrite of MADIS records - * MADIS records are frequently updated for even the same temporal - * record. QC value changes will cause record re-submissions. + * Allow overwrite of MADIS records MADIS records are frequently updated for + * even the same temporal record. QC value changes will cause record + * re-submissions. + * * @return */ public boolean getAllowOverWrite() {