Package org.databene.jdbacl.model

Examples of org.databene.jdbacl.model.DBTable


  }
 
  public void exportTableChange(TableChange tableChange) throws IOException {
    FilePrintWriter out = null;
    try {
      DBTable oldTable = tableChange.getOldTable();
      DBTable newTable = tableChange.getNewTable();
      File htmlFile = tableFile(oldTable);
      FileUtil.ensureDirectoryExists(htmlFile.getParentFile());
      File cssFile = context.reportFile("mad4db.css");
      out = HtmlReportUtil.createFile(htmlFile, "Modified Table " + oldTable.getName(), Encodings.UTF_8, cssFile);
      context.printNavBarFor(tableFile(newTable), out);
      out.println("<table width='90%'>");
     
      // database name
      out.println("  <tr>");
      out.println("    <td width='50%' align='center'><h2>" + oldTable.getSchema().getCatalog().getDatabase().getEnvironment() + "</h2></td>");
      out.println("    <td width='50%' align='center'><h2>" + newTable.getSchema().getCatalog().getDatabase().getEnvironment() + "</h2></td>");
      out.println("  </tr>");
     
      //columns
      out.println("  <tr>");
      out.println("    <td width='50%'>");
View Full Code Here


    out.println("</tr>");
  }

  private String renderMainObject(DBObject mainObject, File file) {
    if (mainObject instanceof DBTable) {
      DBTable table = (DBTable) mainObject;
      return table.getTableType().descriptiveName() + ' ' + TableDetailsExporter.linkFor(table, file, context);
    } else if (mainObject instanceof DBTrigger)
      return "trigger " + TriggerDetailsExporter.linkFor((DBTrigger) mainObject, file, context);
    else if (mainObject instanceof DBPackage)
      return "package " + PackageDetailsExporter.linkFor((DBPackage) mainObject, file, context);
    else
View Full Code Here

    for (int row = 0; row < rowCount; row++) {
      out.println("<tr>");
      for (int column = 0; column < columns; column++) {
        int index = column * rowCount + row;
        if (index < tables.size()) {
          DBTable table = tables.get(index);
          out.println("<td>");
          printTable(table, out);
          out.println("</td>");
        }
      }
View Full Code Here

public class TableComparatorTest extends AbstractComparatorTest {
 
  @Test
  public void testUnchanged() {
    // given two identical table versions
    DBTable table1 = createTableWithColumns("tbl", 3);
    DBTable table2 = createTableWithColumns("tbl", 3);
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be empty
    System.out.println(schemaChange);
View Full Code Here

  }

  @Test
  public void testColumnsAdded() {
    // given a table which got two additional columns
    DBTable table1 = createTableWithColumns("tbl", 2);
    DBTable table2 = createTableWithColumns("tbl", 4);
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be two ColumnCreations
    System.out.println(schemaChange);
View Full Code Here

  }

  @Test
  public void testColumnsRemoved() {
    // given a table of which two columns were removed
    DBTable table1 = createTableWithColumns("tbl", 4);
    DBTable table2 = createTableWithColumns("tbl", 2);
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be two ColumnDeletions
    System.out.println(schemaChange);
View Full Code Here

  }

  @Test
  public void testColumnOrderChanged() {
    // given a table in which the column order was reversed
    DBTable table1 = createTableWithColumns("tbl", 3);
    DBTable table2 = createTableWithColumns("tbl", "col3", "col2", "col1");
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be a ColumnOrderChange
    System.out.println(schemaChange);
View Full Code Here

 
  @Test
  public void testColumnsRemovedAddedAndReordered() {
    // given a table in which the the first column (col1) is removed,
    // col2 and col3 swapped and a new column (col4) appended
    DBTable table1 = createTableWithColumns("tbl", "col1", "col2", "col3");
    DBTable table2 = createTableWithColumns("tbl", "col3", "col2", "col4");
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be a ColumnOrderChange
    System.out.println(schemaChange);
View Full Code Here

    assertEquals(ChangeSeverity.RESTRICTION, schemaChange.getSubChange(ForeignKeyConstraintCreation.class, "new_fk").getSeverity());
  }

  private SchemaChange createSchemaChange(boolean nullableFk) {
    SchemaChange schemaChange = new SchemaChange(new ComparisonConfig(null, null, null));
    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" });
View Full Code Here

  }
 
  @Test
  public void testPKCreated() {
    // given a table to which a primary key was added
    DBTable table1 = createTableWithColumns("tbl", 2);
    DBTable table2 = createTableWithColumns("tbl", 2);
    new DBPrimaryKeyConstraint(table2, "pk1", false, "col1");
    SchemaChange schemaChange = new SchemaChange(config);
    // when comparing the tables
    new TableComparator(config).compareObjects(table1, table2, schemaChange);
    // then the result must be an primary key creation creation
View Full Code Here

TOP

Related Classes of org.databene.jdbacl.model.DBTable

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.