Search in sources :

Example 11 with IPentahoMetaData

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

the class FilterDefinition method populate.

public boolean populate(final Map parameterProviders, final String[] value) {
    // TODO apply session-based security
    // TODO support static lists of values
    defaultValue = value;
    resultSet = getResultSet(parameterProviders);
    if (resultSet != null) {
        // find the column that we have been told to you
        IPentahoMetaData metaData = resultSet.getMetaData();
        nameColumnNo = metaData.getColumnIndex(descriptionItem);
        valueColumnNo = metaData.getColumnIndex(valueItem);
    }
    return (resultSet != null);
}
Also used : IPentahoMetaData(org.pentaho.commons.connection.IPentahoMetaData)

Example 12 with IPentahoMetaData

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

the class HQLResultSet method memoryCopy.

public IPentahoResultSet memoryCopy() {
    try {
        IPentahoMetaData localMetadata = getMetaData();
        Object[][] columnHeaders = localMetadata.getColumnHeaders();
        MemoryMetaData cachedMetaData = new MemoryMetaData(columnHeaders, null);
        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 13 with IPentahoMetaData

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

the class MDXResultSet method memoryCopy.

public IPentahoResultSet memoryCopy() {
    try {
        IPentahoMetaData metadata = getMetaData();
        Object[][] columnHeaders = metadata.getColumnHeaders();
        Object[][] rowHeaders = metadata.getRowHeaders();
        MemoryMetaData cachedMetaData = new MemoryMetaData(columnHeaders, rowHeaders);
        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 14 with IPentahoMetaData

use of org.pentaho.commons.connection.IPentahoMetaData 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 15 with IPentahoMetaData

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

the class SQLResultSetTest method testMemoryCopy_setMetadaMemory.

@Test
public void testMemoryCopy_setMetadaMemory() throws SQLException {
    IPentahoMetaData metadata = new MemoryMetaData(mock(MemoryMetaData.class));
    SQLResultSet resultSet = new SQLResultSet(nativeResultSet, nativeConnection);
    resultSet.setMetaData(metadata);
    IPentahoResultSet memoryCopyResultSet = resultSet.memoryCopy();
    assertEquals(metadata.getClass(), memoryCopyResultSet.getMetaData().getClass());
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) IPentahoMetaData(org.pentaho.commons.connection.IPentahoMetaData) Test(org.junit.Test)

Aggregations

IPentahoMetaData (org.pentaho.commons.connection.IPentahoMetaData)26 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)12 MemoryMetaData (org.pentaho.commons.connection.memory.MemoryMetaData)9 MemoryResultSet (org.pentaho.commons.connection.memory.MemoryResultSet)7 ArrayList (java.util.ArrayList)4 List (java.util.List)4 SQLConnection (org.pentaho.platform.plugin.services.connections.sql.SQLConnection)4 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 MarshallableResultSet (org.pentaho.commons.connection.marshal.MarshallableResultSet)3 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)3 SQLMetaData (org.pentaho.platform.plugin.services.connections.sql.SQLMetaData)3 StringTokenizer (java.util.StringTokenizer)2 Element (org.dom4j.Element)2 Test (org.junit.Test)2 MarshallableRow (org.pentaho.commons.connection.marshal.MarshallableRow)2 SerializedResultSet (org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet)2 DatasourceServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)2 ModifiableConfiguration (org.pentaho.reporting.libraries.base.config.ModifiableConfiguration)2 FileNotFoundException (java.io.FileNotFoundException)1