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