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

Examples of org.pentaho.reporting.engine.classic.extensions.datasources.pmd.PmdDataFactory


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

      final PmdDataFactory dataFactory = new PmdDataFactory();
      dataFactory.setXmiFile(xmiDefinitionFile);
      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 ("XQuery".equals(connectionType))
    {
      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


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

    xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "pmd-datasource", rootAttrs, XmlWriter.OPEN);

    final PmdDataFactory pmdDataFactory = (PmdDataFactory) dataFactory;

    final AttributeList configAttrs = new AttributeList();
    configAttrs.setAttribute(PmdDataFactoryModule.NAMESPACE, "label-mapping", String.valueOf(pmdDataFactory.isLabelMapping()));
    configAttrs.setAttribute(PmdDataFactoryModule.NAMESPACE, "domain", String.valueOf(pmdDataFactory.getDomainId()));
    configAttrs.setAttribute(PmdDataFactoryModule.NAMESPACE, "xmi-file", String.valueOf(pmdDataFactory.getXmiFile()));
    xmlWriter.writeTag(PmdDataFactoryModule.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(PmdDataFactoryModule.NAMESPACE, "query", "name", queryName, XmlWriterSupport.OPEN);
      xmlWriter.writeTextNormalized(query, false);
      xmlWriter.writeCloseTag();
    }
    xmlWriter.writeCloseTag();
View Full Code Here

   * @throws ReportWriterException
   *           if the data factory cannot be written.
   */
  public void write(final ReportWriterContext reportWriter, final XmlWriter xmlWriter, final DataFactory dataFactory) throws IOException, ReportWriterException
  {
    final PmdDataFactory pmdDataFactory = (PmdDataFactory) dataFactory;

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

    xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "pmd-datasource", rootAttrs, XmlWriter.OPEN);

    final AttributeList configAttrs = new AttributeList();
    configAttrs.setAttribute(PmdDataFactoryModule.NAMESPACE, "label-mapping", String.valueOf(pmdDataFactory.isLabelMapping()));
    configAttrs.setAttribute(PmdDataFactoryModule.NAMESPACE, "domain", String.valueOf(pmdDataFactory.getDomainId()));
    configAttrs.setAttribute(PmdDataFactoryModule.NAMESPACE, "xmi-file", String.valueOf(pmdDataFactory.getXmiFile()));
    xmlWriter.writeTag(PmdDataFactoryModule.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(PmdDataFactoryModule.NAMESPACE, "query", "name", queryName, XmlWriterSupport.OPEN);
      xmlWriter.writeTextNormalized(query, false);
      xmlWriter.writeCloseTag();
    }
    xmlWriter.writeCloseTag();
View Full Code Here

   * @throws SAXException
   *           if there is a parsing error.
   */
  protected void doneParsing() throws SAXException
  {
    final PmdDataFactory pmddf = new PmdDataFactory();
    pmddf.setConnectionProvider(configReadHandler.getConnectionProvider());
    pmddf.setDomainId(configReadHandler.getDomain());
    pmddf.setXmiFile(configReadHandler.getXmiFile());
    if (configReadHandler != null)
    {
      pmddf.setLabelMapping(configReadHandler.isLabelMapping());
      // srdf.setDomain(configReadHandler.getDomain());
    }
    for (int i = 0; i < queries.size(); i++)
    {
      final PropertyReadHandler handler = (PropertyReadHandler) queries.get(i);
      pmddf.setQuery(handler.getName(), handler.getResult());
    }
    dataFactory = pmddf;
  }
