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(), null, null);
      }

      final String queryNameProperty = result.getProperty("queryString");
      if (queryNameProperty != null)
      {
        dataFactory.setQuery("default", queryNameProperty, null, null);
      }
      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(), true);
      }

      final String queryNameProperty = result.getProperty("queryString");
      if (queryNameProperty != null)
      {
        dataFactory.setQuery("default", queryNameProperty, true);
      }
      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();

        // legacy report usecase
        final CubeFileProvider cubeFileProvider = ClassicEngineBoot.getInstance().getObjectFactory().get(CubeFileProvider.class);
        cubeFileProvider.setDesignTimeFile(mondrianCubeDefinition);

        dataFactory.setCubeFileProvider(cubeFileProvider);
        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(), null, null);
        }

        final String queryNameProperty = result.getProperty("queryString");
        if (queryNameProperty != null)
        {
          dataFactory.setQuery("default", queryNameProperty, null, null);
        }
        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(), null, null);
        }

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


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

        final PmdDataFactory dataFactory = createDataFactory();
        final AbstractReportDefinition report = context.getReport();
        final MasterReport masterReport = DesignTimeUtil.getMasterReport(report);
        final Configuration configuration;
        final ResourceKey contentBase;
        final ReportEnvironment reportEnvironment;
        if (masterReport == null)
        {
          contentBase = null;
          configuration = ClassicEngineBoot.getInstance().getGlobalConfig();
          reportEnvironment = new DefaultReportEnvironment(configuration);
        }
        else
        {
          contentBase = masterReport.getContentBase();
          configuration = masterReport.getConfiguration();
          reportEnvironment = masterReport.getReportEnvironment();
        }
        dataFactory.initialize(configuration,
            report.getResourceManager(), contentBase, MasterReport.computeAndInitResourceBundleFactory
            (report.getResourceBundleFactory(), reportEnvironment));

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

    return createDataFactory();
  }

  private PmdDataFactory createDataFactory()
  {
    final PmdDataFactory returnDataFactory = new PmdDataFactory();
    returnDataFactory.setXmiFile(filenameField.getText());
    returnDataFactory.setDomainId(domainIdTextField.getText());
    returnDataFactory.setConnectionProvider(new PmdConnectionProvider());

    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());
    }
    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.