Package org.apache.tuscany.das.rdb

Examples of org.apache.tuscany.das.rdb.Pager


    //Build command to read all customers
    Command custCommand = Command.FACTORY.createCommand("select * from CUSTOMER order by ID");
    custCommand.setConnection(getConnection());

    //Create a pager with the command
    Pager pager = new PagerImpl(custCommand, 2);

    //Get and work with first page
    DataObject root = pager.next();
    DataObject customer1 = root.getDataObject("CUSTOMER[1]");
    DataObject customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(1, customer1.getInt("ID"));
    assertEquals(2, customer2.getInt("ID"));

    //Get and work with the second page
    root = pager.next();
    customer1 = root.getDataObject("CUSTOMER[1]");
    customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(3, customer1.getInt("ID"));
    assertEquals(4, customer2.getInt("ID"));
   
    // First page again
    root = pager.previous();
    customer1 = root.getDataObject("CUSTOMER[1]");
    customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(1, customer1.getInt("ID"));
    assertEquals(2, customer2.getInt("ID"));

View Full Code Here


    //Parameterize the command
    select.setConnection(getConnection());

    //Create a pager
    Pager pager = new PagerImpl(select, 2);

    //Get the first page
    DataObject root = pager.getPage(1);
    DataObject customer1 = root.getDataObject("CUSTOMER[1]");
    DataObject customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(1, customer1.getInt("ID"));
    assertEquals(2, customer2.getInt("ID"));

    //Get the second page
    root = pager.getPage(2);
    customer1 = root.getDataObject("CUSTOMER[1]");
    customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(3, customer1.getInt("ID"));
    assertEquals(4, customer2.getInt("ID"));

   
    // Get the first page again
    root = pager.getPage(1);
    customer1 = root.getDataObject("CUSTOMER[1]");
    customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(1, customer1.getInt("ID"));
    assertEquals(2, customer2.getInt("ID"));
  }
View Full Code Here

        DAS das = DAS.FACTORY.createDAS(getConnection());
        // Build command to read all customers
        Command custCommand = das.createCommand("select * from CUSTOMER order by ID");

        // Create a pager with the command
        Pager pager = new PagerImpl(custCommand, 2);

        // Get and work with first page
        DataObject root = pager.next();
        DataObject customer1 = root.getDataObject("CUSTOMER[1]");
        DataObject customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(1, customer1.getInt("ID"));
        assertEquals(2, customer2.getInt("ID"));

        // Get and work with the second page
        root = pager.next();
        customer1 = root.getDataObject("CUSTOMER[1]");
        customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(3, customer1.getInt("ID"));
        assertEquals(4, customer2.getInt("ID"));

        // First page again
        root = pager.previous();
        customer1 = root.getDataObject("CUSTOMER[1]");
        customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(1, customer1.getInt("ID"));
        assertEquals(2, customer2.getInt("ID"));

View Full Code Here

        DAS das = DAS.FACTORY.createDAS(getConnection());
        // Build the select command
        Command select = das.createCommand("select * from CUSTOMER order by ID");

        // Create a pager
        Pager pager = new PagerImpl(select, 2);

        // Get the first page
        DataObject root = pager.getPage(1);
        DataObject customer1 = root.getDataObject("CUSTOMER[1]");
        DataObject customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(1, customer1.getInt("ID"));
        assertEquals(2, customer2.getInt("ID"));

        // Get the second page
        root = pager.getPage(2);
        customer1 = root.getDataObject("CUSTOMER[1]");
        customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(3, customer1.getInt("ID"));
        assertEquals(4, customer2.getInt("ID"));

        // Get the first page again
        root = pager.getPage(1);
        customer1 = root.getDataObject("CUSTOMER[1]");
        customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(1, customer1.getInt("ID"));
        assertEquals(2, customer2.getInt("ID"));
    }
View Full Code Here

        DAS das = DAS.FACTORY.createDAS(getConnection());
        // Build command to read all customers
        Command custCommand = das.createCommand("select * from CUSTOMER order by ID");

        // Create a pager with the command
        Pager pager = new PagerImpl(custCommand, 2);

        // Get and work with first page
        DataObject root = pager.next();
        DataObject customer1 = root.getDataObject("CUSTOMER[1]");
        DataObject customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(1, customer1.getInt("ID"));
        assertEquals(2, customer2.getInt("ID"));

        // Get and work with the second page
        root = pager.next();
        customer1 = root.getDataObject("CUSTOMER[1]");
        customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(3, customer1.getInt("ID"));
        assertEquals(4, customer2.getInt("ID"));

        // First page again
        root = pager.previous();
        customer1 = root.getDataObject("CUSTOMER[1]");
        customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(1, customer1.getInt("ID"));
        assertEquals(2, customer2.getInt("ID"));

View Full Code Here

        DAS das = DAS.FACTORY.createDAS(getConnection());
        // Build the select command
        Command select = das.createCommand("select * from CUSTOMER order by ID");

        // Create a pager
        Pager pager = new PagerImpl(select, 2);

        // Get the first page
        DataObject root = pager.getPage(1);
        DataObject customer1 = root.getDataObject("CUSTOMER[1]");
        DataObject customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(1, customer1.getInt("ID"));
        assertEquals(2, customer2.getInt("ID"));

        // Get the second page
        root = pager.getPage(2);
        customer1 = root.getDataObject("CUSTOMER[1]");
        customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(3, customer1.getInt("ID"));
        assertEquals(4, customer2.getInt("ID"));

        // Get the first page again
        root = pager.getPage(1);
        customer1 = root.getDataObject("CUSTOMER[1]");
        customer2 = root.getDataObject("CUSTOMER[2]");
        assertEquals(1, customer1.getInt("ID"));
        assertEquals(2, customer2.getInt("ID"));
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.Pager

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.