Package org.pentaho.reporting.engine.classic.core.util

Examples of org.pentaho.reporting.engine.classic.core.util.TypedTableModel


    ClassicEngineBoot.getInstance().start();
  }

  private TableModel createTableModel()
  {
    final TypedTableModel model = new TypedTableModel();
    model.addColumn(ROW_DIMENSION_A, String.class);
    model.addColumn(ROW_DIMENSION_B, String.class);
    model.addColumn(COLUMN_DIMENSION_A, String.class);
    model.addColumn(COLUMN_DIMENSION_B, String.class);
    model.addColumn(VALUE, Integer.class);
    model.addColumn("validate-cell-sum", Boolean.class);
    model.addColumn("validate-detail-sum", Boolean.class);

    model.addRow("R1", "r1", "C1", "c1", 1, false, false);
    model.addRow("R1", "r1", "C1", "c2", 2, false, false);
    model.addRow("R1", "r1", "C2", "c1", 3, false, false);
    model.addRow("R1", "r1", "C2", "c2", 4, false, false);
    model.addRow("R1", "r2", "C1", "c1", 5, true, false); //*
    model.addRow("R1", "r2", "C1", "c2", 6, true, false);
    model.addRow("R1", "r2", "C2", "c1", 7, true, false); //
    model.addRow("R1", "r2", "C2", "c2", 8, true, false);
    model.addRow("R1", "r2", "C2", "c2", 8, true, true);
    model.addRow("R1", "r2", "C2", "c2", 8, true, false); //
    model.addRow("R2", "r1", "C1", "c1", 10, false, false);
    model.addRow("R2", "r1", "C1", "c2", 11, false, false);
    model.addRow("R2", "r1", "C2", "c1", 12, false, false);
    model.addRow("R2", "r1", "C2", "c2", 13, false, false);
    model.addRow("R2", "r2", "C1", "c1", 14, true, false);
    model.addRow("R2", "r2", "C1", "c2", 15, true, false);
    model.addRow("R2", "r2", "C2", "c1", 16, true, false);
    model.addRow("R2", "r2", "C2", "c2", 17, true, false);
    return model;
  }
View Full Code Here


    ClassicEngineBoot.getInstance().start();
  }

  private TableModel createRelationalTableModel()
  {
    final TypedTableModel model = new TypedTableModel();
    model.addColumn(ROW_DIMENSION_A, String.class);
    model.addColumn(ROW_DIMENSION_B, String.class);
    model.addColumn(VALUE, String.class);
    model.addColumn("validate-row-b-sum", Integer.class);
    model.addColumn("validate-row-a-sum", Integer.class);
    model.addColumn("validate-no-group", Integer.class);

    model.addRow("RA", "r1", 1, 1, 5, 5);
    model.addRow("RA", "r2", 1, 1, 5, 5);
    model.addRow("RA", "r1", 1, 3, 5, 5);
    model.addRow("RA", "r1", 1, 3, 5, 5);
    model.addRow("RA", "r1", 1, 3, 5, 5);   // page break
    model.addRow("RA", "r2", 1, 3, 3, 7);
    model.addRow("RA", "r2", 1, 3, 3, 7);
    model.addRow("RA", "r2", 1, 3, 3, 7);
    model.addRow("RB", "r1", 1, 4, 4, 7);
    model.addRow("RB", "r1", 1, 4, 4, 7);
    model.addRow("RB", "r1", 1, 4, 4, 7);
    model.addRow("RB", "r1", 1, 4, 4, 7)// page break
    model.addRow("RB", "r1", 1, 1, 8, 8);
    model.addRow("RB", "r2", 1, 7, 8, 8);
    model.addRow("RB", "r2", 1, 7, 8, 8);
    model.addRow("RB", "r2", 1, 7, 8, 8);
    model.addRow("RB", "r2", 1, 7, 8, 8);
    model.addRow("RB", "r2", 1, 7, 8, 8);
    model.addRow("RB", "r2", 1, 7, 8, 8);
    model.addRow("RB", "r2", 1, 7, 8, 8);
    return model;
  }
