Package org.apache.tuscany.das.rdb.config

Examples of org.apache.tuscany.das.rdb.config.Table


    public void testAddColumnWithPropertyName() throws SQLException {
        String statement = "SELECT * FROM BOOK WHERE BOOK.BOOK_ID = ?";

        // Create Table config programmatically
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("BOOK", "Book");
        helper.addPrimaryKey("Book.BOOK_ID");
        helper.addColumn(table, "NAME", "bookName");
        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand(statement);
        select.setParameter(1, new Integer(1));
View Full Code Here


     * Simple unit test for adding a Delete statement to a Table
     * @throws Exception
     */
    public void testAddDeleteStatement() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("widgets", "WIDGETS");
        helper.addDeleteStatement(table, "delete from widgets where id = ?", "ID");

        Config cfg = helper.getConfig();
        assertEquals(1, cfg.getTable().size());
        Table widgets = (Table) cfg.getTable().get(0);
        assertEquals("delete from widgets where id = ?", widgets.getDelete().getSql());
        assertEquals("WIDGETS", widgets.getTypeName());
        assertEquals("ID", ConfigUtil.getParameters(widgets.getDelete()));

    }
View Full Code Here

     * Simple unit test for adding a Create statement to a Table
     * @throws Exception
     */
    public void testAddCreateStatement() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Table table = helper.addTable("widgets", "WIDGETS");
        helper.addCreateStatement(table, "insert into widgets values (?,?)", "ID NAME");

        Config cfg = helper.getConfig();
        assertEquals(1, cfg.getTable().size());
        Table widgets = (Table) cfg.getTable().get(0);
        assertEquals("insert into widgets values (?,?)", widgets.getCreate().getSql());
        assertEquals("WIDGETS", widgets.getTypeName());
        assertEquals("ID NAME", ConfigUtil.getParameters(widgets.getCreate()));

    }
View Full Code Here

     */
    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
View Full Code Here

     * @param i
     * @return
     */
    public boolean isPKColumn(int i) {

        Table t = configWrapper.getTableByTypeName(getTablePropertyName(i));
        if (t == null) {
            return true;
        }

        // If no Columns have been defined, consider every column to be part of
        // the PK
        if (t.getColumn().isEmpty()) {
            return true;
        }

        Column c = configWrapper.getColumn(t, getDatabaseColumnName(i));

View Full Code Here

  //JIRA-952 - check if there is any entry with no schemaName when support is ON
    public void checkSchemaNameSupport(){
        if(config.isDatabaseSchemaNameSupported()){
          List tableList = config.getTable();
          for(int i=0; i<tableList.size(); i++){
            Table t = (Table)tableList.get(i);
            if(t.getSchemaName() == null || t.getSchemaName().equals("")){
              throw new RuntimeException("No schemaName provided for tableName "+t.getTableName()+" when schemaNameSupport is ON");
            }
           
            if(t.getTypeName()==null){
              t.setTypeName(t.getSchemaName()+"."+t.getTableName());
            }
          }
        }
    }
View Full Code Here

            this.logger.debug("Looking for table " + tableName);
        }

        Iterator i = config.getTable().iterator();
        while (i.hasNext()) {
            Table t = (Table) i.next();
            //JIRA-952
            if(this.config.isDatabaseSchemaNameSupported()){
              if (tableName.equalsIgnoreCase(t.getSchemaName()+"."+t.getTableName())) {
                    return t;
                }
            }else{
            if (tableName.equalsIgnoreCase(t.getTableName())) {
                return t;
                }             
            }
        }
View Full Code Here

            this.logger.debug("Looking for table by property: " + typeName);
        }

        Iterator i = config.getTable().iterator();
        while (i.hasNext()) {
            Table t = (Table) i.next();
            TableWrapper wrapper = new TableWrapper(t);
            if (typeName.equals(wrapper.getTypeName())) {
                return t;
            }
        }
View Full Code Here

            String columnName = (String) i.next();

            QualifiedColumn pkColumn = null;
             pkColumn = new QualifiedColumn(columnName, this.config.isDatabaseSchemaNameSupported());
            //Table t = findOrCreateTable(pkColumn.getTableName());
            Table t = findOrCreateTable(pkColumn);
            Column c = findOrCreateColumn(t, pkColumn.getColumnName());
            c.setPrimaryKey(true);
        }
    }
View Full Code Here

            c.setPrimaryKey(true);
        }
    }

    public String getTableTypeName(String tableName) {
        Table t = getTable(tableName);
        if (t == null) {
            return tableName;
        }
        String propertyName = t.getTypeName();

        if (propertyName == null) {
            return tableName;
        }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.config.Table

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.