diff --git a/cave/build/.pydevproject b/cave/build/.pydevproject
index faf12629d9..f4a659751e 100644
--- a/cave/build/.pydevproject
+++ b/cave/build/.pydevproject
@@ -2,6 +2,6 @@
-python 2.5
+python 2.7
Default
diff --git a/edexOsgi/build.edex/esb/data/utility/common_static/base/python/gfe/TimeRange.py b/edexOsgi/build.edex/esb/data/utility/common_static/base/python/gfe/TimeRange.py
index 2cd383d2a3..8ce0fcc277 100644
--- a/edexOsgi/build.edex/esb/data/utility/common_static/base/python/gfe/TimeRange.py
+++ b/edexOsgi/build.edex/esb/data/utility/common_static/base/python/gfe/TimeRange.py
@@ -32,8 +32,9 @@ import JUtil
# ------------ ---------- ----------- --------------------------
# 04/10/08 chammack Initial Creation.
# 09/30/08 1566 wdougher Quit returning TimeRange from overlaps(), etc.
-# 09/16/09 2899 njensen Huge performance boost by caching
-#
+# 09/16/09 2899 njensen Huge performance boost by caching
+# 04/04/2013 #1787 randerso Removed isValid check to allow 0 duration
+# time ranges to be used in python
#
#
@@ -159,8 +160,6 @@ def javaTimeRangeListToPyList(timeRanges):
return pylist
def encodeJavaTimeRange(javaTimeRange):
- if not javaTimeRange.isValid():
- return None
time = TimeRange(javaTimeRange)
start = time.startTime()
end = time.endTime()
diff --git a/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py b/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py
index be5b6c6a1e..2b69ed97f1 100644
--- a/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py
+++ b/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py
@@ -24,7 +24,10 @@
# 02/16/12 14439 jdynina modified haines thresholds
# 02/16/12 13917 jdynina merged in changes from TRAC ticket 11391
# 07/25/12 #957 dgilling implement edit areas as args to calc methods.
-# 10/5/12 15158 ryu add Forecaster.getDb()
+# 10/05/12 15158 ryu add Forecaster.getDb()
+# 04/04/13 #1787 randerso fix validTime check to work with accumulative parms
+# fix logging so you can actually determine why
+# a smartInit is not calculating a parameter
#
##
import string, sys, re, time, types, getopt, fnmatch, LogStream, DatabaseID, JUtil, AbsTime, TimeRange
@@ -836,8 +839,8 @@ class Forecaster(GridUtilities):
def __sortTimes(self, methods, validTime):
rval = []
calced = []
- haveNoData = {}
for we, mthd, args in methods:
+# LogStream.logEvent("Evaluating times for calc"+we)
calced.append(we)
args = filter(lambda x, ma=self.magicArgs().keys() + [we]:
x not in ma, args)
@@ -865,27 +868,36 @@ class Forecaster(GridUtilities):
if validTime is None:
valid = True
- elif jtr.contains(validTime):
- valid = True
-
+ else:
+ # need check to be inclusive on both ends for methods that
+ # need both accumulative and non-accumulative parms
+ valid = validTime.getTime() >= jtr.getStart().getTime() and \
+ validTime.getTime() <= jtr.getEnd().getTime()
+
if valid:
timelist = TimeRange.encodeJavaTimeRange(jtr)
pylist.append(timelist)
ttimes.append(pylist)
- timeList = ttimes[len(ttimes)-1]
- result = 0
- for xtime in timeList:
- result += xtime[1] - xtime[0]
-
- if result == 0:
- if not haveNoData.has_key(we):
- haveNoData[we] = [p]
- else:
- haveNoData[we].append(p)
+
+# msg = "Times available for " + p + " " + str(validTime) + ":\n"
+# timeList = ttimes[len(ttimes)-1]
+# for xtime in timeList:
+# msg += '('
+# stime = time.gmtime(xtime[0])
+# etime = time.gmtime(xtime[1])
+# stime = time.strftime('%Y%m%d_%H%M', stime)
+# etime = time.strftime('%Y%m%d_%H%M', etime)
+# msg += stime + ", " + etime
+# msg += ')\n'
+# LogStream.logEvent(msg)
# compare the times of each parm and find where they match up
times = self.__compTimes(None, ttimes)
+# LogStream.logEvent("nargs:",nargs)
+# LogStream.logEvent("ttimes:",ttimes)
+# LogStream.logEvent("times:",times)
+
hadDataButSkipped = {}
for i in range(len(ttimes)):
timeList = ttimes[i]
@@ -896,7 +908,16 @@ class Forecaster(GridUtilities):
hadDataButSkipped[xtime].append(parmName)
else:
hadDataButSkipped[xtime] = [parmName]
-
+# LogStream.logEvent("hadDataButSkipped:",hadDataButSkipped)
+
+ hadNoData = []
+ for i in range(len(nargs)):
+ timeList = ttimes[i]
+ parmName = nargs[i]
+ if len(timeList) == 0:
+ hadNoData.append(parmName)
+# LogStream.logEvent("hadNoData:",hadNoData)
+
missing = {}
for xtime in hadDataButSkipped:
stime = time.gmtime(xtime[0])
@@ -908,16 +929,17 @@ class Forecaster(GridUtilities):
for parmName in nargs:
if not hadDataButSkipped[xtime].__contains__(parmName):
- if parmName in calced:
- if haveNoData.has_key(parmName):
- missing[msg].append(parmName)
- else:
- if parmName in haveNoData.values():
- missing[msg].append(parmName)
-
- if not len(missing[msg]):
- del missing[msg]
-
+ missing[msg].append(parmName)
+
+ if len(missing) == 0 and len(hadNoData) > 0:
+ msg = ''
+ if (validTime is not None):
+ vtime = validTime.getTime()/1000
+ vtime = time.gmtime(vtime)
+ msg = time.strftime('%Y%m%d_%H%M', vtime)
+ missing[msg] = hadNoData
+# LogStream.logEvent("missing:",missing)
+
if len(missing):
LogStream.logEvent("Skipping calc" + we + " for some times due to the following " +
"missing data:", missing)
@@ -1130,7 +1152,7 @@ class Forecaster(GridUtilities):
parm = self.__getNewWE(m[0])
tr = parm.getTimeRange(t[0])
- # A vaild time range was not found so the parameter
+ # A valid time range was not found so the parameter
# cannot be calculated, so continue
if not tr.isValid():
continue
diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java
index 5f3ae9bd82..4fb1d08c31 100644
--- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java
+++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFED2DDao.java
@@ -22,35 +22,20 @@ package com.raytheon.edex.plugin.gfe.db.dao;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.hibernate.Query;
-import org.hibernate.SQLQuery;
import org.hibernate.Session;
-import com.raytheon.edex.plugin.gfe.config.IFPServerConfig;
-import com.raytheon.edex.plugin.gfe.config.IFPServerConfigManager;
-import com.raytheon.edex.plugin.gfe.exception.GfeConfigurationException;
-import com.raytheon.edex.plugin.gfe.util.GridTranslator;
-import com.raytheon.uf.common.comm.CommunicationException;
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.GridParmInfo;
-import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
-import com.raytheon.uf.common.dataplugin.grid.GridInfoConstants;
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.parameter.mapping.ParameterMapper;
-import com.raytheon.uf.common.status.UFStatus.Priority;
-import com.raytheon.uf.common.util.mapping.MultipleMappingException;
+import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.query.DatabaseQuery;
import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
@@ -63,6 +48,9 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 03/20/13 #1774 randerso Refactored out of GFEDao
+ * 04/04/13 #1787 randerso Fixed to support changes to D2D grid location
+ * Additional cleanup to move the D2D to GFE translation
+ * logic into D2DGridDatabase.
*
*
*
@@ -81,27 +69,6 @@ public class GFED2DDao extends GridDao {
private static final String REF_TIME = "dataTime.refTime";
- // hibernate query to find grid info record for the given datasetId and
- // parameter
- private static final String SQL_D2D_GRID_PARM_QUERY = "select parameter_abbreviation, id "
- + "FROM grid_info WHERE "
- + GridInfoConstants.DATASET_ID
- + " = :"
- + GridInfoConstants.DATASET_ID
- + " AND "
- + "level_id = :level_id AND "
- + "(lower(parameter_abbreviation) = :abbrev OR lower(parameter_abbreviation) like :hourAbbrev)";
-
- // hibernate query to find the times for the GridRecord for the given
- // info.id, id returned to allow easy lookup of the record associated with
- // the time
- private static final String HQL_D2D_GRID_TIME_QUERY = "select dataTime.fcstTime, id from GridRecord "
- + "where "
- + GridConstants.INFO_ID
- + " = :info_id AND dataTime.refTime = :refTime order by dataTime.fcstTime";
-
- private static final Pattern WIND_PATTERN = Pattern.compile("wind");
-
public GFED2DDao() throws PluginException {
super();
}
@@ -116,20 +83,12 @@ public class GFED2DDao extends GridDao {
* @throws DataAccessLayerException
* If errors occur while querying the metadata database
*/
- public List getD2DForecastTimes(DatabaseID dbId)
+ public List getForecastTimes(String d2dModelName, Date refTime)
throws DataAccessLayerException {
DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName());
query.addDistinctParameter(FCST_TIME);
- try {
- IFPServerConfig config = IFPServerConfigManager
- .getServerConfig(dbId.getSiteId());
- query.addQueryParam(GridConstants.DATASET_ID,
- config.d2dModelNameMapping(dbId.getModelName()));
- } catch (GfeConfigurationException e) {
- throw new DataAccessLayerException(
- "Error occurred looking up model name mapping", e);
- }
- query.addQueryParam(REF_TIME, dbId.getModelTimeAsDate());
+ query.addQueryParam(GridConstants.DATASET_ID, d2dModelName);
+ query.addQueryParam(REF_TIME, refTime);
query.addOrder(FCST_TIME, true);
@SuppressWarnings("unchecked")
@@ -152,14 +111,16 @@ public class GFED2DDao extends GridDao {
* @throws DataAccessLayerException
* If errors occur while querying the metadata database
*/
- public GridRecord getD2DGrid(ParmID id, Integer forecastTime,
+ public GridRecord getGrid(String d2dModelName, Date refTime,
+ String d2dParmName, Level d2dLevel, Integer forecastTime,
GridParmInfo info) throws DataAccessLayerException {
Session s = null;
try {
s = getHibernateTemplate().getSessionFactory().openSession();
// TODO: clean up so we only make one db query
- SortedMap rawTimes = queryByD2DParmId(id, s);
+ SortedMap rawTimes = queryByParmId(d2dModelName,
+ refTime, d2dParmName, d2dLevel, s);
// if forecastTime is null just pick one,
// this is for static data since all times are the same
@@ -198,108 +159,75 @@ public class GFED2DDao extends GridDao {
* @throws DataAccessLayerException
* If errors occur while querying the metadata database
*/
- public SortedMap queryByD2DParmId(ParmID id, Session s)
+ public SortedMap queryByParmId(String d2dModelName,
+ Date refTime, String d2dParmName, Level d2dLevel, Session s)
throws DataAccessLayerException {
- String levelName = GridTranslator.getLevelName(id.getParmLevel());
- double[] levelValues = GridTranslator.getLevelValue(id.getParmLevel());
- boolean levelOnePresent = (levelValues[0] != Level
- .getInvalidLevelValue());
- boolean levelTwoPresent = (levelValues[1] != Level
- .getInvalidLevelValue());
- Level level = null;
-
- // to have a level 2, must have a level one
- try {
- if (levelOnePresent && levelTwoPresent) {
- level = LevelFactory.getInstance().getLevel(levelName,
- levelValues[0], levelValues[1]);
- } else if (levelOnePresent) {
- level = LevelFactory.getInstance().getLevel(levelName,
- levelValues[0]);
- } else {
- level = LevelFactory.getInstance().getLevel(levelName, 0.0);
- }
- } catch (CommunicationException e) {
- logger.error(e.getLocalizedMessage(), e);
- }
- if (level == null) {
- logger.warn("Unable to query D2D parms, ParmID " + id
- + " does not map to a level");
- return new TreeMap();
- }
-
- SQLQuery modelQuery = s.createSQLQuery(SQL_D2D_GRID_PARM_QUERY);
- modelQuery.setLong("level_id", level.getId());
- DatabaseID dbId = id.getDbId();
-
- try {
- IFPServerConfig config = IFPServerConfigManager
- .getServerConfig(dbId.getSiteId());
- modelQuery.setString(GridInfoConstants.DATASET_ID,
- config.d2dModelNameMapping(dbId.getModelName()));
- } catch (GfeConfigurationException e) {
- throw new DataAccessLayerException(
- "Error occurred looking up model name mapping", e);
- }
-
- String abbreviation = null;
- try {
- abbreviation = ParameterMapper.getInstance().lookupBaseName(
- id.getParmName(), "gfeParamName");
- } catch (MultipleMappingException e) {
- statusHandler.handle(Priority.WARN, e.getLocalizedMessage(), e);
- abbreviation = e.getArbitraryMapping();
- }
-
- abbreviation = abbreviation.toLowerCase();
- modelQuery.setString("abbrev", abbreviation);
- modelQuery.setString("hourAbbrev", abbreviation + "%hr");
+ DatabaseQuery query = new DatabaseQuery(GridRecord.class.getName());
+ query.addReturnedField(FCST_TIME);
+ query.addReturnedField("id");
+ query.addQueryParam(GridConstants.DATASET_ID, d2dModelName);
+ query.addQueryParam(REF_TIME, refTime);
+ query.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, d2dParmName);
+ query.addQueryParam(GridConstants.LEVEL_ID, d2dLevel.getId());
+ query.addOrder(FCST_TIME, true);
@SuppressWarnings("unchecked")
- List