if (isInitialized() == false)
{
init();
}
final DefaultDataAttributes globalAttributes = getGlobalAttributes();
final MetaSelectorRule[] indirectRules = getIndirectRules();
final DirectFieldSelectorRule[] directRules = getDirectRules();
final DataAttributeContext context = getContext();
final ParameterDataRow parameters = masterRow.getParameterDataRow();
final ExpressionDataRow expressionsRow = masterRow.getExpressionDataRow();
final ReportDataRow massDataRow = masterRow.getReportDataRow();
// imported data has been compiled in the subreport ...
final ImportedVariablesDataRow importedDataRow = masterRow.getImportedDataRow();
final DefaultDataSchema defaultDataSchema = new DefaultDataSchema();
if (parameters != null)
{
final MasterDataRow parentRow = masterRow.getParentDataRow();
if (parentRow == null)
{
processParameters(parameters, null, reportEnvironment,
globalAttributes, indirectRules, directRules, defaultDataSchema);
}
else
{
// import the parameters that have been computed already ..
final String[] parameterNames = parameters.getParentNames();
final String[] innerNames = parameters.getColumnNames();
for (int i = 0; i < parameterNames.length; i++)
{
final String name = parameterNames[i];
final DataAttributes attributes = parentRow.getDataSchema().getAttributes(name);
defaultDataSchema.setAttributes(innerNames[i], attributes);
}
}
}
// expressions
final Expression[] expressions = expressionsRow.getExpressions();
for (int i = 0; i < expressions.length; i++)
{
final Expression expression = expressions[i];
final String name = expression.getName();
if (name == null)
{
continue;
}
final DefaultDataAttributes computedParameterDataAttributes = new DefaultDataAttributes();
computedParameterDataAttributes.merge(globalAttributes, context);
computedParameterDataAttributes.merge(new ExpressionsDataAttributes(expression), context);
applyRules(indirectRules, directRules, computedParameterDataAttributes);
defaultDataSchema.setAttributes(name, computedParameterDataAttributes);
}
// massdata
if (massDataRow != null)
{
final GenericDataAttributes parameterDataAttributes = getTableDataAttributes();
final TableModel data = massDataRow.getReportData();
if (data instanceof MetaTableModel == false)
{
final int count = data.getColumnCount();
for (int i = 0; i < count; i++)
{
final String colName = data.getColumnName(i);
parameterDataAttributes.setup
(colName, data.getColumnClass(i), MetaAttributeNames.Core.SOURCE_VALUE_TABLE, colName, globalAttributes);
final DefaultDataAttributes computedParameterDataAttributes = new DefaultDataAttributes();
computedParameterDataAttributes.merge(parameterDataAttributes, context);
applyRules(indirectRules, directRules, computedParameterDataAttributes);
defaultDataSchema.setAttributes(colName, computedParameterDataAttributes);
}
}
else
{
final MetaTableModel mt = (MetaTableModel) data;
final DefaultDataAttributes tableGlobalAttributes = new DefaultDataAttributes();
tableGlobalAttributes.merge(globalAttributes, context);
tableGlobalAttributes.merge(mt.getTableAttributes(), context);
try
{
defaultDataSchema.setTableAttributes(tableGlobalAttributes);
}
catch (CloneNotSupportedException e)
{
logger.warn("Unable to copy global data-attributes", e);
}
final int count = data.getColumnCount();
for (int i = 0; i < count; i++)
{
final String colName = data.getColumnName(i);
final DefaultDataAttributes computedParameterDataAttributes = new DefaultDataAttributes();
computedParameterDataAttributes.merge(tableGlobalAttributes, context);
computedParameterDataAttributes.merge(mt.getColumnAttributes(i), context);
parameterDataAttributes.setup(colName, data.getColumnClass(i),
MetaAttributeNames.Core.SOURCE_VALUE_TABLE, null, EmptyDataAttributes.INSTANCE);
computedParameterDataAttributes.merge(parameterDataAttributes, context);
applyRules(indirectRules, directRules, computedParameterDataAttributes);
defaultDataSchema.setAttributes(colName, computedParameterDataAttributes);
}
}