Package org.databene.mad4db.cmd

Examples of org.databene.mad4db.cmd.TableCreation


      CompositeStructuralChange<?> ownerChange) {
    return -1; // TODO
  }

  public StructuralChange<DBTable> creation(DBTable table) {
    return new TableCreation(table);
  }
View Full Code Here


public class ChangeFactory {

  @SuppressWarnings("unchecked")
  public static <E extends DBObject> Creation<E> creation(E dbObject) {
    if (dbObject instanceof DBTable)
      return (Creation<E>) new TableCreation((DBTable) dbObject);
    else if (dbObject instanceof DBColumn)
      return (Creation<E>) new ColumnCreation((DBColumn) dbObject);
    else if (dbObject instanceof DBPrimaryKeyConstraint)
      return (Creation<E>) new PrimaryKeyCreation((DBPrimaryKeyConstraint) dbObject);
    else if (dbObject instanceof DBUniqueConstraint)
View Full Code Here

    DBTable refereeTable = new DBTable("referee");
    DBTable refererTable = new DBTable("referer");
    DBColumn fkColumn = new DBColumn("ref", refererTable, DBDataType.getInstance(Types.INTEGER, "int"));
    fkColumn.setNullable(nullableFk);
    refereeTable.addColumn(fkColumn);
    schemaChange.addSubChange(new TableCreation(refereeTable));
    DBForeignKeyConstraint fk = new DBForeignKeyConstraint("new_fk", true, refererTable, new String[] { "ref" }, refereeTable, new String[] { "id" });
    schemaChange.addSubChange(new ForeignKeyConstraintCreation(fk));
    return schemaChange;
  }
View Full Code Here

  public void process(SchemaChange schemaChange) {
    // check all new FKs...
    for (ForeignKeyConstraintCreation fkCreation : schemaChange.getSubChanges(ForeignKeyConstraintCreation.class)) {
      DBForeignKeyConstraint fk = fkCreation.getAffectedObject();
      String refereeTableName = fk.getRefereeTable().getName();
      TableCreation refereeTableCreation = schemaChange.getSubChange(TableCreation.class, refereeTableName);
      if (refereeTableCreation != null && DBUtil.containsMandatoryColumn(fk)) {
        // a new 'not null' fk on an old column referring a new table makes the table creation an AUGMENTATION...
        refereeTableCreation.setTypeAndSeverity("created table with mandatory reference from remaining table",
            ChangeSeverity.AUGMENTATION);
        refereeTableCreation.setDetails(MadUtil.formatFK(fk, false, false, false, false));
        // and the reference an AUGMENTATION
        fkCreation.setTypeAndSeverity("created mandatory foreign key on remaining table referencing a new table",
            ChangeSeverity.AUGMENTATION);
        refereeTableCreation.setDetails(MadUtil.formatFK(fk, false, false, true, false));
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.databene.mad4db.cmd.TableCreation

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.