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

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


    try
    {
      final DatabaseMeta databaseMeta = getDatabaseMeta(queryObject);
      final DatabaseMeta activeDatabaseMeta = getActiveDatabaseMeta(databaseMeta, parameters);
      final MappedQuery mappedQuery = generateSQL(queryObject, activeDatabaseMeta, parameters);
      // get active database meta

      return buildTableModel(databaseMeta, queryObject, mappedQuery, parameters);
    }
    catch (ReportDataFactoryException e)
View Full Code Here


    if (queryObject.getLogicalModel().getPhysicalModel() instanceof SqlPhysicalModel) {
      try
      {
        final DatabaseMeta databaseMeta = getDatabaseMeta(queryObject);
        final DatabaseMeta activeDatabaseMeta = getActiveDatabaseMeta(databaseMeta, parameters);
        final MappedQuery mappedQuery = generateSQL(queryObject, activeDatabaseMeta, parameters);
        // get active database meta
 
        return buildTableModel(databaseMeta, queryObject, mappedQuery, parameters);
      }
      catch (final ReportDataFactoryException e)
View Full Code Here

        if ( parameters.containsKey( pName ) && !parameters.get( pName ).getClass().isArray() ) {
          parameters.put( pName, this.convertParameterValue( param, parameters.get( pName ) ) );
        }
      }

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

      Integer timeout = getTimeout();
      if ( timeout != null && timeout >= 0 ) {
        sqlConnection.setQueryTimeout( timeout );
      }

      Integer maxRows = getMaxRows();
      if ( maxRows != null && maxRows >= 0 ) {
        sqlConnection.setMaxRows( maxRows );
      }

      Boolean readOnly = isReadOnly();
      if ( readOnly != null && readOnly.booleanValue() ) {
        sqlConnection.setReadOnly( true );
      }

      IPentahoResultSet localResultSet = null;
      sql = mappedQuery.getQuery();
      if ( logger.isDebugEnabled() ) {
        logger.debug( "SQL: " + sql ); //$NON-NLS-1$
      }
      if ( getDoQueryLog() ) {
        logger.info( "SQL: " + sql ); //$NON-NLS-1$
      }

      // populate prepared sql params
      List<Object> sqlParams = null;
      if ( mappedQuery.getParamList() != null ) {
        sqlParams = new ArrayList<Object>();
        for ( String param : mappedQuery.getParamList() ) {
          Object sqlParam = parameters.get( param );
          // lets see if the parameter is a multi valued param
          if ( sqlParam instanceof Object[] ) {
            Object[] multivaluedParamValues = (Object[]) sqlParam;
            for ( Object p : multivaluedParamValues ) {
              sqlParams.add( p );
            }
          } else {
            sqlParams.add( sqlParam );
          }
        }
      }

      try {
        if ( !isForwardOnly() ) {
          if ( sqlParams != null ) {
            localResultSet = sqlConnection.prepareAndExecuteQuery( sql, sqlParams );
          } else {
            localResultSet = sqlConnection.executeQuery( sql );
          }
        } else {
          if ( sqlParams != null ) {
            localResultSet =
                sqlConnection.prepareAndExecuteQuery( sql, sqlParams, SQLConnection.RESULTSET_FORWARDONLY,
                    SQLConnection.CONCUR_READONLY );
          } else {
            localResultSet =
                sqlConnection.executeQuery( sql, SQLConnection.RESULTSET_FORWARDONLY, SQLConnection.CONCUR_READONLY );
          }
        }
        IPentahoMetaData metadata = mappedQuery.generateMetadata( localResultSet.getMetaData() );
        ( (SQLResultSet) localResultSet ).setMetaData( metadata );
        closeConnection = false;

      } catch ( Exception e ) {
        logger.error( Messages.getInstance().getErrorString(
View Full Code Here

TOP

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

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.