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

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


        return deleteCommand;
    }

    private UpdateCommandImpl getUpdateCommand(DataObject changedObject) {

        Table table = mapping.getTableByTypeName(changedObject.getType().getName());
        if (table == null) {
            if (changedObject.getType().getProperty("ID") != null) {
                mapping.addPrimaryKey(changedObject.getType().getName() + ".ID");
                table = mapping.getTableByTypeName(changedObject.getType().getName());
            } else {
                throw new RuntimeException("Table " + changedObject.getType().getName()
                        + " was changed in the DataGraph but is not present in the Config");
            }
        }
        Update update = table.getUpdate();
        if (update == null) {
            updateCommand = UpdateGenerator.INSTANCE.getUpdateCommand(mapping, changedObject, table);
        } else {
            TableWrapper t = new TableWrapper(table);
            if (t.getCollisionColumn() != null) {
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 = ? where ID = ?", "LASTNAME ID");

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

        //Read customer 1
View Full Code Here

        if (r == null) {
            return dataObject.get(parameter);
        }

        //JIRA-952
        Table tbl = this.mappingWrapper.getTable(r.getPrimaryKeyTable());
        Property parentRef = null;
        if(tbl == null){
          //this is case when config file is not present and
          //ConfigHelper helper = new ConfigHelper(); is used
          parentRef = getParentReference(r.getPrimaryKeyTable())
View Full Code Here

    private boolean isPartOfPrimaryKey(String parameter) {
        if (mappingWrapper.getConfig() == null) {
            return false;
        }
       
        Table t = mappingWrapper.getTable(getTableName());
        if (t == null) {
            return false;
        }
        Column c = mappingWrapper.getColumnByPropertyName(t, parameter);
        if (c == null) {
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()))
                    && (CollectionsUtil.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

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

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.