final Section section) throws ReportProcessingException
{
final int count = section.getElementCount();
for (int i = 0; i < count; i++)
{
final ReportElement element = section.getElement(i);
if (element instanceof SubReport)
{
continue;
}
if (element instanceof Section)
{
processSection(schema, definition, (Section) element);
continue;
}
final Object attribute =
element.getAttribute(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_TYPE);
if (attribute instanceof Class == false)
{
continue;
}
final Class aggType = (Class) attribute;
if (AggregationFunction.class.isAssignableFrom(aggType) == false)
{
continue;
}
try
{
final AggregationFunction o = (AggregationFunction) aggType.newInstance();
final String group = (String) element.getAttribute
(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_GROUP);
if (group != null)
{
o.setGroup(group);
}
else
{
final Group g = findGroup(element);
if (g != null)
{
if (g.getName() == null)
{
g.setName("::wizard:group:" + g.getClass().getName() + ':' + System.identityHashCode(g));
}
o.setGroup(g.getName());
}
}
final String fieldName = (String) element.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD);
if (o instanceof FieldAggregationFunction)
{
final FieldAggregationFunction fo = (FieldAggregationFunction) o;
fo.setField(fieldName);
}
final Object labelFor =
element.getAttribute(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR);
if (labelFor == null)
{
element.setAttribute(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.LABEL_FOR, fieldName);
}
final String name = AutoGeneratorUtility.generateUniqueExpressionName
(schema, "::wizard:aggregation:{0}",
(String[]) generatedExpressionNames.toArray(new String[generatedExpressionNames.size()]));
o.setName(name);
generatedExpressionNames.add(name);
element.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, name);
// finally clean up
element.setAttribute(AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.AGGREGATION_TYPE, null);
definition.addExpression(o);
}
catch (Exception e)
{
throw new ReportProcessingException("Failed to pre-process the report", e);