Merge "Omaha #5254 Remove dataURI from CWA plugin" into omaha_16.2.2
Former-commit-id: 3c405d873beae2c752e480de5f82c85360d5e7ae
This commit is contained in:
commit
d903d90bdf
6 changed files with 53 additions and 87 deletions
18
deltaScripts/16.2.2/DR5254/alter_cwa_drop_datauri.sh
Executable file
18
deltaScripts/16.2.2/DR5254/alter_cwa_drop_datauri.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
# DR #5254 - This script drops dataURI column from cwa table and adds a new
|
||||
# multi-column unique constraint
|
||||
|
||||
PSQL="/awips2/psql/bin/psql"
|
||||
|
||||
echo "INFO: Altering table cwa"
|
||||
|
||||
${PSQL} -U awips -d metadata << EOF
|
||||
begin transaction;
|
||||
delete from cwa where eventid is null;
|
||||
alter table cwa
|
||||
drop constraint if exists uk_cwa_datauri_fields,
|
||||
drop column if exists datauri,
|
||||
alter eventid set not null,
|
||||
add constraint uk_cwa_datauri_fields unique (reftime, eventid);
|
||||
commit transaction;
|
||||
EOF
|
|
@ -21,8 +21,6 @@ package com.raytheon.uf.common.dataplugin.cwa;
|
|||
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
|
@ -61,6 +59,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Oct 15, 2013 2361 njensen Removed XML annotations
|
||||
* Feb 27, 2014 2638 njensen Corrected dataURI annotation for eventId
|
||||
* Jul 23, 2015 2360 rferrel Add name to unique constraint.
|
||||
* Jan 25, 2016 5254 tgurney Remove dataURI column and update unique
|
||||
* constraint.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -69,7 +69,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "cwaseq")
|
||||
@Table(name = "cwa", uniqueConstraints = { @UniqueConstraint(name = "uk_cwa_datauri_fields", columnNames = { "dataURI" }) })
|
||||
@Table(name = "cwa", uniqueConstraints = { @UniqueConstraint(name = "uk_cwa_datauri_fields", columnNames = {
|
||||
"refTime", "eventId" }) })
|
||||
/*
|
||||
* Both refTime and forecastTime are included in the refTimeIndex since
|
||||
* forecastTime is unlikely to be used.
|
||||
|
@ -96,6 +97,7 @@ public class CWARecord extends PersistablePluginDataObject implements
|
|||
private CWADimension dimension;
|
||||
|
||||
@DataURI(position = 1)
|
||||
@Column(nullable = false)
|
||||
@DynamicSerializeElement
|
||||
private String eventId;
|
||||
|
||||
|
@ -139,17 +141,6 @@ public class CWARecord extends PersistablePluginDataObject implements
|
|||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the data uri for this observation.
|
||||
*
|
||||
* @param dataURI
|
||||
*/
|
||||
@Override
|
||||
public void setDataURI(String dataURI) {
|
||||
super.setDataURI(dataURI);
|
||||
identifier = dataURI;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
@ -181,13 +172,6 @@ public class CWARecord extends PersistablePluginDataObject implements
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Column
|
||||
@Access(AccessType.PROPERTY)
|
||||
public String getDataURI() {
|
||||
return super.getDataURI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "cwa";
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
<parameter name="latitude" numDims="1" type="FLOAT" unit="degree_N" />
|
||||
<parameter name="longitude" numDims="1" type="FLOAT" unit="degree_E" />
|
||||
<parameter name="wmoHeader" numDims="1" type="STRING" />
|
||||
<parameter name="dataURI" numDims="1" type="STRING" />
|
||||
<parameter name="dimension" numDims="1" type="STRING" />
|
||||
<parameter name="text" numDims="1" type="STRING" />
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.raytheon.uf.edex.plugin.cwa.util.TableLoader;
|
|||
* Apr 19, 2012 #457 dgilling Minor code cleanup.
|
||||
* Mar 25, 2014 2930 skorolev Fixed error in distance.
|
||||
* Apr 02, 2014 2930 skorolev Corrected log message.
|
||||
* Jan 26, 2016 5254 tgurney Discard reports where eventId is null.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -119,7 +120,12 @@ public class CWADecoder {
|
|||
while (parser.hasNext()) {
|
||||
report = parser.next();
|
||||
if (report != null) {
|
||||
obsList.add(report);
|
||||
if (report.getEventId() == null) {
|
||||
logger.warn("Discarding report with eventId = null: "
|
||||
+ report.toString());
|
||||
} else {
|
||||
obsList.add(report);
|
||||
}
|
||||
}
|
||||
if (!obsList.isEmpty()) {
|
||||
decodedData = obsList.toArray(new PluginDataObject[obsList
|
||||
|
|
|
@ -19,77 +19,37 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.plugin.cwa;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.dataplugin.cwa.CWARecord;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 1, 2010 jsanchez Initial creation
|
||||
*
|
||||
* Feb 1, 2010 jsanchez Initial creation
|
||||
* Jan 25, 2016 5254 tgurney Remove dead code
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author jsanchez
|
||||
* @version 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CWARecordDao extends PointDataPluginDao<CWARecord> {
|
||||
/**
|
||||
* Creates a new CWARecordnDao
|
||||
* @throws PluginException
|
||||
* Creates a new CWARecordDao
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
public CWARecordDao(String pluginName) throws PluginException {
|
||||
super(pluginName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an sfcobs report using the datauri .
|
||||
*
|
||||
* @param dataURI
|
||||
* The dataURI to match against.
|
||||
* @return The report record if it exists.
|
||||
*/
|
||||
public CWARecord queryByDataURI(String dataURI) {
|
||||
CWARecord report = null;
|
||||
List<?> obs = null;
|
||||
try {
|
||||
obs = queryBySingleCriteria("dataURI", dataURI);
|
||||
} catch (DataAccessLayerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if ((obs != null) && (obs.size() > 0)) {
|
||||
report = (CWARecord) obs.get(0);
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries for to determine if a given data uri exists on the sfcobs table.
|
||||
*
|
||||
* @param dataUri
|
||||
* The DataURI to find.
|
||||
* @return An array of objects. If not null, there should only be a single
|
||||
* element.
|
||||
*/
|
||||
public Object[] queryDataUriColumn(final String dataUri) {
|
||||
|
||||
String sql = "select datauri from awips.cwa where datauri='"
|
||||
+ dataUri + "';";
|
||||
|
||||
Object[] results = executeSQLQuery(sql);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getKeysRequiredForFileName() {
|
||||
return new String[] { "dataTime.refTime" };
|
||||
|
|
|
@ -54,11 +54,11 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
|
||||
/**
|
||||
* The County Warning Area (CWA) text Parser.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 01, 2010 jsanchez Initial creation
|
||||
|
@ -70,9 +70,10 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* May 04, 2015 4379 nabowle Set valid period. Support future end dates.
|
||||
* Drop bad dates. Extract patterns. eventId
|
||||
* is now only in the db.
|
||||
*
|
||||
* Jan 25, 2016 5254 tgurney Remove reference to dataURI column
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author jsanchez
|
||||
* @version 1.0
|
||||
*/
|
||||
|
@ -148,7 +149,6 @@ public class CWAParser {
|
|||
private static Pattern DIR_DIST_PTRN = Pattern
|
||||
.compile(InternalReport.DIRDIST);
|
||||
|
||||
|
||||
static {
|
||||
dirToDeg.put("N", 0f);
|
||||
dirToDeg.put("NNE", 22.5f);
|
||||
|
@ -184,7 +184,7 @@ public class CWAParser {
|
|||
|
||||
/**
|
||||
* Does this parser contain any more reports.
|
||||
*
|
||||
*
|
||||
* @return Does this parser contain any more reports.
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
|
@ -202,7 +202,7 @@ public class CWAParser {
|
|||
/**
|
||||
* Get the next available report. Returns a null reference if no more
|
||||
* reports are available.
|
||||
*
|
||||
*
|
||||
* @return The next available report.
|
||||
*/
|
||||
public CWARecord next() {
|
||||
|
@ -230,7 +230,6 @@ public class CWAParser {
|
|||
// Populate the point data.
|
||||
PointDataView view = pdc.append();
|
||||
view.setString("wmoHeader", report.getWmoHeader());
|
||||
view.setString("dataURI", report.getDataURI());
|
||||
view.setString("dimension", report.getDimension().toString());
|
||||
view.setString("text", report.getText());
|
||||
|
||||
|
@ -250,7 +249,7 @@ public class CWAParser {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param obsData
|
||||
* @return
|
||||
*/
|
||||
|
@ -324,7 +323,7 @@ public class CWAParser {
|
|||
|
||||
/**
|
||||
* Validates the current report and adds valid reports to the list.
|
||||
*
|
||||
*
|
||||
* @param reports
|
||||
* The list to add valid reports to.
|
||||
*/
|
||||
|
@ -340,7 +339,7 @@ public class CWAParser {
|
|||
|
||||
/**
|
||||
* Set the message data and decode all message reports.
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* Raw message data.
|
||||
* @param traceId
|
||||
|
@ -528,7 +527,7 @@ public class CWAParser {
|
|||
|
||||
/**
|
||||
* Get the issuance data time.
|
||||
*
|
||||
*
|
||||
* @param timeStr
|
||||
* The datatime string.
|
||||
* @return DataTime from header
|
||||
|
@ -545,7 +544,7 @@ public class CWAParser {
|
|||
|
||||
/**
|
||||
* Get the Valid To data time.
|
||||
*
|
||||
*
|
||||
* @param timeStr
|
||||
* The datatime string.
|
||||
* @return The valid to DataTime.
|
||||
|
|
Loading…
Add table
Reference in a new issue