}
String queryExecName = queryObject.getLogicalModel().getPhysicalModel().getQueryExecName();
String queryExecDefault = queryObject.getLogicalModel().getPhysicalModel().getDefaultQueryClassname();
// String modelType = (String) inputs.get("modeltype");
IMetadataQueryExec executor = PentahoSystem.get( IMetadataQueryExec.class, queryExecName, session );
if ( executor == null ) {
// get the executor from a plugin possibly?
Class clazz;
try {
clazz =
Class.forName( queryExecDefault, true, queryObject.getLogicalModel().getPhysicalModel().getClass()
.getClassLoader() );
executor = (IMetadataQueryExec) clazz.getConstructor( new Class[] {} ).newInstance( new Object[] {} );
} catch ( Exception e ) {
logger.warn( Messages.getInstance().getErrorString(
"MetadataQueryComponent.ERROR_0002_NO_EXECUTOR", queryExecName ) ); //$NON-NLS-1$
}
}
if ( executor == null ) {
// the query exec class is not defined thru configuration, go with the default
Class clazz;
try {
clazz = Class.forName( queryExecDefault );
executor = (IMetadataQueryExec) clazz.getConstructor( new Class[] {} ).newInstance( new Object[] {} );
} catch ( Exception e ) {
logger.error( Messages.getInstance().getErrorString(
"MetadataQueryComponent.ERROR_0002_NO_EXECUTOR", queryExecName ) ); //$NON-NLS-1$
return false;
}
}
// determine parameter values
if ( queryObject.getParameters() != null ) {
for ( Parameter param : queryObject.getParameters() ) {
Object value = null;
if ( inputs != null ) {
value = inputs.get( param.getName() );
}
executor.setParameter( param, value );
}
}
try {
executor.setDoQueryLog( logSql );
executor.setForwardOnly( this.useForwardOnlyResultSet );
executor.setMaxRows( this.maxRows );
executor.setMetadataDomainRepository( repo );
executor.setReadOnly( this.readOnly );
executor.setTimeout( this.timeout );
if ( this.inputs != null ) {
executor.setInputs( this.inputs );
}
resultSet = executor.executeQuery( queryObject );
if ( resultSet != null && !live && executor.isLive() ) {
// read the results and cache them
MemoryResultSet cachedResultSet = new MemoryResultSet( resultSet.getMetaData() );
Object[] rowObjects = resultSet.next();
while ( rowObjects != null ) {
cachedResultSet.addRow( rowObjects );