Package org.teiid.query.sql.proc

Examples of org.teiid.query.sql.proc.Block


        //ifblock
        Expression[] args = new Expression[] {new Constant("x"), new Constant("y")}; //$NON-NLS-1$ //$NON-NLS-2$
        Function function = new Function("concat", args); //$NON-NLS-1$
        AssignmentStatement queryStmt = new AssignmentStatement(var1, function);
             
        Block ifBlock = new Block();     
        ifBlock.addStatement(queryStmt);
       
        //else block
        ElementSymbol var2 = new ElementSymbol("var2"); //$NON-NLS-1$
        Statement elseDeclStmt = new DeclareStatement(var2, shortType);    
       
        List elseSymbols = new ArrayList();
        elseSymbols.add(new ElementSymbol("b1"))//$NON-NLS-1$
        Select elseSelect = new Select(elseSymbols);

        From from = new From();
        from.addGroup(new GroupSymbol("g")); //$NON-NLS-1$
       
        Criteria criteria = new CompareCriteria(new ElementSymbol("a2"), CompareCriteria.EQ,  //$NON-NLS-1$
            new Constant(new Integer(5)));
       
        Query elseQuery = new Query();
        elseQuery.setSelect(elseSelect);
        elseQuery.setFrom(from);
        elseQuery.setCriteria(criteria);
       
        AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
       
        Block elseBlock = new Block();
        List elseStmts = new ArrayList();
        elseStmts.add(elseDeclStmt);
        elseStmts.add(elseQueryStmt);
     
        elseBlock.setStatements(elseStmts);
   
        //has criteria
        ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
        List elements = new ArrayList();
        elements.add(a);
       
        CriteriaSelector critSelector = new CriteriaSelector();
        critSelector.setSelectorType(CriteriaSelector.IS_NULL);
        critSelector.setElements(elements);
       
        HasCriteria hasSelector = new HasCriteria();
        hasSelector.setSelector(critSelector);
       
        IfStatement stmt = new IfStatement(hasSelector, ifBlock, elseBlock);
         
        Block block = new Block();
       
        block.addStatement(declStmt);
        block.addStatement(stmt);
               
        CreateUpdateProcedureCommand cmd = new CreateUpdateProcedureCommand();
        cmd.setBlock(block);
        helpTest(procedureString, expectedString, cmd);