View Full Code Here

    ClassicEngineBoot.getInstance().start();
  }

  private TableModel createTableModel()
  {
    final TypedTableModel model = new TypedTableModel();
    model.addColumn(ROW_DIMENSION_A, String.class);
    model.addColumn(ROW_DIMENSION_B, String.class);
    model.addColumn(COLUMN_DIMENSION_A, String.class);
    model.addColumn(COLUMN_DIMENSION_B, String.class);
    model.addColumn(VALUE, String.class);
    model.addColumn("validate-cell-sum", String.class);
    model.addColumn("validate-detail-sum", String.class);
    model.addColumn("validate-row-b-sum", String.class);
    model.addColumn("validate-row-a-sum", String.class);
    model.addColumn("validate-column-a-sum", String.class); // same as row-b
    model.addColumn("validate-column-b-sum", String.class);

    model.addRow("R1", "r1", "C1", "c1", 1, 1, 1, 2, 6, 2, 5);
    model.addRow("R1", "r1", "C1", "c2", 2, 2, 2, 2, 6, 2, 6);
    model.addRow("R1", "r1", "C2", "c1", 3, 3, 3, 4, 8, 4, 7);
    model.addRow("R1", "r1", "C2", "c2", 4, 4, 4, 4, 8, 4, 8);
    model.addRow("R1", "r2", "C1", "c1", 5, 5, 5, 6, 6, 6, 5); //*
    model.addRow("R1", "r2", "C1", "c2", 6, 6, 6, 6, 6, 6, 6);
    model.addRow("R1", "r2", "C2", "c1", 7, 7, 7, 8, 8, 8, 7); //
    model.addRow("R1", "r2", "C2", "c2", 8, 8, 8, 8, 8, 8, 8);
    model.addRow("R1", "r2", "C2", "c2", 8, 8, 8, 8, 8, 8, 8);
    model.addRow("R1", "r2", "C2", "c2", 8, 8, 8, 8, 8, 8, 8); //
    model.addRow("R2", "r1", "C1", "c1", 10, 10, 10, 11, 15, 11, 14);
    model.addRow("R2", "r1", "C1", "c2", 11, 11, 11, 11, 15, 11, 15);
    model.addRow("R2", "r1", "C2", "c1", 12, 12, 12, 13, 17, 13, 16);
    model.addRow("R2", "r1", "C2", "c2", 13, 13, 13, 13, 17, 13, 17);
    model.addRow("R2", "r2", "C1", "c1", 14, 14, 14, 15, 15, 15, 14);
    model.addRow("R2", "r2", "C1", "c2", 15, 15, 15, 15, 15, 15, 15);
    model.addRow("R2", "r2", "C2", "c1", 16, 16, 16, 17, 17, 17, 16);
    model.addRow("R2", "r2", "C2", "c2", 17, 17, 17, 17, 17, 17, 17);
    return model;
  }
View Full Code Here

    ClassicEngineBoot.getInstance().start();
  }

  private TableModel createTableModel()
  {
    final TypedTableModel model = new TypedTableModel();
    model.addColumn(ROW_DIMENSION_A, String.class);
    model.addColumn(ROW_DIMENSION_B, String.class);
    model.addColumn(COLUMN_DIMENSION_A, String.class);
    model.addColumn(COLUMN_DIMENSION_B, String.class);
    model.addColumn(VALUE, String.class);
    model.addColumn("validate-cell-sum", String.class);
    model.addColumn("validate-detail-sum", String.class);
    model.addColumn("validate-row-b-sum", String.class);
    model.addColumn("validate-row-a-sum", String.class);
    model.addColumn("validate-column-a-sum", String.class);
    model.addColumn("validate-column-b-sum", String.class);

    model.addRow("R1", "r1", "C1", "c1", 1, 1, 1, 3, 14, 3, 6);
    model.addRow("R1", "r1", "C1", "c2", 2, 2, 2, 3, 14, 3, 8);
    model.addRow("R1", "r1", "C2", "c1", 3, 3, 3, 7, 38, 7, 10);
    model.addRow("R1", "r1", "C2", "c2", 4, 4, 4, 7, 38, 7, 28);
    model.addRow("R1", "r2", "C1", "c1", 5, 5, 5, 11, 14, 11, 6); //*
    model.addRow("R1", "r2", "C1", "c2", 6, 6, 6, 11, 14, 11, 8);
    model.addRow("R1", "r2", "C2", "c1", 7, 7, 7, 31, 38, 31, 10); //
    model.addRow("R1", "r2", "C2", "c2", 8, 24, 24, 31, 38, 31, 28);
    model.addRow("R1", "r2", "C2", "c2", 8, 24, 24, 31, 38, 31, 28);
    model.addRow("R1", "r2", "C2", "c2", 8, 24, 24, 31, 38, 31, 28); //
    model.addRow("R2", "r1", "C1", "c1", 10, 10, 10, 21, 50, 21, 24);
    model.addRow("R2", "r1", "C1", "c2", 11, 11, 11, 21, 50, 21, 26);
    model.addRow("R2", "r1", "C2", "c1", 12, 12, 12, 25, 58, 25, 28);
    model.addRow("R2", "r1", "C2", "c2", 13, 13, 13, 25, 58, 25, 30);
    model.addRow("R2", "r2", "C1", "c1", 14, 14, 14, 29, 50, 29, 24);
    model.addRow("R2", "r2", "C1", "c2", 15, 15, 15, 29, 50, 29, 26);
    model.addRow("R2", "r2", "C2", "c1", 16, 16, 16, 33, 58, 33, 28);
    model.addRow("R2", "r2", "C2", "c2", 17, 17, 17, 33, 58, 33, 30);
    return model;
  }
