{
addBrokenRule("Unknown dataset name " + datasetName + ".", datasetRun);
}
}
JRExpression parametersMapExpression = datasetRun.getParametersMapExpression();
if (parametersMapExpression != null)
{
try
{
Class clazz = parametersMapExpression.getValueClass();
if (clazz == null)
{
addBrokenRule("Class not set for dataset " + datasetName + " parameters map expression.", parametersMapExpression);
}
else if (!java.util.Map.class.isAssignableFrom(clazz))
{
addBrokenRule("Class " + clazz + " not supported for dataset " + datasetName + " parameters map expression. Use java.util.Map instead.", parametersMapExpression);
}
}
catch (JRRuntimeException e)
{
addBrokenRule(e, parametersMapExpression);
}
}
JRDatasetParameter[] parameters = datasetRun.getParameters();
if (parameters != null && parameters.length > 0)
{
for(int index = 0; index < parameters.length; index++)
{
JRDatasetParameter parameter = parameters[index];
String paramName = parameter.getName();
if (paramName == null || paramName.trim().length() == 0)
{
addBrokenRule("Dataset " + datasetName + " parameter name missing.", parameter);
}
JRParameter datasetParam = null;
if (dataset != null)
{
datasetParam = (JRParameter) dataset.getParametersMap().get(paramName);
if (datasetParam == null)
{
addBrokenRule("Unknown parameter " + paramName + " in dataset " + datasetName + ".", parameter);
}
}
JRExpression expression = parameter.getExpression();
if (expression != null)
{
try
{
Class clazz = expression.getValueClass();
if (clazz == null)
{
addBrokenRule("Class not set for dataset " + datasetName + " parameter expression : " + paramName + ".", expression);
}
else if (datasetParam != null && !datasetParam.getValueClass().isAssignableFrom(clazz))
{
addBrokenRule("Class " + clazz + " not supported for parameter " + paramName + " of dataset " + datasetName + ". Use " + datasetParam.getValueClass() + " instead.",
expression);
}
}
catch (JRRuntimeException e)
{
addBrokenRule(e, expression);
}
}
}
}
JRExpression connectionExpression = datasetRun.getConnectionExpression();
JRExpression dataSourceExpression = datasetRun.getDataSourceExpression();
if (connectionExpression != null && dataSourceExpression != null)
{
addBrokenRule("Dataset " + datasetName + " cannot have both connection expresion and data source expression.", datasetRun);
}
if (connectionExpression != null)
{
try
{
Class clazz = connectionExpression.getValueClass();
if (clazz == null)
{
addBrokenRule("Class not set for dataset " + datasetName + " connection expression.", connectionExpression);
}
else if (!java.sql.Connection.class.isAssignableFrom(clazz))
{
addBrokenRule("Class " + clazz + " not supported for dataset " + datasetName + " connection expression. Use java.sql.Connection instead.", connectionExpression);
}
}
catch (JRRuntimeException e)
{
addBrokenRule(e, connectionExpression);
}
}
if (dataSourceExpression != null)
{
try
{
Class clazz = dataSourceExpression.getValueClass();
if (clazz == null)
{
addBrokenRule("Class not set for dataset " + datasetName + " data source expression.", dataSourceExpression);
}
else if (!net.sf.jasperreports.engine.JRDataSource.class.isAssignableFrom(clazz))