Merge "Omaha #5269 - Removed nonfunctional textdb -tA / -tR options." into omaha_16.2.2
Former-commit-id: 1c491ca527a1908a1434ed0d34f0980723fbfe5a
This commit is contained in:
commit
e57a2fd011
9 changed files with 20 additions and 822 deletions
16
deltaScripts/16.2.2/DR5269/watchwarn_drop.sh
Normal file
16
deltaScripts/16.2.2/DR5269/watchwarn_drop.sh
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# DR #5269 - This script drops table fxatext.watchwarn
|
||||||
|
|
||||||
|
PSQL="/awips2/psql/bin/psql"
|
||||||
|
|
||||||
|
echo "INFO: Dropping table fxatext.watchwarn."
|
||||||
|
|
||||||
|
${PSQL} -U awips -d fxatext -q -c "DROP TABLE IF EXISTS watchwarn CASCADE;"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "INFO: watchwarn table successfully dropped."
|
||||||
|
else
|
||||||
|
echo "WARNING: Unable to drop watchwarn table."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
|
@ -1,160 +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.
|
|
||||||
**/
|
|
||||||
package com.raytheon.uf.common.dataplugin.text.db;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import javax.persistence.EmbeddedId;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
|
|
||||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
|
||||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|
||||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Initial Implementation
|
|
||||||
* 15 Oct 2008 1538 jkorman Core functions added.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Entity
|
|
||||||
@Table
|
|
||||||
@DynamicSerialize
|
|
||||||
@XmlAccessorType(XmlAccessType.NONE)
|
|
||||||
public class WatchWarn extends PersistableDataObject implements Serializable,
|
|
||||||
ISerializableObject {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** identifier field */
|
|
||||||
@EmbeddedId
|
|
||||||
@DynamicSerializeElement
|
|
||||||
@XmlElement
|
|
||||||
private WatchWarnPK pk;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default no-arg constructor
|
|
||||||
*/
|
|
||||||
public WatchWarn() {
|
|
||||||
pk = new WatchWarnPK();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance with supplied product identifier and a script.
|
|
||||||
*
|
|
||||||
* @param productid
|
|
||||||
* A not null reference to the product identifier to store.
|
|
||||||
* @param script
|
|
||||||
* A not null reference to the script to store.
|
|
||||||
*/
|
|
||||||
public WatchWarn(String productid, String script) {
|
|
||||||
pk = new WatchWarnPK(productid, script);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the product identifier for this instance.
|
|
||||||
*
|
|
||||||
* @return The product identifier for this instance.
|
|
||||||
* @hibernate.property column="productid"
|
|
||||||
*/
|
|
||||||
public String getProductid() {
|
|
||||||
return pk.getProductid();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the script for this instance.
|
|
||||||
*
|
|
||||||
* @return The script for this instance.
|
|
||||||
*/
|
|
||||||
public String getScript() {
|
|
||||||
return pk.getScript();
|
|
||||||
}
|
|
||||||
|
|
||||||
public WatchWarnPK getPk() {
|
|
||||||
return pk;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPk(WatchWarnPK pk) {
|
|
||||||
this.pk = pk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param buffer
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public StringBuilder toStringBuilder(StringBuilder buffer) {
|
|
||||||
if (buffer != null) {
|
|
||||||
buffer = new StringBuilder(90);
|
|
||||||
}
|
|
||||||
buffer.append(pk.getProductid());
|
|
||||||
buffer.append("=>{");
|
|
||||||
buffer.append(pk.getScript());
|
|
||||||
buffer.append("}");
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the string representation of this class instance.
|
|
||||||
*
|
|
||||||
* @return The string representation of this class instance.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return toStringBuilder(null).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((pk == null) ? 0 : pk.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
WatchWarn other = (WatchWarn) obj;
|
|
||||||
if (pk == null) {
|
|
||||||
if (other.pk != null)
|
|
||||||
return false;
|
|
||||||
} else if (!pk.equals(other.pk))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,102 +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.
|
|
||||||
**/
|
|
||||||
package com.raytheon.uf.common.dataplugin.text.db;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Embeddable;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
|
|
||||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|
||||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|
||||||
|
|
||||||
@Embeddable
|
|
||||||
@XmlRootElement
|
|
||||||
@XmlAccessorType(XmlAccessType.NONE)
|
|
||||||
@DynamicSerialize
|
|
||||||
public class WatchWarnPK extends PersistableDataObject {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Column(nullable = false, length = 9)
|
|
||||||
@DynamicSerializeElement
|
|
||||||
@XmlAttribute
|
|
||||||
private String productid;
|
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
@DynamicSerializeElement
|
|
||||||
@XmlAttribute
|
|
||||||
private String script;
|
|
||||||
|
|
||||||
public WatchWarnPK(String productid, String script) {
|
|
||||||
this.productid = productid;
|
|
||||||
this.script = script;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WatchWarnPK() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProductid() {
|
|
||||||
return this.productid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProductid(String productid) {
|
|
||||||
this.productid = productid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getScript() {
|
|
||||||
return this.script;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setScript(String script) {
|
|
||||||
this.script = script;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this).append("productid", getProductid())
|
|
||||||
.append("script", getScript()).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
if (!(other instanceof WatchWarnPK)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
WatchWarnPK castOther = (WatchWarnPK) other;
|
|
||||||
return new EqualsBuilder()
|
|
||||||
.append(this.getProductid(), castOther.getProductid())
|
|
||||||
.append(this.getScript(), castOther.getScript()).isEquals();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder().append(getProductid()).append(getScript())
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -42,6 +42,7 @@ import com.raytheon.uf.common.message.Property;
|
||||||
* Aug 22, 2014 2926 bclement compatibility changes with new textdb service
|
* Aug 22, 2014 2926 bclement compatibility changes with new textdb service
|
||||||
* Jan 18, 2016 4562 tjensen Moved from edex.plugin.text to
|
* Jan 18, 2016 4562 tjensen Moved from edex.plugin.text to
|
||||||
* edex.plugin.text.dbsrv
|
* edex.plugin.text.dbsrv
|
||||||
|
* Feb 05, 2016 5269 skorolev Removed WarnTableAdapter from execMap
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -66,7 +67,6 @@ public class CommandExecutor implements ICommandExecutor {
|
||||||
*/
|
*/
|
||||||
public CommandExecutor() {
|
public CommandExecutor() {
|
||||||
execMap.put(StateTableAdapter.getViewTag(), new StateTableAdapter());
|
execMap.put(StateTableAdapter.getViewTag(), new StateTableAdapter());
|
||||||
execMap.put(WarnTableAdapter.getViewTag(), new WarnTableAdapter());
|
|
||||||
execMap.put(VersionsAdapter.getViewTag(), new VersionsAdapter());
|
execMap.put(VersionsAdapter.getViewTag(), new VersionsAdapter());
|
||||||
execMap.put(TextViewAdapter.getViewTag(), new TextViewAdapter());
|
execMap.put(TextViewAdapter.getViewTag(), new TextViewAdapter());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,251 +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.
|
|
||||||
**/
|
|
||||||
package com.raytheon.uf.edex.plugin.text.dbsrv.impl;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.text.db.WatchWarn;
|
|
||||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.ICommandExecutor;
|
|
||||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.TextDBSrvCommandTags;
|
|
||||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.WarnTableTags;
|
|
||||||
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.edex.core.EDEXUtil;
|
|
||||||
import com.raytheon.uf.edex.core.EdexException;
|
|
||||||
import com.raytheon.uf.edex.plugin.text.db.TextDB;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes warning textdbsrv command messages
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Oct 7, 2008 1538 jkorman Initial creation
|
|
||||||
* Aug 9,2010 3944 cjeanbap Added logic to delete all records
|
|
||||||
* from WatchWarn table.
|
|
||||||
* Sep 14,2010 3944 cjenabap Added sendTextToQueue()
|
|
||||||
* May 15, 2014 2536 bclement moved from uf.edex.textdbsrv
|
|
||||||
* Aug 22, 2014 2926 bclement compatibility changes with new textdb service
|
|
||||||
* Dec 09, 2015 5166 kbisanz Update logging to use SLF4J.
|
|
||||||
* Jan 18, 2016 4562 tjensen Moved from edex.plugin.text to
|
|
||||||
* edex.plugin.text.dbsrv
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author jkorman
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
public class WarnTableAdapter implements ICommandExecutor {
|
|
||||||
|
|
||||||
private TextDB textDB;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: This introduces a dependency on the text.subscription plugin. This
|
|
||||||
* dependency should be broken if possible.
|
|
||||||
*/
|
|
||||||
private static final String WATCH_WARN_QUEUE = "watchWarnDirect";
|
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public WarnTableAdapter() {
|
|
||||||
textDB = new TextDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static final String getViewTag() {
|
|
||||||
return "warn";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void dispose() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Message execute(Message cmdMessage) {
|
|
||||||
|
|
||||||
Header sHeader = cmdMessage.getHeader();
|
|
||||||
|
|
||||||
// Get the operation code
|
|
||||||
String op = sHeader.getProperty(WarnTableTags.OP.name());
|
|
||||||
|
|
||||||
TextDBSrvCommandTags opTag = TextDBSrvCommandTags.valueOf(op);
|
|
||||||
|
|
||||||
if (opTag != null) {
|
|
||||||
switch (opTag) {
|
|
||||||
|
|
||||||
case PUT: {
|
|
||||||
String productId = sHeader.getProperty(WarnTableTags.PRODID
|
|
||||||
.name());
|
|
||||||
String script = sHeader
|
|
||||||
.getProperty(WarnTableTags.SCRIPT.name());
|
|
||||||
|
|
||||||
addWatchWarn(sHeader, productId, script);
|
|
||||||
sendTextToQueue(productId, WATCH_WARN_QUEUE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GET: {
|
|
||||||
String productId = sHeader.getProperty(WarnTableTags.PRODID
|
|
||||||
.name());
|
|
||||||
if (productId != null) {
|
|
||||||
getWatchWarn(sHeader, productId);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DELETE: {
|
|
||||||
String productId = sHeader.getProperty(WarnTableTags.PRODID
|
|
||||||
.name());
|
|
||||||
String script = sHeader
|
|
||||||
.getProperty(WarnTableTags.SCRIPT.name());
|
|
||||||
|
|
||||||
if ((productId != null) && (script != null)) {
|
|
||||||
deleteWatchWarn(sHeader, productId, script);
|
|
||||||
} else {
|
|
||||||
Collection<WatchWarn> watchWarns = textDB
|
|
||||||
.queryAllWatchWarn();
|
|
||||||
Property[] tempProps = new Property[watchWarns.size()];
|
|
||||||
int i = 0;
|
|
||||||
for (WatchWarn ww : watchWarns) {
|
|
||||||
deleteWatchWarn(sHeader, ww.getProductid(),
|
|
||||||
ww.getScript());
|
|
||||||
tempProps[i++] = sHeader.getProperties()[0];
|
|
||||||
}
|
|
||||||
sHeader.setProperties(tempProps);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
String tagName = (opTag != null) ? opTag.name() : "null";
|
|
||||||
Property[] props = new Property[] { new Property(
|
|
||||||
CommandExecutor.STDERR, "ERROR:Invalid command tag = ["
|
|
||||||
+ tagName + "]"), };
|
|
||||||
sHeader.setProperties(props);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
cmdMessage.setHeader(sHeader);
|
|
||||||
return cmdMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param state
|
|
||||||
* @param xxxId
|
|
||||||
* @param cccId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private void addWatchWarn(Header header, String productId, String script) {
|
|
||||||
Property newProperty = new Property(CommandExecutor.STDERR,
|
|
||||||
"NORMAL:Adding productId " + productId + " to trigger.");
|
|
||||||
Property errProperty = new Property(CommandExecutor.STDERR,
|
|
||||||
"ERROR:Failure adding to state_ccc table.");
|
|
||||||
|
|
||||||
Property[] props = new Property[] { newProperty, };
|
|
||||||
if (!textDB.addWatchWarn(productId, script)) {
|
|
||||||
props = new Property[] { newProperty, errProperty };
|
|
||||||
}
|
|
||||||
header.setProperties(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param header
|
|
||||||
* @param productId
|
|
||||||
*/
|
|
||||||
private void getWatchWarn(Header header, String productId) {
|
|
||||||
String PROP_FMT = CommandExecutor.STDOUT;
|
|
||||||
|
|
||||||
Property[] props = null;
|
|
||||||
|
|
||||||
List<WatchWarn> dataList = textDB.queryWatchWarn(productId);
|
|
||||||
|
|
||||||
if (dataList.size() > 0) {
|
|
||||||
props = new Property[dataList.size() + 2];
|
|
||||||
int i = 0;
|
|
||||||
props[i] = new Property(PROP_FMT, "PRODUCTID SCRIPT");
|
|
||||||
props[i] = new Property(PROP_FMT, "--------- ------");
|
|
||||||
for (WatchWarn w : dataList) {
|
|
||||||
props[i++] = new Property(PROP_FMT, String.format("%9s %s",
|
|
||||||
w.getProductid(), w.getScript()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
props = new Property[] { new Property(CommandExecutor.STDERR,
|
|
||||||
"ERROR:Failure reading from watch warn table."), };
|
|
||||||
}
|
|
||||||
header.setProperties(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param state
|
|
||||||
* @param xxxId
|
|
||||||
* @param cccId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private void deleteWatchWarn(Header header, String productId, String script) {
|
|
||||||
Property newProperty = new Property(CommandExecutor.STDERR,
|
|
||||||
"NORMAL:Deleting product id " + productId + " trigger.");
|
|
||||||
Property errProperty = new Property(CommandExecutor.STDERR,
|
|
||||||
"ERROR:Failure adding to state_ccc table.");
|
|
||||||
|
|
||||||
Property[] props = new Property[] { newProperty, };
|
|
||||||
if (!textDB.deleteWatchWarn(productId, script)) {
|
|
||||||
props = new Property[] { newProperty, errProperty };
|
|
||||||
}
|
|
||||||
header.setProperties(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends an asynchronous message to the specified queue.
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
* the message to send
|
|
||||||
* @param queue
|
|
||||||
* the queue to receive the message
|
|
||||||
*/
|
|
||||||
private void sendTextToQueue(String message, String queue) {
|
|
||||||
try {
|
|
||||||
EDEXUtil.getMessageProducer().sendAsync(queue, message);
|
|
||||||
} catch (EdexException e) {
|
|
||||||
logger.warn("Unable to send product '" + message + "' to queue '"
|
|
||||||
+ queue + "'", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,125 +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.
|
|
||||||
**/
|
|
||||||
|
|
||||||
package com.raytheon.uf.edex.plugin.text.dao;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.Criteria;
|
|
||||||
import org.hibernate.Session;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.dataplugin.text.db.WatchWarn;
|
|
||||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
|
||||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
|
||||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The dao implementation associated with the TextDao classes used for all
|
|
||||||
* database interaction.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* 09/04/07 400 garmendariz Initial Check in
|
|
||||||
* Oct 1, 2008 1538 jkorman Added additional functionality.
|
|
||||||
* Aug 9, 2010 3944 cjeanbap Added method, queryAllWatchWarn.
|
|
||||||
* May 20, 2014 2536 bclement moved from edex.textdb to edex.plugin.text
|
|
||||||
* 10/28/2014 3454 bphillip Fix usage of getSession()
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author garmendariz
|
|
||||||
* @version 1
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class WatchWarnDao extends CoreDao {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public WatchWarnDao() {
|
|
||||||
super(DaoConfig.forClass("fxa", WatchWarn.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an entry to the WatchWarn table.
|
|
||||||
*
|
|
||||||
* @param watchWarn
|
|
||||||
*/
|
|
||||||
public boolean addEntry(WatchWarn watchWarn) {
|
|
||||||
this.persist(watchWarn);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an entry to the WatchWarn table.
|
|
||||||
*
|
|
||||||
* @param watchWarn
|
|
||||||
*/
|
|
||||||
public boolean deleteEntry(WatchWarn watchWarn) {
|
|
||||||
this.delete(watchWarn);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of all scripts associated with a given product identifier.
|
|
||||||
*
|
|
||||||
* @param productId
|
|
||||||
* A product identifier to query for.
|
|
||||||
* @return List of scripts retrieved. Returns an empty list if no values
|
|
||||||
* were found.
|
|
||||||
*/
|
|
||||||
public List<String> queryWatchWarn(String productId) {
|
|
||||||
|
|
||||||
List<String> retList = new ArrayList<String>();
|
|
||||||
|
|
||||||
List<?> values = null;
|
|
||||||
try {
|
|
||||||
values = queryBySingleCriteria("productid", productId);
|
|
||||||
} catch (DataAccessLayerException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (values != null) {
|
|
||||||
for (Object o : values) {
|
|
||||||
retList.add(((WatchWarn) o).getScript());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public List<WatchWarn> queryAllWatchWarn() {
|
|
||||||
|
|
||||||
Session session = getSession();
|
|
||||||
try{
|
|
||||||
Criteria criteria = session.createCriteria(WatchWarn.class);
|
|
||||||
|
|
||||||
return criteria.list();
|
|
||||||
} finally {
|
|
||||||
if(session != null){
|
|
||||||
session.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -34,7 +34,6 @@ import com.raytheon.uf.common.dataplugin.text.db.PracticeStdTextProduct;
|
||||||
import com.raytheon.uf.common.dataplugin.text.db.StateMatch;
|
import com.raytheon.uf.common.dataplugin.text.db.StateMatch;
|
||||||
import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct;
|
import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct;
|
||||||
import com.raytheon.uf.common.dataplugin.text.db.TextProductInfo;
|
import com.raytheon.uf.common.dataplugin.text.db.TextProductInfo;
|
||||||
import com.raytheon.uf.common.dataplugin.text.db.WatchWarn;
|
|
||||||
import com.raytheon.uf.common.dataplugin.text.util.AFOSParser;
|
import com.raytheon.uf.common.dataplugin.text.util.AFOSParser;
|
||||||
import com.raytheon.uf.common.site.SiteMap;
|
import com.raytheon.uf.common.site.SiteMap;
|
||||||
import com.raytheon.uf.common.wmo.AFOSProductId;
|
import com.raytheon.uf.common.wmo.AFOSProductId;
|
||||||
|
@ -43,7 +42,6 @@ import com.raytheon.uf.common.wmo.WMOTimeParser;
|
||||||
import com.raytheon.uf.edex.plugin.text.dao.StateMatchDao;
|
import com.raytheon.uf.edex.plugin.text.dao.StateMatchDao;
|
||||||
import com.raytheon.uf.edex.plugin.text.dao.StdTextProductDao;
|
import com.raytheon.uf.edex.plugin.text.dao.StdTextProductDao;
|
||||||
import com.raytheon.uf.edex.plugin.text.dao.TextProductInfoDao;
|
import com.raytheon.uf.edex.plugin.text.dao.TextProductInfoDao;
|
||||||
import com.raytheon.uf.edex.plugin.text.dao.WatchWarnDao;
|
|
||||||
import com.raytheon.uf.edex.plugin.text.impl.WMOReportData;
|
import com.raytheon.uf.edex.plugin.text.impl.WMOReportData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,6 +74,7 @@ import com.raytheon.uf.edex.plugin.text.impl.WMOReportData;
|
||||||
* May 20, 2014 2536 bclement moved from edex.textdb to edex.plugin.text
|
* May 20, 2014 2536 bclement moved from edex.textdb to edex.plugin.text
|
||||||
* Jul 10, 2014 2914 garmendariz Remove EnvProperties
|
* Jul 10, 2014 2914 garmendariz Remove EnvProperties
|
||||||
* Dec 09, 2015 5166 kbisanz Update logging to use SLF4J.
|
* Dec 09, 2015 5166 kbisanz Update logging to use SLF4J.
|
||||||
|
* Feb 05, 2016 5269 skorolev Removed WatchWarn methods.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author jkorman
|
* @author jkorman
|
||||||
|
@ -394,120 +393,6 @@ public class TextDB {
|
||||||
return stateList;
|
return stateList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* --- watchwarn
|
|
||||||
*
|
|
||||||
* @param watchWarn
|
|
||||||
* @return success
|
|
||||||
*/
|
|
||||||
public boolean addWatchWarn(WatchWarn watchWarn) {
|
|
||||||
boolean success = false;
|
|
||||||
|
|
||||||
WatchWarnDao dao = new WatchWarnDao();
|
|
||||||
try {
|
|
||||||
success = dao.addEntry(watchWarn);
|
|
||||||
} catch (Exception e) {
|
|
||||||
String msg = "Error adding watch/warning: watchWarn=" + watchWarn;
|
|
||||||
logger.error(msg, e);
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* --- watchwarn
|
|
||||||
*
|
|
||||||
* @param productId
|
|
||||||
* A not null reference to the product identifier to store.
|
|
||||||
* @param script
|
|
||||||
* A not null reference to the script to store.
|
|
||||||
* @return success
|
|
||||||
*/
|
|
||||||
public boolean addWatchWarn(String productId, String script) {
|
|
||||||
return addWatchWarn(new WatchWarn(productId, script));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* --- watchwarn Get a list of all entries for a specific state.
|
|
||||||
*
|
|
||||||
* @param stateInfo
|
|
||||||
* A state to lookup.
|
|
||||||
* @return List of StateMatch entries for the specified state. If none were
|
|
||||||
* found, an empty list is returned.
|
|
||||||
*/
|
|
||||||
public List<WatchWarn> queryWatchWarn(String productId) {
|
|
||||||
|
|
||||||
List<WatchWarn> watchList = new ArrayList<WatchWarn>();
|
|
||||||
|
|
||||||
List<String> results = null;
|
|
||||||
|
|
||||||
WatchWarnDao dao = new WatchWarnDao();
|
|
||||||
try {
|
|
||||||
results = dao.queryWatchWarn(productId);
|
|
||||||
} catch (Exception e) {
|
|
||||||
String msg = "Error querying for watch/warning: productId="
|
|
||||||
+ productId;
|
|
||||||
logger.error(msg, e);
|
|
||||||
}
|
|
||||||
if (results != null) {
|
|
||||||
for (String s : results) {
|
|
||||||
watchList.add(new WatchWarn(productId, s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return watchList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of all entries in database table.
|
|
||||||
*
|
|
||||||
* @return List of WatchWarn entries.
|
|
||||||
*/
|
|
||||||
public List<WatchWarn> queryAllWatchWarn() {
|
|
||||||
WatchWarnDao dao = new WatchWarnDao();
|
|
||||||
|
|
||||||
List<WatchWarn> results = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
results = dao.queryAllWatchWarn();
|
|
||||||
} catch (Exception e) {
|
|
||||||
String msg = "Error querying all watches/warnings";
|
|
||||||
logger.error(msg, e);
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* --- watchwarn
|
|
||||||
*
|
|
||||||
* @param watchWarn
|
|
||||||
* @return success
|
|
||||||
*/
|
|
||||||
public boolean deleteWatchWarn(WatchWarn watchWarn) {
|
|
||||||
boolean success = false;
|
|
||||||
|
|
||||||
WatchWarnDao dao = new WatchWarnDao();
|
|
||||||
try {
|
|
||||||
success = dao.deleteEntry(watchWarn);
|
|
||||||
} catch (Exception e) {
|
|
||||||
String msg = "Error deleting watch/warning: watchWarn=" + watchWarn;
|
|
||||||
logger.error(msg, e);
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* --- watchwarn
|
|
||||||
*
|
|
||||||
* @param productId
|
|
||||||
* A not null reference to the product identifier to store.
|
|
||||||
* @param script
|
|
||||||
* A not null reference to the script to store.
|
|
||||||
* @return success
|
|
||||||
*/
|
|
||||||
public boolean deleteWatchWarn(String productId, String script) {
|
|
||||||
return deleteWatchWarn(new WatchWarn(productId, script));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the latest time for each product in the stdtextproducts table.
|
* Get the latest time for each product in the stdtextproducts table.
|
||||||
*
|
*
|
||||||
|
|
|
@ -62,8 +62,6 @@ flags = {'-r':('text_get_prod','Read data from the database'),
|
||||||
|
|
||||||
'-c':('afos_cmds','Reviews AFOS commands'),
|
'-c':('afos_cmds','Reviews AFOS commands'),
|
||||||
|
|
||||||
'-tA':('trig_add','Add trigger(s) to populate the subscription table.'),
|
|
||||||
'-tR':('trig_del','Remove trigger(s) from the subscription table.'),
|
|
||||||
'-n':('site_node', 'Display the current site')
|
'-n':('site_node', 'Display the current site')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,9 +173,7 @@ usage: textdb -r AFOSCmd Does a standard afos read
|
||||||
textdb -s -r SS Displays XXX list for state [SS]
|
textdb -s -r SS Displays XXX list for state [SS]
|
||||||
textdb -pil -a productID script Adds a PIL watch warning product with script pathname
|
textdb -pil -a productID script Adds a PIL watch warning product with script pathname
|
||||||
textdb -pil -d productID script Deletes a PIL watch warning product with script pathname
|
textdb -pil -d productID script Deletes a PIL watch warning product with script pathname
|
||||||
textdb -c Reviews AFOS commands
|
textdb -c Reviews AFOS commands
|
||||||
textdb -tA script Add trigger(s) to subscription table
|
|
||||||
textdb -tR all Remove trigger(s) from subscriptions table
|
|
||||||
textdb -n [site] Gets current node (CCC) site for running edex
|
textdb -n [site] Gets current node (CCC) site for running edex
|
||||||
"""
|
"""
|
||||||
# AFOS commands summary. Displayed when text database CLI tool is run with
|
# AFOS commands summary. Displayed when text database CLI tool is run with
|
||||||
|
|
|
@ -87,6 +87,7 @@ def appendIfNotPresent(multimap, key, value):
|
||||||
# 08/15/14 2926 bclement Fixed hasSubOperations()
|
# 08/15/14 2926 bclement Fixed hasSubOperations()
|
||||||
# 08/22/14 2926 bclement Switched to ThriftClient
|
# 08/22/14 2926 bclement Switched to ThriftClient
|
||||||
# 09/05/14 2926 bclement Moved TextDBRequest to common
|
# 09/05/14 2926 bclement Moved TextDBRequest to common
|
||||||
|
# 02/05/16 5269 skorolev Removed Handles the Watch Warn Trigger requests
|
||||||
##############################################################################
|
##############################################################################
|
||||||
class TextDB:
|
class TextDB:
|
||||||
|
|
||||||
|
@ -407,68 +408,6 @@ class TextDB:
|
||||||
sm = SM.SubscriptionManager(name='textdb',args=cline)
|
sm = SM.SubscriptionManager(name='textdb',args=cline)
|
||||||
return sm.execute()
|
return sm.execute()
|
||||||
|
|
||||||
# Handles the Watch Warn Trigger requests
|
|
||||||
#
|
|
||||||
# raise:
|
|
||||||
# propagates any exception received
|
|
||||||
def __handleWatchWarnRequest(self):
|
|
||||||
cmd = self.commands.get('command')[0]
|
|
||||||
args = self.commands.get(cmd)
|
|
||||||
if cmd == 'trig_add':
|
|
||||||
if (os.path.exists(args[0])):
|
|
||||||
try:
|
|
||||||
self.__deleteWatchWarn()
|
|
||||||
self.__deleteSubscriptions()
|
|
||||||
except Exception,e:
|
|
||||||
raise MessageError('unable to create message for textdb request',e)
|
|
||||||
try:
|
|
||||||
for i in range(len(args)):
|
|
||||||
f = open(args[i],'r')
|
|
||||||
for line in f:
|
|
||||||
# remove all white-spaces at beginning of the line.
|
|
||||||
line = line.lstrip()
|
|
||||||
if (line.find('#') == -1):
|
|
||||||
try:
|
|
||||||
values = line.split(' ', 1)
|
|
||||||
try:
|
|
||||||
props = []
|
|
||||||
props.append(Property(name='VIEW',value='warn'))
|
|
||||||
props.append(Property(name='OP',value='PUT'))
|
|
||||||
props.append(Property(name='PRODID',value=values[0]))
|
|
||||||
props.append(Property(name='SCRIPT',value=values[1]))
|
|
||||||
msg = Message(header=Header(props))
|
|
||||||
except Exception,e:
|
|
||||||
raise MessageError('unable to create message for textdb request',e)
|
|
||||||
|
|
||||||
if ((len(values[0]) >= 8) & (len(values[1].strip('\r\n')) > 0)):
|
|
||||||
# print "Insert Subscription [" + values[0] + "] Status:" + str(sm.execute())
|
|
||||||
cline = ['-o','add', '-t','ldad', '-r','ldad', '-p', values[0], '-f', values[1], '-c','%TRIGGER%']
|
|
||||||
sm = SM.SubscriptionManager(name='textdb',args=cline)
|
|
||||||
sm.execute()
|
|
||||||
msg = self.__submitRequestMessage(msg)
|
|
||||||
status = self.__processRequestResponse(msg)
|
|
||||||
except ValueError:
|
|
||||||
util.printMessage(sys.stderr,
|
|
||||||
header='Error processing line',
|
|
||||||
body=line)
|
|
||||||
finally:
|
|
||||||
f.close()
|
|
||||||
else:
|
|
||||||
raise MessageError('Unable to locate file: ' + args[0])
|
|
||||||
else:
|
|
||||||
self.__deleteSubscriptions()
|
|
||||||
return
|
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
def __deleteWatchWarn(self):
|
|
||||||
props = []
|
|
||||||
props.append(Property(name='VIEW',value='warn'))
|
|
||||||
props.append(Property(name='OP',value='DELETE'))
|
|
||||||
msg = self.__submitRequestMessage(Message(header=Header(props)))
|
|
||||||
status = self.__processRequestResponse(msg)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Reference in a new issue