Package ar.com.fdvs.dj.domain.entities

Examples of ar.com.fdvs.dj.domain.entities.DJGroupVariable


    this.columnToGroupByProperty = columnToGroupByProperty;
  }

  protected void registerEntity(Entity entity) {
    log.debug("registering group variable...");
    DJGroupVariable columnsGroupVariable = (DJGroupVariable) entity;
    try {
      JRDesignVariable jrVariable = (JRDesignVariable)transformEntity(entity);
      getDjd().addVariable(jrVariable);
     
      registerValueFormatter( columnsGroupVariable, jrVariable.getName() );
View Full Code Here


   
  }

  protected Object transformEntity(Entity entity) {
    log.debug("transforming group variable...");
    DJGroupVariable columnsGroupVariable = (DJGroupVariable) entity;
    AbstractColumn col = columnsGroupVariable.getColumnToApplyOperation();
    DJCalculation op = columnsGroupVariable.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 {
      expression.setText(col.getTextForExpression());
      expression.setValueClassName(col.getValueClassNameForExpression());
    }
   
    String variableName = col.getGroupVariableName(type, columnToGroupByProperty);

    JRDesignVariable variable = new JRDesignVariable();
    variable.setExpression(expression);
    variable.setCalculation(columnsGroupVariable.getOperation().getValue());
    variable.setName(variableName);

    variable.setResetType(JRDesignVariable.RESET_TYPE_GROUP);
    variable.setResetGroup(registeredGroup);
View Full Code Here

  protected void placeVariableInBand(List variables, DJGroup columnsGroup, JRDesignGroup jgroup, String type, JRDesignBand band, int yOffset) {
    log.debug("Placing variables in "+type+" band...");
    if ((variables != null) && (!variables.isEmpty())) {
      Iterator it = variables.iterator();
      while (it.hasNext()) {
        DJGroupVariable var = (DJGroupVariable) it.next();
        AbstractColumn col = var.getColumnToApplyOperation();

        String variableName = col.getGroupVariableName(type, columnsGroup.getColumnToGroupBy().getColumnProperty().getProperty());

        JRDesignExpression expression = new JRDesignExpression();
        JRDesignTextField textField = new JRDesignTextField();
        expression.setText("$V{" + variableName + "}");
        expression.setValueClassName(col.getVariableClassName(var.getOperation()));
        if (var.getOperation() != DJCalculation.COUNT)
          textField.setPattern(col.getPattern());

        textField.setKey(variableName);
        textField.setExpression(expression);

        if (DJConstants.FOOTER.equals(type)){
          textField.setPositionType(JRDesignElement.POSITION_TYPE_FIX_RELATIVE_TO_TOP);
        }

        textField.setX(col.getPosX().intValue());
        if (yOffset!=0)
          textField.setY(yOffset);

//        textField.setHeight(columnsGroup.getHeaderHeight().intValue());
        textField.setHeight(2 + getReport().getOptions().getDetailHeight().intValue()); //XXX be carefull with the "2+ ..."
        textField.setWidth(col.getWidth().intValue());

        textField.setEvaluationTime(JRExpression.EVALUATION_TIME_GROUP);

        textField.setEvaluationGroup(jgroup);
        //Assign the style to the element.
        //First we look for the specific element style, then the default style for the group variables
        //and finally the column style.
        Style defStyle = DJConstants.HEADER.equals(type)?columnsGroup.getDefaulHeaderVariableStyle():columnsGroup.getDefaulFooterVariableStyle();

        if (var.getStyle() != null)
          applyStyleToElement(var.getStyle(), textField);
        else if (defStyle != null)
          applyStyleToElement(defStyle, textField);
        else {
          //Last resource is tu use the column style, but a copy of it because
          //the one in the internal cache can get modified by the layout manager (like in the odd row case)
          Style style = col.getStyle();
          try {
            style = (Style) BeanUtils.cloneBean(style);
            style.setName(null); //set to null to make applyStyleToElement(...) assign a name
          } catch (Exception e) {  }
          applyStyleToElement(style, textField);
        }


        band.addElement(textField);

      }

      if (columnsGroup.getColumnToGroupBy() instanceof GlobalGroupColumn) {
        int totalWidth = 0;

        DJGroupVariable leftmostColumn = findLeftMostColumn(variables);
        totalWidth = leftmostColumn.getColumnToApplyOperation().getPosX().intValue();

        GlobalGroupColumn globalCol = (GlobalGroupColumn) columnsGroup.getColumnToGroupBy();

        JRDesignTextField globalTextField = new JRDesignTextField();
        JRDesignExpression globalExp = new JRDesignExpression();
View Full Code Here

    }
  }

  protected DJGroupVariable findLeftMostColumn(List variables) {
    int mostLeftX = Integer.MAX_VALUE;
    DJGroupVariable mostLeftColumn =  null;
    for (Iterator iterator = variables.iterator(); iterator.hasNext();) {
      DJGroupVariable currentCol = (DJGroupVariable) iterator.next();
      if (currentCol.getColumnToApplyOperation().getPosX().intValue() <= mostLeftX) {
        mostLeftColumn = currentCol;
                mostLeftX = mostLeftColumn.getColumnToApplyOperation().getPosX().intValue();
            }
        }
    return mostLeftColumn;
View Full Code Here

   * @return
   */
  public DynamicReportBuilder addGlobalHeaderVariable(AbstractColumn col, DJCalculation op) {
    if (this.globalHeaderVariables == null)
      this.globalHeaderVariables = new ArrayList();
    this.globalHeaderVariables.add(new DJGroupVariable(col, op));
    return this;
  }
View Full Code Here

  }

  public DynamicReportBuilder addGlobalHeaderVariable(AbstractColumn col, DJCalculation op, Style style) {
    if (this.globalHeaderVariables == null)
      this.globalHeaderVariables = new ArrayList();
    this.globalHeaderVariables.add(new DJGroupVariable(col, op, style));
    return this;
  }
View Full Code Here

   * @return
   */
  public DynamicReportBuilder addGlobalFooterVariable(AbstractColumn col, DJCalculation op) {
    if (this.globalFooterVariables == null)
      this.globalFooterVariables = new ArrayList();
    this.globalFooterVariables.add(new DJGroupVariable(col, op));
    return this;
  }
View Full Code Here

  }

  public DynamicReportBuilder addGlobalFooterVariable(AbstractColumn col, DJCalculation op, Style style) {
    if (this.globalFooterVariables == null)
      this.globalFooterVariables = new ArrayList();
    this.globalFooterVariables.add(new DJGroupVariable(col, op, style));
    return this;
  }
View Full Code Here

    this.columnToGroupByProperty = columnToGroupByProperty;
  }

  protected void registerEntity(Entity entity) {
    log.debug("registering group variable...");
    DJGroupVariable columnsGroupVariable = (DJGroupVariable) entity;
    try {
      String name = columnsGroupVariable.getColumnToApplyOperation().getGroupVariableName(type, columnToGroupByProperty);
      if (columnsGroupVariable.getValueExpression() == null) {     
        JRDesignVariable jrVariable = (JRDesignVariable)transformEntity(entity);
        getDjd().addVariable(jrVariable);
     
        registerValueFormatter( columnsGroupVariable, jrVariable.getName() );
      }
      else
        registerCustomExpressionParameter(name + "_valueExpression", columnsGroupVariable.getValueExpression());
      if (columnsGroupVariable.getPrintWhenExpression() != null)
        registerCustomExpressionParameter(name + "_printWhenExpression", columnsGroupVariable.getPrintWhenExpression())
      if (columnsGroupVariable.getLabel() != null && columnsGroupVariable.getLabel().getLabelExpression() != null) {
        registerCustomExpressionParameter(name + "_labelExpression", columnsGroupVariable.getLabel().getLabelExpression());
      }
     
    } catch (JRException e) {
      throw new EntitiesRegistrationException(e.getMessage(),e);
    }
View Full Code Here

   
  }

  protected Object transformEntity(Entity entity) {
    log.debug("transforming group variable...");
    DJGroupVariable groupVariable = (DJGroupVariable) entity;
    AbstractColumn col = groupVariable.getColumnToApplyOperation();
    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);
   
    String variableName = col.getGroupVariableName(type, columnToGroupByProperty);

    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(groupVariable.getOperation().getValue());
    variable.setName(variableName);   

    variable.setResetType(JRDesignVariable.RESET_TYPE_GROUP);
    variable.setResetGroup(registeredGroup);
View Full Code Here

TOP

Related Classes of ar.com.fdvs.dj.domain.entities.DJGroupVariable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.