Examples of FunctionDescriptor


Examples of org.teiid.query.function.FunctionDescriptor

        e1.setType(String.class);       
        ElementSymbol e2 = new ElementSymbol("e2"); //$NON-NLS-1$
        e1.setType(Integer.class);       
       
        Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), e1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
        func.setFunctionDescriptor(desc);

        SingleElementSymbol[] elements = new SingleElementSymbol[] {
            e1, e2
        };
View Full Code Here

Examples of org.teiid.query.function.FunctionDescriptor

        }
    }

    @Test public void testUser() throws Exception {
        Function func = new Function("user", new Expression[] {}); //$NON-NLS-1$
        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("user", new Class[] {} );         //$NON-NLS-1$
        func.setFunctionDescriptor(desc);

        FakeDataManager dataMgr = new FakeDataManager();
        CommandContext context = new CommandContext(new Long(1), null, null, null, 0);
        context.setUserName("logon")//$NON-NLS-1$
View Full Code Here

Examples of org.teiid.query.function.FunctionDescriptor

     * these files.
     * @throws Exception
     */
    @Test public void testEnv() throws Exception {
        Function func = new Function("env", new Expression[] {}); //$NON-NLS-1$
        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("env", new Class[] {String.class} );         //$NON-NLS-1$
        func.setFunctionDescriptor(desc);
       
        FakeDataManager dataMgr = new FakeDataManager();
       
        Properties props = new Properties();
View Full Code Here

Examples of org.teiid.query.function.FunctionDescriptor

        if(property == null) {
            parameterSignature = new Class[] {};
        } else {
            parameterSignature = new Class[] { String.class };
        }       
        FunctionDescriptor desc = FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("commandpayload", parameterSignature );         //$NON-NLS-1$
        func.setFunctionDescriptor(desc);
       
        FakeDataManager dataMgr = new FakeDataManager();      
        CommandContext context = new CommandContext(new Long(-1), null, "user", payload, "vdb", 1, null, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
View Full Code Here

Examples of org.teiid.query.function.FunctionDescriptor

        Class srcType = DataTypeManager.DefaultDataClasses.STRING;
        String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
        Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
       
    FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();                        
    FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] { srcType, DataTypeManager.DefaultDataClasses.STRING });

    Function conversion = new Function(fd.getName(), new Expression[] { expression, new Constant(tgtTypeName) });
    conversion.setType(DataTypeManager.getDataTypeClass(tgtTypeName));
    conversion.setFunctionDescriptor(fd);
    conversion.makeImplicit();
   
    // Expected criteria
View Full Code Here

Examples of org.teiid.query.function.FunctionDescriptor

    Class srcType = DataTypeManager.DefaultDataClasses.STRING;
    String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
    Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
       
    FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();                       
    FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] { srcType, DataTypeManager.DefaultDataClasses.STRING });

    Function conversion = new Function(fd.getName(), new Expression[] { expression, new Constant(tgtTypeName) });
    conversion.setType(DataTypeManager.getDataTypeClass(tgtTypeName));
    conversion.setFunctionDescriptor(fd);
    conversion.makeImplicit();
   
    // Expected criteria
View Full Code Here

Examples of org.teiid.query.function.FunctionDescriptor

    @Test public void testUser() {
        //String sql = "select intkey from SmallA where user() = 'bqt2'";

        // Expected left expression
        FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();                         
        FunctionDescriptor fd = library.findFunction(FunctionLibrary.USER, new Class[] { });
        Function user = new Function(fd.getName(), new Expression[] {});
        user.setFunctionDescriptor(fd);

        // Expected criteria
        CompareCriteria expected = new CompareCriteria();
        // Expected right expression
View Full Code Here

Examples of org.teiid.query.function.FunctionDescriptor

 
  private Object evaluate(Function function, List<?> tuple)
    throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
 
      // Get function based on resolved function info
      FunctionDescriptor fd = function.getFunctionDescriptor();
     
    // Evaluate args
    Expression[] args = function.getArgs();
      Object[] values = null;
      int start = 0;
     
      if (fd.requiresContext()) {
      values = new Object[args.length+1];
          values[0] = context;
          start = 1;
      }
      else {
          values = new Object[args.length];
      }
     
      for(int i=0; i < args.length; i++) {
          values[i+start] = internalEvaluate(args[i], tuple);
      }           
     
      // Check for function we can't evaluate
      if(fd.getPushdown() == PushDown.MUST_PUSHDOWN) {
          throw new TeiidComponentException(QueryPlugin.Util.getString("ExpressionEvaluator.Must_push", fd.getName())); //$NON-NLS-1$
      }
 
      // Check for special lookup function
      if(fd.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)) {
          if(dataMgr == null) {
              throw new ComponentNotFoundException("ERR.015.006.0055", QueryPlugin.Util.getString("ERR.015.006.0055")); //$NON-NLS-1$ //$NON-NLS-2$
          }
 
          String codeTableName = (String) values[0];
          String returnElementName = (String) values[1];
          String keyElementName = (String) values[2];
         
          try {
        return dataMgr.lookupCodeValue(context, codeTableName, returnElementName, keyElementName, values[3]);
      } catch (TeiidProcessingException e) {
        throw new ExpressionEvaluationException(e, e.getMessage());
      }
      }
     
    // Execute function
    Object result = fd.invokeFunction(values);
    return result;       
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.