Package org.pentaho.platform.plugin.action.pentahometadata

Examples of org.pentaho.platform.plugin.action.pentahometadata.MetadataQueryComponent


            + "<constraints>"
            + "<constraint><operator>AND</operator><condition>LIKE([CATEGORY.LC_CUSTOMERNAME];"
            + "[param:param1])</condition></constraint>"
            + "</constraints>" + "</mql>";

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

    IPentahoResultSet rs = component.getResultSet();
    try {
      Assert.assertNotNull( rs );
      Assert.assertEquals( 16, 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();
    Map<String, Object> inputs = new HashMap<String, Object>();
    inputs.put( "param1", "B%" );
    component.setInputs( inputs );
    component.setQuery( mql );
    component.execute();

    rs = component.getResultSet();
    try {
      Assert.assertNotNull( rs );
      Assert.assertEquals( 5, rs.getRowCount() );
      Object[] obj;
      while ( ( obj = rs.next() ) != null ) {
View Full Code Here


            + "<constraints>"
            + "<constraint><operator>AND</operator><condition>EQUALS([CATEGORY.LC_CUSTOMERNAME];"
            + "[param:param1])</condition></constraint>"
            + "</constraints>" + "</mql>";

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

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

    } finally {
      rs.close();
      rs.closeConnection();
    }

    component = new MetadataQueryComponent();
    Map<String, Object> inputs = new HashMap<String, Object>();
    inputs.put( "param1", new String[] { "BG&E Collectables", "Baane Mini Imports",
      "Bavarian Collectables Imports, Co.", "Boards & Toys Co." } );
    component.setInputs( inputs );
    component.setQuery( mql );
    component.execute();

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

    } finally {
      rs.close();
      rs.closeConnection();
    }

    mql =
        "<mql><domain_id>DOMAIN</domain_id><model_id>MODEL</model_id>"
            + "<parameters><parameter name=\"param1\" type=\"NUMERIC\" defaultValue=\"1504|1337\"/></parameters>"
            + "<selections><selection>"
            + "<view>CATEGORY</view>"
            + "<column>LC_CUSTOMERNAME</column>"
            + "</selection><selection>"
            + "<view>CATEGORY</view>"
            + "<column>LC_SALESREP</column>"
            + "</selection>"
            + "</selections>"
            + "<constraints>"
            + "<constraint><operator>AND</operator><condition>EQUALS([CATEGORY.LC_SALESREP];"
            + "[param:param1])</condition></constraint>"
            + "</constraints>" + "</mql>";

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

    rs = component.getResultSet();
    try {
      Assert.assertNotNull( rs );
      Assert.assertEquals( 15, rs.getRowCount() );
      Object[] obj;
      while ( ( obj = rs.next() ) != null ) {
View Full Code Here

            + "<constraints>"
            + "<constraint><operator>AND</operator><condition>LIKE([CATEGORY.LC_CUSTOMERNAME];"
            + "[param:param1])</condition></constraint>"
            + "</constraints>" + "</mql>";

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

    // Preprocessor test code will add condition narrowing
    // resultset to 6 rows, all customers starting with 'Au'

    IPentahoResultSet rs = component.getResultSet();
    try {
      Assert.assertNotNull( rs );
      Assert.assertEquals( 6, rs.getRowCount() );
      Object[] obj;
      while ( ( obj = rs.next() ) != null ) {
View Full Code Here

            + "<constraints>"
            + "<constraint><operator>AND</operator><condition>LIKE([CATEGORY.LC_CUSTOMERNAME];"
            + "[param:param1])</condition></constraint>"
            + "</constraints>" + "</mql>";

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

    // Postprocessor test code will add condition changing
    // resultset to 10 rows, all contactfirstnames starting with 'A'

    IPentahoResultSet rs = component.getResultSet();
    try {
      Assert.assertNotNull( rs );
      Assert.assertEquals( 10, rs.getRowCount() );
      Object[] obj;
      while ( ( obj = rs.next() ) != null ) {
View Full Code Here

  public void testComponent() {
    String mql =
        "<mql><domain_id>DOMAIN</domain_id><model_id>MODEL</model_id>" + "<selections><selection>"
            + "<view>CATEGORY</view>" + "<column>LC_CUSTOMERNAME</column>" + "</selection>" + "</selections></mql>";

    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;
View Full Code Here

    String mql =
        "<mql><domain_id>MYSQL_DOMAIN</domain_id><model_id>MODEL</model_id>" + "<selections><selection>"
            + "<view>CATEGORY</view>" + "<column>LC_CUSTOMERNAME</column>" + "</selection>" + "</selections></mql>";

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

    Assert.assertTrue( result );

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

    // second, test with forceDb = true

    MetadataQueryComponent component2 = new MetadataQueryComponent();
    component2.setQuery( mql );
    Map<String, Object> inputs = new HashMap<String, Object>();
    inputs.put( "forcedbdialect", "true" );
    component2.setInputs( inputs );
    result = component2.execute();
    Assert.assertFalse( result );
    Assert.assertNull( component2.getResultSet() );
  }
View Full Code Here

  public void testJdbcComponent() {
    String mql =
        "<mql><domain_id>JDBCDOMAIN</domain_id><model_id>MODEL</model_id>" + "<selections><selection>"
            + "<view>CATEGORY</view>" + "<column>LC_CUSTOMERNAME</column>" + "</selection>" + "</selections></mql>";

    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;
View Full Code Here

  public void testApplyTemplates() {
    String mql =
        "<mql><domain_id>{domain}</domain_id><model_id>MODEL</model_id>" + "<selections><selection>"
            + "<view>CATEGORY</view>" + "<column>LC_CUSTOMERNAME</column>" + "</selection>" + "</selections></mql>";

    MetadataQueryComponent component = new MetadataQueryComponent();
    Map<String, Object> map = new HashMap<String, Object>();
    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;
View Full Code Here

  public void testJdbcComponentMaxRows() {
    String mql =
        "<mql><domain_id>JDBCDOMAIN2</domain_id><model_id>MODEL</model_id>" + "<selections><selection>"
            + "<view>CATEGORY</view>" + "<column>LC_CUSTOMERNAME</column>" + "</selection>" + "</selections></mql>";

    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;
View Full Code Here

TOP

Related Classes of org.pentaho.platform.plugin.action.pentahometadata.MetadataQueryComponent

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.