Package org.pentaho.reporting.engine.classic.extensions.datasources.xpath

Examples of org.pentaho.reporting.engine.classic.extensions.datasources.xpath.XPathDataFactory


    {
      if (xQueryDataFile == null)
      {
        throw new ParseException("Required property 'xQueryDataFile' is missing");
      }
      final XPathDataFactory dataFactory = new XPathDataFactory();
      dataFactory.setXqueryDataFile(xQueryDataFile);
      for (int i = 0; i < queries.size(); i++)
      {
        final QueryReadHandler handler = (QueryReadHandler) queries.get(i);
        dataFactory.setQuery(handler.getQueryName(), handler.getQuery());
      }

      final String queryNameProperty = result.getProperty("queryString");
      if (queryNameProperty != null)
      {
        dataFactory.setQuery("default", queryNameProperty);
      }
      this.dataFactory = dataFactory;
    }
    else if ("JNDI".equals(connectionType))
    {
      if (selectedJNDIDataSourceReadHandler == null)
      {
        throw new ParseException("Required element 'selectedJNDIDataSourceReadHandler' is missing");
      }

      if (useMondrianCubeDefinition)
      {
        if (mondrianCubeDefinition == null)
        {
          throw new ParseException("Required property 'mondrianCubeDefinitionFile' is missing");
        }

        final LegacyBandedMDXDataFactory dataFactory = new LegacyBandedMDXDataFactory();
        dataFactory.setCubeFileProvider(new DefaultCubeFileProvider(mondrianCubeDefinition));
        dataFactory.setJdbcUser(selectedJNDIDataSourceReadHandler.getUsername());
        dataFactory.setJdbcPassword(selectedJNDIDataSourceReadHandler.getPassword());
        dataFactory.setDesignTimeName(selectedJNDIDataSourceReadHandler.getJndiName());

        final DriverDataSourceProvider driverDataSourceProvider = new DriverDataSourceProvider();
        driverDataSourceProvider.setDriver(selectedJNDIDataSourceReadHandler.getDriverClass());
        driverDataSourceProvider.setUrl(selectedJNDIDataSourceReadHandler.getConnectionString());
        dataFactory.setDataSourceProvider(driverDataSourceProvider);
        for (int i = 0; i < queries.size(); i++)
        {
          final QueryReadHandler handler = (QueryReadHandler) queries.get(i);
          dataFactory.setQuery(handler.getQueryName(), handler.getQuery());
        }

        final String queryNameProperty = result.getProperty("queryString");
        if (queryNameProperty != null)
        {
          dataFactory.setQuery("default", queryNameProperty);
        }
        this.dataFactory = dataFactory;
      }
      else
      {
        final DriverConnectionProvider drc = new DriverConnectionProvider();
        drc.setUrl(selectedJNDIDataSourceReadHandler.getConnectionString());
        drc.setDriver(selectedJNDIDataSourceReadHandler.getDriverClass());
        drc.setProperty("user", selectedJNDIDataSourceReadHandler.getUsername());
        drc.setProperty("password", selectedJNDIDataSourceReadHandler.getPassword());
        drc.setProperty("::pentaho-reporting::name", selectedJNDIDataSourceReadHandler.getJndiName());

        final SQLReportDataFactory dataFactory = new SQLReportDataFactory(drc);
        for (int i = 0; i < queries.size(); i++)
        {
          final QueryReadHandler handler = (QueryReadHandler) queries.get(i);
          dataFactory.setQuery(handler.getQueryName(), handler.getQuery());
        }

        final String queryNameProperty = result.getProperty("queryString");
        if (queryNameProperty != null)
        {
          dataFactory.setQuery("default", queryNameProperty);
        }
        this.dataFactory = dataFactory;
      }
    }
    else
View Full Code Here


   *
   * @throws SAXException if there is a parsing error.
   */
  protected void doneParsing() throws SAXException
  {
    final XPathDataFactory srdf = new XPathDataFactory();
    if (configReadHandler == null)
    {
      throw new ParseException("Required element 'config' is missing.", getLocator());
    }
   
    srdf.setXqueryDataFile(configReadHandler.getSourceFile());
    for (int i = 0; i < queries.size(); i++)
    {
      final PropertyReadHandler handler = (PropertyReadHandler) queries.get(i);
      srdf.setQuery(handler.getName(), handler.getResult());
    }
    dataFactory = srdf;
  }
