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

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


  }

  private boolean hasState(MappingWrapper config, Relationship rel, DataObject changedObject) {             
     
      if ( !rel.isMany()) {
        Table t = config.getTableByPropertyName(changedObject.getType().getName());
        TableWrapper tw = new TableWrapper(t);
        RelationshipWrapper rw = new RelationshipWrapper(rel);
        if (( rel.getForeignKeyTable().equals(t.getName())) &&
            ( Collections.disjoint(tw.getPrimaryKeyProperties(),rw.getForeignKeys()) ))
          return true;     
      }
       
    return false;
View Full Code Here


                DebugUtil
                        .debugln(getClass(), debug,
                                "No mapping model exists, all columns will be considered PK columns");
            return true;
        } else {
            Table t = mappingWrapper.getTable(getTablePropertyName(i));
            if (t == null)
                return true;
            Column c = mappingWrapper.getColumn(t, getDatabaseColumnName(i));

            if (c == null)
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)
            return false;
View Full Code Here

     
      Relationship rel = mw.getRelationshipByReference(ref);     
     
      if ( !rel.isMany()) {
        // This is a one-one relationship
        Table t = mapping.getTableByPropertyName(changedObject.getType().getName());
        TableWrapper tw = new TableWrapper(t);
        RelationshipWrapper rw = new RelationshipWrapper(rel);
        if (( rel.getForeignKeyTable().equals(t.getName())) &&
            ( Collections.disjoint(tw.getPrimaryKeyProperties(),rw.getForeignKeys()) ))
          return true;
       
      }
   
View Full Code Here

    if ( mapping.getConfig() == null )
      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()) {
          DebugUtil.debugln(getClass(), debug, "adding generated key "
              + t.getName() + "."
              + c.getName());
          generatedKeys.put(t.getName(), c.getName());
        }
      }
    }
  }
View Full Code Here


  private InsertCommandImpl getCreateCommand(DataObject changedObject) {
   
    if ( createCommand == null ) {
      Table table = mapping.getTableByPropertyName(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.getTableByPropertyName(changedObject.getType().getName());
        } else {
          throw new RuntimeException("Table " + changedObject.getType().getName() + " was changed in the DataGraph but is not present in the Config");
        }
      }

 
      String createStatement = table.getCreate();
      if ( createStatement == null ) {
        createCommand = getCudGenerator().getInsertCommand(mapping, changedObject, table);
      } else {
        createCommand = new InsertCommandImpl(createStatement);
        Iterator i = getCudGenerator().getCreateParameters(mapping, changedObject, table).iterator();
View Full Code Here

  }

  private DeleteCommandImpl getDeleteCommand(DataObject changedObject) {
   
    if ( deleteCommand == null ) {
      Table table = mapping.getTableByPropertyName(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.getTableByPropertyName(changedObject.getType().getName());
        } else {
          throw new RuntimeException("Table " + changedObject.getType().getName() + " was changed in the DataGraph but is not present in the Config");
        }
      }
     
      String deleteStatement = table.getDelete();
      if ( deleteStatement == null ) {
        deleteCommand = getCudGenerator().getDeleteCommand(table);
      } else {
        deleteCommand = new DeleteCommandImpl(deleteStatement);     
        Iterator i = getCudGenerator().getDeleteParameters(table).iterator();
View Full Code Here

  }

  private UpdateCommandImpl getUpdateCommand(DataObject changedObject) {
 
    if ( updateCommand == null ) {
      Table table = mapping.getTableByPropertyName(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.getTableByPropertyName(changedObject.getType().getName());
        } else {
          throw new RuntimeException("Table " + changedObject.getType().getName() + " was changed in the DataGraph but is not present in the Config");
        }
      }
      String updateStatement = table.getUpdate();
      if ( updateStatement == null ) {
        updateCommand = getCudGenerator().getUpdateCommand(mapping, changedObject,table);
      } else {
        TableWrapper t = new TableWrapper(table);
        if ( t.getCollisionColumn() != null )
View Full Code Here

        if (config == null)
            return null;
        DebugUtil.debugln(getClass(), debug, "Looking for table " + name);
        Iterator i = config.getTable().iterator();
        while (i.hasNext()) {
            Table t = (Table) i.next();
            if (name.equals(t.getName()))
                return t;
        }

        return null;
    }
View Full Code Here

        if (config == null)
            return null;
        DebugUtil.debugln(getClass(), debug, "Looking for table by property: " + name);
        Iterator i = config.getTable().iterator();
        while (i.hasNext()) {
            Table t = (Table) i.next();
            TableWrapper wrapper = new TableWrapper(t);
            if (name.equals(wrapper.getPropertyName()))
                return t;
        }
        return null;
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.