Issue #189 switch gfe to grid.
Former-commit-id:5cf650b61a
[formerly 7c029a18dcfd9f955fd3a9a2351d5dfef6d18912] Former-commit-id:4ab3357b8d
This commit is contained in:
parent
fcf5cba055
commit
18da7f96bd
6 changed files with 117 additions and 141 deletions
|
@ -21,6 +21,7 @@ Require-Bundle: com.raytheon.uf.common.dataplugin.gfe;bundle-version="1.12.1174"
|
|||
org.springframework,
|
||||
org.junit;bundle-version="1.0.0",
|
||||
com.raytheon.edex.plugin.grib,
|
||||
com.raytheon.uf.edex.plugin.grid,
|
||||
com.raytheon.messaging.mhs;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.datastorage.hdf5;bundle-version="1.11.24",
|
||||
ncsa.hdf5;bundle-version="2.4.0",
|
||||
|
@ -33,7 +34,8 @@ Require-Bundle: com.raytheon.uf.common.dataplugin.gfe;bundle-version="1.12.1174"
|
|||
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.plugin.nwsauth;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.site;bundle-version="1.12.1174",
|
||||
ucar.nc2;bundle-version="1.0.0"
|
||||
ucar.nc2;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.parameter;bundle-version="1.0.0"
|
||||
Export-Package: com.raytheon.edex.plugin.gfe,
|
||||
com.raytheon.edex.plugin.gfe.config,
|
||||
com.raytheon.edex.plugin.gfe.db.dao,
|
||||
|
@ -51,16 +53,14 @@ Import-Package: com.raytheon.edex.db.dao,
|
|||
com.raytheon.edex.db.mapping,
|
||||
com.raytheon.edex.msg,
|
||||
com.raytheon.edex.plugin,
|
||||
com.raytheon.edex.plugin.grib.dao,
|
||||
com.raytheon.edex.site,
|
||||
com.raytheon.edex.topo,
|
||||
com.raytheon.edex.util,
|
||||
com.raytheon.edex.util.grib,
|
||||
com.raytheon.uf.common.activetable,
|
||||
com.raytheon.uf.common.comm,
|
||||
com.raytheon.uf.common.dataplugin,
|
||||
com.raytheon.uf.common.dataplugin.annotations,
|
||||
com.raytheon.uf.common.dataplugin.grib,
|
||||
com.raytheon.uf.common.dataplugin.grid,
|
||||
com.raytheon.uf.common.dataplugin.level,
|
||||
com.raytheon.uf.common.dataplugin.persist,
|
||||
com.raytheon.uf.common.dataplugin.warning,
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</bean>
|
||||
|
||||
<bean id="gfeRegistered" factory-bean="pluginRegistry" factory-method="register"
|
||||
depends-on="gribRegistered, textRegistered">
|
||||
depends-on="gridRegistered, textRegistered">
|
||||
<constructor-arg value="gfe" />
|
||||
<constructor-arg ref="gfeProperties" />
|
||||
</bean>
|
||||
|
|
|
@ -41,8 +41,6 @@ import com.raytheon.edex.plugin.gfe.server.database.D2DSatDatabase;
|
|||
import com.raytheon.edex.plugin.gfe.server.database.D2DSatDatabaseManager;
|
||||
import com.raytheon.edex.plugin.gfe.server.database.GridDatabase;
|
||||
import com.raytheon.edex.plugin.grib.util.DataFieldTableLookup;
|
||||
import com.raytheon.edex.plugin.grib.util.GribModelLookup;
|
||||
import com.raytheon.edex.plugin.grib.util.GridModel;
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
|
||||
|
@ -328,19 +326,17 @@ public class D2DParmIdCache {
|
|||
IFPServerConfig config = IFPServerConfigManager
|
||||
.getServerConfig(siteID);
|
||||
GFEDao dao = new GFEDao();
|
||||
GribModelLookup modelLookup = GribModelLookup.getInstance();
|
||||
Set<ParmID> parmIds = new HashSet<ParmID>();
|
||||
long start = System.currentTimeMillis();
|
||||
List<String> d2dModels = config.getD2dModels();
|
||||
for (String d2dModelName : d2dModels) {
|
||||
GridModel model = modelLookup.getModelByName(d2dModelName);
|
||||
String gfeModel = config.gfeModelNameMapping(d2dModelName);
|
||||
|
||||
if ((model != null) && (gfeModel != null)) {
|
||||
if ((d2dModelName != null) && (gfeModel != null)) {
|
||||
List<DatabaseID> dbIds = null;
|
||||
try {
|
||||
dbIds = dao.getD2DDatabaseIdsFromDb(model, gfeModel,
|
||||
siteID);
|
||||
dbIds = dao.getD2DDatabaseIdsFromDb(d2dModelName,
|
||||
gfeModel, siteID);
|
||||
} catch (DataAccessLayerException e) {
|
||||
throw new PluginException(
|
||||
"Unable to get D2D Database Ids from database!",
|
||||
|
@ -354,8 +350,8 @@ public class D2DParmIdCache {
|
|||
|
||||
for (int i = 0; i < versions; i++) {
|
||||
try {
|
||||
parmIds.addAll(dao.getD2DParmIdsFromDb(model,
|
||||
dbIds.get(i)));
|
||||
parmIds.addAll(dao.getD2DParmIdsFromDb(
|
||||
d2dModelName, dbIds.get(i)));
|
||||
} catch (DataAccessLayerException e) {
|
||||
throw new PluginException(
|
||||
"Error adding parmIds to D2DParmIdCache!!",
|
||||
|
|
|
@ -41,8 +41,6 @@ import com.raytheon.edex.plugin.gfe.server.database.GridDatabase;
|
|||
import com.raytheon.edex.plugin.gfe.server.database.NetCDFDatabaseManager;
|
||||
import com.raytheon.edex.plugin.gfe.server.database.TopoDatabaseManager;
|
||||
import com.raytheon.edex.plugin.gfe.smartinit.SmartInitRecord;
|
||||
import com.raytheon.edex.plugin.grib.util.GribModelLookup;
|
||||
import com.raytheon.edex.plugin.grib.util.GridModel;
|
||||
import com.raytheon.edex.site.SiteUtil;
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
|
||||
|
@ -408,25 +406,24 @@ public class GFESiteActivation implements ISiteActivationListener {
|
|||
boolean clearTime = false;
|
||||
try {
|
||||
GFEDao dao = new GFEDao();
|
||||
GribModelLookup modelLookup = GribModelLookup
|
||||
.getInstance();
|
||||
List<String> d2dModels = configRef.getD2dModels();
|
||||
List<List<String>> idsByVersion = new ArrayList<List<String>>(
|
||||
5);
|
||||
for (String d2dModelName : d2dModels) {
|
||||
GridModel model = modelLookup
|
||||
.getModelByName(d2dModelName);
|
||||
|
||||
String gfeModel = configRef
|
||||
.gfeModelNameMapping(d2dModelName);
|
||||
|
||||
if ((model != null) && (gfeModel != null)) {
|
||||
if ((d2dModelName != null)
|
||||
&& (gfeModel != null)) {
|
||||
int versions = configRef
|
||||
.desiredDbVersions(new DatabaseID(
|
||||
siteID, DataType.GRID, "",
|
||||
gfeModel));
|
||||
List<DatabaseID> dbIds = dao
|
||||
.getD2DDatabaseIdsFromDb(model,
|
||||
gfeModel, siteID, versions);
|
||||
.getD2DDatabaseIdsFromDb(
|
||||
d2dModelName, gfeModel,
|
||||
siteID, versions);
|
||||
|
||||
while (versions > idsByVersion.size()) {
|
||||
idsByVersion.add(new ArrayList<String>(
|
||||
|
@ -593,4 +590,4 @@ public class GFESiteActivation implements ISiteActivationListener {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -58,7 +58,6 @@ import com.raytheon.edex.plugin.gfe.server.database.GridDatabase;
|
|||
import com.raytheon.edex.plugin.gfe.util.GridTranslator;
|
||||
import com.raytheon.edex.plugin.gfe.util.SendNotifications;
|
||||
import com.raytheon.edex.plugin.grib.util.DataFieldTableLookup;
|
||||
import com.raytheon.edex.plugin.grib.util.GridModel;
|
||||
import com.raytheon.uf.common.comm.CommunicationException;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
|
@ -71,8 +70,10 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.GridUpdateNotification;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.server.notify.LockNotification;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.util.GfeUtil;
|
||||
import com.raytheon.uf.common.dataplugin.grib.GribModel;
|
||||
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridInfoConstants;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridInfoRecord;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
|
||||
import com.raytheon.uf.common.dataplugin.persist.IPersistable;
|
||||
|
@ -85,8 +86,6 @@ import com.raytheon.uf.common.time.DataTime;
|
|||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.purge.PurgeLogger;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
|
||||
|
@ -112,8 +111,6 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
|||
*/
|
||||
public class GFEDao extends DefaultPluginDao {
|
||||
|
||||
private static String D2D_PARM_QUERY_STRING = "select model.id,model.parameterabbreviation, level.masterLevel_name, level.levelonevalue, level.leveltwovalue from awips.grib_models model, awips.level level where model.modelName = ':modelName' and model.id in (select distinct modelinfo_id from awips.grib where reftime=':reftime') and model.level_id = level.id";
|
||||
|
||||
public GFEDao() throws PluginException {
|
||||
super("gfe");
|
||||
}
|
||||
|
@ -588,12 +585,12 @@ public class GFEDao extends DefaultPluginDao {
|
|||
@SuppressWarnings("unchecked")
|
||||
public List<Integer> getD2DForecastTimes(DatabaseID dbId)
|
||||
throws DataAccessLayerException {
|
||||
DatabaseQuery query = new DatabaseQuery(GribRecord.class.getName());
|
||||
DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName());
|
||||
query.addDistinctParameter("dataTime.fcstTime");
|
||||
try {
|
||||
IFPServerConfig config = IFPServerConfigManager
|
||||
.getServerConfig(dbId.getSiteId());
|
||||
query.addQueryParam("modelInfo.modelName",
|
||||
query.addQueryParam(GridConstants.DATASET_ID,
|
||||
config.d2dModelNameMapping(dbId.getModelName()));
|
||||
} catch (GfeConfigurationException e) {
|
||||
throw new DataAccessLayerException(
|
||||
|
@ -606,22 +603,22 @@ public class GFEDao extends DefaultPluginDao {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves a GribRecord from the grib metadata database based on a ParmID
|
||||
* Retrieves a GridRecord from the grib metadata database based on a ParmID
|
||||
* and a TimeRange
|
||||
*
|
||||
* @param id
|
||||
* The parmID of the desired GribRecord
|
||||
* The parmID of the desired GridRecord
|
||||
* @param timeRange
|
||||
* The timeRange of the desired GribRecord
|
||||
* @return The GribRecord from the grib metadata database
|
||||
* The timeRange of the desired GridRecord
|
||||
* @return The GridRecord from the grib metadata database
|
||||
* @throws DataAccessLayerException
|
||||
* If errors occur while querying the metadata database
|
||||
*/
|
||||
public GribRecord getD2DGrid(ParmID id, TimeRange timeRange,
|
||||
public GridRecord getD2DGrid(ParmID id, TimeRange timeRange,
|
||||
GridParmInfo info) throws DataAccessLayerException {
|
||||
List<GribRecord> records = queryByD2DParmId(id);
|
||||
List<GridRecord> records = queryByD2DParmId(id);
|
||||
List<TimeRange> gribTimes = new ArrayList<TimeRange>();
|
||||
for (GribRecord record : records) {
|
||||
for (GridRecord record : records) {
|
||||
gribTimes.add(record.getDataTime().getValidPeriod());
|
||||
}
|
||||
|
||||
|
@ -633,15 +630,15 @@ public class GFEDao extends DefaultPluginDao {
|
|||
gribTime.getEnd());
|
||||
if (timeRange.getEnd().equals(time.getEnd())
|
||||
|| !info.getTimeConstraints().anyConstraints()) {
|
||||
GribRecord retVal = records.get(i);
|
||||
retVal.setPluginName("grib");
|
||||
GridRecord retVal = records.get(i);
|
||||
retVal.setPluginName(GridConstants.GRID);
|
||||
return retVal;
|
||||
}
|
||||
} else if (D2DGridDatabase.isNonAccumDuration(id, gribTimes)) {
|
||||
if (timeRange.getStart().equals(gribTime.getEnd())
|
||||
|| timeRange.equals(gribTime)) {
|
||||
GribRecord retVal = records.get(i);
|
||||
retVal.setPluginName("grib");
|
||||
GridRecord retVal = records.get(i);
|
||||
retVal.setPluginName(GridConstants.GRID);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -650,8 +647,8 @@ public class GFEDao extends DefaultPluginDao {
|
|||
gribTime.getStart());
|
||||
if ((timeRange.getStart().equals(time.getStart()) || !info
|
||||
.getTimeConstraints().anyConstraints())) {
|
||||
GribRecord retVal = records.get(i);
|
||||
retVal.setPluginName("grib");
|
||||
GridRecord retVal = records.get(i);
|
||||
retVal.setPluginName(GridConstants.GRID);
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
@ -661,23 +658,24 @@ public class GFEDao extends DefaultPluginDao {
|
|||
+ id.getDbId().getSiteId(), e);
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of GribRecords from the grib metadata database which match
|
||||
* Gets a list of GridRecords from the grib metadata database which match
|
||||
* the given ParmID
|
||||
*
|
||||
* @param id
|
||||
* The ParmID to search with
|
||||
* @return The list of GribRecords from the grib metadata database which
|
||||
* @return The list of GridRecords from the grib metadata database which
|
||||
* match the given ParmID
|
||||
* @throws DataAccessLayerException
|
||||
* If errors occur while querying the metadata database
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<GribRecord> queryByD2DParmId(ParmID id)
|
||||
public List<GridRecord> queryByD2DParmId(ParmID id)
|
||||
throws DataAccessLayerException {
|
||||
Session s = null;
|
||||
try {
|
||||
|
@ -708,26 +706,26 @@ public class GFEDao extends DefaultPluginDao {
|
|||
if (level == null) {
|
||||
logger.warn("Unable to query D2D parms, ParmID " + id
|
||||
+ " does not map to a level");
|
||||
return new ArrayList<GribRecord>();
|
||||
return new ArrayList<GridRecord>();
|
||||
}
|
||||
|
||||
s = getHibernateTemplate().getSessionFactory().openSession();
|
||||
|
||||
Criteria modelCrit = s.createCriteria(GribModel.class);
|
||||
Criterion baseCrit = Restrictions.eq("level", level);
|
||||
Criteria modelCrit = s.createCriteria(GridInfoRecord.class);
|
||||
Criterion baseCrit = Restrictions
|
||||
.eq(GridInfoConstants.LEVEL, level);
|
||||
|
||||
DatabaseID dbId = id.getDbId();
|
||||
try {
|
||||
IFPServerConfig config = IFPServerConfigManager
|
||||
.getServerConfig(dbId.getSiteId());
|
||||
baseCrit = Restrictions.and(baseCrit, Restrictions.eq(
|
||||
"modelName",
|
||||
GridInfoConstants.DATASET_ID,
|
||||
config.d2dModelNameMapping(dbId.getModelName())));
|
||||
} catch (GfeConfigurationException e) {
|
||||
throw new DataAccessLayerException(
|
||||
"Error occurred looking up model name mapping", e);
|
||||
}
|
||||
|
||||
String abbreviation = DataFieldTableLookup.getInstance()
|
||||
.lookupDataName(id.getParmName());
|
||||
if (abbreviation == null) {
|
||||
|
@ -738,24 +736,25 @@ public class GFEDao extends DefaultPluginDao {
|
|||
.and(baseCrit,
|
||||
Restrictions.or(
|
||||
Restrictions
|
||||
.sqlRestriction("lower(parameterAbbreviation) = '"
|
||||
.sqlRestriction("lower(parameter_abbreviation) = '"
|
||||
+ abbreviation + "'"),
|
||||
Restrictions
|
||||
.sqlRestriction("lower(parameterAbbreviation) like '"
|
||||
.sqlRestriction("lower(parameter_abbreviation) like '"
|
||||
+ abbreviation + "%hr'")));
|
||||
|
||||
modelCrit.add(abbrevCrit);
|
||||
List<?> results = modelCrit.list();
|
||||
GribModel model = null;
|
||||
GridInfoRecord model = null;
|
||||
if (results.size() == 0) {
|
||||
return new ArrayList<GribRecord>(0);
|
||||
return new ArrayList<GridRecord>(0);
|
||||
} else if (results.size() > 1) {
|
||||
// hours matched, take hour with least number that matches exact
|
||||
// param
|
||||
Pattern p = Pattern.compile("^" + abbreviation + "(\\d+)hr$");
|
||||
int lowestHr = -1;
|
||||
for (GribModel m : (List<GribModel>) results) {
|
||||
String param = m.getParameterAbbreviation().toLowerCase();
|
||||
for (GridInfoRecord m : (List<GridInfoRecord>) results) {
|
||||
String param = m.getParameter().getAbbreviation()
|
||||
.toLowerCase();
|
||||
if (param.equals(abbreviation) && lowestHr < 0) {
|
||||
model = m;
|
||||
} else {
|
||||
|
@ -771,11 +770,11 @@ public class GFEDao extends DefaultPluginDao {
|
|||
}
|
||||
|
||||
} else {
|
||||
model = (GribModel) results.get(0);
|
||||
model = (GridInfoRecord) results.get(0);
|
||||
}
|
||||
|
||||
Criteria recordCrit = s.createCriteria(GribRecord.class);
|
||||
baseCrit = Restrictions.eq("modelInfo", model);
|
||||
Criteria recordCrit = s.createCriteria(GridRecord.class);
|
||||
baseCrit = Restrictions.eq("info", model);
|
||||
baseCrit = Restrictions.and(
|
||||
baseCrit,
|
||||
Restrictions.eq("dataTime.refTime",
|
||||
|
@ -867,8 +866,8 @@ public class GFEDao extends DefaultPluginDao {
|
|||
private List<DataTime> executeD2DParmQuery(ParmID id)
|
||||
throws DataAccessLayerException {
|
||||
List<DataTime> times = new ArrayList<DataTime>();
|
||||
List<GribRecord> records = queryByD2DParmId(id);
|
||||
for (GribRecord record : records) {
|
||||
List<GridRecord> records = queryByD2DParmId(id);
|
||||
for (GridRecord record : records) {
|
||||
times.add(record.getDataTime());
|
||||
}
|
||||
return times;
|
||||
|
@ -895,36 +894,27 @@ public class GFEDao extends DefaultPluginDao {
|
|||
});
|
||||
}
|
||||
|
||||
public List<DatabaseID> getD2DDatabaseIdsFromDb(GridModel d2dModel,
|
||||
public List<DatabaseID> getD2DDatabaseIdsFromDb(String d2dModelName,
|
||||
String gfeModel, String siteID) throws DataAccessLayerException {
|
||||
return getD2DDatabaseIdsFromDb(d2dModel, gfeModel, siteID, -1);
|
||||
return getD2DDatabaseIdsFromDb(d2dModelName, gfeModel, siteID, -1);
|
||||
}
|
||||
|
||||
public List<DatabaseID> getD2DDatabaseIdsFromDb(GridModel d2dModel,
|
||||
public List<DatabaseID> getD2DDatabaseIdsFromDb(String d2dModelName,
|
||||
String gfeModel, String siteID, int maxRecords)
|
||||
throws DataAccessLayerException {
|
||||
List<DatabaseID> dbInventory = new ArrayList<DatabaseID>();
|
||||
|
||||
StringBuffer modelQueryString = new StringBuffer();
|
||||
modelQueryString.append("select id from awips.grib_models where ");
|
||||
modelQueryString.append("modelName = '").append(d2dModel.getName())
|
||||
.append("'");
|
||||
DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName());
|
||||
query.addDistinctParameter("dataTime.refTime");
|
||||
query.addQueryParam(GridConstants.DATASET_ID, d2dModelName);
|
||||
query.addOrder("dataTime.refTime", false);
|
||||
|
||||
StringBuffer gribQueryString = new StringBuffer();
|
||||
gribQueryString
|
||||
.append("select distinct refTime from awips.grib where modelinfo_id in (")
|
||||
.append(modelQueryString).append(") order by refTime DESC ");
|
||||
if (maxRecords > 0) {
|
||||
gribQueryString.append("limit ").append(maxRecords);
|
||||
}
|
||||
List<?> result = this.queryByCriteria(query);
|
||||
|
||||
QueryResult result = (QueryResult) new CoreDao(DaoConfig.DEFAULT)
|
||||
.executeNativeSql(gribQueryString.toString());
|
||||
|
||||
for (int i = 0; i < result.getResultCount(); i++) {
|
||||
for (Object obj : result) {
|
||||
DatabaseID dbId = null;
|
||||
dbId = new DatabaseID(siteID, DataType.GRID, "D2D", gfeModel,
|
||||
(Date) result.getRowColumnValue(i, 0));
|
||||
(Date) obj);
|
||||
if (!dbInventory.contains(dbId)) {
|
||||
dbInventory.add(dbId);
|
||||
}
|
||||
|
@ -947,10 +937,10 @@ public class GFEDao extends DefaultPluginDao {
|
|||
* be found.
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public DatabaseID getLatestD2DDatabaseIdsFromDb(GridModel d2dModel,
|
||||
public DatabaseID getLatestD2DDatabaseIdsFromDb(String d2dModelName,
|
||||
String gfeModel, String siteID) throws DataAccessLayerException {
|
||||
List<DatabaseID> dbIds = getD2DDatabaseIdsFromDb(d2dModel, gfeModel,
|
||||
siteID, 1);
|
||||
List<DatabaseID> dbIds = getD2DDatabaseIdsFromDb(d2dModelName,
|
||||
gfeModel, siteID, 1);
|
||||
if (!dbIds.isEmpty()) {
|
||||
return dbIds.get(0);
|
||||
} else {
|
||||
|
@ -958,28 +948,30 @@ public class GFEDao extends DefaultPluginDao {
|
|||
}
|
||||
}
|
||||
|
||||
public Set<ParmID> getD2DParmIdsFromDb(GridModel model, DatabaseID dbId)
|
||||
public Set<ParmID> getD2DParmIdsFromDb(String d2dModelName, DatabaseID dbId)
|
||||
throws DataAccessLayerException {
|
||||
|
||||
Set<ParmID> parmIds = new HashSet<ParmID>();
|
||||
|
||||
String query = D2D_PARM_QUERY_STRING.replace(":modelName",
|
||||
model.getName());
|
||||
query = query.replace(
|
||||
":reftime",
|
||||
DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName());
|
||||
query.addDistinctParameter(GridConstants.PARAMETER_ABBREVIATION);
|
||||
query.addDistinctParameter(GridConstants.MASTER_LEVEL_NAME);
|
||||
query.addDistinctParameter(GridConstants.LEVEL_ONE);
|
||||
query.addDistinctParameter(GridConstants.LEVEL_TWO);
|
||||
query.addQueryParam(GridConstants.DATASET_ID, d2dModelName);
|
||||
query.addQueryParam(
|
||||
"dataTime.refTime",
|
||||
TimeUtil.formatDate(dbId.getModelTimeAsDate()).replaceAll("_",
|
||||
" "));
|
||||
|
||||
QueryResult result = (QueryResult) this.executeNativeSql(query);
|
||||
List<?> result = this.queryByCriteria(query);
|
||||
|
||||
for (int i = 0; i < result.getResultCount(); i++) {
|
||||
for (Object obj : result) {
|
||||
Object[] objArr = (Object[]) obj;
|
||||
String levelName = GridTranslator.getShortLevelName(
|
||||
(String) result.getRowColumnValue(i, "masterlevel_name"),
|
||||
(Double) result.getRowColumnValue(i, "levelonevalue"),
|
||||
(Double) result.getRowColumnValue(i, "leveltwovalue"));
|
||||
(String) objArr[1], (Double) objArr[2], (Double) objArr[3]);
|
||||
if (!levelName.equals(LevelFactory.UNKNOWN_LEVEL)) {
|
||||
String abbrev = (String) result.getRowColumnValue(i,
|
||||
"parameterabbreviation");
|
||||
String abbrev = (String) objArr[0];
|
||||
abbrev = DataFieldTableLookup.getInstance().lookupCdlName(
|
||||
abbrev);
|
||||
ParmID newParmId = new ParmID(abbrev, dbId, levelName);
|
||||
|
|
|
@ -34,12 +34,10 @@ import javax.measure.converter.UnitConverter;
|
|||
import javax.measure.unit.Unit;
|
||||
|
||||
import com.raytheon.edex.plugin.gfe.cache.d2dparms.D2DParmIdCache;
|
||||
import com.raytheon.edex.plugin.gfe.cache.gridlocations.GridLocationCache;
|
||||
import com.raytheon.edex.plugin.gfe.config.IFPServerConfig;
|
||||
import com.raytheon.edex.plugin.gfe.config.IFPServerConfigManager;
|
||||
import com.raytheon.edex.plugin.gfe.db.dao.GFEDao;
|
||||
import com.raytheon.edex.plugin.gfe.exception.GfeConfigurationException;
|
||||
import com.raytheon.edex.plugin.grib.dao.GribDao;
|
||||
import com.raytheon.edex.plugin.grib.spatial.GribSpatialCache;
|
||||
import com.raytheon.edex.plugin.grib.util.GribParamInfoLookup;
|
||||
import com.raytheon.edex.plugin.grib.util.ParameterInfo;
|
||||
|
@ -60,7 +58,7 @@ import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
|
|||
import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.slice.VectorGridSlice;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.util.GfeUtil;
|
||||
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
||||
|
@ -71,6 +69,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.plugin.PluginFactory;
|
||||
import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
||||
|
||||
/**
|
||||
* Singleton that assists with grid data
|
||||
|
@ -95,10 +94,7 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
.getHandler(D2DGridDatabase.class);
|
||||
|
||||
/** The remap object used for resampling grids */
|
||||
private RemapGrid remap;
|
||||
|
||||
/** The source GridLocation (The D2D grid coverage) */
|
||||
private GridLocation inputLoc;
|
||||
private Map<String, RemapGrid> remap = new HashMap<String, RemapGrid>();
|
||||
|
||||
/** The destination GridLocation (The local GFE grid coverage) */
|
||||
private GridLocation outputLoc;
|
||||
|
@ -118,36 +114,28 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
valid = this.dbId.isValid();
|
||||
|
||||
if (valid) {
|
||||
String siteId = dbId.getSiteId();
|
||||
GridLocationCache locCache = GridLocationCache.getInstance(dbId
|
||||
.getSiteId());
|
||||
String gfeModelName = dbId.getModelName();
|
||||
inputLoc = locCache.getGridLocation(gfeModelName);
|
||||
|
||||
if (inputLoc == null) {
|
||||
String d2dModelName = this.config
|
||||
.d2dModelNameMapping(gfeModelName);
|
||||
GridCoverage awipsGrid = GribSpatialCache.getInstance()
|
||||
.getGrid(d2dModelName);
|
||||
|
||||
if (awipsGrid == null) {
|
||||
throw new GfeException(
|
||||
"Unable to lookup coverage for GFE Model ["
|
||||
+ gfeModelName + "] for site [" + siteId
|
||||
+ "]. GribSpatialCache for d2dModel ["
|
||||
+ d2dModelName + "] returned null");
|
||||
}
|
||||
|
||||
inputLoc = GfeUtil.transformGridCoverage(awipsGrid);
|
||||
locCache.addGridLocation(gfeModelName, inputLoc);
|
||||
}
|
||||
|
||||
outputLoc = this.config.dbDomain();
|
||||
|
||||
remap = new RemapGrid(inputLoc, outputLoc);
|
||||
String d2dModelName = this.config.d2dModelNameMapping(gfeModelName);
|
||||
for (GridCoverage awipsGrid : GribSpatialCache.getInstance()
|
||||
.getGridsForModel(d2dModelName)) {
|
||||
getOrCreateRemap(awipsGrid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private RemapGrid getOrCreateRemap(GridCoverage awipsGrid) {
|
||||
RemapGrid remap = this.remap.get(awipsGrid.getName());
|
||||
if (remap == null) {
|
||||
GridLocation inputLoc = GfeUtil.transformGridCoverage(awipsGrid);
|
||||
remap = new RemapGrid(inputLoc, outputLoc);
|
||||
this.remap.put(awipsGrid.getName(), remap);
|
||||
}
|
||||
return remap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDbs() {
|
||||
// no op
|
||||
|
@ -471,7 +459,7 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
public Grid2DFloat getGrid(ParmID parmId, TimeRange time, GridParmInfo gpi,
|
||||
boolean convertUnit) throws GfeException {
|
||||
Grid2DFloat bdata = null;
|
||||
GribRecord d2dRecord = null;
|
||||
GridRecord d2dRecord = null;
|
||||
|
||||
GFEDao dao = null;
|
||||
try {
|
||||
|
@ -508,7 +496,8 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
// Resample the data to fit desired region
|
||||
Grid2DFloat retVal;
|
||||
try {
|
||||
retVal = this.remap.remap(bdata, fillV, gpi.getMaxValue(),
|
||||
RemapGrid remap = getOrCreateRemap(d2dRecord.getLocation());
|
||||
retVal = remap.remap(bdata, fillV, gpi.getMaxValue(),
|
||||
gpi.getMinValue(), gpi.getMinValue());
|
||||
if (convertUnit && d2dRecord != null) {
|
||||
long t5 = System.currentTimeMillis();
|
||||
|
@ -539,10 +528,10 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
* @throws GfeException
|
||||
* If the source and target units are incompatible
|
||||
*/
|
||||
private void convertUnits(GribRecord d2dRecord, Grid2DFloat data,
|
||||
private void convertUnits(GridRecord d2dRecord, Grid2DFloat data,
|
||||
Unit<?> targetUnit) throws GfeException {
|
||||
|
||||
Unit<?> sourceUnit = d2dRecord.getModelInfo().getParameterUnitObject();
|
||||
Unit<?> sourceUnit = d2dRecord.getParameter().getUnit();
|
||||
if (sourceUnit.equals(targetUnit)) {
|
||||
return;
|
||||
}
|
||||
|
@ -585,10 +574,10 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
} catch (PluginException e1) {
|
||||
throw new GfeException("Unable to get GFE dao!!", e1);
|
||||
}
|
||||
GribRecord uRecord = null;
|
||||
GribRecord vRecord = null;
|
||||
GribRecord sRecord = null;
|
||||
GribRecord dRecord = null;
|
||||
GridRecord uRecord = null;
|
||||
GridRecord vRecord = null;
|
||||
GridRecord sRecord = null;
|
||||
GridRecord dRecord = null;
|
||||
try {
|
||||
|
||||
// Get the metadata from the grib metadata database
|
||||
|
@ -619,7 +608,8 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
}
|
||||
|
||||
try {
|
||||
this.remap.remapUV(uData, vData, fillV, gpi.getMaxValue(),
|
||||
RemapGrid remap = getOrCreateRemap(uRecord.getLocation());
|
||||
remap.remapUV(uData, vData, fillV, gpi.getMaxValue(),
|
||||
gpi.getMinValue(), gpi.getMinValue(), true, true, mag,
|
||||
dir);
|
||||
} catch (Exception e) {
|
||||
|
@ -655,7 +645,8 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
}
|
||||
|
||||
try {
|
||||
this.remap.remap(sData, dData, fillV, gpi.getMaxValue(),
|
||||
RemapGrid remap = getOrCreateRemap(sRecord.getLocation());
|
||||
remap.remap(sData, dData, fillV, gpi.getMaxValue(),
|
||||
gpi.getMinValue(), gpi.getMinValue(), mag, dir);
|
||||
} catch (Exception e) {
|
||||
throw new GfeException("Unable to remap wind grids", e);
|
||||
|
@ -689,10 +680,10 @@ public class D2DGridDatabase extends VGridDatabase {
|
|||
* The grib metadata
|
||||
* @return The raw data
|
||||
*/
|
||||
private Grid2DFloat getRawGridData(GribRecord d2dRecord) {
|
||||
private Grid2DFloat getRawGridData(GridRecord d2dRecord) {
|
||||
FloatDataRecord hdf5Record;
|
||||
try {
|
||||
GribDao dao = new GribDao();
|
||||
GridDao dao = new GridDao();
|
||||
IDataRecord[] hdf5Data = dao.getHDF5Data(d2dRecord, -1);
|
||||
hdf5Record = (FloatDataRecord) hdf5Data[0];
|
||||
} catch (PluginException e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue