use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestDQPCoreRequestHandling method addRequest.
private RequestID addRequest(DQPCore rm, String sessionId, int executionId) {
// $NON-NLS-1$
RequestMessage r0 = new RequestMessage("test command");
RequestID id = new RequestID(sessionId, executionId);
addRequest(rm, r0, id, null, null);
return id;
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestDataTierManager method helpSetupRequest.
private AtomicRequestMessage helpSetupRequest(String sql, int nodeId, QueryMetadataInterface metadata) throws Exception {
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, vdb);
Command command = helpGetCommand(sql, metadata);
RequestMessage original = new RequestMessage();
original.setExecutionId(id++);
original.setPartialResults(true);
RequestID requestID = workContext.getRequestID(original.getExecutionId());
context = new CommandContext();
context.setSession(workContext.getSession());
// $NON-NLS-1$
context.setVdbName("test");
context.setVdbVersion(1);
context.setQueryProcessorFactory(new QueryProcessorFactoryImpl(dtm.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
workItem = TestDQPCoreRequestHandling.addRequest(rm, original, requestID, null, workContext);
context.setWorkItem(workItem);
AtomicRequestMessage request = new AtomicRequestMessage(original, workContext, nodeId);
request.setCommand(command);
// $NON-NLS-1$
request.setConnectorName("FakeConnectorID");
request.setCommandContext(context);
return request;
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestMetaDataProcessor method helpGetMetadata.
public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata, VDBMetaData vdb) throws Exception {
// Prepare sql
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
// Create components
SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(new CacheConfiguration()), SessionAwareCache.Type.PREPAREDPLAN, 0);
DQPCore requestMgr = new DQPCore();
requestMgr.setTransactionService(new FakeTransactionService());
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, vdb);
// Initialize components
RequestID requestID = workContext.getRequestID(1);
RequestMessage requestMsg = new RequestMessage(sql);
TestDQPCoreRequestHandling.addRequest(requestMgr, requestMsg, requestID, command, null);
MetaDataProcessor mdProc = new MetaDataProcessor(requestMgr, prepPlanCache, "MyVDB", 1);
return mdProc.processMessage(requestID, workContext, null, true).getColumnMetadata();
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestPreparedStatement method helpGetProcessorPlan.
static PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List<?> values, CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, int conn, boolean callableStatement, boolean limitResults, VDBMetaData vdb) throws TeiidComponentException, TeiidProcessingException {
// Create Request
RequestMessage request = new RequestMessage(preparedSql);
if (callableStatement) {
request.setStatementType(StatementType.CALLABLE);
} else {
request.setStatementType(StatementType.PREPARED);
}
request.setParameterValues(values);
if (values != null && values.size() > 0 && values.get(0) instanceof List) {
request.setBatchedUpdate(true);
}
if (limitResults) {
request.setRowLimit(1);
}
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, vdb);
workContext.getSession().setSessionId(String.valueOf(conn));
PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache);
ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), null, workContext, prepPlanCache);
serverRequest.setMetadata(capFinder, metadata);
DefaultAuthorizationValidator drav = new DefaultAuthorizationValidator();
serverRequest.setAuthorizationValidator(drav);
serverRequest.processRequest();
assertNotNull(serverRequest.processPlan);
return serverRequest;
}
use of org.teiid.client.RequestMessage in project teiid by teiid.
the class TestRequest method testValidateEntitlement.
/**
* Test Request.validateEntitlement().
* Make sure that this can be called both before and after metadata is initialized.
* See defect 17209.
* @throws Exception
* @since 4.2
*/
@Test
public void testValidateEntitlement() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
Request request = new Request();
Command command = QueryParser.getQueryParser().parseCommand(QUERY);
QueryResolver.resolveCommand(command, metadata);
RequestMessage message = new RequestMessage();
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
request.initialize(message, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), TEMP_TABLE_STORE, workContext, null);
request.initMetadata();
DefaultAuthorizationValidator drav = new DefaultAuthorizationValidator();
DataRolePolicyDecider drpd = new DataRolePolicyDecider();
drpd.setAllowCreateTemporaryTablesByDefault(true);
drpd.setAllowFunctionCallsByDefault(true);
drav.setPolicyDecider(drpd);
request.setAuthorizationValidator(drav);
request.validateAccess(new String[] { QUERY }, command, CommandType.USER);
}
Aggregations