//PropertyColumn only can be used for grouping (not OperationColumn)
protected Object transformEntity(Entity entity) {
log.debug("transforming group...");
DJGroup djgroup = (DJGroup) entity;
PropertyColumn column = djgroup.getColumnToGroupBy();
JRDesignGroup group = new JRDesignGroup();
int groupIndex = getDynamicReport().getColumnsGroups().indexOf(djgroup);
int columnIndex = getDynamicReport().getColumns().indexOf(djgroup.getColumnToGroupBy());
if (column instanceof GlobalGroupColumn){
group.setName("global_column_" + groupIndex);
} else {
group.setName( "group["+groupIndex+"]_for_column_" + columnIndex + "-" + column.getTitle());
}
getLayoutManager().getReferencesMap().put(group.getName(), djgroup);
group.setCountVariable(new JRDesignVariable());
group.setGroupFooter(new JRDesignBand());
group.setGroupHeader(new JRDesignBand());
JRDesignExpression jrExpression = new JRDesignExpression();
CustomExpression expressionToGroupBy = column.getExpressionToGroupBy();
if (expressionToGroupBy != null) { //new in 3.0.7-b5
String expToGroupByName = group.getName() + "_expression_to_group_by";
registerCustomExpressionParameter(expToGroupByName, expressionToGroupBy);
String expText = ExpressionUtils.createCustomExpressionInvocationText(expToGroupByName);
jrExpression.setText(expText);
log.debug("Expression for CustomExpression = " + expText);
jrExpression.setValueClassName(expressionToGroupBy.getClassName());
} else {
jrExpression.setText(column.getTextForExpression());
jrExpression.setValueClassName(column.getValueClassNameForExpression());
}
group.setExpression(jrExpression);
group.setCountVariable(new JRDesignVariable());
return group;
}