diff --git a/deltaScripts/14.4.1/DR2536/moveSubscriptions.sh b/deltaScripts/14.4.1/DR2536/moveSubscriptions.sh
new file mode 100755
index 0000000000..d26ad34567
--- /dev/null
+++ b/deltaScripts/14.4.1/DR2536/moveSubscriptions.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+# moves subscriptions tables from metadata db to fxatext db
+
+function rowcount {
+ psql -U awips -d $1 -c "select count(*) from $2"
+}
+
+function getSeqStart {
+ CURR_ID=$(psql -U awips metadata -Aqzt0 -c "select max(id) from $1")
+ if [[ -z $CURR_ID ]]
+ then
+ echo 1
+ else
+ echo $(( $CURR_ID + 1 ))
+ fi
+}
+
+BACKUPFILE=sub_dump.bak
+MODIFIED_BACKUP=sub_modified.bak
+
+echo "Moving subscriptions tables from metadata to fxatext"
+
+OLD_SUB_COUNT=$(rowcount metadata subscription.subscriptions)
+OLD_REP_COUNT=$(rowcount metadata subscription.replacements)
+
+SUB_SEQ_START=$(getSeqStart subscription.subscriptions)
+REQ_SEQ_START=$(getSeqStart subscription.replacements)
+
+pg_dump -U awips -t subscription.subscriptions -t subscription.replacements metadata > $BACKUPFILE
+if [[ $? != 0 ]]
+then
+ echo "subscription tables backup failed, aborting"
+ exit 1
+fi
+
+sed 's/\(\(TABLE\s\+\)\|\(Schema:\s\+\)\|=\s\+\)subscription\([^s]\)/\1public\4/' $BACKUPFILE > $MODIFIED_BACKUP
+if [[ $? != 0 ]]
+then
+ echo "subscription tables backup editing failed, aborting"
+ exit 1
+fi
+
+psql -U awips fxatext < $MODIFIED_BACKUP
+if [[ $? != 0 ]]
+then
+ echo "Subscription tables restore failed, backup located at $BACKUPFILE"
+ exit 1
+fi
+
+NEW_SUB_COUNT=$(rowcount fxatext public.subscriptions)
+NEW_REP_COUNT=$(rowcount fxatext public.replacements)
+
+if [[ $OLD_SUB_COUNT != $NEW_SUB_COUNT || $OLD_REP_COUNT != $NEW_REP_COUNT ]]
+then
+ echo "Row counts do not match before and after table move"
+ echo "Subscriptions before: \n$OLD_SUB_COUNT"
+ echo "Subscriptions after: \n$NEW_SUB_COUNT"
+ echo "Replacements before: \n$OLD_REP_COUNT"
+ echo "Replacements after: \n$NEW_REP_COUNT"
+ echo "skipping old table cleanup, backup exists at $BACKUPFILE"
+ exit 1
+fi
+
+echo "Creating sequences"
+psql -U awips -d fxatext -c "CREATE SEQUENCE subscriptionseq START WITH $SUB_SEQ_START"
+psql -U awips -d fxatext -c "CREATE SEQUENCE replacementseq START WITH $REQ_SEQ_START"
+
+echo "Cleaning up old tables"
+psql -U awips -d metadata -c 'DROP SCHEMA subscription CASCADE'
+psql -U awips -d metadata -c "DELETE from awips.plugin_info WHERE name = 'com.raytheon.edex.autobldsrv'"
+
+rm $MODIFIED_BACKUP
+rm $BACKUPFILE
+echo "Done moving subscription tables"
diff --git a/edexOsgi/build.edex/opt/db/ddl/setup/create_subscription_tables.sql b/edexOsgi/build.edex/opt/db/ddl/setup/create_subscription_tables.sql
deleted file mode 100644
index 05a78cde18..0000000000
--- a/edexOsgi/build.edex/opt/db/ddl/setup/create_subscription_tables.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * This software was developed and / or modified by Raytheon Company,
- * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
- *
- * U.S. EXPORT CONTROLLED TECHNICAL DATA
- * This software product contains export-restricted data whose
- * export/transfer/disclosure is restricted by U.S. law. Dissemination
- * to non-U.S. persons whether in the United States or abroad requires
- * an export license or other authorization.
- *
- * Contractor Name: Raytheon Company
- * Contractor Address: 6825 Pine Street, Suite 340
- * Mail Stop B8
- * Omaha, NE 68106
- * 402.291.0100
- *
- * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
- * further licensing information.
- **/
--- Contains SQL/DDL statements to create the tables used by the subscription service
---
--- Database: metadata
--- Schema: subscription
--- Tables: subscriptions
--- replacements
---
--- File History:
--- 08Dec2008 1709 MW Fegan replaced existing DDL with DDL for new
--- subscription tables.
-
--- Create the SUBSCRIPTION schema
-create schema subscription authorization awips;
-
diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/.classpath b/edexOsgi/com.raytheon.edex.autobldsrv/.classpath
deleted file mode 100644
index 1fa3e6803d..0000000000
--- a/edexOsgi/com.raytheon.edex.autobldsrv/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
* @@ -44,7 +46,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * + * May 22, 2014 2536 bclement moved from autobldsrv to common.dataplugin.text * ** @@ -53,7 +55,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; */ @Entity -@Table(name = "replacements", schema = "subscription") +@SequenceGenerator(initialValue = 1, name = ReplacementRecord.SEQ_GEN_NAME, sequenceName = "replacementseq") +@Table(name = "replacements") @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) @DynamicSerialize @@ -61,10 +64,12 @@ public class ReplacementRecord extends PersistableDataObject { private static final long serialVersionUID = 1L; + public static final String SEQ_GEN_NAME = "REPLACEMENT_GENERATOR"; + @XmlAttribute @DynamicSerializeElement @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SEQ_GEN_NAME) private long id; @ManyToOne diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/autobldsrv/data/SubscriptionRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/SubscriptionRecord.java similarity index 78% rename from edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/autobldsrv/data/SubscriptionRecord.java rename to edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/SubscriptionRecord.java index ffa43cc560..528c29fb85 100644 --- a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/autobldsrv/data/SubscriptionRecord.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.text/src/com/raytheon/uf/common/dataplugin/text/db/SubscriptionRecord.java @@ -17,9 +17,8 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.edex.autobldsrv.data; +package com.raytheon.uf.common.dataplugin.text.db; -import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -30,8 +29,10 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import javax.xml.bind.annotation.XmlAccessType; @@ -40,8 +41,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.quartz.CronExpression; - import com.raytheon.uf.common.dataplugin.persist.IPersistableDataObject; import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; @@ -58,6 +57,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 18Nov2008 1709 MW Fegan Initial creation + * May 22, 2014 2536 bclement moved from autobldsrv to common.dataplugin.text + * moved matchesTrigger() to TriggerMatcher class * * * @@ -65,7 +66,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * @version 1.0 */ @Entity -@Table(name = "subscriptions", schema = "subscription", uniqueConstraints = @UniqueConstraint(columnNames = { +@SequenceGenerator(initialValue = 1, name = SubscriptionRecord.SEQ_GEN_NAME, sequenceName = "subscriptionseq") +@Table(name = "subscriptions", uniqueConstraints = @UniqueConstraint(columnNames = { "type", "trigger", "runner", "script", "filepath", "arguments" })) @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) @@ -75,10 +77,12 @@ public class SubscriptionRecord extends PersistableDataObject implements private static final long serialVersionUID = 1L; + public static final String SEQ_GEN_NAME = "SUBSCRIPTION_GENERATOR"; + @XmlAttribute @DynamicSerializeElement @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SEQ_GEN_NAME) private long id; @XmlAttribute @@ -273,58 +277,6 @@ public class SubscriptionRecord extends PersistableDataObject implements } } - /** - * Determines if the specified trigger value matches the trigger value of - * this SubscriptionRecord. - * - * @param trigger - * the trigger value to compare - * - * @return true if the trigger matches, false otherwise - */ - public boolean matchesTrigger(String trigger) { - boolean retVal = false; - if ("timer".equalsIgnoreCase(this.type)) { - try { - long date = Long.parseLong(trigger); - CronExpression cexp = new CronExpression(this.trigger); - retVal = cexp.isSatisfiedBy(new Date(date)); - } catch (Exception e) { - retVal = false; - } - } else if ("ldad".equalsIgnoreCase(this.type)) { - /* - * Legacy code has these patterns: TextString patterns[] = { - * productId, productId.left(6) + "XXX", "CCC" + productId.mid(3,3) - * + "XXX", productId.left(3) + "NNNXXX", productId.left(3) + "NNN" - * + productId.right(productId.length() - 6) }; - */ - // System.out.println("matching trigger=" + trigger + - // " -- this.trigger="+ this.trigger + - // " -- trigger.substr(0,6)+\"XXX\"="+trigger.substring(0,6)+"XXX" + - // " -- \"CCC\"+trigger.substring(3,6)+\"XXX\"="+"CCC"+trigger.substring(3, - // 6)+"XXX" + - // " -- trigger.substring(0,3)+\"NNNXXX\"=" + trigger.substring(0, - // 3)+"NNNXXX" + - // " -- trigger.substring(0, 3)+\"NNN\"+trigger.substring(6)="+trigger.substring(0, - // 3)+"NNN"+trigger.substring(6)); - retVal = (trigger.equalsIgnoreCase(this.trigger)) - || ((trigger.substring(0, 6) + "XXX") - .equalsIgnoreCase(this.trigger)) - || (("CCC" + trigger.substring(3, 6) + "XXX") - .equalsIgnoreCase(this.trigger)) - || ((trigger.substring(0, 3) + "NNNXXX") - .equalsIgnoreCase(this.trigger)) - || ((trigger.substring(0, 3) + "NNN" + trigger.substring(6)) - .equalsIgnoreCase(this.trigger) || (this.trigger - .startsWith(trigger))); - } else { - String pattern = this.trigger.replaceAll("\\*", ".+"); - retVal = trigger.matches(pattern); - } - return retVal; - } - /** * * @param name diff --git a/edexOsgi/com.raytheon.uf.edex.core.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.core.feature/feature.xml index 407c7eab4c..0261d31be8 100644 --- a/edexOsgi/com.raytheon.uf.edex.core.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.core.feature/feature.xml @@ -28,13 +28,6 @@ version="0.0.0" unpack="false"/> -
- * Also provided are two factory methods ({@link ASubscribeRunner#getInstance(String)} - * and {@link ASubscribeRunner#getInstance(String, Message)}) may be used to instantiate - * the known concrete implementations. + * Also provided are two factory methods ( + * {@link ASubscribeRunner#getInstance(String)} and + * {@link ASubscribeRunner#getInstance(String, Message)}) may be used to + * instantiate the known concrete implementations. *
* Expected usage: - *
+ *
+ *
+ *
* String type = "..."; // name of an appropriate runner action
* Message message = null; // initialized later...
*
@@ -56,20 +55,22 @@ import com.raytheon.uf.edex.core.EdexException;
* } catch (EdexException e) {
* // handle the exception
* }
- *
+ *
+ *
*
* - * + * * SOFTWARE HISTORY - * + * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 14Nov2008 1709 MW Fegan Initial creation + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text * *- * + * * @author mfegan - * @version 1.0 + * @version 1.0 */ public abstract class ASubscribeRunner implements ISubscribeRunner { diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/ISubscribeRunner.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/ISubscribeRunner.java similarity index 90% rename from edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/ISubscribeRunner.java rename to edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/ISubscribeRunner.java index 053488e3b3..df6f5c5af5 100644 --- a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/ISubscribeRunner.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/ISubscribeRunner.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.edex.subscription.runners; +package com.raytheon.uf.edex.plugin.text.subscription.runners; import java.util.List; @@ -31,21 +31,22 @@ import com.raytheon.uf.common.message.Property; * no-arg constructor; they should also define a constructor that takes a * {@link Message} instance as its sole argument. *
- * Each implementation of this class should ensure the {@link #getResults()} returns - * a valid, though possibly empty, List. + * Each implementation of this class should ensure the {@link #getResults()} + * returns a valid, though possibly empty, List. * *
- * + * * SOFTWARE HISTORY - * + * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 14Nov2008 1709 MW Fegan Initial creation. + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text * *- * + * * @author mfegan - * @version 1.0 + * @version 1.0 */ public interface ISubscribeRunner { diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/SubscribeAddRunner.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/SubscribeAddRunner.java similarity index 91% rename from edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/SubscribeAddRunner.java rename to edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/SubscribeAddRunner.java index 1c985d6c7c..cad348abe9 100644 --- a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/SubscribeAddRunner.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/SubscribeAddRunner.java @@ -17,17 +17,15 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.edex.subscription.runners; +package com.raytheon.uf.edex.plugin.text.subscription.runners; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import com.raytheon.edex.autobldsrv.data.SubscriptionRecord; -import com.raytheon.edex.subscription.dao.SubscriptionDAO; -import com.raytheon.edex.subscription.util.Tools; +import com.raytheon.uf.common.dataplugin.text.db.SubscriptionRecord; import com.raytheon.uf.common.message.Message; import com.raytheon.uf.common.message.Property; +import com.raytheon.uf.edex.plugin.text.dao.SubscriptionDAO; +import com.raytheon.uf.edex.plugin.text.subscription.util.Tools; /** * Implements a subscription request runner that performs an insert into the @@ -44,6 +42,7 @@ import com.raytheon.uf.common.message.Property; * 14Sep2010 3944 cjeanbap Trim property values. * 25May2011 8686 cjeanbap Updated if-statement to check for filepath * 26May2011 8686 cjeanbap fixed a punctuation bug + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text * * * @author mfegan diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/SubscribeDeleteRunner.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/SubscribeDeleteRunner.java similarity index 85% rename from edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/SubscribeDeleteRunner.java rename to edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/SubscribeDeleteRunner.java index 6abc51cdc2..672c34464b 100644 --- a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/SubscribeDeleteRunner.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/SubscribeDeleteRunner.java @@ -17,32 +17,34 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.edex.subscription.runners; +package com.raytheon.uf.edex.plugin.text.subscription.runners; import java.util.ArrayList; import java.util.List; -import com.raytheon.edex.autobldsrv.data.SubscriptionRecord; -import com.raytheon.edex.subscription.dao.SubscriptionDAO; -import com.raytheon.edex.subscription.util.Tools; +import com.raytheon.uf.common.dataplugin.text.db.SubscriptionRecord; import com.raytheon.uf.common.message.Message; import com.raytheon.uf.common.message.Property; +import com.raytheon.uf.edex.plugin.text.dao.SubscriptionDAO; +import com.raytheon.uf.edex.plugin.text.subscription.util.Tools; /** - * Implements a subscription request runner that performs a delete operation - * in the subscription database. + * Implements a subscription request runner that performs a delete operation in + * the subscription database. + * *
- * + * * SOFTWARE HISTORY - * + * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 14Nov2008 1709 MW Fegan Initial creation. + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text * *- * + * * @author mfegan - * @version 1.0 + * @version 1.0 */ public class SubscribeDeleteRunner extends ASubscribeRunner { @@ -61,8 +63,12 @@ public class SubscribeDeleteRunner extends ASubscribeRunner { super(message); } - /* (non-Javadoc) - * @see com.raytheon.edex.subscription.runners.ASubscribeRunner#execute() + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.plugin.text.subscription.runners.ASubscribeRunner + * #execute() */ @Override public boolean execute() { diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/SubscribeQueryRunner.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/SubscribeQueryRunner.java similarity index 84% rename from edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/SubscribeQueryRunner.java rename to edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/SubscribeQueryRunner.java index 7af1ec4a92..bc6bed0f9c 100644 --- a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/runners/SubscribeQueryRunner.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/runners/SubscribeQueryRunner.java @@ -17,25 +17,28 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.edex.subscription.runners; +package com.raytheon.uf.edex.plugin.text.subscription.runners; import java.util.ArrayList; import java.util.List; -import com.raytheon.edex.autobldsrv.data.SubscriptionRecord; -import com.raytheon.edex.subscription.dao.SubscriptionDAO; -import com.raytheon.edex.subscription.util.Tools; +import com.raytheon.uf.common.dataplugin.text.db.SubscriptionRecord; import com.raytheon.uf.common.message.Message; import com.raytheon.uf.common.message.Property; import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.edex.plugin.text.dao.SubscriptionDAO; +import com.raytheon.uf.edex.plugin.text.subscription.util.Tools; +import com.raytheon.uf.edex.plugin.text.subscription.util.TriggerMatcher; /** * Implements a subscription request runner that performs a query to determine - * if there are currently any subscriptions for a specific trigger value. If there - * are subscriptions, they are placed into the response list. + * if there are currently any subscriptions for a specific trigger value. If + * there are subscriptions, they are placed into the response list. *
- * This runner expects a message similar to - *
+ * This runner expects a message similar to
+ *
+ *
+ *
*
*
*
@@ -43,10 +46,14 @@ import com.raytheon.uf.common.serialization.SerializationUtil;
*
*
*
- *
- * The response following execution is a list of Property objects that can be used
- * to form a Message similar to
- *
+ *
+ *
+ *
+ * The response following execution is a list of Property objects that can be
+ * used to form a Message similar to
+ *
+ *
+ *
*
*
*
@@ -54,21 +61,25 @@ import com.raytheon.uf.common.serialization.SerializationUtil;
*
*
*
- *
- * In the response, the value of each subscription property is the XML serialization
- * of the subscription from the database.
+ *
+ *
+ *
+ * In the response, the value of each subscription property is the XML
+ * serialization of the subscription from the database.
+ *
* - * + * * SOFTWARE HISTORY - * + * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 14Nov2008 1709 MW Fegan Initial creation. + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text * *- * + * * @author mfegan - * @version 1.0 + * @version 1.0 */ public class SubscribeQueryRunner extends ASubscribeRunner { @@ -88,8 +99,12 @@ public class SubscribeQueryRunner extends ASubscribeRunner { super(message); } - /* (non-Javadoc) - * @see com.raytheon.edex.subscription.runners.ASubscribeRunner#execute() + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.plugin.text.subscription.runners.ASubscribeRunner + * #execute() */ @Override public boolean execute() { @@ -118,7 +133,7 @@ public class SubscribeQueryRunner extends ASubscribeRunner { private List
- * Two factory methods ({@link ASubscribeRunner#getInstance(String)} - * and {@link ASubscribeRunner#getInstance(String, Message)}) are used to instantiate - * the known concrete implementations. + * Two factory methods ({@link ASubscribeRunner#getInstance(String)} and + * {@link ASubscribeRunner#getInstance(String, Message)}) are used to + * instantiate the known concrete implementations. *
* Expected usage: - *
+ *
+ *
+ *
* String type = "..."; // name of an appropriate runner action
* Message message = null; // initialized later...
*
@@ -50,20 +50,23 @@ import com.raytheon.uf.edex.core.EdexException;
* } catch (EdexException e) {
* // handle the exception
* }
- *
+ *
+ *
*
* - * + * * SOFTWARE HISTORY - * + * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 18Nov2008 1709 MW Fegan Initial creation + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text + * removed duplicate SubscribeAction enum * *- * + * * @author mfegan - * @version 1.0 + * @version 1.0 */ public class SubscribeRunner { @@ -143,63 +146,4 @@ public class SubscribeRunner { return retVal; } - /** - * - * An enumeration of Subscription Actions. This enumeration is used by the factory methods - * ({@link ASubscribeRunner#getInstance(String, Message)} and - * {@link ASubscribeRunner#getInstance(String)}) to determine the correct class to - * instantiate to create a worker. - * - * @author mfegan - * @version 1.0 - */ - public enum SubscribeAction { - ACTION_ADD,ACTION_READ,ACTION_DELETE,ACTION_UPDATE,ACTION_QUERY; - /** - * A mapping of action names to SubscribeAction objects. - */ - private static final Map
* Typical Usage: - *
+ *
+ *
+ *
* List results = null;
* SubscribeAction action = SubscribeAction.ACTION_UPDATE;
* ISubscribeRunner runner = RunnerFactory.getInstance().getWorker(action);
@@ -43,19 +45,22 @@ import com.raytheon.uf.common.message.Property;
* runner.execute();
* results = runner.getResults();
* }
- *
+ *
+ *
+ *
* - * + * * SOFTWARE HISTORY - * + * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 05Dec2008 1709 MW Fegan Initial creation. + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text * *- * + * * @author mfegan - * @version 1.0 + * @version 1.0 */ public class SubscribeUpdateRunner extends ASubscribeRunner { @@ -74,8 +79,12 @@ public class SubscribeUpdateRunner extends ASubscribeRunner { super(message); } - /* (non-Javadoc) - * @see com.raytheon.edex.subscription.runners.ASubscribeRunner#execute() + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.plugin.text.subscription.runners.ASubscribeRunner + * #execute() */ @Override public boolean execute() { diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/services/ScriptRunner.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/services/ScriptRunner.java similarity index 96% rename from edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/services/ScriptRunner.java rename to edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/services/ScriptRunner.java index 0c753ec662..c2af3e88cc 100644 --- a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/services/ScriptRunner.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/services/ScriptRunner.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.edex.services; +package com.raytheon.uf.edex.plugin.text.subscription.services; import java.io.File; import java.util.ArrayList; @@ -31,15 +31,12 @@ import javax.xml.bind.JAXBException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.raytheon.edex.autobldsrv.data.ReplacementRecord; -import com.raytheon.edex.autobldsrv.data.SubscriptionRecord; -import com.raytheon.edex.subscription.runners.ISubscribeRunner; -import com.raytheon.edex.subscription.runners.SubscribeRunner; -import com.raytheon.edex.subscription.util.Tools; import com.raytheon.edex.uengine.runners.IMicroEngine; import com.raytheon.edex.uengine.runners.MicroEngine; import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.message.DataURINotificationMessage; +import com.raytheon.uf.common.dataplugin.text.db.ReplacementRecord; +import com.raytheon.uf.common.dataplugin.text.db.SubscriptionRecord; import com.raytheon.uf.common.message.Header; import com.raytheon.uf.common.message.Message; import com.raytheon.uf.common.message.Property; @@ -47,6 +44,9 @@ import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.util.ReflectionUtil; import com.raytheon.uf.common.util.StringUtil; import com.raytheon.uf.edex.core.EdexException; +import com.raytheon.uf.edex.plugin.text.subscription.runners.ISubscribeRunner; +import com.raytheon.uf.edex.plugin.text.subscription.runners.SubscribeRunner; +import com.raytheon.uf.edex.plugin.text.subscription.util.Tools; /** * Main class of the EDEX Script Runner. @@ -72,6 +72,7 @@ import com.raytheon.uf.edex.core.EdexException; * 30Aug2011 10581 rferrel executeScript now sending proper trigger * argument to the engine. * Feb 15, 2013 1638 mschenke Moved DataURINotificationMessage to uf.common.dataplugin + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text * * * diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/services/SubscribeManager.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/services/SubscribeManager.java similarity index 88% rename from edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/services/SubscribeManager.java rename to edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/services/SubscribeManager.java index 5484eaf5a1..b789968209 100644 --- a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/services/SubscribeManager.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/services/SubscribeManager.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.edex.services; +package com.raytheon.uf.edex.plugin.text.subscription.services; import java.util.ArrayList; import java.util.List; @@ -25,30 +25,32 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.raytheon.edex.subscription.runners.ISubscribeRunner; -import com.raytheon.edex.subscription.runners.SubscribeRunner; -import com.raytheon.edex.subscription.util.Tools; import com.raytheon.uf.common.message.Header; import com.raytheon.uf.common.message.Message; import com.raytheon.uf.common.message.Property; import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.edex.plugin.text.subscription.runners.ISubscribeRunner; +import com.raytheon.uf.edex.plugin.text.subscription.runners.SubscribeRunner; +import com.raytheon.uf.edex.plugin.text.subscription.util.Tools; /** - * The main class of the Subscription Manager. Receives and processes subscription - * requests from a client. Returns a response based on the result of processing the - * request. + * The main class of the Subscription Manager. Receives and processes + * subscription requests from a client. Returns a response based on the result + * of processing the request. + * *
- * + * * SOFTWARE HISTORY - * + * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 15Dec2008 1709 MW Fegan Initial Creation. Replaces SubscribeSrv. + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text * *- * + * * @author mfegan - * @version 1.0 + * @version 1.0 */ public class SubscribeManager { diff --git a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/util/SubscribeAction.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/util/SubscribeAction.java similarity index 63% rename from edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/util/SubscribeAction.java rename to edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/util/SubscribeAction.java index 9d05b9e20e..9306d5a09a 100644 --- a/edexOsgi/com.raytheon.edex.autobldsrv/src/com/raytheon/edex/subscription/util/SubscribeAction.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/util/SubscribeAction.java @@ -17,25 +17,39 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.edex.subscription.util; +package com.raytheon.uf.edex.plugin.text.subscription.util; import java.util.HashMap; import java.util.Map; +import com.raytheon.uf.common.message.Message; +import com.raytheon.uf.edex.plugin.text.subscription.runners.ASubscribeRunner; +import com.raytheon.uf.edex.plugin.text.subscription.runners.SubscribeAddRunner; +import com.raytheon.uf.edex.plugin.text.subscription.runners.SubscribeDeleteRunner; +import com.raytheon.uf.edex.plugin.text.subscription.runners.SubscribeQueryRunner; +import com.raytheon.uf.edex.plugin.text.subscription.runners.SubscribeReadRunner; +import com.raytheon.uf.edex.plugin.text.subscription.runners.SubscribeUpdateRunner; + /** - * An enumeration of Subscription Actions. + * An enumeration of Subscription Actions. This enumeration is used by the + * factory methods ({@link ASubscribeRunner#getInstance(String, Message)} and + * {@link ASubscribeRunner#getInstance(String)}) to determine the correct class + * to instantiate to create a worker. + * *
- * + * * SOFTWARE HISTORY - * + * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 14Nov2008 1709 MW Fegan Initial creation. + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text + * removed hard coded class names * *- * + * * @author mfegan - * @version 1.0 + * @version 1.0 */ public enum SubscribeAction { @@ -59,11 +73,11 @@ public enum SubscribeAction { private static final Map
- * + * * SOFTWARE HISTORY - * + * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 14Nov2008 1709 MW Fegan Initial creation. * 14Sep2010 3944 cjeanbap Trim the newline char from value. + * May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text * *- * + * * @author mfegan - * @version 1.0 + * @version 1.0 */ public final class Tools { diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/util/TriggerMatcher.java b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/util/TriggerMatcher.java new file mode 100644 index 0000000000..8e38d49829 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.text/src/com/raytheon/uf/edex/plugin/text/subscription/util/TriggerMatcher.java @@ -0,0 +1,101 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.plugin.text.subscription.util; + +import java.util.Date; + +import org.quartz.CronExpression; + +import com.raytheon.uf.common.dataplugin.text.db.SubscriptionRecord; + +/** + * Utility for matching stored subscriptions to query triggers + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * May 22, 2014 2536 bclement Initial creation + * + *+ * + * @author bclement + * @version 1.0 + */ +public class TriggerMatcher { + + /** + * Determines if the specified trigger value matches the trigger value of + * the provided SubscriptionRecord. + * + * @param record + * @param trigger + * the trigger value to compare + * + * @return true if the trigger matches, false otherwise + */ + public static boolean matches(SubscriptionRecord record, String trigger) { + String type = record.getType(); + String recordTrigger = record.getTrigger(); + boolean retVal = false; + if ("timer".equalsIgnoreCase(type)) { + try { + long date = Long.parseLong(trigger); + CronExpression cexp = new CronExpression(recordTrigger); + retVal = cexp.isSatisfiedBy(new Date(date)); + } catch (Exception e) { + retVal = false; + } + } else if ("ldad".equalsIgnoreCase(type)) { + /* + * Legacy code has these patterns: TextString patterns[] = { + * productId, productId.left(6) + "XXX", "CCC" + productId.mid(3,3) + * + "XXX", productId.left(3) + "NNNXXX", productId.left(3) + "NNN" + * + productId.right(productId.length() - 6) }; + */ + // System.out.println("matching trigger=" + trigger + + // " -- this.trigger="+ this.trigger + + // " -- trigger.substr(0,6)+\"XXX\"="+trigger.substring(0,6)+"XXX" + + // " -- \"CCC\"+trigger.substring(3,6)+\"XXX\"="+"CCC"+trigger.substring(3, + // 6)+"XXX" + + // " -- trigger.substring(0,3)+\"NNNXXX\"=" + trigger.substring(0, + // 3)+"NNNXXX" + + // " -- trigger.substring(0, 3)+\"NNN\"+trigger.substring(6)="+trigger.substring(0, + // 3)+"NNN"+trigger.substring(6)); + retVal = (trigger.equalsIgnoreCase(recordTrigger)) + || ((trigger.substring(0, 6) + "XXX") + .equalsIgnoreCase(recordTrigger)) + || (("CCC" + trigger.substring(3, 6) + "XXX") + .equalsIgnoreCase(recordTrigger)) + || ((trigger.substring(0, 3) + "NNNXXX") + .equalsIgnoreCase(recordTrigger)) + || ((trigger.substring(0, 3) + "NNN" + trigger.substring(6)) + .equalsIgnoreCase(recordTrigger) || (recordTrigger + .startsWith(trigger))); + } else { + String pattern = recordTrigger.replaceAll("\\*", ".+"); + retVal = trigger.matches(pattern); + } + return retVal; + } + +} diff --git a/rpms/awips2.core/Installer.database/component.spec b/rpms/awips2.core/Installer.database/component.spec index 33fb773e8e..d579f4f976 100644 --- a/rpms/awips2.core/Installer.database/component.spec +++ b/rpms/awips2.core/Installer.database/component.spec @@ -273,7 +273,6 @@ execute_psql_sql_script /awips2/postgresql/share/contrib/postgis-2.0/spatial_ref execute_psql_sql_script /awips2/postgresql/share/contrib/postgis-2.0/rtpostgis.sql metadata execute_psql_sql_script /awips2/postgresql/share/contrib/postgis-2.0/legacy.sql metadata execute_psql_sql_script ${SQL_SHARE_DIR}/permissions.sql metadata -execute_psql_sql_script ${SQL_SHARE_DIR}/create_subscription_tables.sql metadata execute_psql_sql_script ${SQL_SHARE_DIR}/fxatext.sql metadata # create the events schema