{
JRQuery query = dataset.getQuery();
if (query != null)
{
String language = query.getLanguage();
JRQueryExecuterFactory queryExecuterFactory = null;
if (language == null || language.length() == 0)
{
addBrokenRule("Query language not set.", query);
}
else
{
try
{
queryExecuterFactory = JRQueryExecuterUtils.getQueryExecuterFactory(query.getLanguage());
}
catch (JRException e1)
{
addBrokenRule("Query executer factory for " + language + " cannot be created.", query);
}
}
JRQueryChunk[] chunks = query.getChunks();
if (chunks != null && chunks.length > 0)
{
Map parametersMap = dataset.getParametersMap();
for(int j = 0; j < chunks.length; j++)
{
JRQueryChunk queryChunk = chunks[j];
switch (queryChunk.getType())
{
case JRQueryChunk.TYPE_PARAMETER :
{
JRParameter parameter = (JRParameter)parametersMap.get(queryChunk.getText());
if ( parameter == null )
{
addBrokenRule("Query parameter not found : " + queryChunk.getText(), query);
}
else if (queryExecuterFactory != null)
{
String parameterType = null;
try
{
parameterType = parameter.getValueClassName();
}
catch (JRRuntimeException e)
{
// ignore, already added when the parameter got verified
}
if (parameterType != null && !queryExecuterFactory.supportsQueryParameterType(parameterType))
{
addBrokenRule("Parameter type not supported in query : " + queryChunk.getText() + " class " + parameterType, query);
}
}