use of org.pentaho.di.trans.steps.tableinput.TableInputData in project pdi-dataservice-server-plugin by pentaho.
the class TableInputParameterGeneration method getDatabaseWrapper.
private DatabaseWrapper getDatabaseWrapper(StepInterface stepInterface) throws PushDownOptimizationException {
TableInputData stepDataInterface = getTableInputData(stepInterface);
DatabaseWrapper db;
if (stepDataInterface.db instanceof DatabaseWrapper) {
// Use existing wrapper if available
db = (DatabaseWrapper) stepDataInterface.db;
} else {
// Create a new wrapper
db = new DatabaseWrapper(stepDataInterface.db);
}
return db;
}
use of org.pentaho.di.trans.steps.tableinput.TableInputData in project pdi-dataservice-server-plugin by pentaho.
the class TableInputParameterGeneration method pushDown.
@Override
public void pushDown(Condition condition, ParameterGeneration parameterGeneration, StepInterface stepInterface) throws PushDownOptimizationException {
DatabaseWrapper db = getDatabaseWrapper(stepInterface);
verifyDbConnection(db);
dbMeta = db.getDatabaseMeta();
StringBuilder sqlFragment = new StringBuilder();
RowMeta paramsMeta = new RowMeta();
List<Object> params = new LinkedList<Object>();
convertCondition(condition, sqlFragment, paramsMeta, params);
// Save conversion results for injection at runtime
String fragmentId = db.createRuntimePushDown(sqlFragment.toString(), paramsMeta, params, getParameterDefault());
// Set variable to fragment ID
stepInterface.setVariable(parameterGeneration.getParameterName(), fragmentId);
TableInputData tableInput = getTableInputData(stepInterface);
tableInput.db = db;
}
use of org.pentaho.di.trans.steps.tableinput.TableInputData in project pdi-dataservice-server-plugin by pentaho.
the class TableInputParameterGenerationTest method setUp.
@Before
public void setUp() throws Exception {
// Setup Mock Step and Data
data = new TableInputData();
when(stepInterface.getLogLevel()).thenReturn(LogLevel.NOTHING);
data.db = new Database(stepInterface, databaseMeta);
// Add mock connection to connection map, prevent an actual connection attempt
data.db.setConnection(mock(Connection.class));
data.db.setConnectionGroup(MOCK_CONNECTION_GROUP);
data.db.setPartitionId(MOCK_PARTITION_ID);
when(stepInterface.getStepDataInterface()).thenReturn(data);
service.dbMeta = databaseMeta;
when(databaseMeta.quoteField(anyString())).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return (String) invocation.getArguments()[0];
}
});
DatabaseConnectionMap connectionMap = DatabaseConnectionMap.getInstance();
connectionMap.getMap().clear();
connectionMap.storeDatabase(MOCK_CONNECTION_GROUP, MOCK_PARTITION_ID, data.db);
setupValueMetaResolverMock();
}
Aggregations