View Full Code Here


        query.setFrom(from);
        query.setCriteria(criteria);
       
        AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
             
        Block ifBlock = new Block();     
        ifBlock.addStatement(queryStmt);
       
        //else block
        ElementSymbol var2 = new ElementSymbol("var2"); //$NON-NLS-1$
        Statement elseDeclStmt = new DeclareStatement(var2, shortType);    
       
        List elseSymbols = new ArrayList();
        elseSymbols.add(new ElementSymbol("b1"))//$NON-NLS-1$
        Select elseSelect = new Select(elseSymbols);
   
        Query elseQuery = new Query();
        elseQuery.setSelect(elseSelect);
        elseQuery.setFrom(from);
        elseQuery.setCriteria(criteria);
       
        AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
       
        Block elseBlock = new Block();
        List elseStmts = new ArrayList();
        elseStmts.add(elseDeclStmt);
        elseStmts.add(elseQueryStmt);
     
        elseBlock.setStatements(elseStmts);
  
        //has criteria
        ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
        List elements = new ArrayList();
        elements.add(a);
       
        CriteriaSelector critSelector = new CriteriaSelector();
        critSelector.setElements(elements);
       
        HasCriteria hasSelector = new HasCriteria();
        hasSelector.setSelector(critSelector);
       
        IfStatement stmt = new IfStatement(hasSelector, ifBlock, elseBlock);
       
        Block block = new Block();       
        block.addStatement(declStmt);
        block.addStatement(stmt);
               
        CreateUpdateProcedureCommand cmd = new CreateUpdateProcedureCommand();
        cmd.setBlock(block);
      
        helpTest("CREATE PROCEDURE BEGIN DECLARE short var1;"+ //$NON-NLS-1$
View Full Code Here

        query.setFrom(from);
        query.setCriteria(criteria);
       
        AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
             
        Block ifBlock = new Block();     
        ifBlock.addStatement(queryStmt);
       
        //else block
        ElementSymbol var2 = new ElementSymbol("var2"); //$NON-NLS-1$
        Statement elseDeclStmt = new DeclareStatement(var2, shortType);    
       
        List elseSymbols = new ArrayList();
        elseSymbols.add(new ElementSymbol("b1"))//$NON-NLS-1$
        Select elseSelect = new Select(elseSymbols);
   
        Query elseQuery = new Query();
        elseQuery.setSelect(elseSelect);
        elseQuery.setFrom(from);
        elseQuery.setCriteria(criteria);
       
        AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
       
        Block elseBlock = new Block();
        List elseStmts = new ArrayList();
        elseStmts.add(elseDeclStmt);
        elseStmts.add(elseQueryStmt);
     
        elseBlock.setStatements(elseStmts);
  
        //has criteria
        ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
        List elements = new ArrayList();
        elements.add(a);
       
        CriteriaSelector critSelector = new CriteriaSelector();
        //critSelector.setElements(elements);
       
        HasCriteria hasSelector = new HasCriteria();
        hasSelector.setSelector(critSelector);
       
        IfStatement stmt = new IfStatement(hasSelector, ifBlock, elseBlock);
       
        Block block = new Block();       
        block.addStatement(declStmt);
        block.addStatement(stmt);
               
        CreateUpdateProcedureCommand cmd = new CreateUpdateProcedureCommand();
        cmd.setBlock(block);
      
        helpTest("CREATE PROCEDURE BEGIN DECLARE short var1;"+ //$NON-NLS-1$
View Full Code Here

        query.setFrom(from);
        query.setCriteria(criteria);
       
        AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
             
        Block ifBlock = new Block();     
        ifBlock.addStatement(queryStmt);
       
        //else block
        ElementSymbol var2 = new ElementSymbol("var2"); //$NON-NLS-1$
        Statement elseDeclStmt = new DeclareStatement(var2, shortType);    
       
        List elseSymbols = new ArrayList();
        elseSymbols.add(new ElementSymbol("b1"))//$NON-NLS-1$
        Select elseSelect = new Select(elseSymbols);
   
        Query elseQuery = new Query();
        elseQuery.setSelect(elseSelect);
        elseQuery.setFrom(from);
        elseQuery.setCriteria(criteria);
       
        AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
       
        Block elseBlock = new Block();
        List elseStmts = new ArrayList();
        elseStmts.add(elseDeclStmt);
        elseStmts.add(elseQueryStmt);
     
        elseBlock.setStatements(elseStmts);
  
        //has criteria
        ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
        List elements = new ArrayList();
        elements.add(a);
       
        CriteriaSelector critSelector = new CriteriaSelector();
        critSelector.setSelectorType(CriteriaSelector.LIKE);
        critSelector.setElements(elements);
       
        HasCriteria hasSelector = new HasCriteria();
        hasSelector.setSelector(critSelector);
       
        IfStatement stmt = new IfStatement(hasSelector, ifBlock, elseBlock);
       
        Block block = new Block();       
        block.addStatement(declStmt);
        block.addStatement(stmt);
               
        CreateUpdateProcedureCommand cmd = new CreateUpdateProcedureCommand();
        cmd.setBlock(block);
      
        helpTest("CREATE PROCEDURE BEGIN DECLARE short var1;"+ //$NON-NLS-1$
View Full Code Here

        query.setFrom(from);
        query.setCriteria(criteria);
       
        AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
             
        Block ifBlock = new Block();     
        ifBlock.addStatement(queryStmt);
       
        //else block
        ElementSymbol var2 = new ElementSymbol("var2"); //$NON-NLS-1$
        Statement elseDeclStmt = new DeclareStatement(var2, shortType);    
       
        List elseSymbols = new ArrayList();
        elseSymbols.add(new ElementSymbol("b1"))//$NON-NLS-1$
        Select elseSelect = new Select(elseSymbols);
   
        Query elseQuery = new Query();
        elseQuery.setSelect(elseSelect);
        elseQuery.setFrom(from);
        elseQuery.setCriteria(criteria);
       
        AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
       
        Block elseBlock = new Block();
        List elseStmts = new ArrayList();
        elseStmts.add(elseDeclStmt);
        elseStmts.add(elseQueryStmt);
     
        elseBlock.setStatements(elseStmts);
  
        //has criteria
        ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
        List elements = new ArrayList();
        elements.add(a);
       
        CriteriaSelector critSelector = new CriteriaSelector();
        critSelector.setSelectorType(CriteriaSelector.IN);
        critSelector.setElements(elements);
       
        HasCriteria hasSelector = new HasCriteria();
        hasSelector.setSelector(critSelector);
       
        IfStatement stmt = new IfStatement(hasSelector, ifBlock, elseBlock);
       
        Block block = new Block();       
        block.addStatement(declStmt);
        block.addStatement(stmt);
               
        CreateUpdateProcedureCommand cmd = new CreateUpdateProcedureCommand();
        cmd.setBlock(block);
      
        helpTest("CREATE PROCEDURE BEGIN DECLARE short var1;"+ //$NON-NLS-1$
View Full Code Here

        query.setFrom(from);
        query.setCriteria(criteria);
       
        AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
             
        Block ifBlock = new Block();     
        ifBlock.addStatement(queryStmt);
       
        //else block
        ElementSymbol var2 = new ElementSymbol("var2"); //$NON-NLS-1$
        Statement elseDeclStmt = new DeclareStatement(var2, shortType);    
       
        List elseSymbols = new ArrayList();
        elseSymbols.add(new ElementSymbol("b1"))//$NON-NLS-1$
        Select elseSelect = new Select(elseSymbols);
   
        Query elseQuery = new Query();
        elseQuery.setSelect(elseSelect);
        elseQuery.setFrom(from);
        elseQuery.setCriteria(criteria);
       
        AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
       
        Block elseBlock = new Block();
        List elseStmts = new ArrayList();
        elseStmts.add(elseDeclStmt);
        elseStmts.add(elseQueryStmt);
     
        elseBlock.setStatements(elseStmts);
  
        //has criteria
        ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
        List elements = new ArrayList();
        elements.add(a);
       
        CriteriaSelector critSelector = new CriteriaSelector();
        critSelector.setSelectorType(CriteriaSelector.COMPARE_NE);
        critSelector.setElements(elements);
       
        HasCriteria hasSelector = new HasCriteria();
        hasSelector.setSelector(critSelector);
       
        IfStatement stmt = new IfStatement(hasSelector, ifBlock, elseBlock);
       
        Block block = new Block();       
        block.addStatement(declStmt);
        block.addStatement(stmt);
               
        CreateUpdateProcedureCommand cmd = new CreateUpdateProcedureCommand();
        cmd.setBlock(block);
      
        helpTest("CREATE PROCEDURE BEGIN DECLARE short var1;"+ //$NON-NLS-1$
View Full Code Here

        query.setFrom(from);
        query.setCriteria(criteria);
       
        AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
             
        Block ifBlock = new Block();     
        ifBlock.addStatement(queryStmt);
       
        //else block
        ElementSymbol var2 = new ElementSymbol("var2"); //$NON-NLS-1$
        Statement elseDeclStmt = new DeclareStatement(var2, shortType);    
  
        //element for has criteria
        ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
        List elements = new ArrayList();
        elements.add(a);    
      
        List elseSymbols = new ArrayList();
        elseSymbols.add(new ElementSymbol("b1"))//$NON-NLS-1$
        Select elseSelect = new Select(elseSymbols);
   
        Query elseQuery = new Query();
        elseQuery.setSelect(elseSelect);
        elseQuery.setFrom(from);
  
        CriteriaSelector critSelector2 = new CriteriaSelector();
        //critSelector2.setSelectorType(CriteriaSelector.COMPARE_NE);
        critSelector2.setElements(elements);
       
        HasCriteria hasSelector2 = new HasCriteria();
        hasSelector2.setSelector(critSelector2);    
        //has criteria for else block
        elseQuery.setCriteria(hasSelector2);
       
        AssignmentStatement elseQueryStmt = new AssignmentStatement(var2, elseQuery);
        
        Block elseBlock = new Block();
        List elseStmts = new ArrayList();
        elseStmts.add(elseDeclStmt);
        elseStmts.add(elseQueryStmt);
     
        elseBlock.setStatements(elseStmts);
       
        CriteriaSelector critSelector1 = new CriteriaSelector();
        critSelector1.setSelectorType(CriteriaSelector.COMPARE_NE);
        critSelector1.setElements(elements);
       
        HasCriteria hasSelector1 = new HasCriteria();
        hasSelector1.setSelector(critSelector1);
       
        IfStatement stmt = new IfStatement(hasSelector1, ifBlock, elseBlock);
       
        Block block = new Block();       
        block.addStatement(declStmt);
        block.addStatement(stmt);
               
        CreateUpdateProcedureCommand cmd = new CreateUpdateProcedureCommand();
        cmd.setBlock(block);
      
        helpTest("CREATE PROCEDURE BEGIN DECLARE short var1;"+ //$NON-NLS-1$
View Full Code Here

    }  
   
    // ################################## TEST HELPERS ################################

    public static final WhileStatement sample1() {
        Block block = TestBlock.sample1();
        Criteria criteria = TestHasCriteria.sample1();
        return new WhileStatement(criteria, block);
    }
View Full Code Here

        Criteria criteria = TestHasCriteria.sample1();
        return new WhileStatement(criteria, block);
    }

    public static final WhileStatement sample2() {
        Block block = TestBlock.sample2();
        Criteria criteria = TestHasCriteria.sample2();
        return new WhileStatement(criteria, block);
    }
View Full Code Here

        String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
       
        CreateUpdateProcedureCommand command = helpResolveUpdateProcedure(proc.toString(), userUpdateStr,
                                     FakeMetadataObject.Props.UPDATE_PROCEDURE);
       
        Block block = command.getBlock();
       
        AssignmentStatement assStmt = (AssignmentStatement)block.getStatements().get(1);
        assertEquals(ProcedureReservedWords.VARIABLES, assStmt.getVariable().getGroupSymbol().getCanonicalName());
        assertEquals(ProcedureReservedWords.VARIABLES, ((ElementSymbol)assStmt.getValue()).getGroupSymbol().getCanonicalName());
       
        Block inner = ((LoopStatement)block.getStatements().get(2)).getBlock();
       
        assStmt = (AssignmentStatement)inner.getStatements().get(0);
       
        ElementSymbol value = ElementCollectorVisitor.getElements(assStmt.getValue(), false).iterator().next();
       
        assertEquals("LOOPCURSOR", value.getGroupSymbol().getCanonicalName()); //$NON-NLS-1$
    }
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.proc.Block

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.