From 3f98d329c9de4b85e403b889adce919844fa1d59 Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Mon, 9 Dec 2013 14:11:58 -0600 Subject: [PATCH] Issue #2616 - Set overwrite allowed flag on madis records when decoded Added delta script for table MADIS with the hibernate generated key name Change-Id: Id8cfee5bfba68aa686b9d998bdbf85e5de5c7519 Former-commit-id: 9a02ae7d68b7c69cd9e78e81985f7a4b3407c243 [formerly 9a02ae7d68b7c69cd9e78e81985f7a4b3407c243 [formerly b3a18fd5270f2ce109b0560fba6e11e76e721bc9]] Former-commit-id: 5a42580c2bc490d425518bbe7badd36f9438699e Former-commit-id: dc6ab027b583bffa327bb8f3ac71a80ee97ec929 --- deltaScripts/14.2.1/updateMadisTableConstraint.sql | 3 +++ deltaScripts/14.2.1/updateMadisUniqueConstraint.sh | 5 +++++ .../com/raytheon/uf/common/dataplugin/madis/MadisRecord.java | 3 ++- .../src/com/raytheon/uf/edex/plugin/madis/MadisDecoder.java | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 deltaScripts/14.2.1/updateMadisTableConstraint.sql create mode 100644 deltaScripts/14.2.1/updateMadisUniqueConstraint.sh diff --git a/deltaScripts/14.2.1/updateMadisTableConstraint.sql b/deltaScripts/14.2.1/updateMadisTableConstraint.sql new file mode 100644 index 0000000000..68ead33a90 --- /dev/null +++ b/deltaScripts/14.2.1/updateMadisTableConstraint.sql @@ -0,0 +1,3 @@ +alter table madis drop constraint madis_location_reftime_provider_subprovider_restriction_key; + +alter table madis add constraint madis_location_stationid_reftime_provider_subprovider_restr_key UNIQUE (location, stationid, reftime, provider, subprovider, restriction) diff --git a/deltaScripts/14.2.1/updateMadisUniqueConstraint.sh b/deltaScripts/14.2.1/updateMadisUniqueConstraint.sh new file mode 100644 index 0000000000..90cedd207a --- /dev/null +++ b/deltaScripts/14.2.1/updateMadisUniqueConstraint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +PSQL=/awips2/psql/bin/psql +DIR=`dirname $0` +${PSQL} -U awips -d metadata -f ${DIR}/updateMadisTableConstraint.sql 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 685fbfc6b5..4b06740e42 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 @@ -73,6 +73,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Jul 14, 2013 2180 dhladky GUI update for mouse over display * Aug 30, 2013 2298 rjpeter Make getPluginName abstract * Oct 14, 2013 2361 njensen Removed IDecoderGettable + * Dec 10, 2013 2616 mpduff Added stationId to the unique constraint * * * @@ -83,7 +84,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; @Entity @SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "madisseq") @Table(name = "madis", uniqueConstraints = { @UniqueConstraint(columnNames = { - "location", "refTime", "provider", "subProvider", "restriction" }) }) + "location", "stationId", "refTime", "provider", "subProvider", "restriction" }) }) @org.hibernate.annotations.Table(appliesTo = "madis", indexes = { @Index(name = "madis_wfsQueryIndex", columnNames = { "refTime", "location" }), }) @DynamicSerialize diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.madis/src/com/raytheon/uf/edex/plugin/madis/MadisDecoder.java b/edexOsgi/com.raytheon.uf.edex.plugin.madis/src/com/raytheon/uf/edex/plugin/madis/MadisDecoder.java index 318c57ae3e..496fd9db79 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.madis/src/com/raytheon/uf/edex/plugin/madis/MadisDecoder.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.madis/src/com/raytheon/uf/edex/plugin/madis/MadisDecoder.java @@ -55,6 +55,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Mar 27, 2013 1746 dhladky Initial creation * Jun 17, 2013 2113 dhladky QPID memory usage alleviation * Aug 30, 2013 2298 rjpeter Make getPluginName abstract + * Dec 10, 2013 2616 mpduff Set overwrite allowed on MadisRecord. * * * @author dhladky @@ -140,6 +141,7 @@ public class MadisDecoder extends AbstractDecoder { long time3 = System.currentTimeMillis(); MadisRecord rec = processMadis(headerType, line); + rec.setOverwriteAllowed(true); long time4 = System.currentTimeMillis(); statusHandler.handle(Priority.DEBUG, "MADIS record decode time: " + (time4 - time3)