//PropertyColumn only can be used for grouping (not OperationColumn)
protected Object transformEntity(Entity entity) throws JRException {
log.debug("transforming group...");
DJGroup djgroup = (DJGroup) entity;
PropertyColumn column = djgroup.getColumnToGroupBy();
JRDesignGroup group = new JRDesignGroup();
if (djgroup.getName() == null) {
int groupIndex = getDynamicReport().getColumnsGroups().indexOf(djgroup);
int columnIndex = getDynamicReport().getColumns().indexOf(djgroup.getColumnToGroupBy());
if (column instanceof GlobalGroupColumn){
djgroup.setName("global_column_" + groupIndex);
} else {
djgroup.setName( "group["+groupIndex+"]_for_column_" + columnIndex + "-" + column.getName());
}
}
group.setName(djgroup.getName());
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
useVariableForCustomExpression(group, jrExpression, expressionToGroupBy);
} else {
if (column instanceof ExpressionColumn){
ExpressionColumn col = (ExpressionColumn)column;
CustomExpression customExpression = col.getExpression();
useVariableForCustomExpression(group, jrExpression, customExpression);
} else {
jrExpression.setText(column.getTextForExpression());
jrExpression.setValueClassName(column.getValueClassNameForExpression());
}
}
group.setExpression(jrExpression);
return group;
}