Search in sources :

Example 21 with MemoryResultSet

use of org.pentaho.commons.connection.memory.MemoryResultSet in project pentaho-platform by pentaho.

the class XQResultSet method memoryCopy.

public IPentahoResultSet memoryCopy() {
    try {
        IPentahoMetaData metadata = getMetaData();
        Object[][] columnHeaders = metadata.getColumnHeaders();
        MemoryMetaData cachedMetaData = new MemoryMetaData(columnHeaders, null);
        // set column types of cachedMetaData
        String[] columnTypeClones = new String[columnTypes.length];
        System.arraycopy(columnTypes, 0, columnTypeClones, 0, columnTypes.length);
        cachedMetaData.setColumnTypes(columnTypeClones);
        MemoryResultSet cachedResultSet = new MemoryResultSet(cachedMetaData);
        Object[] rowObjects = next();
        while (rowObjects != null) {
            cachedResultSet.addRow(rowObjects);
            rowObjects = next();
        }
        return cachedResultSet;
    } finally {
        close();
    }
}
Also used : MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) IPentahoMetaData(org.pentaho.commons.connection.IPentahoMetaData) MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet)

Example 22 with MemoryResultSet

use of org.pentaho.commons.connection.memory.MemoryResultSet in project pentaho-platform by pentaho.

the class PentahoFlashChartTest method createFromLists.

public static MemoryResultSet createFromLists(List colHeaders, List rHeaders, List data) {
    Object[][] columnHeaders = new String[1][colHeaders.size()];
    for (int i = 0; i < colHeaders.size(); i++) {
        columnHeaders[0][i] = colHeaders.get(i);
    }
    Object[][] rowHeaders = new String[rHeaders.size()][1];
    for (int i = 0; i < rHeaders.size(); i++) {
        rowHeaders[i][0] = rHeaders.get(i);
    }
    IPentahoMetaData metaData = new MemoryMetaData(columnHeaders, rowHeaders);
    MemoryResultSet result = new MemoryResultSet(metaData);
    for (int i = 0; i < data.size(); i++) {
        result.addRow(((List) data.get(i)).toArray());
    }
    return result;
}
Also used : MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) IPentahoMetaData(org.pentaho.commons.connection.IPentahoMetaData) MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet)

Example 23 with MemoryResultSet

use of org.pentaho.commons.connection.memory.MemoryResultSet in project pentaho-platform by pentaho.

the class MultipleComponentIT method getResultSet.

private IPentahoResultSet getResultSet() {
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Object[][] columnHeaders = new Object[][] { { "COL1", "COL2", "COL3" } };
    IPentahoMetaData md = new MemoryMetaData(columnHeaders, null);
    MemoryResultSet rs = new MemoryResultSet(md);
    // $NON-NLS-1$ //$NON-NLS-2$
    rs.addRow(new Object[] { "DATA1", "DATA2", new Date() });
    rs.isScrollable();
    return rs;
}
Also used : MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) IPentahoMetaData(org.pentaho.commons.connection.IPentahoMetaData) Date(java.util.Date) MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet)

Example 24 with MemoryResultSet

use of org.pentaho.commons.connection.memory.MemoryResultSet in project pentaho-platform by pentaho.

the class XQueryIT method testCopyMemoryResultSet.

public void testCopyMemoryResultSet() {
    MemoryMetaData metadata = new MemoryMetaData(new String[][] { { "col1", "col2" } }, null);
    MemoryResultSet data1 = new MemoryResultSet(metadata);
    data1.addRow(new Object[] { "a", new Integer(1) });
    data1.addRow(new Object[] { "b", new Integer(2) });
    data1.addRow(new Object[] { "c", new Integer(3) });
    MemoryResultSet data = (MemoryResultSet) data1.memoryCopy();
    assertNotNull(data.getMetaData());
    assertNotNull(data.getMetaData().getColumnHeaders());
    assertNull(data.getMetaData().getRowHeaders());
    assertEquals(2, data.getMetaData().getColumnCount());
    assertEquals(1, data.getMetaData().getColumnHeaders().length);
    assertEquals(2, data.getMetaData().getColumnHeaders()[0].length);
    assertEquals("col1", data.getMetaData().getColumnHeaders()[0][0]);
    assertEquals("col2", data.getMetaData().getColumnHeaders()[0][1]);
    assertEquals(3, data.getRowCount());
    assertEquals("a", data.getValueAt(0, 0));
    assertEquals(1, data.getValueAt(0, 1));
    assertEquals("b", data.getValueAt(1, 0));
    assertEquals(2, data.getValueAt(1, 1));
    assertEquals("c", data.getValueAt(2, 0));
    assertEquals(3, data.getValueAt(2, 1));
}
Also used : MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet)

Example 25 with MemoryResultSet

use of org.pentaho.commons.connection.memory.MemoryResultSet in project pentaho-platform by pentaho.

the class SimpleParameterProviderTest method testResultSet.

public void testResultSet() {
    MemoryResultSet data = new MemoryResultSet();
    SimpleParameterProvider params = new SimpleParameterProvider();
    params.setParameter("data", data);
    assertTrue(params.hasParameter("data"));
    assertEquals("param value is wrong", data, params.getListParameter("data"));
}
Also used : MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Aggregations

MemoryResultSet (org.pentaho.commons.connection.memory.MemoryResultSet)31 MemoryMetaData (org.pentaho.commons.connection.memory.MemoryMetaData)24 IPentahoMetaData (org.pentaho.commons.connection.IPentahoMetaData)7 JavaScriptResultSet (org.pentaho.platform.plugin.services.connections.javascript.JavaScriptResultSet)7 Date (java.util.Date)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 StepMetaDataCombi (org.pentaho.di.trans.step.StepMetaDataCombi)2 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 MimeHeaders (javax.xml.soap.MimeHeaders)1 Name (javax.xml.soap.Name)1 Node (javax.xml.soap.Node)1 SOAPBody (javax.xml.soap.SOAPBody)1 SOAPConnection (javax.xml.soap.SOAPConnection)1 SOAPElement (javax.xml.soap.SOAPElement)1