use of org.teiid.language.Call in project teiid by teiid.
the class S3ProcedureExecution method invokeHTTP.
protected BinaryWSProcedureExecution invokeHTTP(String method, String uri, Object payload, Map<String, String> headers) throws TranslatorException {
Map<String, List<String>> targetHeaders = new HashMap<String, List<String>>();
headers.forEach((k, v) -> targetHeaders.put(k, Arrays.asList(v)));
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
try {
LogManager.logDetail(LogConstants.CTX_WS, "Source-URL=", // $NON-NLS-1$ //$NON-NLS-2$
URLDecoder.decode(uri, "UTF-8"));
} catch (UnsupportedEncodingException e) {
}
}
List<Argument> parameters = new ArrayList<Argument>();
parameters.add(new Argument(Direction.IN, new Literal(method, TypeFacility.RUNTIME_TYPES.STRING), null));
parameters.add(new Argument(Direction.IN, new Literal(payload, TypeFacility.RUNTIME_TYPES.OBJECT), null));
parameters.add(new Argument(Direction.IN, new Literal(uri, TypeFacility.RUNTIME_TYPES.STRING), null));
parameters.add(new Argument(Direction.IN, new Literal(true, TypeFacility.RUNTIME_TYPES.BOOLEAN), null));
// the engine currently always associates out params at resolve time even if the
// values are not directly read by the call
parameters.add(new Argument(Direction.OUT, TypeFacility.RUNTIME_TYPES.STRING, null));
Call call = this.ef.getLanguageFactory().createCall("invokeHttp", parameters, null);
BinaryWSProcedureExecution execution = new BinaryWSProcedureExecution(call, this.metadata, this.ec, null, this.conn);
execution.setUseResponseContext(true);
execution.setCustomHeaders(targetHeaders);
return execution;
}
use of org.teiid.language.Call in project teiid by teiid.
the class TestConnectorWorkItem method testProcedureBatching.
@Test
public void testProcedureBatching() throws Exception {
ProcedureExecution exec = new FakeProcedureExecution(2, 1);
// this has two result set columns and 1 out parameter
int total_columns = 3;
// $NON-NLS-1$
StoredProcedure command = (StoredProcedure) helpGetCommand("{call pm2.spTest8(?)}", EXAMPLE_BQT);
command.getInputParameters().get(0).setExpression(new Constant(1));
Call proc = new LanguageBridgeFactory(EXAMPLE_BQT).translate(command);
ProcedureBatchHandler pbh = new ProcedureBatchHandler(proc, exec);
assertEquals(total_columns, pbh.padRow(Arrays.asList(null, null)).size());
List params = pbh.getParameterRow();
assertEquals(total_columns, params.size());
// check the parameter value
assertEquals(Integer.valueOf(0), params.get(2));
try {
pbh.padRow(Arrays.asList(1));
// $NON-NLS-1$
fail("Expected exception from resultset mismatch");
} catch (TranslatorException err) {
assertEquals("TEIID30479 Could not process stored procedure results for EXEC spTest8(1). Expected 2 result set columns, but was 1. Please update your models to allow for stored procedure results batching.", // $NON-NLS-1$
err.getMessage());
}
}
use of org.teiid.language.Call in project teiid by teiid.
the class TestProcedureImpl method testGetParameters.
public void testGetParameters() throws Exception {
Call exec = example();
assertNotNull(exec.getArguments());
assertEquals(2, exec.getArguments().size());
}
use of org.teiid.language.Call in project teiid by teiid.
the class JDBCProcedureExecution method execute.
@Override
public void execute() throws TranslatorException {
Call procedure = (Call) command;
columnDataTypes = procedure.getResultSetColumnTypes();
// translate command
TranslatedCommand translatedComm = translateCommand(procedure);
// create statement or CallableStatement and execute
String sql = translatedComm.getSql();
try {
// create parameter index map
CallableStatement cstmt = getCallableStatement(sql);
this.results = this.executionFactory.executeStoredProcedure(cstmt, translatedComm.getPreparedValues(), procedure.getReturnType());
addStatementWarnings();
} catch (SQLException e) {
throw new TranslatorException(JDBCPlugin.Event.TEIID11004, e, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11004, sql));
}
}
use of org.teiid.language.Call in project teiid by teiid.
the class TestMetadataObject method getProcedureID.
// ################ TEST PROCEDURE AND PARAMETER METADATAID ######################
public Procedure getProcedureID(String procName, int inputParamCount, TranslationUtility transUtil) {
// $NON-NLS-1$
StringBuffer sql = new StringBuffer("EXEC ");
sql.append(procName);
// $NON-NLS-1$
sql.append("(");
for (int i = 0; i < inputParamCount; i++) {
// $NON-NLS-1$
sql.append("null");
if (i < (inputParamCount - 1)) {
// $NON-NLS-1$
sql.append(", ");
}
}
// $NON-NLS-1$
sql.append(")");
Call proc = (Call) transUtil.parseCommand(sql.toString());
return proc.getMetadataObject();
}
Aggregations