protected Object transformEntity(Entity entity) {

    DJGroupVariable groupVariable = (DJGroupVariable) entity;
    AbstractColumn col = groupVariable.getColumnToApplyOperation();

    String variableName = groupVariable.getName();
    log.debug("transforming group variable " + variableName);
    DJCalculation op = groupVariable.getOperation();

    JRDesignExpression expression = new JRDesignExpression();

    // only variables from the last registered group are important now
    List groupsList = getDjd().getGroupsList();
    JRDesignGroup registeredGroup = (JRDesignGroup) groupsList.get(groupsList.size() - 1);

    if (col instanceof ExpressionColumn
        && ((ExpressionColumn) col).getExpressionForCalculation() != null) {
      ExpressionColumn expcol = (ExpressionColumn) col;
      expression.setText(expcol.getTextForExpressionForCalculartion());
      expression.setValueClassName(expcol.getExpressionForCalculation().getClassName());
    } else if (col instanceof PercentageColumn) {
      PercentageColumn pcol = (PercentageColumn) col;
      expression.setText(pcol.getPercentageColumn().getTextForExpression());
      expression.setValueClassName(pcol.getPercentageColumn().getValueClassNameForExpression());

      DJGroup djgroup = groupVariable.getGroup();
      registeredGroup =
          LayoutUtils.findParentJRGroup(djgroup, getDynamicReport(), getDjd(), getLayoutManager());
    } else {
      if (col.getTextFormatter() != null) {
        PropertyColumn pcol = (PropertyColumn) col;
        expression.setText("$F{" + pcol.getColumnProperty().getProperty() + "}");
        expression.setValueClassName(pcol.getColumnProperty().getValueClassName());
      } else {
        expression.setText(col.getTextForExpression());
        expression.setValueClassName(col.getValueClassNameForExpression());
      }
    }

    JRDesignVariable variable = new JRDesignVariable();
    variable.setExpression(expression);
    variable.setCalculation(CalculationEnum.getByValue(groupVariable.getOperation().getValue()));
    variable.setName(variableName);

    variable.setResetType(ResetTypeEnum.GROUP);
    variable.setResetGroup(registeredGroup);

    String valueClassName = col.getVariableClassName(op);
    String initialExpression = col.getInitialExpression(op);

    //		if (DJCalculation.SYSTEM.equals(groupVariable.getOperation())){
    //			variable.setValueClassName(Object.class.getName());
    //		} else {
    //		}
    variable.setValueClassName(valueClassName);

    if (initialExpression != null) {
      JRDesignExpression initialExp = new JRDesignExpression();
      initialExp.setText(initialExpression);
      initialExp.setValueClassName(valueClassName);
      variable.setInitialValueExpression(initialExp);
    }

    return variable;
  }
 /** @deprecated Replaced by {@link #setCalculation(CalculationEnum)} */
 public void setCalculation(byte calculation) {
   setCalculation(CalculationEnum.getByValue(calculation));
 }