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

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


     */
    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


        if (!rel.isMany()) {
            if (rel.isKeyRestricted()) {
                throw new RuntimeException("Can not modify a one to one relationship that is key restricted");
            }
            // This is a one-one relationship
            Table t = mapping.getTableByTypeName(changedObject.getType().getName());
            TableWrapper tw = new TableWrapper(t);
            RelationshipWrapper rw = new RelationshipWrapper(rel);
            if ((rel.getForeignKeyTable().equals(t.getTableName()))
                    && (Collections.disjoint(tw.getPrimaryKeyProperties(), rw.getForeignKeys()))) {
                return true;
            }

        }
View Full Code Here

            return;
        }

        Iterator i = mapping.getConfig().getTable().iterator();
        while (i.hasNext()) {
            Table t = (Table) i.next();
            Iterator columns = t.getColumn().iterator();
            while (columns.hasNext()) {
                Column c = (Column) columns.next();
                if (c.isPrimaryKey() && c.isGenerated()) {
                    if (this.logger.isDebugEnabled()) {
                        this.logger.debug("adding generated key " + t.getTableName() + "." + c.getColumnName());
                    }

                    generatedKeys.put(t.getTableName(), c.getColumnName());
                }
            }
        }
    }
View Full Code Here

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

        Iterator i = config.getTable().iterator();
        while (i.hasNext()) {
            Table t = (Table) i.next();
            if (tableName.equalsIgnoreCase(t.getTableName())) {
                return t;
            }
        }

        return null;
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

        Iterator i = columnNames.iterator();
        while (i.hasNext()) {
            String columnName = (String) i.next();

            QualifiedColumn pkColumn = new QualifiedColumn(columnName);
            Table t = findOrCreateTable(pkColumn.getTableName());
            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

        return null;
    }

    public String getColumnPropertyName(String tableName, String columnName) {
        Table t = getTable(tableName);
        Column c = getColumn(t, columnName);
        if (c == null) {
            return columnName;
        }
View Full Code Here

        return propertyName;
    }

    public Table addTable(String tableName, String typeName) {
        Table table = getTable(tableName);
        if (table != null) {
            throw new RuntimeException("Table " + tableName + "already exists");
        }

        table = ConfigFactory.INSTANCE.createTable();
        table.setTableName(tableName);
        table.setTypeName(typeName);
        config.getTable().add(table);

        return table;
    }
View Full Code Here

        return table;
    }

    private Table findOrCreateTable(String tableName) {
        Table table = getTable(tableName);
        if (table == null) {
            table = ConfigFactory.INSTANCE.createTable();
            table.setTableName(tableName);
            config.getTable().add(table);
        }
        return table;

    }
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.