Examples of QueryCommand


Examples of org.teiid.query.sql.lang.QueryCommand

    if (query.getWith() == null) {
      return;
    }
    LinkedHashSet<GroupSymbol> discoveredGroups = new LinkedHashSet<GroupSymbol>();
    for (WithQueryCommand obj : query.getWith()) {
            QueryCommand queryExpression = obj.getCommand();
           
            QueryResolver.setChildMetadata(queryExpression, query);
           
            QueryResolver.resolveCommand(queryExpression, metadata.getMetadata(), false);
View Full Code Here

Examples of org.teiid.query.sql.lang.QueryCommand

        FakeMetadataFacade metadata = exampleMetadata();

        String resultSetName = "xmltest.rs"; //$NON-NLS-1$
       
        String sql = "SELECT itemNum, itemName, itemQuantity FROM xmltest.rs";         //$NON-NLS-1$
        QueryCommand command = (QueryCommand) helpGetCommand(sql, metadata);              
       
        Criteria crit = helpGetCriteria("xmltest.rs.itemName = 'Screwdriver'", metadata)//$NON-NLS-1$
        FakeXMLProcessorEnvironment env = new FakeXMLProcessorEnvironment();
        Program program = exampleProgram2(crit, metadata, env);
               
        BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
        XMLPlan temp = new XMLPlan(env);
        CommandContext context = new CommandContext("pid", null, null, null, 1); //$NON-NLS-1$
        temp.initialize(context,null,bufferMgr);
        env.addData(resultSetName, command.getProjectedSymbols(), new List[] {
                    Arrays.asList( new Object[] { "001", "Lamp", new Integer(5) } ),         //$NON-NLS-1$ //$NON-NLS-2$
                    Arrays.asList( new Object[] { "002", "Screwdriver", new Integer(100) } ),         //$NON-NLS-1$ //$NON-NLS-2$
                    Arrays.asList( new Object[] { "003", "Goat", new Integer(4) } )         //$NON-NLS-1$ //$NON-NLS-2$
                    } );           
View Full Code Here

Examples of org.teiid.query.sql.lang.QueryCommand

        int cmdType = command.getType();
        Criteria criteria = null;
        switch(cmdType) {
            case Command.TYPE_QUERY:
               
                QueryCommand queryCommand = (QueryCommand) command;
               
                Limit limit = queryCommand.getLimit();
               
                if (limit != null && limit.getRowLimit() instanceof Constant) {
                    Constant rowLimit = (Constant)limit.getRowLimit();
                    if (Integer.valueOf(0).equals(rowLimit.getValue())) {
                        return false;
                    }
                }
           
                if(queryCommand instanceof SetQuery) {
                    SetQuery union = (SetQuery) queryCommand;
                    boolean shouldExecute = false;
                    for (QueryCommand innerQuery : union.getQueryCommands()) {
                        boolean shouldInner = shouldExecute(innerQuery, simplifyCriteria, duringPlanning);
                        if(shouldInner) {
                          shouldExecute = true;
                            break;                           
                        }                       
                    }
                    return shouldExecute;
                }

                // Else this is a query
                Query query = (Query) queryCommand;               
                criteria = query.getCriteria();

                if(criteria == null) {
                    return true;
                } else if(!EvaluatableVisitor.isFullyEvaluatable(criteria, duringPlanning)) {
                    // If there are elements present in the criteria,
                    // then we don't know the result, so assume we need to execute
                    return true;
                } else if(Evaluator.evaluate(criteria)) {
                    if (simplifyCriteria) {
                        query.setCriteria(null);
                    }
                    return true;
                }
                break;
            case Command.TYPE_INSERT:
              Insert insert = (Insert) command;
              QueryCommand expr = insert.getQueryExpression();
              if (expr != null) {
                return shouldExecute(expr, simplifyCriteria);
              }
              return true;
            case Command.TYPE_UPDATE:
View Full Code Here

Examples of org.teiid.query.sql.lang.QueryCommand

    /**
     * Returns a safe clone
     * @see java.lang.Object#clone()
     */
    public Object clone() {
      QueryCommand copyCommand = null;
        if(getCommand() != null) {
            copyCommand = (QueryCommand) getCommand().clone();
        }
        ScalarSubquery clone = new ScalarSubquery(copyCommand);
        //Don't invoke the lazy-loading getType()
View Full Code Here

Examples of org.teiid.query.sql.lang.QueryCommand

        /*
         * Adds a row limit to a query if Statement.setMaxRows has been called and the command
         * doesn't already have a limit clause.
         */
        if (requestMsg.getRowLimit() > 0 && command instanceof QueryCommand) {
            QueryCommand query = (QueryCommand)command;
            if (query.getLimit() == null) {
                query.setLimit(new Limit(null, new Constant(new Integer(requestMsg.getRowLimit()), DataTypeManager.DefaultDataClasses.INTEGER)));
                this.addedLimit = true;
            }
        }
       
        try {
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.