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

Examples of org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext


    }

    try
    {
      final ReportParameterDefinition parameters = report.getParameterDefinition();
      final DefaultParameterContext parameterContext = new DefaultParameterContext(report);

      try
      {
        final ReportParameterValidator reportParameterValidator = parameters.getValidator();
        final ValidationResult validationResult =
            reportParameterValidator.validate(new ValidationResult(), parameters, parameterContext);
        // first compute the default values ...
        this.reportParameterValues = validationResult.getParameterValues();
      }
      finally
      {
        parameterContext.close();
      }
    }
    catch (ReportDataFactoryException e)
    {
      e.printStackTrace();
      // this may fail if the datasource is not there or the report is really messed up ..
      this.reportParameterValues = new ReportParameterValues(report.getParameterValues());
    }

    parameterComponents = new ArrayList<ParameterComponent>();
    // we are using a very simple model here (for now).
    parameterContext.update(report);
    parameterContext.update(this.reportParameterValues);

    validator = parameterDefinition.getValidator();

    final ParameterDefinitionEntry[] entries = parameterDefinition.getParameterDefinitions();
    for (int i = 0; i < entries.length; i++)
View Full Code Here


      throw new NullPointerException();
    }

    // process parameters - validate!
    final ReportParameterValues parameterValues = definition.getParameterValues();
    final DefaultParameterContext parameterContext = new DefaultParameterContext
        (definition.getDataFactory(),
            parameterValues,
            ClassicEngineBoot.getInstance().getGlobalConfig(),
            definition.getResourceBundleFactory(),
            definition.getResourceManager(),
            definition.getContextKey(),
            definition.getReportEnvironment());
    parameterContext.open();
    try
    {
      final ReportParameterDefinition parameterDefinition = definition.getParameterDefinition();
      final ReportParameterValidator reportParameterValidator = parameterDefinition.getValidator();
      final ValidationResult validationResult =
          reportParameterValidator.validate(new ValidationResult(), parameterDefinition, parameterContext);
      if (validationResult.isEmpty() == false)
      {
        throw new ReportParameterValidationException
            ("The parameters provided for this report are not valid.", validationResult);
      }
    }
    finally
    {
      parameterContext.close();
    }

    // definition: Single mail or multi-mail
    final TableModel burstingData;
    final DataFactory dataFactory = definition.getDataFactory();
    if (definition.getBurstQuery() != null &&
        dataFactory.isQueryExecutable(definition.getBurstQuery(), parameterValues))
    {
      burstingData = wrapWithParameters(dataFactory.queryData(definition.getBurstQuery(), parameterValues), parameterValues);
    }
    else
    {
      burstingData = wrapWithParameters(new DefaultTableModel(1, 0), parameterValues);
    }


    if (burstingData.getRowCount() > 0)
    {
//      final Transport transport = session.getTransport();
//      transport.connect();
      for (int i = 0; i < burstingData.getRowCount(); i++)
      {
        final DataRow parameterDataRow = createReportParameterDataRow(burstingData, i);
        final MimeMessage message = createReport(definition, session, parameterDataRow);

        parameterContext.setParameterValues(parameterDataRow);

        final MailHeader[] headers = definition.getHeaders();
        for (int j = 0; j < headers.length; j++)
        {
          final MailHeader header = headers[j];
View Full Code Here

  private static boolean isAllParametersHidden(final MasterReport report,
                                               final ReportParameterDefinition parameterDefinition)
  {
    try
    {
      final DefaultParameterContext parameterContext = new DefaultParameterContext(report);
      parameterContext.open();
      try
      {
        final ParameterDefinitionEntry[] entries = parameterDefinition.getParameterDefinitions();
        for (int i = 0; i < entries.length; i++)
        {
          final ParameterDefinitionEntry entry = entries[i];
          if ("true".equals(entry.getParameterAttribute
              (ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.HIDDEN, parameterContext)) == false)
          {
            return false;
          }
        }
      }
      finally
      {
        parameterContext.close();
      }
      return true;
    }
    catch (ReportDataFactoryException e)
    {
View Full Code Here

      {
        throw new NullPointerException();
      }
      this.globalAttributes = globalAttributes;
      this.entry = parameter;
      this.parameterContext = new DefaultParameterContext(new CompoundDataFactory(), new StaticDataRow(),
          ClassicEngineBoot.getInstance().getGlobalConfig(), null, null, null, reportEnvironment);
    }
View Full Code Here

  public static ValidationResult validate(final MasterReport report,
                                          final ValidationResult result) throws ReportProcessingException
  {

    final ReportParameterDefinition parameters = report.getParameterDefinition();
    final DefaultParameterContext parameterContext = new DefaultParameterContext(report);
    parameterContext.open();
    try
    {
      final ReportParameterValidator reportParameterValidator = parameters.getValidator();
      return reportParameterValidator.validate(result, parameters, parameterContext);
    }
    finally
    {
      parameterContext.close();
    }
  }
View Full Code Here

   */
  public static ReportParameterValues computeParameterValueSet(final MasterReport report) throws ReportProcessingException
  {

    final ReportParameterDefinition parameters = report.getParameterDefinition();
    final DefaultParameterContext parameterContext = new DefaultParameterContext(report);
    parameterContext.open();
    final ReportParameterValues parameterValues;
    try
    {
      final ReportParameterValidator reportParameterValidator = parameters.getValidator();
      final ValidationResult validationResult =
          reportParameterValidator.validate(new ValidationResult(), parameters, parameterContext);
      parameterValues = validationResult.getParameterValues();
      return computeParameterValueSet(report, parameterValues);
    }
    finally
    {
      parameterContext.close();
    }
  }
View Full Code Here

    {
      throw new NullPointerException("ProcessingContext must not be null.");
    }

    final ReportParameterDefinition parameters = report.getParameterDefinition();
    final DefaultParameterContext parameterContext = new DefaultParameterContext(report);
    parameterContext.open();
    final ReportParameterValues parameterValues;
    try
    {
      final ReportParameterValidator reportParameterValidator = parameters.getValidator();
      final ValidationResult validationResult =
          reportParameterValidator.validate(new ValidationResult(), parameters, parameterContext);
      if (validationResult.isEmpty() == false)
      {
        throw new ReportParameterValidationException
            ("The parameters provided for this report are not valid.", validationResult);
      }
      parameterValues = validationResult.getParameterValues();
    }
    finally
    {
      parameterContext.close();
    }

    this.processLevels = new HashSet();
    this.groupStarts = new FastStack();
    this.errorHandler = IgnoreEverythingReportErrorHandler.INSTANCE;
View Full Code Here

      throw new NullPointerException();
    }

    // process parameters - validate!
    final ReportParameterValues parameterValues = definition.getParameterValues();
    final DefaultParameterContext parameterContext = new DefaultParameterContext
        (definition.getDataFactory(),
            parameterValues,
            ClassicEngineBoot.getInstance().getGlobalConfig(),
            definition.getResourceBundleFactory(),
            definition.getResourceManager(),
            definition.getContextKey(),
            definition.getReportEnvironment());

    try
    {
      final ReportParameterDefinition parameterDefinition = definition.getParameterDefinition();
      final ReportParameterValidator reportParameterValidator = parameterDefinition.getValidator();
      final ValidationResult validationResult =
          reportParameterValidator.validate(new ValidationResult(), parameterDefinition, parameterContext);
      if (validationResult.isEmpty() == false)
      {
        throw new ReportParameterValidationException
            ("The parameters provided for this report are not valid.", validationResult);
      }
    }
    finally
    {
      parameterContext.close();
    }

    // definition: Single mail or multi-mail
    final TableModel burstingData;
    final DataFactory dataFactory = definition.getDataFactory();
    if (definition.getBurstQuery() != null &&
        dataFactory.isQueryExecutable(definition.getBurstQuery(), parameterValues))
    {
      burstingData = wrapWithParameters(dataFactory.queryData(definition.getBurstQuery(), parameterValues), parameterValues);
    }
    else
    {
      burstingData = wrapWithParameters(new DefaultTableModel(1, 0), parameterValues);
    }


    if (burstingData.getRowCount() > 0)
    {
//      final Transport transport = session.getTransport();
//      transport.connect();
      for (int i = 0; i < burstingData.getRowCount(); i++)
      {
        final DataRow parameterDataRow = createReportParameterDataRow(burstingData, i);
        final MimeMessage message = createReport(definition, session, parameterDataRow);

        parameterContext.setParameterValues(parameterDataRow);

        final MailHeader[] headers = definition.getHeaders();
        for (int j = 0; j < headers.length; j++)
        {
          final MailHeader header = headers[j];
View Full Code Here

    final MasterReport report = new MasterReport();
    final DefaultReportParameterValidator validator = new DefaultReportParameterValidator();
    report.setDataFactory(dataFactory);
    report.setParameterDefinition(parameterDefinition);
    report.getParameterValues().put("parameter", new Object[]{"K1", new Integer(1)});
    ValidationResult validate = validator.validate(null, parameterDefinition, new DefaultParameterContext(report));
    assertFalse(validate.isEmpty());

    report.getParameterValues().put("parameter", new Object[]{"K1", "K2"});
    validate = validator.validate(null, parameterDefinition, new DefaultParameterContext(report));
    assertTrue(validate.isEmpty());

    report.getParameterValues().put("parameter", new Object[]{"K1", "K2", "K5"});
    validate = validator.validate(null, parameterDefinition, new DefaultParameterContext(report));
    assertTrue(validate.isEmpty());
  }
View Full Code Here

    final MasterReport report = new MasterReport();
    final DefaultReportParameterValidator validator = new DefaultReportParameterValidator();
    report.setDataFactory(dataFactory);
    report.setParameterDefinition(parameterDefinition);
    report.getParameterValues().put("parameter", new Object[]{"K1", new Integer(1)});
    ValidationResult validate = validator.validate(null, parameterDefinition, new DefaultParameterContext(report));
    assertFalse(validate.isEmpty());

    report.getParameterValues().put("parameter", new Object[]{"K1", "K2"});
    validate = validator.validate(null, parameterDefinition, new DefaultParameterContext(report));
    assertTrue(validate.isEmpty());

    report.getParameterValues().put("parameter", new Object[]{"K1", "K2", "K5"});
    validate = validator.validate(null, parameterDefinition, new DefaultParameterContext(report));
    assertFalse(validate.isEmpty());
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.parameters.DefaultParameterContext

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.