View Full Code Here

    final AttributeList rootAttrs = new AttributeList();
    rootAttrs.addNamespaceDeclaration("data", XPathDataFactoryModule.NAMESPACE);

    xmlWriter.writeTag(XPathDataFactoryModule.NAMESPACE, "xpath-datasource", rootAttrs, XmlWriter.OPEN);

    final XPathDataFactory pmdDataFactory = (XPathDataFactory) dataFactory;
    final AttributeList configAttrs = new AttributeList();
    configAttrs.setAttribute(XPathDataFactoryModule.NAMESPACE,
        "source-file", String.valueOf(pmdDataFactory.getXqueryDataFile()));
    xmlWriter.writeTag(XPathDataFactoryModule.NAMESPACE, "config", configAttrs, XmlWriterSupport.CLOSE);

    final String[] queryNames = pmdDataFactory.getQueryNames();
    for (int i = 0; i < queryNames.length; i++)
    {
      final String queryName = queryNames[i];
      final String query = pmdDataFactory.getQuery(queryName);
      xmlWriter.writeTag(XPathDataFactoryModule.NAMESPACE, "query", "name", queryName, XmlWriterSupport.OPEN);
      xmlWriter.writeTextNormalized(query, false);
      xmlWriter.writeCloseTag();
    }
    xmlWriter.writeCloseTag();
View Full Code Here

  public void write(final ReportWriterContext reportWriter,
                    final XmlWriter xmlWriter,
                    final DataFactory dataFactory)
          throws IOException, ReportWriterException
  {
    final XPathDataFactory pmdDataFactory = (XPathDataFactory) dataFactory;

    final AttributeList rootAttrs = new AttributeList();
    rootAttrs.addNamespaceDeclaration("data", XPathDataFactoryModule.NAMESPACE);

    xmlWriter.writeTag(XPathDataFactoryModule.NAMESPACE, "xpath-datasource", rootAttrs, XmlWriter.OPEN);

    final AttributeList configAttrs = new AttributeList();
    configAttrs.setAttribute(XPathDataFactoryModule.NAMESPACE,
            "source-file", String.valueOf(pmdDataFactory.getXqueryDataFile()));
    xmlWriter.writeTag(XPathDataFactoryModule.NAMESPACE, "config", configAttrs, XmlWriterSupport.CLOSE);

    final String[] queryNames = pmdDataFactory.getQueryNames();
    for (int i = 0; i < queryNames.length; i++)
    {
      final String queryName = queryNames[i];
      final String query = pmdDataFactory.getQuery(queryName);
      xmlWriter.writeTag(XPathDataFactoryModule.NAMESPACE, "query", "name", queryName, XmlWriterSupport.OPEN);
      xmlWriter.writeTextNormalized(query, false);
      xmlWriter.writeCloseTag();
    }
    xmlWriter.writeCloseTag();
View Full Code Here

    return produceFactory();
  }

  private XPathDataFactory produceFactory()
  {
    final XPathDataFactory returnDataFactory = new XPathDataFactory();
    returnDataFactory.setXqueryDataFile(filenameField.getText());

    final DataSetQuery[] queries = this.queries.values().toArray(new DataSetQuery[this.queries.size()]);
    for (int i = 0; i < queries.length; i++)
    {
      final DataSetQuery query = queries[i];
      returnDataFactory.setQuery(query.getQueryName(), query.getQuery(), query.isLegacyQuery());
    }
    return returnDataFactory;
  }