View Full Code Here

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

    xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "pmd-datasource", rootAttrs, XmlWriter.OPEN);

    final PmdDataFactory df = (PmdDataFactory) dataFactory;

    final AttributeList configAttrs = new AttributeList();
    configAttrs.setAttribute(PmdDataFactoryModule.NAMESPACE, "domain", String.valueOf(df.getDomainId()));
    configAttrs.setAttribute(PmdDataFactoryModule.NAMESPACE, "xmi-file", String.valueOf(df.getXmiFile()));
    xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "config", configAttrs, XmlWriterSupport.CLOSE);

    final String globalScript = df.getGlobalScript();
    final String globalScriptLanguage = df.getGlobalScriptLanguage();
    if (StringUtils.isEmpty(globalScript) == false && StringUtils.isEmpty(globalScriptLanguage) == false)
    {
      xmlWriter.writeTag
          (PmdDataFactoryModule.NAMESPACE, "global-script", "language", globalScriptLanguage, XmlWriterSupport.OPEN);
      xmlWriter.writeTextNormalized(globalScript, false);
      xmlWriter.writeCloseTag();
    }

    xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "query-definitions", XmlWriterSupport.OPEN);
    final String[] queryNames = df.getQueryNames();
    for (int i = 0; i < queryNames.length; i++)
    {
      final String queryName = queryNames[i];
      final String query = df.getQuery(queryName);
      xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "query", "name", queryName, XmlWriterSupport.OPEN);

      xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "static-query", XmlWriterSupport.OPEN);
      xmlWriter.writeTextNormalized(query, false);
      xmlWriter.writeCloseTag();

      final String queryScriptLanguage = df.getScriptingLanguage(queryName);
      final String queryScript = df.getScript(queryName);

      if (StringUtils.isEmpty(queryScript) == false &&
          (StringUtils.isEmpty(queryScriptLanguage) == false || StringUtils.isEmpty(globalScriptLanguage) == false))
      {
        if (StringUtils.isEmpty(queryScriptLanguage))
View Full Code Here

   * @throws ReportWriterException
   *           if the data factory cannot be written.
   */
  public void write(final ReportWriterContext reportWriter, final XmlWriter xmlWriter, final DataFactory dataFactory) throws IOException, ReportWriterException
  {
    final PmdDataFactory df = (PmdDataFactory) dataFactory;

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

    xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "pmd-datasource", rootAttrs, XmlWriter.OPEN);

    final AttributeList configAttrs = new AttributeList();
    configAttrs.setAttribute(PmdDataFactoryModule.NAMESPACE, "domain", String.valueOf(df.getDomainId()));
    configAttrs.setAttribute(PmdDataFactoryModule.NAMESPACE, "xmi-file", String.valueOf(df.getXmiFile()));
    xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "config", configAttrs, XmlWriterSupport.CLOSE);


    final String globalScript = df.getGlobalScript();
    final String globalScriptLanguage = df.getGlobalScriptLanguage();
    if (StringUtils.isEmpty(globalScript) == false && StringUtils.isEmpty(globalScriptLanguage) == false)
    {
      xmlWriter.writeTag
          (PmdDataFactoryModule.NAMESPACE, "global-script", "language", globalScriptLanguage, XmlWriterSupport.OPEN);
      xmlWriter.writeTextNormalized(globalScript, false);
      xmlWriter.writeCloseTag();
    }

    xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "query-definitions", XmlWriterSupport.OPEN);
    final String[] queryNames = df.getQueryNames();
    for (int i = 0; i < queryNames.length; i++)
    {
      final String queryName = queryNames[i];
      final String query = df.getQuery(queryName);
      xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "query", "name", queryName, XmlWriterSupport.OPEN);

      xmlWriter.writeTag(PmdDataFactoryModule.NAMESPACE, "static-query", XmlWriterSupport.OPEN);
      xmlWriter.writeTextNormalized(query, false);
      xmlWriter.writeCloseTag();

      final String queryScriptLanguage = df.getScriptingLanguage(queryName);
      final String queryScript = df.getScript(queryName);

      if (StringUtils.isEmpty(queryScript) == false &&
          (StringUtils.isEmpty(queryScriptLanguage) == false || StringUtils.isEmpty(globalScriptLanguage) == false))
      {
        if (StringUtils.isEmpty(queryScriptLanguage))
View Full Code Here

   *
   * @throws SAXException if there is a parsing error.
   */
  protected void doneParsing() throws SAXException
  {
    final PmdDataFactory pmddf = new PmdDataFactory();
    pmddf.setConnectionProvider(configReadHandler.getConnectionProvider());
    pmddf.setDomainId(configReadHandler.getDomain());
    pmddf.setXmiFile(configReadHandler.getXmiFile());
    if (globalScriptReadHandler != null)
    {
      pmddf.setGlobalScript(globalScriptReadHandler.getResult());
      pmddf.setGlobalScriptLanguage(globalScriptReadHandler.getName());
    }

    for (int i = 0; i < queries.size(); i++)
    {
      final PropertyReadHandler handler = queries.get(i);
      pmddf.setQuery(handler.getName(), handler.getResult(), null, null);
    }

    if (queryDefinitionsReadHandler != null)
    {
      final ArrayList<QueryDefinitionReadHandler> scriptedQueries = queryDefinitionsReadHandler.getScriptedQueries();
      for (final QueryDefinitionReadHandler scriptedQuery : scriptedQueries)
      {
        pmddf.setQuery(scriptedQuery.getName(), scriptedQuery.getQuery(),
            scriptedQuery.getScriptLanguage(), scriptedQuery.getScript());
      }
    }
    dataFactory = pmddf;
  }
View Full Code Here

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

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

        if (maxPreviewRowsSpinner.isEnabled())
        {
          theMaxRows = (Integer) maxPreviewRowsSpinner.getValue();
        }

        final PmdDataFactory dataFactory = createDataFactory();
        DataFactoryEditorSupport.configureDataFactoryForPreview(dataFactory, context);

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

    return selectedValue.getLanguageName();
  }

  private PmdDataFactory createDataFactory()
  {
    final PmdDataFactory returnDataFactory = new PmdDataFactory();
    returnDataFactory.setXmiFile(filenameField.getText());
    returnDataFactory.setDomainId(domainIdTextField.getText());
    returnDataFactory.setConnectionProvider(new PmdConnectionProvider());
    returnDataFactory.setGlobalScriptLanguage(getGlobalScriptingLanguage());
    if (StringUtils.isEmpty(globalScriptTextArea.getText()) == false)
    {
      returnDataFactory.setGlobalScript(globalScriptTextArea.getText());
    }

    for (final DataSetQuery query : this.queries.values())
    {
      returnDataFactory.setQuery(query.getQueryName(), query.getQuery(), query.getScriptLanguage(), query.getScript());
    }
    return returnDataFactory;
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.extensions.datasources.pmd.PmdDataFactory

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.