{
final HashMap<StaticDataRow, Object> parameterCache = queryCache.get(query);
if (parameterCache == null)
{
final StaticDataRow params = new StaticDataRow(parameters);
final TableModel dataFromQuery = backend.queryData(query, params);
if (dataFromQuery == null)
{
//final DefaultTableModel value = new DefaultTableModel();
if (debugDataSources && CachingDataFactory.logger.isDebugEnabled())
{
CachingDataFactory.logger.debug("Query failed for query '" + query + '\'');
}
final HashMap<StaticDataRow, Object> paramsForQueryMap = new HashMap<StaticDataRow, Object>();
queryCache.put(query, paramsForQueryMap);
paramsForQueryMap.put(params, NULL_INDICATOR);
return null;
}
else
{
if (debugDataSources && CachingDataFactory.logger.isDebugEnabled())
{
CachingDataFactory.printTableModelContents(dataFromQuery);
}
// totally new query here.
final HashMap<StaticDataRow, Object> paramsForQueryMap = new HashMap<StaticDataRow, Object>();
queryCache.put(query, paramsForQueryMap);
paramsForQueryMap.put(params, dataFromQuery);
return dataFromQuery;
}
}
else
{
// Lookup the parameters ...
final StaticDataRow params = new StaticDataRow(parameters);
final Object dataObj = parameterCache.get(params);
if (dataObj == NULL_INDICATOR)
{
// query is known to be null for the given parameters ...
return null;