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

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


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

    //JIRA-952
    public Table addTable(String tableName, String schemaName, String typeName) {     
        Table table = null;
       
        if(this.config.isDatabaseSchemaNameSupported()){
          table = getTable(schemaName+"."+tableName)
        }
        else{
          table = getTable(tableName);
        }
       
        if (table != null) {
          if(this.config.isDatabaseSchemaNameSupported()){
            throw new RuntimeException("Table " + schemaName+"."+tableName + "already exists")
          }
          else{
            throw new RuntimeException("Table " + tableName + "already exists");
          }           
        }

        table = ConfigFactory.INSTANCE.createTable();
        table.setTableName(tableName);
       
        if(this.config.isDatabaseSchemaNameSupported()){
          table.setSchemaName(schemaName);
        }
        else{
          table.setSchemaName("");
        }
       
        table.setTypeName(typeName);
        config.getTable().add(table);

        return table;
    }
View Full Code Here

        return column;
    }
   
    //JIRA-952
    private Table findOrCreateTable(String schemaName, String tableName) {
        Table table = null;
       
        if(this.config.isDatabaseSchemaNameSupported()){
          table = getTable(schemaName+"."+tableName)
        }
        else{
          table = getTable(tableName)
        }       
        if (table == null) {
            table = ConfigFactory.INSTANCE.createTable();
            table.setTableName(tableName);
            table.setSchemaName(schemaName);
           
            if(this.config.isDatabaseSchemaNameSupported()){
              table.setTypeName(schemaName+"."+tableName);
            }
            else{
              table.setTypeName(tableName);
            }
            config.getTable().add(table);
        }
        return table;
View Full Code Here

    }

    //JIRA-952
    private Table findOrCreateTable(QualifiedColumn column) {    
      Table table = null;
      if(this.config.isDatabaseSchemaNameSupported()){
        table = getTable(column.getSchemaName()+"."+column.getTableName());
      }
      else{
        table = getTable(column.getTableName());
      }

        if (table == null) {
            table = ConfigFactory.INSTANCE.createTable();
            table.setTableName(column.getTableName());
            table.setSchemaName(column.getSchemaName());
            config.getTable().add(table);
        }
        return table;

    }
View Full Code Here

    }

    //JIRA-952
    public void addConverter(String name, String converter) {
        QualifiedColumn column = new QualifiedColumn(name, this.config.isDatabaseSchemaNameSupported());
        Table t = null;
         t = findOrCreateTable(column);
        Column c = findOrCreateColumn(t, column.getColumnName());
        c.setConverterClassName(converter);
    }
View Full Code Here

        Column c = findOrCreateColumn(t, column.getColumnName());
        c.setConverterClassName(converter);
    }

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

        return cmd;
    }

    //JIRA-952
    public void addImpliedPrimaryKey(String schemaName, String tableName, String columnName) {
        Table t = findOrCreateTable(schemaName, tableName);//JIRA-952

        Iterator i = t.getColumn().iterator();
        boolean hasPK = false;
        while (i.hasNext()) {
            Column c = (Column) i.next();
            if (c.isPrimaryKey()) {
                hasPK = true;
View Full Code Here

    }

    private InsertCommandImpl getCreateCommand(DataObject changedObject) {

        if (createCommand == null) {
            Table table = mapping.getTableByTypeName(changedObject.getType().getName());
            if (table == null) {
                if (changedObject.getType().getProperty("ID") != null) {
                    // If the table is not defined in the config, assume it has a primary key of "ID"
                    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");
                }
            }

            Create create = table.getCreate();

            if (create == null) {
                createCommand = InsertGenerator.INSTANCE.getInsertCommand(mapping, changedObject, table);
            } else {
                createCommand = new InsertCommandImpl(create);
View Full Code Here

    }

    private DeleteCommandImpl getDeleteCommand(DataObject changedObject) {

        if (deleteCommand == null) {
            Table table = mapping.getTableByTypeName(changedObject.getType().getName());
            if (table == null) {
                if (changedObject.getType().getProperty("ID") != null) {
                    // If the table is not defined in the config, assume it has a primary key of "ID"
                    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");
                }
            }

            Delete delete = table.getDelete();

            if (delete == null) {
                deleteCommand = DeleteGenerator.INSTANCE.getDeleteCommand(mapping, table);//JIRA-952
            } else {
                deleteCommand = new DeleteCommandImpl(delete);
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.