Package org.apache.tuscany.das.rdb

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


    /**
     * Test passing <Parameter>List to Command through program
     * @throws Exception
     */   
    public void testProgrammaticCommandNamedParameters() throws Exception {
      ConfigHelper helper = new ConfigHelper();     
      //Command insertAdhoc = das.createCommand("insert into CUSTOMER values (?, ?, ?)");
      org.apache.tuscany.das.rdb.config.Command insertAdhoc = ConfigFactory.INSTANCE.createCommand();
      insertAdhoc.setKind("insert");
      insertAdhoc.setSQL("insert into CUSTOMER values (?, ?, ?)");
      insertAdhoc.setName("insertCustomer");
      Parameter parameter1 = ConfigFactory.INSTANCE.createParameter();
    parameter1.setName("ID");
    Parameter parameter2 = ConfigFactory.INSTANCE.createParameter();
    parameter2.setName("LASTNAME");
    Parameter parameter3 = ConfigFactory.INSTANCE.createParameter();
    parameter3.setName("ADDRESS");
    insertAdhoc.getParameter().add(parameter1);
    insertAdhoc.getParameter().add(parameter2);
    insertAdhoc.getParameter().add(parameter3);
    Config cfg = helper.getConfig();
    cfg.getCommand().add(insertAdhoc);
    DAS das = DAS.FACTORY.createDAS(cfg, getConnection());
   
    //setup is over, now set values in params and execute
    Command insert = das.getCommand("insertCustomer");
View Full Code Here


        }
    }

    //add relationship through config helper
    public void testValidFKColumn() throws SQLException {
        ConfigHelper helper = new ConfigHelper();
        Vector parentColumnNames = new Vector();
        Vector childColumnNames = new Vector();

        parentColumnNames.add(0, "ORDERDETAILS.ORDERID");
        parentColumnNames.add(1, "ORDERDETAILS.PRODUCTID");

        childColumnNames.add(0, "ORDERDETAILSDESC.ORDERID");
        childColumnNames.add(1, "ORDERDETAILSDESC.PRODUCTID");       
       
        Relationship r = helper.addRelationship(parentColumnNames, childColumnNames);

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand("SELECT * FROM ORDERDETAILS LEFT JOIN ORDERDETAILSDESC ON ORDERDETAILS.ORDERID = ORDERDETAILSDESC.ORDERID " +
                    " AND ORDERDETAILS.PRODUCTID = ORDERDETAILSDESC.PRODUCTID");

        DataObject root = select.executeQuery()
        DataObject ordDet1 = root.getDataObject("ORDERDETAILS[1]");
View Full Code Here

        }
    }
   
    //add invalid relationship through config helper using invalid FK column name
    public void testInvalidFKColumn() throws SQLException {
        ConfigHelper helper = new ConfigHelper();
        Vector parentColumnNames = new Vector();
        Vector childColumnNames = new Vector();

        parentColumnNames.add(0, "ORDERDETAILS.ORDERID");
        parentColumnNames.add(1, "ORDERDETAILS.PRODUCTID");

        childColumnNames.add(0, "ORDERDETAILSDESC.ORDERID_INVALID");
        childColumnNames.add(1, "ORDERDETAILSDESC.PRODUCTID");       
       
        Relationship r = helper.addRelationship(parentColumnNames, childColumnNames);

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand("SELECT * FROM ORDERDETAILS LEFT JOIN ORDERDETAILSDESC ON ORDERDETAILS.ORDERID = ORDERDETAILSDESC.ORDERID " +
                    " AND ORDERDETAILS.PRODUCTID = ORDERDETAILSDESC.PRODUCTID");

        DataObject root = select.executeQuery()
        DataObject ordDet1 = root.getDataObject("ORDERDETAILS[1]");
View Full Code Here

     * Ensure that an implied relationship is not created when a defined one already exists
     *
     * @throws Exception
     */
    public void testRelationshipAlreadyDefined() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Relationship r = helper.addRelationship("CUSTOMER.ID", "ANORDER.CUSTOMER_ID");
        r.setName("definedRelationship");

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand("select * from CUSTOMER left join ANORDER "
                + "ON CUSTOMER.ID = ANORDER.CUSTOMER_ID");

        DataObject root = select.executeQuery();
        DataObject cust = root.getDataObject("CUSTOMER[1]");
View Full Code Here

     * the method for handling parameters was changed.
     */
    public void testReadModifyApply() throws Exception {

        // Provide updatecommand programmatically via config
        ConfigHelper helper = new ConfigHelper();
        Table customerTable = helper.addTable("CUSTOMER", "CUSTOMER");
        helper.addUpdateStatement(customerTable, "update CUSTOMER set LASTNAME = ? where ID = ?", "LASTNAME ID");

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());

        //Read customer 1
        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
        DataObject root = select.executeQuery();

View Full Code Here

        }
    }

    //add relationship through config helper
    public void testValidFKColumn() throws SQLException {
        ConfigHelper helper = new ConfigHelper();
        Vector parentColumnNames = new Vector();
        Vector childColumnNames = new Vector();

        parentColumnNames.add(0, "ORDERDETAILS.ORDERID");
        parentColumnNames.add(1, "ORDERDETAILS.PRODUCTID");

        childColumnNames.add(0, "ORDERDETAILSDESC.ORDERID");
        childColumnNames.add(1, "ORDERDETAILSDESC.PRODUCTID");       
       
        Relationship r = helper.addRelationship(parentColumnNames, childColumnNames);

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand("SELECT * FROM ORDERDETAILS LEFT JOIN ORDERDETAILSDESC ON ORDERDETAILS.ORDERID = ORDERDETAILSDESC.ORDERID " +
                    " AND ORDERDETAILS.PRODUCTID = ORDERDETAILSDESC.PRODUCTID");

        DataObject root = select.executeQuery()
        DataObject ordDet1 = root.getDataObject("ORDERDETAILS[1]");
View Full Code Here

        }
    }
   
    //add invalid relationship through config helper using invalid FK column name
    public void testInvalidFKColumn() throws SQLException {
        ConfigHelper helper = new ConfigHelper();
        Vector parentColumnNames = new Vector();
        Vector childColumnNames = new Vector();

        parentColumnNames.add(0, "ORDERDETAILS.ORDERID");
        parentColumnNames.add(1, "ORDERDETAILS.PRODUCTID");

        childColumnNames.add(0, "ORDERDETAILSDESC.ORDERID_INVALID");
        childColumnNames.add(1, "ORDERDETAILSDESC.PRODUCTID");       
       
        Relationship r = helper.addRelationship(parentColumnNames, childColumnNames);

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand("SELECT * FROM ORDERDETAILS LEFT JOIN ORDERDETAILSDESC ON ORDERDETAILS.ORDERID = ORDERDETAILSDESC.ORDERID " +
                    " AND ORDERDETAILS.PRODUCTID = ORDERDETAILSDESC.PRODUCTID");

        DataObject root = select.executeQuery()
        DataObject ordDet1 = root.getDataObject("ORDERDETAILS[1]");
View Full Code Here

     * Read and modify a customer. Provide needed Create/Update/Delete statements programatically
     */
    public void testReadModifyApply() throws Exception {

        // Provide updatecommand programmatically via config
        ConfigHelper helper = new ConfigHelper();
        Table customerTable = helper.addTable("CUSTOMER", "CUSTOMER");
        helper.addUpdateStatement(customerTable, "update CUSTOMER set LASTNAME = ?, ADDRESS = ? "
                + "where ID = ?", "LASTNAME ADDRESS ID");

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        // Read customer 1
        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
        DataObject root = select.executeQuery();
        assertFalse(root.get("CUSTOMER[1]/LASTNAME").equals("Pavick"));

View Full Code Here

     */
    public void test0() throws Exception {
        String commandName = "select book by id";
        String commandSQL = "SELECT * FROM BOOK WHERE BOOK_ID =?";
        // Create config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addSelectCommand( commandName, commandSQL );
        helper.addPrimaryKey("BOOK.BOOK_ID");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());

        // Read a book instance
        Command select = das.getCommand("select book by id");
        select.setParameter(1, Integer.valueOf(1));
        DataObject root = select.executeQuery();
View Full Code Here

     * Simple read followed by a write. Config instance is generated
     * programmatically using the ConfigHelper.
     */
    public void test2() throws Exception {
        // Create config programmatically
        ConfigHelper helper = new ConfigHelper();
        helper.addPrimaryKey("BOOK.BOOK_ID");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());

        // Read a book instance
        Command select = das.createCommand("SELECT * FROM BOOK WHERE BOOK_ID = 1");
        DataObject root = select.executeQuery();
        DataObject book = root.getDataObject("BOOK[1]");
View Full Code Here

TOP

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

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.