Package org.pentaho.metadata.query.impl.sql

Examples of org.pentaho.metadata.query.impl.sql.SqlGenerator


  {
    try
    {
      final String sqlGeneratorClass = configuration.getConfigProperty
          ("org.pentaho.reporting.engine.classic.extensions.datasources.pmd.SqlGeneratorClass");
      final SqlGenerator sqlGenerator = (SqlGenerator) ObjectUtilities.loadAndInstantiate
          (sqlGeneratorClass, SimplePmdDataFactory.class, SqlGenerator.class);
      if (sqlGenerator == null)
      {
        logger.error("Default SqlGenerator class " + sqlGeneratorClass + " not found."); //$NON-NLS-1$
        throw new ReportDataFactoryException("Failed to generate SQL. No valid SqlGenerator class found.");//$NON-NLS-1$
      }
      // convert DataRow into Map<String,Object>
      final Map<String, Object> parameterMap = new HashMap<String, Object>();
      final String[] columnNames = parameters.getColumnNames();
      for (int i = 0; i < columnNames.length; i++)
      {
        final String key = columnNames[i];
        final Object value = parameters.get(key);
        parameterMap.put(key, value);
      }

      final IMetadataDomainRepository domainRepository = getDomainRepository();

      Locale locale;
      if (resourceBundleFactory != null)
      {
        locale = resourceBundleFactory.getLocale();
      }
      else
      {
        locale = LocaleHelper.getLocale();
      }
      if (locale == null)
      {
        locale = Locale.getDefault();
      }

      return sqlGenerator.generateSql(queryObject, locale.toString(), domainRepository, databaseMeta, parameterMap, true);
    }
    catch (ReportDataFactoryException e)
    {
      throw e;
    }
View Full Code Here


  {
    try
    {
      final String sqlGeneratorClass = getConfiguration().getConfigProperty
          ("org.pentaho.reporting.engine.classic.extensions.datasources.pmd.SqlGeneratorClass");
      final SqlGenerator sqlGenerator = ObjectUtilities.loadAndInstantiate
          (sqlGeneratorClass, SimplePmdDataFactory.class, SqlGenerator.class);
      if (sqlGenerator == null)
      {
        logger.error("Default SqlGenerator class " + sqlGeneratorClass + " not found."); //$NON-NLS-1$
        throw new ReportDataFactoryException("Failed to generate SQL. No valid SqlGenerator class found.");//$NON-NLS-1$
      }

      final Map<String, Object> parameterMap = convertDataRowToMap(parameters);
      final IMetadataDomainRepository domainRepository = getDomainRepository();
      Locale locale = computeLocale();
      return sqlGenerator.generateSql(queryObject, locale.toString(), domainRepository, databaseMeta, parameterMap, true);
    }
    catch (final ReportDataFactoryException e)
    {
      throw e;
    }
View Full Code Here

        }
      }

      MappedQuery mappedQuery = null;
      try {
        SqlGenerator sqlGenerator = createSqlGenerator();
        mappedQuery =
            sqlGenerator.generateSql( queryObject, LocaleHelper.getLocale().toString(), getMetadataDomainRepository(),
              activeDatabaseMeta, parameters, true );
      } catch ( Exception e ) {
        throw new RuntimeException( e.getLocalizedMessage(), e );
      }
View Full Code Here

   * and if there is a SqlGenerator specified in there, we use that SqlGenerator, overriding
   * the default. The setter always overrides the pentahoSpring.objects.xml class.  
   */
  private SqlGenerator createSqlGenerator() throws Exception {

    SqlGenerator sqlGenerator = null;

    String inputClass = (String) inputs.get( "sqlgenerator" );
    if ( inputClass != null ) {
      sqlGeneratorClass = inputClass;
    }
View Full Code Here

TOP

Related Classes of org.pentaho.metadata.query.impl.sql.SqlGenerator

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.