use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.
the class TempTableDataManager method createWorkContext.
private DQPWorkContext createWorkContext(final CommandContext context, VDBMetaData vdb) {
// $NON-NLS-1$
SessionMetadata session = createTemporarySession(context.getUserName(), "asynch-mat-view-load", vdb);
session.setSubject(context.getSubject());
session.setSecurityDomain(context.getSession().getSecurityDomain());
session.setSecurityContext(context.getSession().getSecurityContext());
DQPWorkContext workContext = new DQPWorkContext();
workContext.setAdmin(true);
DQPWorkContext current = context.getDQPWorkContext();
workContext.setSession(session);
workContext.setPolicies(current.getAllowedDataPolicies());
workContext.setSecurityHelper(current.getSecurityHelper());
return workContext;
}
use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.
the class TempTableDataManager method loadViaRefresh.
private void loadViaRefresh(final CommandContext context, final String tableName, VDBMetaData vdb, MatTableInfo info) throws TeiidProcessingException, TeiidComponentException {
info.setAsynchLoad();
DQPWorkContext workContext = createWorkContext(context, vdb);
final String viewName = tableName.substring(RelationalPlanner.MAT_PREFIX.length());
workContext.runInContext(new Runnable() {
@Override
public void run() {
executor.execute(REFRESH_SQL, Arrays.asList(viewName, Boolean.FALSE));
}
});
}
use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.
the class TestConnectorWorkItem method createNewAtomicRequestMessage.
static AtomicRequestMessage createNewAtomicRequestMessage(int requestid, int nodeid) throws Exception {
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(EXAMPLE_BQT, RealMetadataFactory.exampleBQTVDB());
workContext.getSession().setSessionId(String.valueOf(1));
// $NON-NLS-1$
workContext.getSession().setUserName("foo");
AtomicRequestMessage request = new AtomicRequestMessage(rm, workContext, nodeid);
// $NON-NLS-1$
request.setCommand(helpGetCommand("SELECT BQT1.SmallA.INTKEY FROM BQT1.SmallA", EXAMPLE_BQT));
request.setRequestID(new RequestID(requestid));
// $NON-NLS-1$
request.setConnectorName("testing");
request.setFetchSize(5);
request.setCommandContext(new CommandContext());
return request;
}
use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.
the class TestMultiSourcePlanToProcessConverter method helpTestMultiSourcePlan.
public ProcessorPlan helpTestMultiSourcePlan(QueryMetadataInterface metadata, String userSql, String multiModel, int sourceCount, ProcessorDataManager dataMgr, List<?>[] expectedResults, VDBMetaData vdb, List<?> params, Options options, SourceCapabilities bsc) throws Exception {
Map<String, String> multiSourceModels = MultiSourceMetadataWrapper.getMultiSourceModels(vdb);
for (String model : multiSourceModels.keySet()) {
char sourceID = 'a';
// by default every model has one binding associated, but for multi-source there were none assigned.
ModelMetaData m = vdb.getModel(model);
int x = m.getSourceNames().size();
for (int i = x; i < sourceCount; i++, sourceID++) {
// $NON-NLS-1$ //$NON-NLS-2$
m.addSourceMapping("" + sourceID, "translator", null);
}
}
QueryMetadataInterface wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels);
wrapper = new TempMetadataAdapter(wrapper, new TempMetadataStore());
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(wrapper, vdb);
AnalysisRecord analysis = new AnalysisRecord(DEBUG, DEBUG);
Command command = TestResolver.helpResolve(userSql, wrapper);
ValidatorReport report = Validator.validate(command, metadata);
if (report.hasItems()) {
fail(report.toString());
}
// Plan
command = QueryRewriter.rewrite(command, wrapper, null);
DefaultCapabilitiesFinder fakeFinder = new DefaultCapabilitiesFinder(bsc);
CapabilitiesFinder finder = new TempCapabilitiesFinder(fakeFinder);
IDGenerator idGenerator = new IDGenerator();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
CommandContext context = new CommandContext("test", "user", null, vdb.getName(), vdb.getVersion(), false);
context.setDQPWorkContext(workContext);
context.setOptions(options);
ProcessorPlan plan = QueryOptimizer.optimizePlan(command, wrapper, idGenerator, finder, analysis, context);
if (DEBUG) {
System.out.println(analysis.getDebugLog());
// $NON-NLS-1$
System.out.println("\nMultiSource Plan:");
System.out.println(plan);
}
if (params != null) {
TestProcessor.setParameterValues(params, command, context);
}
TestProcessor.helpProcess(plan, context, dataMgr, expectedResults);
return plan;
}
use of org.teiid.dqp.internal.process.DQPWorkContext in project teiid by teiid.
the class TestColumnMasking method createContext.
private static CommandContext createContext() {
CommandContext context = createCommandContext();
DQPWorkContext workContext = new DQPWorkContext();
HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
DataPolicyMetadata policy = new DataPolicyMetadata();
PermissionMetaData pmd = new PermissionMetaData();
pmd.setResourceName("pm1.sp1.e1");
pmd.setMask("case when e2 > 1 then null else e1 end");
PermissionMetaData pmd1 = new PermissionMetaData();
pmd1.setResourceName("pm1.g1.e2");
pmd1.setMask("case when e1 = 'a' then null else e2 end");
policy.addPermission(pmd, pmd1);
policy.setName("some-role");
policies.put("some-role", policy);
workContext.setPolicies(policies);
context.setDQPWorkContext(workContext);
return context;
}
Aggregations