Omaha #5309 Drop dataURI column from bufrsigwx
Change-Id: Id1a3290845edc4787a37da3c3119b4977d0419d5 Former-commit-id: 90055d2a94cfcaaf0cb74b02d159b2a51c7efbbd
This commit is contained in:
parent
8a883a2a3c
commit
9901cd4d60
5 changed files with 51 additions and 84 deletions
|
@ -29,8 +29,6 @@ import org.eclipse.swt.graphics.Rectangle;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.bufrsigwx.SigWxData;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
|
||||
import com.raytheon.uf.common.pointdata.PointDataContainer;
|
||||
import com.raytheon.uf.common.pointdata.PointDataView;
|
||||
|
@ -57,6 +55,7 @@ import com.raytheon.viz.pointdata.PointDataRequest;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 28, 2009 3099 bsteffen Initial creation
|
||||
* Nov 05, 2015 5070 randerso Adjust font sizes for dpi scaling
|
||||
* Feb 04, 2015 5309 tgurney Remove dependency on dataURI
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -168,21 +167,11 @@ public abstract class SigWxResource extends
|
|||
* @throws VizException
|
||||
*/
|
||||
protected void updateRecords(DataTime dataTime) throws VizException {
|
||||
|
||||
RequestConstraint constraint = new RequestConstraint();
|
||||
|
||||
constraint.setConstraintType(ConstraintType.IN);
|
||||
|
||||
for (SigWxData record : recordsToParse.get(dataTime)) {
|
||||
constraint.addToConstraintValueList(record.getDataURI());
|
||||
}
|
||||
Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
|
||||
constraints.put("dataURI", constraint);
|
||||
// Request the point data
|
||||
PointDataContainer pdc = PointDataRequest.requestPointDataAllLevels(
|
||||
dataTime, resourceData.getMetadataMap().get("pluginName")
|
||||
.getConstraintValue(), getParameters(), null,
|
||||
constraints);
|
||||
resourceData.getMetadataMap());
|
||||
if (recordsToDisplay.containsKey(dataTime)) {
|
||||
recordsToDisplay.get(dataTime).combine(pdc);
|
||||
} else {
|
||||
|
|
26
deltaScripts/16.2.2/DR5309/alter_bufrsigwx_drop_datauri.sh
Executable file
26
deltaScripts/16.2.2/DR5309/alter_bufrsigwx_drop_datauri.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
# DR #5309 - This script drops dataURI column from bufrsigwx table and adds a
|
||||
# new multi-column unique constraint
|
||||
|
||||
TABLE=bufrsigwx
|
||||
|
||||
PSQL="/awips2/psql/bin/psql"
|
||||
|
||||
echo "INFO: Altering table ${TABLE}"
|
||||
|
||||
${PSQL} -U awips -d metadata << EOF
|
||||
begin transaction;
|
||||
delete from ${TABLE}
|
||||
where wxLayer is null
|
||||
or wxType is null
|
||||
or key is null;
|
||||
alter table ${TABLE}
|
||||
drop constraint if exists uk_${TABLE}_datauri_fields,
|
||||
drop column if exists datauri,
|
||||
alter wxLayer set not null,
|
||||
alter wxType set not null,
|
||||
alter key set not null,
|
||||
add constraint uk_${TABLE}_datauri_fields unique
|
||||
(reftime, wxLayer, wxType, key);
|
||||
commit transaction;
|
||||
EOF
|
|
@ -19,8 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.dataplugin.bufrsigwx;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
|
@ -60,6 +58,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Oct 14, 2013 2361 njensen Removed XML annotations and IDecoderGettable
|
||||
* Jul 23, 2015 2360 rferrel Add name to unique constraint.
|
||||
* Feb 04, 2015 5309 tgurney Drop dataURI column and update unique constraint.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -68,7 +67,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "bufrsigwxseq")
|
||||
@Table(name = "bufrsigwx", uniqueConstraints = { @UniqueConstraint(name = "uk_bufrsigwx_datauri_fields", columnNames = { "dataURI" }) })
|
||||
@Table(name = "bufrsigwx", uniqueConstraints = { @UniqueConstraint(name = "uk_bufrsigwx_datauri_fields", columnNames = {
|
||||
"refTime", "wxLayer", "wxType", "key" }) })
|
||||
/*
|
||||
* Both refTime and forecastTime are included in the refTimeIndex since
|
||||
* forecastTime is unlikely to be used.
|
||||
|
@ -81,17 +81,17 @@ public class SigWxData extends PersistablePluginDataObject implements
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column
|
||||
@Column(nullable = false)
|
||||
@DataURI(position = 1)
|
||||
@DynamicSerializeElement
|
||||
private SigWxLayer wxLayer;
|
||||
|
||||
@Column
|
||||
@Column(nullable = false)
|
||||
@DataURI(position = 2)
|
||||
@DynamicSerializeElement
|
||||
private SigWxType wxType;
|
||||
|
||||
@Column
|
||||
@Column(nullable = false)
|
||||
@DataURI(position = 3)
|
||||
@DynamicSerializeElement
|
||||
private Integer key;
|
||||
|
@ -275,13 +275,6 @@ public class SigWxData extends PersistablePluginDataObject implements
|
|||
return obs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Column
|
||||
@Access(AccessType.PROPERTY)
|
||||
public String getDataURI() {
|
||||
return super.getDataURI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "bufrsigwx";
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.plugin.bufrsigwx;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
|
@ -28,11 +27,10 @@ import com.raytheon.uf.common.dataplugin.bufrsigwx.common.SigWxLayer;
|
|||
import com.raytheon.uf.common.dataplugin.bufrsigwx.common.SigWxType;
|
||||
import com.raytheon.uf.common.pointdata.PointDataDescription;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* DAO for bufrsigwx
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -41,6 +39,7 @@ import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 18, 2009 jkorman Initial creation
|
||||
* Feb 04, 2016 5309 tgurney Remove dead code
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -50,7 +49,7 @@ import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
|
|||
public class SigWxDataDao extends PointDataPluginDao<SigWxData> {
|
||||
|
||||
/**
|
||||
* Creates a new BufrMOSDao object.
|
||||
* Creates a new SigWxDataDao object.
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
|
@ -58,46 +57,6 @@ public class SigWxDataDao extends PointDataPluginDao<SigWxData> {
|
|||
super(pluginName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an MOS report using the datauri .
|
||||
*
|
||||
* @param dataURI
|
||||
* The dataURI to match against.
|
||||
* @return The report record if it exists.
|
||||
*/
|
||||
public SigWxData queryByDataURI(String dataURI) {
|
||||
SigWxData report = null;
|
||||
List<?> obs = null;
|
||||
try {
|
||||
obs = queryBySingleCriteria("dataURI", dataURI);
|
||||
} catch (DataAccessLayerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if ((obs != null) && (obs.size() > 0)) {
|
||||
report = (SigWxData) obs.get(0);
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries for to determine if a given data uri exists on the profiler
|
||||
* 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.bufrsigwx where datauri='"
|
||||
+ dataUri + "';";
|
||||
|
||||
Object[] results = executeSQLQuery(sql);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getKeysRequiredForFileName() {
|
||||
return new String[] { "dataTime.refTime", "wxType", "wxLayer" };
|
||||
|
@ -126,13 +85,6 @@ public class SigWxDataDao extends PointDataPluginDao<SigWxData> {
|
|||
return new SigWxData();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.edex.pointdata.PointDataPluginDao#getPointDataDescription
|
||||
* (java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public PointDataDescription getPointDataDescription(Map<String, Object> obj) {
|
||||
SigWxLayer layer = (SigWxLayer) obj.get("wxLayer");
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.dataplugin.bufrsigwx.SigWxData;
|
||||
import com.raytheon.uf.common.pointdata.PointDataDescription;
|
||||
import com.raytheon.uf.common.wmo.WMOHeader;
|
||||
|
@ -43,6 +42,9 @@ import com.raytheon.uf.edex.plugin.bufrsigwx.decoder.SigWxDataAdapter;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 21, 2009 1939 jkorman Initial creation
|
||||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Feb 04, 2016 5309 tgurney Remove call to constructDataURI and
|
||||
* check for null on dataURI component
|
||||
* fields
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -87,13 +89,18 @@ public class SigWxDecoder extends AbstractBUFRDecoder {
|
|||
if (sigwx != null) {
|
||||
for (SigWxData d : sigwx) {
|
||||
d.setTraceId(traceId);
|
||||
try {
|
||||
d.constructDataURI();
|
||||
} catch (PluginException e) {
|
||||
logger.error(traceId
|
||||
+ "- Unable to construct dataURI", e);
|
||||
if (d.getWxLayer() == null) {
|
||||
logger.warn("Discarding record with wxLayer == null: "
|
||||
+ d.toString());
|
||||
} else if (d.getWxType() == null) {
|
||||
logger.warn("Discarding record with wxType == null: "
|
||||
+ d.toString());
|
||||
} else if (d.getKey() == null) {
|
||||
logger.warn("Discarding record with key == null: "
|
||||
+ d.toString());
|
||||
} else {
|
||||
decodedData.add(d);
|
||||
}
|
||||
decodedData.add(d);
|
||||
}
|
||||
} else {
|
||||
logger.info("No data returned from createDataList");
|
||||
|
|
Loading…
Add table
Reference in a new issue