Package org.teiid.query.util

Examples of org.teiid.query.util.CommandContext


      TestProcessor.doProcess(plan, dataManager, expectedResults, context);
    }

    protected CommandContext createCommandContext() {
        CommandContext context = new CommandContext(new RequestID(), "test", "user", "myvdb", 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        return context;
    }      
View Full Code Here


       
        dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", new List[] { //$NON-NLS-1$
            Arrays.asList(new Object[] { "fooRole", new Integer(0) }), //$NON-NLS-1$ 
        });
       
        CommandContext context = new CommandContext();
        context.setSecurityFunctionEvaluator(new SecurityFunctionEvaluator() {
            public boolean hasRole(String roleType,
                                   String roleName) throws TeiidComponentException {
                return false;
            }});
       
View Full Code Here

    public void helpTestModifyTimeZone(String tsStr, String tzStart, String tzEnd, String expectedStr) throws Exception {
        Timestamp ts = tsStr != null ? Timestamp.valueOf(tsStr) : null;
        Timestamp actual = null;
       
        if(tzStart == null) {
            actual = (Timestamp) FunctionMethods.modifyTimeZone(new CommandContext(), ts, tzEnd);
        } else {
            actual = (Timestamp) FunctionMethods.modifyTimeZone(ts, tzStart, tzEnd);
        }
       
        String actualStr = null;
View Full Code Here

        assertEquals(cal1.get(Calendar.DATE), 1);
             
    }   
   
    @Test public void testRand() throws Exception {
        Double d = (Double)FunctionMethods.rand(new CommandContext(), new Integer(100));
        assertEquals(new Double(0.7220096548596434), d);
       
        try {
            FunctionMethods.rand(new CommandContext(), new Double(34.5));
            fail("should have failed to take a double"); //$NON-NLS-1$
        } catch (FunctionExecutionException e) {           
        }  

        FunctionMethods.rand(new CommandContext());           
    }
View Full Code Here

        String envProperty = "EnvProperty"; //$NON-NLS-1$
        String systemProperty = "SystemProperty"; //$NON-NLS-1$       
        p.setProperty(envProperty.toLowerCase(), envProperty);

        // set an environment property
        CommandContext context = new CommandContext();
        context.setEnvironmentProperties(p);

        // set the system property
        System.setProperty(systemProperty, systemProperty);
        System.setProperty(systemProperty.toLowerCase(), systemProperty+"_lowercase"); //$NON-NLS-1$
       
View Full Code Here

       
        Properties props = new Properties();
        props.setProperty(ContextProperties.SESSION_ID, workContext.getSessionId());
       
        this.context =
            new CommandContext(
                reqID,
                groupName,
                workContext.getUserName(),
                requestMsg.getExecutionPayload(),
                workContext.getVdbName(),
View Full Code Here

        if(method == null) {
          throw new FunctionExecutionException("ERR.015.001.0002", QueryPlugin.Util.getString("ERR.015.001.0002", getName())); //$NON-NLS-1$ //$NON-NLS-2$
        }
       
        if (getDeterministic().compareTo(Determinism.USER_DETERMINISTIC) <= 0 && values.length > 0 && values[0] instanceof CommandContext) {
          CommandContext cc = (CommandContext)values[0];
          cc.setDeterminismLevel(getDeterministic());
        }
       
        // Invoke the method and return the result
        try {
          if (method.isVarArgs()) {
View Full Code Here

  }

  @Override
  public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext, Object... params) throws TeiidProcessingException, TeiidComponentException {
    PreparedPlan pp = commandContext.getPlan(query);
        CommandContext copy = commandContext.clone();
        if (recursionGroup != null) {
          copy.pushCall(recursionGroup);
        }
    if (pp == null) {
      ParseInfo parseInfo = new ParseInfo();
      Command newCommand = QueryParser.getQueryParser().parseCommand(query, parseInfo);
          QueryResolver.resolveCommand(newCommand, metadata);           
         
          List<Reference> references = ReferenceCollectorVisitor.getReferences(newCommand);
         
          AbstractValidationVisitor visitor = new ValidationVisitor();
          Request.validateWithVisitor(visitor, metadata, newCommand);
          Determinism determinismLevel = copy.resetDeterminismLevel();
          newCommand = QueryRewriter.rewrite(newCommand, metadata, copy);
          AnalysisRecord record = new AnalysisRecord(false, false);
          ProcessorPlan plan = QueryOptimizer.optimizePlan(newCommand, metadata, idGenerator, finder, record, copy);
          pp = new PreparedPlan();
          pp.setPlan(plan, copy);
          pp.setReferences(references);
          pp.setAnalysisRecord(record);
          pp.setCommand(newCommand);
          commandContext.putPlan(query, pp, copy.getDeterminismLevel());
          copy.setDeterminismLevel(determinismLevel);
    }
    copy.pushVariableContext(new VariableContext());
    PreparedStatementRequest.resolveParameterValues(pp.getReferences(), Arrays.asList(params), copy, metadata);
        return new QueryProcessor(pp.getPlan().clone(), copy, bufferMgr, dataMgr);
  }
View Full Code Here

    String sql = "insert into gx (x, y) values (1, 2)";
   
    FakeDataManager dm = new FakeDataManager();
    FakeDataStore.addTable("pm1.g1", dm, metadata);
   
    CommandContext context = createCommandContext();
        BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
        ProcessorPlan plan = TestProcessor.helpGetPlan(TestResolver.helpResolve(sql, metadata), metadata, new DefaultCapabilitiesFinder(caps), context);
        List[] expected = new List[] {Arrays.asList(1)};
      helpProcess(plan, context, dm, expected);
  }
View Full Code Here

   
    String sql = "insert into gx (x, y) select e1, e2 from pm1.g1";
   
    FakeDataManager dm = new FakeDataManager();
    FakeDataStore.addTable("pm1.g1", dm, metadata);
    CommandContext context = createCommandContext();
        BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
        ProcessorPlan plan = TestProcessor.helpGetPlan(TestResolver.helpResolve(sql, metadata), metadata, new DefaultCapabilitiesFinder(caps), context);
        List[] expected = new List[] {Arrays.asList(6)};
      helpProcess(plan, context, dm, expected);
  }
View Full Code Here

TOP

Related Classes of org.teiid.query.util.CommandContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.