View Full Code Here

    ClassicEngineBoot.getInstance().start();
  }

  private TableModel createTableModel()
  {
    final TypedTableModel model = new TypedTableModel();
    model.addColumn(ROW_DIMENSION_A, String.class);
    model.addColumn(ROW_DIMENSION_B, String.class);
    model.addColumn(COLUMN_DIMENSION_A, String.class);
    model.addColumn(COLUMN_DIMENSION_B, String.class);
    model.addColumn(VALUE, String.class);
    model.addColumn("validate-cell-sum", String.class);
    model.addColumn("validate-detail-sum", String.class);
    model.addColumn("validate-row-b-sum", String.class);
    model.addColumn("validate-row-a-sum", String.class);
    model.addColumn("validate-column-a-sum", String.class);
    model.addColumn("validate-column-b-sum", String.class);

    model.addRow("R1", "r1", "C1", "c1"111,      1,      1,   1,    1);
    model.addRow("R1", "r1", "C1", "c2"222,    1.5,    1.5, 1.5,    2);
    model.addRow("R1", "r1", "C2", "c1"333,      3,      3, 3.0,    3);
    model.addRow("R1", "r1", "C2", "c2"444,    3.5,    3.5, 3.5,    4);
    model.addRow("R1", "r2", "C1", "c1"555,      58/3.0, 5.0,    3); //*
    model.addRow("R1", "r2", "C1", "c2"666,    5.5,    3.5, 5.5,    4);
    model.addRow("R1", "r2", "C2", "c1"777,      7, 14/3.0, 7.0,    5); //
    model.addRow("R1", "r2", "C2", "c2"888,    7.5,    5.5, 7.5,    6);
    model.addRow("R1", "r2", "C2", "c2"888, 23/3.0,      6, 23/3.0, 20/3.0);
    model.addRow("R1", "r2", "C2", "c2"888,   7.75, 19/3.0, 7.75,    7); //
    model.addRow("R2", "r1", "C1", "c1", 10, 10, 10,     10,     10, 10,   10);
    model.addRow("R2", "r1", "C1", "c2", 11, 11, 11,   10.5,   10.5, 10.5,   11);
    model.addRow("R2", "r1", "C2", "c1", 12, 12, 12,     12,     12, 12,   12);
    model.addRow("R2", "r1", "C2", "c2", 13, 13, 13,   12.5,   12.5, 12.5,   13);
    model.addRow("R2", "r2", "C1", "c1", 14, 14, 14,     14, 35/3.0, 14,   12);
    model.addRow("R2", "r2", "C1", "c2", 15, 15, 15,   14.5,   12.5,14.5,    13);
    model.addRow("R2", "r2", "C2", "c1", 16, 16, 16,     16, 41/3.0, 16,   14);
    model.addRow("R2", "r2", "C2", "c2", 17, 17, 17,   16.5,   14.5, 16.5,   15);
    return model;
  }
