From d6548c9fdd76dec74548816de43bada22f7db302 Mon Sep 17 00:00:00 2001 From: Mark Peters Date: Thu, 9 Oct 2014 15:30:23 -0500 Subject: [PATCH] Omaha #3644 Remove dataURI from ccfp plugin Change-Id: I35e2e9239e6059f64c444d173b0a745d889abc27 Former-commit-id: 6bb4f5dbdf4063b557858b67864ff6c4df39982a [formerly c20d19a2d3dcb815de69770668856e99f5bc43ff [formerly cf1bff0d0233711e18ffa5c712fc4759b4f951f5] [formerly 6bb4f5dbdf4063b557858b67864ff6c4df39982a [formerly 3eaa3fa11068cbf6d1a58d4eb414f52f243bbaea]]] Former-commit-id: c20d19a2d3dcb815de69770668856e99f5bc43ff [formerly cf1bff0d0233711e18ffa5c712fc4759b4f951f5] Former-commit-id: c20d19a2d3dcb815de69770668856e99f5bc43ff Former-commit-id: 94364ab11566834e6f3e23060f3e933b8e15f183 --- deltaScripts/14.4.1/DR3644/dropCcfpDataURI.sh | 41 +++++++++++++++++++ .../uf/common/dataplugin/ccfp/CcfpRecord.java | 20 +++------ 2 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 deltaScripts/14.4.1/DR3644/dropCcfpDataURI.sh diff --git a/deltaScripts/14.4.1/DR3644/dropCcfpDataURI.sh b/deltaScripts/14.4.1/DR3644/dropCcfpDataURI.sh new file mode 100644 index 0000000000..68ff870223 --- /dev/null +++ b/deltaScripts/14.4.1/DR3644/dropCcfpDataURI.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# DR #3644 - this update script will drop the dataURI column from ccfp + +PSQL="/awips2/psql/bin/psql" + +# takes one arg: a table name +# drops the datauri constraint and column if they exist +function dropDatauri { + echo "INFO: Dropping DataURI column from $1" + ${PSQL} -U awips -d metadata -c "ALTER TABLE $1 DROP CONSTRAINT IF EXISTS ${1}_datauri_key;" + ${PSQL} -U awips -d metadata -c "ALTER TABLE $1 DROP COLUMN IF EXISTS datauri;" + if [ $? -ne 0 ]; then + echo "ERROR: Failed to drop dataURI column for $table" + echo "FATAL: The update has failed." + exit 1 + fi +} + +# takes three args: table, constraint name, unique columns +# will first drop the constraint if it exists and then adds it back, this is +# fairly inefficient if it does exist but operationally it won't exist and for +# testing this allows the script to be run easily as a noop. +function dropDatauriAndAddConstraint { + dropDatauri $1 + ${PSQL} -U awips -d metadata -c "ALTER TABLE $1 DROP CONSTRAINT IF EXISTS $2;" + ${PSQL} -U awips -d metadata -c "ALTER TABLE $1 ADD CONSTRAINT $2 UNIQUE $3;" + if [ $? -ne 0 ]; then + echo "ERROR: Failed to add new unique constraint for $table" + echo "FATAL: The update has failed." + exit 1 + fi +} + +echo "INFO: Dropping ccfp dataURI columns." + +dropDatauriAndAddConstraint ccfp ccfp_reftime_producttype_boxlat_boxlong_key "(reftime, producttype, boxlat, boxlong)" +${PSQL} -U awips -d metadata -c "DROP INDEX ccfp_reftimeindex;" +${PSQL} -U awips -d metadata -c "CREATE INDEX ccfp_reftimeindex ON ccfp USING btree (reftime);" +${PSQL} -U awips -d metadata -c "VACUUM FULL ANALYZE ccfp" + +echo "INFO: ccfp dataURI columns dropped successfully" diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ccfp/src/com/raytheon/uf/common/dataplugin/ccfp/CcfpRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ccfp/src/com/raytheon/uf/common/dataplugin/ccfp/CcfpRecord.java index 730548c9fb..e26094eebb 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ccfp/src/com/raytheon/uf/common/dataplugin/ccfp/CcfpRecord.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ccfp/src/com/raytheon/uf/common/dataplugin/ccfp/CcfpRecord.java @@ -20,8 +20,6 @@ package com.raytheon.uf.common.dataplugin.ccfp; -import javax.persistence.Access; -import javax.persistence.AccessType; import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; @@ -58,6 +56,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Nov 01, 2013 2361 njensen Remove XML annotations * Apr 15, 2014 3001 bgonzale Refactored to common package, * com.raytheon.uf.common.dataplugin.ccfp. + * Oct 03, 2014 3644 mapeters Removed dataURI column. * * * @@ -67,13 +66,11 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; */ @Entity @SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "ccfpseq") -@Table(name = "ccfp", uniqueConstraints = { @UniqueConstraint(columnNames = { "dataURI" }) }) -/* - * Both refTime and forecastTime are included in the refTimeIndex since - * forecastTime is unlikely to be used. - */ +@Table(name = "ccfp", uniqueConstraints = { @UniqueConstraint(columnNames = { + "refTime", "producttype", "boxLat", "boxLong" }) }) + @org.hibernate.annotations.Table(appliesTo = "ccfp", indexes = { @Index(name = "ccfp_refTimeIndex", columnNames = { - "refTime", "forecastTime" }) }) + "refTime" }) }) @DynamicSerialize public class CcfpRecord extends PluginDataObject implements ISpatialEnabled { @@ -272,13 +269,6 @@ public class CcfpRecord extends PluginDataObject implements ISpatialEnabled { this.location = location; } - @Override - @Column - @Access(AccessType.PROPERTY) - public String getDataURI() { - return super.getDataURI(); - } - @Override public String getPluginName() { return "ccfp";