View Full Code Here

    {
      try
      {
        final String query = queryNameTextField.getText();
        final DataPreviewDialog previewDialog = new DataPreviewDialog(XPathDataSourceEditor.this);
        final XPathDataFactory dataFactory = produceFactory();
        DataFactoryEditorSupport.configureDataFactoryForPreview(dataFactory, designTimeContext);

        final XPathPreviewWorker worker = new XPathPreviewWorker(dataFactory, query);
        previewDialog.showData(worker);
View Full Code Here

  public void write(final ReportWriterContext reportWriter,
                    final XmlWriter xmlWriter,
                    final DataFactory dataFactory)
      throws IOException, ReportWriterException
  {
    final XPathDataFactory pmdDataFactory = (XPathDataFactory) dataFactory;

    final AttributeList rootAttrs = new AttributeList();
    rootAttrs.addNamespaceDeclaration("data", XPathDataFactoryModule.NAMESPACE);

    xmlWriter.writeTag(XPathDataFactoryModule.NAMESPACE, "xpath-datasource", rootAttrs, XmlWriter.OPEN);

    final AttributeList configAttrs = new AttributeList();
    configAttrs.setAttribute(XPathDataFactoryModule.NAMESPACE,
        "source-file", String.valueOf(pmdDataFactory.getXqueryDataFile()));
    xmlWriter.writeTag(XPathDataFactoryModule.NAMESPACE, "config", configAttrs, XmlWriterSupport.CLOSE);

    final String[] queryNames = pmdDataFactory.getQueryNames();
    for (int i = 0; i < queryNames.length; i++)
    {
      final String queryName = queryNames[i];
      final XPathDataFactory.QueryDefinition query = pmdDataFactory.getQuery(queryName);
      final AttributeList attributes = new AttributeList();
      attributes.setAttribute(XPathDataFactoryModule.NAMESPACE, "name", queryName);
      if (query.isLegacyQuery())
      {
        attributes.setAttribute(XPathDataFactoryModule.NAMESPACE, "query-mode", "legacy");
View Full Code Here

   *
   * @throws SAXException if there is a parsing error.
   */
  protected void doneParsing() throws SAXException
  {
    final XPathDataFactory srdf = new XPathDataFactory();
    if (configReadHandler == null)
    {
      throw new ParseException("Required element 'config' is missing.", getLocator());
    }

    srdf.setXqueryDataFile(configReadHandler.getSourceFile());
    for (int i = 0; i < queries.size(); i++)
    {
      final XPathQueryReadHandler handler = queries.get(i);
      srdf.setQuery(handler.getName(), handler.getResult(), handler.isLegacyMode());
    }
    dataFactory = srdf;
  }
View Full Code Here

    final AttributeList rootAttrs = new AttributeList();
    rootAttrs.addNamespaceDeclaration("data", XPathDataFactoryModule.NAMESPACE);

    xmlWriter.writeTag(XPathDataFactoryModule.NAMESPACE, "xpath-datasource", rootAttrs, XmlWriter.OPEN);

    final XPathDataFactory pmdDataFactory = (XPathDataFactory) dataFactory;
    final AttributeList configAttrs = new AttributeList();
    configAttrs.setAttribute(XPathDataFactoryModule.NAMESPACE,
        "source-file", String.valueOf(pmdDataFactory.getXqueryDataFile()));
    xmlWriter.writeTag(XPathDataFactoryModule.NAMESPACE, "config", configAttrs, XmlWriterSupport.CLOSE);

    final String[] queryNames = pmdDataFactory.getQueryNames();
    for (int i = 0; i < queryNames.length; i++)
    {
      final String queryName = queryNames[i];
      final XPathDataFactory.QueryDefinition query = pmdDataFactory.getQuery(queryName);
      final AttributeList attributes = new AttributeList();
      attributes.setAttribute(XPathDataFactoryModule.NAMESPACE, "name", queryName);
      if (query.isLegacyQuery())
      {
        attributes.setAttribute(XPathDataFactoryModule.NAMESPACE, "query-mode", "legacy");
View Full Code Here

  {
    DataSourcePlugin editor =
        DataFactoryRegistry.getInstance().getMetaData(XPathDataFactory.class.getName()).createEditor();
    assertNotNull(editor);

    assertTrue(editor.canHandle(new XPathDataFactory()));
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.extensions.datasources.xpath.XPathDataFactory

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.