View Full Code Here

    ClassicEngineBoot.getInstance().start();
  }

  private TableModel createTableModel()
  {
    final TypedTableModel model = new TypedTableModel();
    model.addColumn(ROW_DIMENSION_A, String.class);
    model.addColumn(ROW_DIMENSION_B, String.class);
    model.addColumn(COLUMN_DIMENSION_A, String.class);
    model.addColumn(COLUMN_DIMENSION_B, String.class);
    model.addColumn(VALUE, String.class);
    model.addColumn("validate-cell-sum", String.class);
    model.addColumn("validate-detail-sum", String.class);
    model.addColumn("validate-row-b-sum", String.class);
    model.addColumn("validate-row-a-sum", String.class);
    model.addColumn("validate-column-a-sum", String.class);
    model.addColumn("validate-column-b-sum", String.class);

    model.addRow("R1", "r1", "C1", "c1", 1, 1, 1, 1, 1, 1, 1);
    model.addRow("R1", "r1", "C1", "c2", 2, 2, 2, 3, 3, 3, 2);
    model.addRow("R1", "r1", "C2", "c1", 3, 3, 3, 3, 3, 3, 3);
    model.addRow("R1", "r1", "C2", "c2", 4, 4, 4, 7, 7, 7, 4);
    model.addRow("R1", "r2", "C1", "c1", 5, 5, 5, 5, 8, 5, 6); //*
    model.addRow("R1", "r2", "C1", "c2", 6, 6, 6, 11, 14, 11, 8);
    model.addRow("R1", "r2", "C2", "c1", 7, 7, 7, 7, 14, 7, 10); //
    model.addRow("R1", "r2", "C2", "c2", 8, 8, 8, 15, 22, 15, 12);
    model.addRow("R1", "r2", "C2", "c2", 8, 16, 16, 23, 30, 23, 20);
    model.addRow("R1", "r2", "C2", "c2", 8, 24, 24, 31, 38, 31, 28); //
    model.addRow("R2", "r1", "C1", "c1", 10, 10, 10, 10, 10, 10, 10);
    model.addRow("R2", "r1", "C1", "c2", 11, 11, 11, 21, 21, 21, 11);
    model.addRow("R2", "r1", "C2", "c1", 12, 12, 12, 12, 12, 12, 12);
    model.addRow("R2", "r1", "C2", "c2", 13, 13, 13, 25, 25, 25, 13);
    model.addRow("R2", "r2", "C1", "c1", 14, 14, 14, 14, 35, 14, 24);
    model.addRow("R2", "r2", "C1", "c2", 15, 15, 15, 29, 50, 29, 26);
    model.addRow("R2", "r2", "C2", "c1", 16, 16, 16, 16, 41, 16, 28);
    model.addRow("R2", "r2", "C2", "c2", 17, 17, 17, 33, 58, 33, 30);
    return model;
  }
View Full Code Here

        default:
          fieldTypes[columnNo] = String.class;
      }

    }
    return new TypedTableModel(fieldNames, fieldTypes);
  }
View Full Code Here

      else
      {
        this.dataLimit = Math.min(1, maxRowsToProcess);
      }

      backend = new TypedTableModel();
      final LinkedHashMap<String, String> results = new LinkedHashMap<String, String>();
      // try to find all valid column names
      // visit all entries and add the names as we find them
      final NodeList rows = evaluateNodeList(xPath, xPathExpression, xmlResource, resourceManager);
      for (int r = 0; r < rows.getLength(); r++)
View Full Code Here

  {
  }

  public TableModel queryData(final String query, final DataRow parameters) throws ReportDataFactoryException
  {
    final TypedTableModel tableModel = new TypedTableModel();
    tableModel.addRow();
    return tableModel;
  }
