Issue #2060 dropping grid dataURI column
Change-Id: I8b8ba3f2ec71e15aa3c40e7eab42525dbf09157e Former-commit-id: 1aab87d9572089a09351ebdfb8fbcef884866feb
This commit is contained in:
parent
35891b2dcd
commit
5dfb652775
12 changed files with 201 additions and 135 deletions
|
@ -19,7 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.viz.hydro.flashfloodguidance;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -27,12 +26,10 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.datastorage.StorageException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -51,6 +48,7 @@ import com.raytheon.viz.hydrocommon.HydroConstants;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 03Sept2008 #1507 dhladky Initial Creation.
|
||||
* 12Oct2009 2256 mpduff Added additional data query capability.
|
||||
* Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -59,13 +57,12 @@ import com.raytheon.viz.hydrocommon.HydroConstants;
|
|||
*/
|
||||
|
||||
public class FlashFloodGuidanceDataManager {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(FlashFloodGuidanceDataManager.class);
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(FlashFloodGuidanceDataManager.class);
|
||||
|
||||
/** Instance of this class */
|
||||
private static FlashFloodGuidanceDataManager instance = null;
|
||||
|
||||
private static final String LINESEGS_QUERY = "select hrap_row, hrap_beg_col, "
|
||||
+ "hrap_end_col, area from linesegs";
|
||||
|
||||
/** RFC Site name to RFC lookup map */
|
||||
public static Map<String, String> RFCMAP = new HashMap<String, String>();
|
||||
|
||||
|
@ -136,8 +133,6 @@ public class FlashFloodGuidanceDataManager {
|
|||
query.addColumn(GridConstants.DATASET_ID);
|
||||
query.addColumn(GridConstants.PARAMETER_ABBREVIATION);
|
||||
query.addColumn("dataTime.refTime");
|
||||
query.addColumn("dataURI");
|
||||
query.addColumn("id");
|
||||
query.addConstraint(GridConstants.DATASET_ID, new RequestConstraint(
|
||||
"FFG%", ConstraintType.LIKE));
|
||||
query.addConstraint(GridConstants.SECONDARY_ID, "Version0");
|
||||
|
@ -174,8 +169,7 @@ public class FlashFloodGuidanceDataManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
public GridRecord getGridRecord(String uri) throws PluginException,
|
||||
FileNotFoundException, StorageException {
|
||||
public GridRecord getGridRecord(String uri) {
|
||||
StringBuilder query = new StringBuilder();
|
||||
query.append("from "
|
||||
+ com.raytheon.uf.common.dataplugin.grid.GridRecord.class
|
||||
|
@ -197,8 +191,9 @@ public class FlashFloodGuidanceDataManager {
|
|||
List<Object[]> rs = null;
|
||||
|
||||
try {
|
||||
rs = DirectDbQuery.executeQuery("select area_id, interior_lat, interior_lon from geoArea " + where,
|
||||
HydroConstants.IHFS, QueryLanguage.SQL);
|
||||
rs = DirectDbQuery.executeQuery(
|
||||
"select area_id, interior_lat, interior_lon from geoArea "
|
||||
+ where, HydroConstants.IHFS, QueryLanguage.SQL);
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "FFG Query"
|
||||
+ " Error querying GeoArea table");
|
||||
|
@ -207,7 +202,8 @@ public class FlashFloodGuidanceDataManager {
|
|||
return rs;
|
||||
}
|
||||
|
||||
public List<Object[]> getContingencyValue(String areaId, int duration, Date refTime) {
|
||||
public List<Object[]> getContingencyValue(String areaId, int duration,
|
||||
Date refTime) {
|
||||
List<Object[]> rs = null;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
|
@ -227,14 +223,14 @@ public class FlashFloodGuidanceDataManager {
|
|||
dur = 2001;
|
||||
}
|
||||
|
||||
String where = " where pe = 'PP' and ts = 'CF' and " +
|
||||
"validtime >= '" + date + "' and lid = '" + areaId + "' " +
|
||||
"and dur = " + dur + " order by validtime desc;";
|
||||
String where = " where pe = 'PP' and ts = 'CF' and " + "validtime >= '"
|
||||
+ date + "' and lid = '" + areaId + "' " + "and dur = " + dur
|
||||
+ " order by validtime desc;";
|
||||
|
||||
try {
|
||||
rs = DirectDbQuery.executeQuery("select lid, validtime, value from " +
|
||||
"contingencyvalue " + where,
|
||||
HydroConstants.IHFS, QueryLanguage.SQL);
|
||||
rs = DirectDbQuery.executeQuery(
|
||||
"select lid, validtime, value from " + "contingencyvalue "
|
||||
+ where, HydroConstants.IHFS, QueryLanguage.SQL);
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "FFG Query"
|
||||
+ " Error querying ContingencyValue table");
|
||||
|
@ -246,15 +242,11 @@ public class FlashFloodGuidanceDataManager {
|
|||
|
||||
public List<Object[]> getContingencyValue(String boundaryType) {
|
||||
List<Object[]> rs = null;
|
||||
|
||||
String where = " where pe='PP' and ts='CF' and lid in (select area_id from " +
|
||||
"GeoArea where boundary_type = '" + boundaryType.toUpperCase() +
|
||||
"') order by validtime desc, dur asc";
|
||||
String sql = "select distinct(validtime), dur from contingencyvalue";
|
||||
|
||||
|
||||
try {
|
||||
rs = DirectDbQuery.executeQuery(sql,
|
||||
HydroConstants.IHFS, QueryLanguage.SQL);
|
||||
rs = DirectDbQuery.executeQuery(sql, HydroConstants.IHFS,
|
||||
QueryLanguage.SQL);
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "FFG Query"
|
||||
+ " Error querying ContingencyValue table");
|
||||
|
|
41
deltaScripts/14.3.1/dropGridDataURI.sh
Normal file
41
deltaScripts/14.3.1/dropGridDataURI.sh
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
# DR #2060 - this update script will drop the dataURI column from the grid table
|
||||
|
||||
PSQL="/awips2/psql/bin/psql"
|
||||
|
||||
# drops the datauri constraint and column if they exist
|
||||
function dropDatauri {
|
||||
echo "INFO: Dropping DataURI column from grid"
|
||||
${PSQL} -U awips -d metadata -c "ALTER TABLE grid DROP CONSTRAINT IF EXISTS grid_datauri_key;"
|
||||
${PSQL} -U awips -d metadata -c "ALTER TABLE grid DROP COLUMN IF EXISTS datauri;"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Failed to drop dataURI column for grid"
|
||||
echo "FATAL: The update has failed."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# takes three args: table, constraint name, unique columns
|
||||
# will first drop the constraint if it exists and then adds it back, this is
|
||||
# fairly inefficient if it does exist but operationally it won't exist and for
|
||||
# testing this allows the script to be run easily as a noop.
|
||||
function dropAndAddConstraint {
|
||||
${PSQL} -U awips -d metadata -c "ALTER TABLE $1 DROP CONSTRAINT IF EXISTS $2;"
|
||||
${PSQL} -U awips -d metadata -c "ALTER TABLE $1 ADD CONSTRAINT $2 UNIQUE $3;"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Failed to add new unique constraint for $1"
|
||||
echo "FATAL: The update has failed."
|
||||
exit 1
|
||||
fi
|
||||
${PSQL} -U awips -d metadata -c "VACUUM FULL ANALYZE $1"
|
||||
}
|
||||
|
||||
echo "INFO: Dropping dataURI columns."
|
||||
|
||||
dropDatauri
|
||||
dropAndAddConstraint grid grid_reftime_forecasttime_rangestart_rangeend_info_id "(refTime, forecastTime, rangestart, rangeend, info_id)"
|
||||
dropAndAddConstraint grid_info grid_info_datasetid_secondaryid_ensembleid_location_id_parameter_abbreviation_level_id "(datasetid, secondaryid, ensembleid, location_id, parameter_abbreviation, level_id)"
|
||||
|
||||
|
||||
echo "INFO: grid dataURI column dropped successfully"
|
|
@ -58,8 +58,8 @@ import com.raytheon.uf.edex.core.EDEXUtil;
|
|||
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils;
|
||||
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils.LockState;
|
||||
import com.raytheon.uf.edex.database.cluster.ClusterTask;
|
||||
import com.raytheon.uf.edex.database.plugin.DataURIDatabaseUtil;
|
||||
import com.raytheon.uf.edex.database.plugin.PluginFactory;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
||||
|
||||
/**
|
||||
|
@ -81,6 +81,7 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
|||
* Oct 15, 2013 2473 bsteffen Remove deprecated method calls.
|
||||
* Nov 19, 2013 2478 rjpeter Make update process update database also.
|
||||
* Dec 06, 2013 2170 rjpeter Update to pass PluginDataObject[] to notification.
|
||||
* Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -214,15 +215,11 @@ public class EnsembleGridAssembler implements IDecoderPostProcessor {
|
|||
*/
|
||||
private void processGrid(GridRecord record, CompositeModel thinned)
|
||||
throws Exception {
|
||||
|
||||
GridDao dao = (GridDao) PluginFactory.getInstance().getPluginDao(
|
||||
GridConstants.GRID);
|
||||
GridRecord assembledRecord = createAssembledRecord(record, thinned);
|
||||
DatabaseQuery query = new DatabaseQuery(GridRecord.class);
|
||||
query.addReturnedField("dataURI");
|
||||
query.addQueryParam("dataURI", assembledRecord.getDataURI());
|
||||
List<?> result = dao.queryByCriteria(query);
|
||||
if (result.isEmpty()) {
|
||||
boolean exists = DataURIDatabaseUtil.existingDataURI(assembledRecord);
|
||||
if (!exists) {
|
||||
persistNewRecord(record, assembledRecord, thinned, dao);
|
||||
} else {
|
||||
updateExistingRecord(record, assembledRecord, thinned, dao);
|
||||
|
|
|
@ -85,6 +85,7 @@ import com.vividsolutions.jts.io.WKTWriter;
|
|||
* 03/01/13 DR 13228 G. Zhang Add state for VGB query and related code
|
||||
* 03/18/13 1817 D. Hladky Fixed issue with BOX where only 1 HUC was showing up.
|
||||
* 08/20/13 2250 mnash Fixed incorrect return types for database queries.
|
||||
* Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
|
@ -943,10 +944,8 @@ public class FFMPUtils {
|
|||
*/
|
||||
public static String getFFGDataURI(String rfc, String parameter,
|
||||
String plugin) {
|
||||
|
||||
DbQueryRequest request = new DbQueryRequest();
|
||||
request.setEntityClass(GridRecord.class.getName());
|
||||
request.addRequestField("dataURI");
|
||||
request.addConstraint(GridConstants.PARAMETER_ABBREVIATION,
|
||||
new RequestConstraint(parameter));
|
||||
request.addConstraint(GridConstants.DATASET_ID, new RequestConstraint(
|
||||
|
@ -955,10 +954,7 @@ public class FFMPUtils {
|
|||
try {
|
||||
DbQueryResponse response = (DbQueryResponse) RequestRouter
|
||||
.route(request);
|
||||
|
||||
for (Map<String, Object> map : response.getResults()) {
|
||||
return (String) map.get("dataURI");
|
||||
}
|
||||
return response.getEntityObjects(GridRecord.class)[0].getDataURI();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.persistence.ManyToOne;
|
|||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
|
@ -53,6 +54,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* May 21, 2012 bsteffen Initial creation
|
||||
* Nov 25, 2013 2574 bsteffen Add converter to location dataURI
|
||||
* annotation.
|
||||
* Apr 15, 2014 2060 njensen Added unique constraint annotation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -60,7 +62,9 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* @version 1.0
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "grid_info")
|
||||
@Table(name = "grid_info", uniqueConstraints = { @UniqueConstraint(columnNames = {
|
||||
"datasetid", "secondaryid", "ensembleid", "location_id",
|
||||
"parameter_abbreviation", "level_id" }) })
|
||||
@SequenceGenerator(name = "GRIDINFO_GENERATOR", sequenceName = "gridinfo_seq", allocationSize = 1)
|
||||
@DynamicSerialize
|
||||
public class GridInfoRecord extends PersistableDataObject<Integer> {
|
||||
|
|
|
@ -22,9 +22,6 @@ package com.raytheon.uf.common.dataplugin.grid;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
|
@ -68,6 +65,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* PluginDataObject.
|
||||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Dec 16, 2013 2574 bsteffen Remove getDecoderGettable.
|
||||
* Apr 15, 2014 2060 njensen Remove dataURI column
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -76,7 +74,8 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
*/
|
||||
@Entity
|
||||
@SequenceGenerator(initialValue = 1, name = PluginDataObject.ID_GEN, sequenceName = "gridseq")
|
||||
@Table(name = "grid", uniqueConstraints = { @UniqueConstraint(columnNames = { "dataURI" }) })
|
||||
@Table(name = "grid", uniqueConstraints = { @UniqueConstraint(columnNames = {
|
||||
"refTime", "forecastTime", "rangestart", "rangeend", "info_id" }) })
|
||||
/*
|
||||
* Both refTime and forecastTime are included in the refTimeIndex since
|
||||
* forecastTime is unlikely to be used.
|
||||
|
@ -254,13 +253,6 @@ public class GridRecord extends PersistablePluginDataObject implements
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Column
|
||||
@Access(AccessType.PROPERTY)
|
||||
public String getDataURI() {
|
||||
return super.getDataURI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "grid";
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/**
|
||||
* 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.database.plugin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.dataplugin.annotations.DataURIUtil;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
|
||||
/**
|
||||
* Utilities related to dataURIs and their corresponding database tables.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 21, 2014 2060 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DataURIDatabaseUtil {
|
||||
|
||||
private DataURIDatabaseUtil() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for the existence in the database of a PluginDataObject that
|
||||
* matches the argument. The check for existence is based on if the dataURI
|
||||
* of the PluginDataObject matches.
|
||||
*
|
||||
* @param pdo
|
||||
* the PluginDataObject to check to see if its equivalent dataURI
|
||||
* is in the database
|
||||
* @return true if a matching dataURI was found, false otherwise
|
||||
* @throws PluginException
|
||||
*/
|
||||
public static boolean existingDataURI(PluginDataObject pdo)
|
||||
throws PluginException {
|
||||
PluginDao dao = PluginFactory.getInstance().getPluginDao(
|
||||
pdo.getPluginName());
|
||||
DatabaseQuery dbQuery = new DatabaseQuery(pdo.getClass());
|
||||
Map<String, Object> dataUriFields = DataURIUtil.createDataURIMap(pdo);
|
||||
for (Map.Entry<String, Object> field : dataUriFields.entrySet()) {
|
||||
String fieldName = field.getKey();
|
||||
// ignore pluginName
|
||||
if (!PluginDataObject.PLUGIN_NAME_ID.equals(fieldName)) {
|
||||
dbQuery.addQueryParam(field.getKey(), field.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
List<?> list = dao.queryByCriteria(dbQuery);
|
||||
return (list != null && !list.isEmpty());
|
||||
} catch (DataAccessLayerException e) {
|
||||
throw new PluginException("Error querying database", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -35,8 +35,7 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.plugin.DataURIDatabaseUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.handlers.RetrievalRequestWrapper;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.handlers.SubscriptionRetrievalRequestWrapper;
|
||||
|
||||
|
@ -54,6 +53,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.handlers.SubscriptionRetrieva
|
|||
* Dec 10, 2012 1259 bsteffen Switch Data Delivery from LatLon to referenced envelopes.
|
||||
* Dec 11, 2013 2625 mpduff Remove creation of DataURI.
|
||||
* Jan 30, 2014 2686 dhladky refactor of retrieval.
|
||||
* Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -65,31 +65,6 @@ public class RetrievalGeneratorUtilities {
|
|||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RetrievalGeneratorUtilities.class);
|
||||
|
||||
/**
|
||||
* Find duplicate URI's
|
||||
*
|
||||
* @param dataURI
|
||||
* @return
|
||||
*/
|
||||
public static boolean findDuplicateUri(String dataUri, String plugin) {
|
||||
|
||||
boolean isDuplicate = false;
|
||||
try {
|
||||
String sql = "select id from " + plugin + " where datauri = '"
|
||||
+ dataUri + "'";
|
||||
|
||||
CoreDao dao = new CoreDao(DaoConfig.forDatabase("metadata"));
|
||||
Object[] results = dao.executeSQLQuery(sql);
|
||||
if (results.length > 0) {
|
||||
isDuplicate = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Couldn't determine duplicate status! ", e);
|
||||
}
|
||||
|
||||
return isDuplicate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the duplicate URI's for grid
|
||||
*
|
||||
|
@ -116,13 +91,12 @@ public class RetrievalGeneratorUtilities {
|
|||
for (Level level : levels) {
|
||||
for (String ensembleMember : ensembleMembers) {
|
||||
try {
|
||||
|
||||
GridRecord rec = ResponseProcessingUtilities
|
||||
.getGridRecord(name, parm, level,
|
||||
ensembleMember, cov);
|
||||
rec.setDataTime(time);
|
||||
boolean isDup = findDuplicateUri(rec.getDataURI(),
|
||||
"grid");
|
||||
boolean isDup = DataURIDatabaseUtil
|
||||
.existingDataURI(rec);
|
||||
if (isDup) {
|
||||
levDups.add(level);
|
||||
}
|
||||
|
@ -140,7 +114,7 @@ public class RetrievalGeneratorUtilities {
|
|||
|
||||
return dups;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Drops Retrievals by subscription into a common queue for processing
|
||||
|
@ -151,7 +125,7 @@ public class RetrievalGeneratorUtilities {
|
|||
* @throws Exception
|
||||
*/
|
||||
public static void sendToRetrieval(String destinationUri, Network network,
|
||||
Object[] payload) throws Exception{
|
||||
Object[] payload) throws Exception {
|
||||
|
||||
if (payload != null) {
|
||||
|
||||
|
|
|
@ -50,10 +50,10 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
|||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils;
|
||||
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils.LockState;
|
||||
import com.raytheon.uf.edex.database.cluster.ClusterTask;
|
||||
import com.raytheon.uf.edex.database.plugin.DataURIDatabaseUtil;
|
||||
import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
||||
import com.raytheon.uf.edex.grid.staticdata.topo.StaticTopoData;
|
||||
import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
||||
|
@ -68,10 +68,11 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 3, 2010 rjpeter Initial creation
|
||||
* Dec 3, 2010 rjpeter Initial creation
|
||||
* Feb 15, 2013 1638 mschenke Moved DataURINotificationMessage to uf.common.dataplugin
|
||||
* Mar 07, 2013 1587 bsteffen rewrite static data generation.
|
||||
* Mar 14, 2013 1587 bsteffen Fix persisting to datastore.
|
||||
* Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -383,19 +384,19 @@ public class StaticDataGenerator {
|
|||
|
||||
/**
|
||||
* Return a set with only records which are not already in the database
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
private Set<GridRecord> checkDatabase(GridDao dao,
|
||||
Set<GridRecord> staticRecords) throws DataAccessLayerException {
|
||||
Set<GridRecord> staticRecords) throws PluginException {
|
||||
if (staticRecords.isEmpty()) {
|
||||
return staticRecords;
|
||||
}
|
||||
Set<GridRecord> missing = new HashSet<GridRecord>();
|
||||
for (GridRecord staticRecord : staticRecords) {
|
||||
// a possible future optimization would be to do one bulk query for
|
||||
// all records.
|
||||
List<?> list = dao.queryBySingleCriteria("dataURI",
|
||||
staticRecord.getDataURI());
|
||||
if (list.isEmpty()) {
|
||||
// TODO a possible future optimization would be to do one bulk query
|
||||
// for all records.
|
||||
if (!DataURIDatabaseUtil.existingDataURI(staticRecord)) {
|
||||
missing.add(staticRecord);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Jan 26, 2011 snaples Initial creation
|
||||
* Jan 10, 2013 1448 bgonzale Added app context check in processArealQpe().
|
||||
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
|
||||
* Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -152,11 +153,6 @@ public class ArealQpeGenSrv {
|
|||
|
||||
private Rectangle wfoExtent;
|
||||
|
||||
/**
|
||||
* The reference time
|
||||
*/
|
||||
private Date grReftime = null;
|
||||
|
||||
/**
|
||||
* The previous Duration
|
||||
*/
|
||||
|
@ -588,7 +584,7 @@ public class ArealQpeGenSrv {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the data URI
|
||||
* Get the grid record
|
||||
*
|
||||
* @param rfc
|
||||
* The RFC
|
||||
|
@ -599,13 +595,12 @@ public class ArealQpeGenSrv {
|
|||
* @return The database uri, or null if no data
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
private String getDataURI(String rfc, String duration, String today)
|
||||
private GridRecord getGridRecord(String rfc, String duration, String today)
|
||||
throws DataAccessLayerException {
|
||||
String uri = null;
|
||||
GridRecord rec = null;
|
||||
|
||||
// Query for uri
|
||||
DatabaseQuery query = new DatabaseQuery(GridRecord.class);
|
||||
query.addReturnedField("dataURI");
|
||||
query.addQueryParam(GridConstants.DATASET_ID, "QPE-" + rfc);
|
||||
query.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, "QPE"
|
||||
+ duration + "%", "like");
|
||||
|
@ -615,13 +610,12 @@ public class ArealQpeGenSrv {
|
|||
dao = new CoreDao(DaoConfig.forDatabase("metadata"));
|
||||
List<?> rs = dao.queryByCriteria(query);
|
||||
if ((rs != null) && (!rs.isEmpty())) {
|
||||
if ((rs.get(0) != null) && (rs.get(0) instanceof String)) {
|
||||
uri = (String) rs.get(0);
|
||||
Object result = rs.get(0);
|
||||
if (result != null && result instanceof GridRecord) {
|
||||
rec = ((GridRecord) result);
|
||||
}
|
||||
} else {
|
||||
uri = null;
|
||||
}
|
||||
return uri;
|
||||
return rec;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -656,19 +650,13 @@ public class ArealQpeGenSrv {
|
|||
IDataStore dataStore = null;
|
||||
|
||||
try {
|
||||
uri = getDataURI(rfc, durString, today);
|
||||
if (uri == null) {
|
||||
grReftime = cal.getTime();
|
||||
GridRecord gr = getGridRecord(rfc, durString, today);
|
||||
if (gr == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GridRecord gr = new GridRecord(uri);
|
||||
PluginDao gd = null;
|
||||
|
||||
gd = PluginFactory.getInstance().getPluginDao(gr.getPluginName());
|
||||
gr = (GridRecord) gd.getMetadata(uri);
|
||||
grReftime = gr.getDataTime().getRefTime();
|
||||
|
||||
dataStore = gd.getDataStore(gr);
|
||||
|
||||
int nx = gr.getSpatialObject().getNx();
|
||||
|
|
|
@ -65,6 +65,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Sep 5, 2013 16437 wkwock Fix the "HiRes" issue
|
||||
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
|
||||
* Apr 10, 2014 2675 mpduff Modified to be called from quartz timer.
|
||||
* Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -263,7 +264,6 @@ public class GAFF {
|
|||
.buildThreadLocalSimpleDateFormat("yyyy-MM-dd HH:mm:ss",
|
||||
TimeZone.getTimeZone("GMT"));
|
||||
String today = sdf.get().format(cal.getTime());
|
||||
String uri = null;
|
||||
IDataRecord dataRec;
|
||||
Rectangle rfcExtent = null;
|
||||
|
||||
|
@ -307,22 +307,18 @@ public class GAFF {
|
|||
IDataStore dataStore = null;
|
||||
|
||||
try {
|
||||
uri = db.getDataURI(rfc, durString, today);
|
||||
if (uri == null) {
|
||||
uri = db.getDataURI(rfc + "-HiRes", durString, today);
|
||||
GridRecord gr = db.getGridRecord(rfc, durString, today);
|
||||
if (gr == null) {
|
||||
gr = db.getGridRecord(rfc + "-HiRes", durString, today);
|
||||
}
|
||||
if (uri == null) {
|
||||
if (gr == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GridRecord gr = new GridRecord(uri);
|
||||
PluginDao gd = null;
|
||||
|
||||
gd = PluginFactory.getInstance().getPluginDao(
|
||||
gr.getPluginName());
|
||||
gr = (GridRecord) gd.getMetadata(uri);
|
||||
grReftime = gr.getDataTime().getRefTime();
|
||||
|
||||
dataStore = gd.getDataStore(gr);
|
||||
|
||||
int nx = gr.getSpatialObject().getNx();
|
||||
|
@ -341,7 +337,8 @@ public class GAFF {
|
|||
(int) ulRfcNationalScale.y - ny, nx, ny);
|
||||
extentsMap.put(rfc, rfcExtent);
|
||||
|
||||
dataRec = dataStore.retrieve(uri, "Data", Request.ALL);
|
||||
dataRec = dataStore.retrieve(gr.getDataURI(), "Data",
|
||||
Request.ALL);
|
||||
|
||||
if (dataRec instanceof FloatDataRecord) {
|
||||
gridMap.put(rfc, ((FloatDataRecord) dataRec).getFloatData());
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 11, 2011 mpduff Initial creation
|
||||
* Mar 28, 2014 2952 mpduff Changed to use UFStatus for logging.
|
||||
* Apr 21, 2014 2060 njensen Remove dependency on grid dataURI column
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -152,7 +153,7 @@ public class GAFFDB {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the data URI
|
||||
* Get the grid record
|
||||
*
|
||||
* @param rfc
|
||||
* The RFC
|
||||
|
@ -163,13 +164,10 @@ public class GAFFDB {
|
|||
* @return The database uri, or null if no data
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public String getDataURI(String rfc, String duration, String today)
|
||||
public GridRecord getGridRecord(String rfc, String duration, String today)
|
||||
throws DataAccessLayerException {
|
||||
String uri = null;
|
||||
|
||||
// Query for uri
|
||||
GridRecord rec = null;
|
||||
DatabaseQuery query = new DatabaseQuery(GridRecord.class);
|
||||
query.addReturnedField("dataURI");
|
||||
query.addQueryParam(GridConstants.DATASET_ID, "FFG-" + rfc);
|
||||
query.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, "FFG"
|
||||
+ duration + "24hr");
|
||||
|
@ -180,14 +178,13 @@ public class GAFFDB {
|
|||
dao = new CoreDao(DaoConfig.forDatabase("metadata"));
|
||||
List<?> rs = dao.queryByCriteria(query);
|
||||
if ((rs != null) && (!rs.isEmpty())) {
|
||||
if ((rs.get(0) != null) && (rs.get(0) instanceof String)) {
|
||||
uri = (String) rs.get(0);
|
||||
Object result = rs.get(0);
|
||||
if (result != null && result instanceof GridRecord) {
|
||||
rec = ((GridRecord) result);
|
||||
}
|
||||
} else {
|
||||
uri = null;
|
||||
}
|
||||
|
||||
return uri;
|
||||
return rec;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue