Package org.pentaho.commons.connection

Examples of org.pentaho.commons.connection.IPentahoResultSet


    MetadataQueryComponent component = new MetadataQueryComponent();
    component.setQuery( mql );
    component.execute();

    IPentahoResultSet rs = component.getResultSet();
    try {
      Assert.assertNotNull( rs );
      Assert.assertEquals( 1, rs.getColumnCount() );
      Assert.assertEquals( 122, rs.getRowCount() );
      Object[] obj;
      while ( ( obj = rs.next() ) != null ) {
        System.out.println( obj[0] );
      }

    } finally {
      if ( rs != null ) {
        rs.close();
        rs.closeConnection();
      }
    }
  }
View Full Code Here


  @Override
  protected IPentahoResultSet getResultSet( final Map parameterProviders ) {
    String globalAttribute = XmlDom4JHelper.getNodeText( "global-attribute", node ); //$NON-NLS-1$
    try {
      IPentahoResultSet data = (IPentahoResultSet) PentahoSystem.getGlobalParameters().getParameter( globalAttribute );
      return data;
    } catch ( Exception e ) {
      logger.error(
          Messages.getInstance().getString( "FilterDefinition.ERROR_0003_NOT_IN_SESSION", globalAttribute ), e ); //$NON-NLS-1$
    }
View Full Code Here

    map.put( "domain", "JDBCDOMAIN" );
    component.setInputs( map );
    component.setQuery( mql );
    component.execute();

    IPentahoResultSet rs = component.getResultSet();
    try {
      Assert.assertNotNull( rs );
      Assert.assertEquals( 1, rs.getColumnCount() );
      Assert.assertEquals( 122, rs.getRowCount() );
      Object[] obj;
      while ( ( obj = rs.next() ) != null ) {
        System.out.println( obj[0] );
      }

    } finally {
      if ( rs != null ) {
        rs.close();
        rs.closeConnection();
      }
    }
  }
View Full Code Here

  @Override
  protected IPentahoResultSet getResultSet( final Map parameterProviders ) {
    String sessionAttribute = XmlDom4JHelper.getNodeText( "session-attribute", node ); //$NON-NLS-1$
    try {
      IPentahoResultSet data = (IPentahoResultSet) session.getAttribute( sessionAttribute );
      return data;
    } catch ( Exception e ) {
      logger.error(
          Messages.getInstance().getString( "FilterDefinition.ERROR_0003_NOT_IN_SESSION", sessionAttribute ), e ); //$NON-NLS-1$
    }
View Full Code Here

    MetadataQueryComponent component = new MetadataQueryComponent();
    component.setQuery( mql );
    component.execute();

    IPentahoResultSet rs = component.getResultSet();
    try {
      Assert.assertNotNull( rs );
      Assert.assertEquals( 1, rs.getColumnCount() );
      Assert.assertEquals( 10, rs.getRowCount() );
      Object[] obj;
      while ( ( obj = rs.next() ) != null ) {
        System.out.println( obj[0] );
      }

    } finally {
      if ( rs != null ) {
        rs.close();
        rs.closeConnection();
      }
    }

    component = new MetadataQueryComponent();
    component.setQuery( mql );
    component.setMaxRows( 100 );
    component.execute();

    rs = component.getResultSet();
    try {
      Assert.assertNotNull( rs );
      Assert.assertEquals( 1, rs.getColumnCount() );
      Assert.assertEquals( 100, rs.getRowCount() );
      Object[] obj;
      while ( ( obj = rs.next() ) != null ) {
        System.out.println( obj[0] );
      }

    } finally {
      if ( rs != null ) {
        rs.close();
        rs.closeConnection();
      }
    }

  }
View Full Code Here

    IllegalAccessException, Exception {
    PentahoTableDataFactory factory = null;
    if ( reportSpec != null ) {
      if ( !isDefinedInput( AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTTEMP_PERFQRY )
          || "true".equals( getInputParameter( AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTTEMP_PERFQRY ) ) ) { //$NON-NLS-1$
        IPentahoResultSet pentahoResultSet = getResultSet( getReportSpec() );
        factory = new PentahoTableDataFactory();
        pentahoResultSet.beforeFirst();
        factory.addTable( AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, new PentahoTableModel(
              pentahoResultSet ) );

      } else {
        factory = super.getDataFactory();
View Full Code Here

      connection =
          PentahoConnectionFactory.getConnection( IPentahoConnection.SQL_DATASOURCE, jndiName, getSession(), this );
    }
    String query = ReportParameterUtility.setupParametersForActionSequence( reportSpec.getQuery() );
    query = setupQueryParameters( query );
    IPentahoResultSet res = connection.executeQuery( query );
    return res;
  }
View Full Code Here

              outputHandler, null, null, messages );

      if ( listSource != null ) {
        if ( context.getOutputNames().contains( listSource ) ) {
          IActionParameter output = context.getOutputParameter( listSource );
          IPentahoResultSet results = output.getValueAsResultSet();
          if ( results != null ) {
            results = results.memoryCopy();
          }
          return results;
        } else {
          // this is an error
          return null;
        }
      } else {
        // return the first list that we find...
        Iterator it = context.getOutputNames().iterator();
        while ( it.hasNext() ) {
          IActionParameter output = (IActionParameter) it.next();
          if ( output.getType().equalsIgnoreCase( IActionParameter.TYPE_RESULT_SET ) ) {
            IPentahoResultSet results = output.getValueAsResultSet();
            if ( results != null ) {
              results = results.memoryCopy();
            }
            return results;
          }
        }
      }
View Full Code Here

        String outputName = (String) outputNameIterator.next();
        Object value = context.getOutputParameter( outputName ).getValue();
        if ( value == null ) {
          value = ""; //$NON-NLS-1$
        } else if ( value instanceof IPentahoResultSet ) {
          IPentahoResultSet resultSet = (IPentahoResultSet) value;
          Object[][] columnHeaders = resultSet.getMetaData().getColumnHeaders();
          Object[][] rowHeaders = resultSet.getMetaData().getRowHeaders();
          boolean hasColumnHeaders = columnHeaders != null;
          boolean hasRowHeaders = rowHeaders != null;
          if ( hasColumnHeaders ) {
            for ( Object[] element : columnHeaders ) {
              for ( int column = 0; column < element.length; column++ ) {
                if ( hasRowHeaders ) {
                  for ( int indent = 0; indent < rowHeaders[0].length; indent++ ) {
                    messageBuffer.append( "\t" ); //$NON-NLS-1$
                  }
                }
                messageBuffer.append( element[column] ).append( "\t" ); //$NON-NLS-1$
              }
              messageBuffer.append( "\n" ); //$NON-NLS-1$
            }
          }
          int headerRow = 0;
          Object[] dataRow = resultSet.next();
          int currentRow = 0;
          while ( ( dataRow != null ) && ( currentRow < MessageFormatter.MAX_RESULT_THRESHOLD ) ) {
            if ( hasRowHeaders ) {
              for ( int rowHeaderCol = 0; rowHeaderCol < rowHeaders[headerRow].length; rowHeaderCol++ ) {
                messageBuffer.append( rowHeaders[headerRow][rowHeaderCol].toString() ).append( "\t" ); //$NON-NLS-1$
              }
            }
            for ( Object element : dataRow ) {
              messageBuffer.append( element.toString() ).append( "\t" ); //$NON-NLS-1$
            }
            dataRow = resultSet.next();
            currentRow++;
          }
        } else {
          // Temporary fix for BISERVER-3348
          ReturnParameter rpm = (ReturnParameter) context.getParameterManager().getReturnParameters().get( outputName );
View Full Code Here

@SuppressWarnings( { "unchecked", "nls" } )
public class PentahoFlashChartTest {

  public static IPentahoResultSet getRelationData() {
    IPentahoResultSet ips = null;

    ArrayList<String> colHeaders = new ArrayList();

    colHeaders.add( 0, "DEPARTMENT" );
    colHeaders.add( 1, "ACTUAL" );
    colHeaders.add( 2, "BUDGET" );

    ArrayList r1 = new ArrayList();
    r1.add( "Sales" );
    r1.add( 11 );
    r1.add( 12 );
    ArrayList r2 = new ArrayList();
    r2.add( "Finance" );
    r2.add( 14 );
    r2.add( 9 );
    ArrayList r3 = new ArrayList();
    r3.add( "Human Resource" );
    r3.add( 7 );
    r3.add( 100 );

    ArrayList data = new ArrayList();
    data.add( r1 );
    data.add( r2 );
    data.add( r3 );

    ips = MemoryResultSet.createFromLists( colHeaders, data );

    System.out.println( ips.getRowCount() );

    return ips;
  }
View Full Code Here

TOP

Related Classes of org.pentaho.commons.connection.IPentahoResultSet

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.