View Full Code Here

    if (config == null)
    {
      throw new ReportDataFactoryException("Configuration is empty."); //$NON-NLS-1$
    }

    final TypedTableModel resultSet = new TypedTableModel();

    final int queryLimit = calculateQueryLimit(parameters);
    final OpenERPHelper helper = new OpenERPHelper();
    final OpenERPConfiguration targetConfig = config.clone();
    final ArrayList<OpenERPFilterInfo> configFilters = targetConfig.getFilters();

    // Build a hashmap to pass all parameters as a dictionary to a custom OpenERP procedure
    final HashMap<String, Object> openERPParams = new HashMap<String, Object>();
    for (final String paramName : parameters.getColumnNames())
    {
      Object value = parameters.get(paramName);
      if (value == null)
      {
        value = false;
      }

      openERPParams.put(paramName, value);
    }

    // Can't get selected fields from config, because we may be calling a custom function
    ArrayList<OpenERPFieldInfo> selectedFields = null;
    try
    {
      selectedFields = helper.getFields(targetConfig, openERPParams);
    }
    catch (Exception e1)
    {
      throw new ReportDataFactoryException("Failed to select field", e1);
    }

    // Build a field list
    for (final OpenERPFieldInfo selectedFld : selectedFields)
    {
      resultSet.addColumn(selectedFld.getRenamedFieldName(), convertFieldType(selectedFld.getFieldType()));
    }

    // Called by the designer to get column layout, return a empty resultSet with columns already set
    if (queryLimit == 1)
    {
      return resultSet;
    }

    // Parameter parser to replace parameters in strings
    final PropertyLookupParser parameterParser = new PropertyLookupParser()
    {
      private static final long serialVersionUID = -7264648195698966110L;

      @Override
      protected String lookupVariable(final String property)
      {
        return parameters.get(property).toString();
      }
    };

    // Replace parameterized filters with values from parameters
    if (configFilters != null)
    {
      for (final OpenERPFilterInfo filter : configFilters)
      {
        // You could have set a filter without using the Designer.  Then the filter could be any data type that should not be converted to a String.
        if (filter.getValue() instanceof String)
        {
          try
          {
            final String realFilterValue = filter.getValue().toString();

            // If you specify the filter on its own, try in get the object value
            // Not all parameter values are a string.  Could be an Object[] of ids for example in a multi-select parameter
            final Object filterValue;
            if (realFilterValue.length() >= 4
                && realFilterValue.substring(0, 2).equals("${")
                && realFilterValue.endsWith("}"))
            {

              final String parameterName = realFilterValue.substring(2, realFilterValue.length() - 1);
              filterValue = parameters.get(parameterName);
            }
            // Cater for cases where users specify compound filer: "name" "like" "some${post_fix}"
            else
            {
              filterValue = parameterParser.translateAndLookup(realFilterValue, parameters);
            }

            // If the value is null, this may be a dependent query and it is waiting for a parameter.
            // just return and wait
            if (filterValue == null)
            {
              return resultSet;
            }

            filter.setValue(filterValue);
          }
          catch (Exception e)
          {
            throw new ReportDataFactoryException(e.getMessage(), e);
          }
        }
      }
    }

    // Get the data
    final Object[][] rows;
    try
    {
      rows = helper.getData(targetConfig, openERPParams);
    }
    catch (Exception e)
    {
      throw new ReportDataFactoryException(e.getMessage(), e);
    }

    // Add data to resultSet and do some data transformations
    for (int row = 0; row < rows.length; row++)
    {
      final Object[] rowData = rows[row];

      for (int column = 0; column < selectedFields.size(); column++)
      {
        final OpenERPFieldInfo fld = selectedFields.get(column);

        // Base64 Decode Binary
        if (fld.getFieldType() == FieldType.BINARY
            && rowData[column] != null)
        {
          try
          {
            rowData[column] = Base64.decode(rowData[column].toString());
          }
          catch (DecodingException e)
          {
            rowData[column] = "Unable to decode string";
          }
          catch (Exception e)
          {
            logger.debug("Failed to decode string on query-result: Row=" + row + " Col=" + column, e);
          }
        }

        // Only return integer part (exclude name) from many2one field
        if (fld.getFieldType() == FieldType.MANY2ONE
            && rowData[column] instanceof Object[])
        {
          final Object[] value = (Object[]) rowData[column];
          rowData[column] = Integer.parseInt(String.valueOf(value[0]));
        }

        // make many2many and one2many a comma separated list of values
        if ((fld.getFieldType() == FieldType.MANY2MANY || fld.getFieldType() == FieldType.ONE2MANY)
            && rowData[column] instanceof Object[])
        {

          final StringBuilder stringValue = new StringBuilder();
          final Object[] mcolumn = (Object[]) rowData[column];
          for (int x = 0; x < mcolumn.length; x += 1)
          {
            if (x != 0)
            {
              stringValue.append(',');
            }
            stringValue.append(mcolumn[x]);
          }

          rowData[column] = stringValue.toString();
        }
      }

      resultSet.addRow(rowData);
    }
    return resultSet;
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.util.TypedTableModel

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.