Merge "Omaha #5254 Remove dataURI from CWA plugin" into omaha_16.2.2

Former-commit-id: 3c405d873beae2c752e480de5f82c85360d5e7ae
This commit is contained in:
Richard Peter 2016-01-26 12:53:46 -06:00 committed by Gerrit Code Review
commit d903d90bdf
6 changed files with 53 additions and 87 deletions

View 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

View file

@ -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";

View file

@ -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" />

View file

@ -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,8 +120,13 @@ public class CWADecoder {
while (parser.hasNext()) {
report = parser.next();
if (report != null) {
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
.size()]);

View file

@ -19,11 +19,8 @@
**/
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;
/**
@ -36,6 +33,7 @@ import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 1, 2010 jsanchez Initial creation
* Jan 25, 2016 5254 tgurney Remove dead code
*
* </pre>
*
@ -44,52 +42,14 @@ import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
*/
public class CWARecordDao extends PointDataPluginDao<CWARecord> {
/**
* Creates a new CWARecordnDao
* 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" };

View file

@ -70,6 +70,7 @@ 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>
*
@ -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);
@ -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());