Package org.databene.mad4db.cmd

Examples of org.databene.mad4db.cmd.ColumnChange


  public TableColumnComparator(ComparisonConfig config) {
    super(config);
  }

  public void compareObjects(DBColumn col1, DBColumn col2, CompositeStructuralChange<?> tableChange) {
    ColumnChange columnChange = new ColumnChange(col1);

    // check column type, size and fractionDigits
    DBDataType newType = col2.getType();
    Integer newSize = col2.getSize();
    Integer newFractionDigits = col2.getFractionDigits();
    if (!col1.getType().equals(newType)
        || !NullSafeComparator.equals(col1.getSize(), newSize)
        || !NullSafeComparator.equals(col1.getFractionDigits(), newFractionDigits))
      columnChange.addSubChange(new ColumnTypeChange(col1, newType, newSize, newFractionDigits));

    // check column default
    if (!NullSafeComparator.equals(col1.getDefaultValue(), col2.getDefaultValue()))
      columnChange.addSubChange(new DefaultValueChange(col1, col2.getDefaultValue()));
   
    // check column nullability
    if (col1.isNullable() && !col2.isNullable())
      columnChange.addSubChange(new NotNullConstraintCreation(col2.getNotNullConstraint()));
    if (!col1.isNullable() && col2.isNullable())
      columnChange.addSubChange(new ConstraintDeletion<DBNotNullConstraint>(col1.getNotNullConstraint()));

    // if there were changes, add them to the parent tableChange
    if (columnChange.getSubChanges().size() > 0)
      tableChange.addSubChange(columnChange);
  }
View Full Code Here


    DBColumn newColumn2 = new DBColumn("C2", newTable, DBDataType.getInstance("INTEGER"));
    DBNotNullConstraint constraint = new DBNotNullConstraint(newTable, "T_C1_NOT_NULL", true, "C1");
    newColumn.setNotNullConstraint(constraint);
   
    NotNullConstraintCreation constraintCreation = new NotNullConstraintCreation(constraint);
    ColumnChange columnChange = new ColumnChange(newColumn);
    columnChange.addSubChange(constraintCreation);
    TableChange tableChange = new TableChange(oldTable, newTable);
    tableChange.addSubChange(columnChange);
   
    assertFalse(new ChangeByAffectedObjectFilter(newColumn2).accept(columnChange));
    assertFalse(new ChangeByAffectedObjectFilter(oldColumn2).accept(columnChange));
View Full Code Here

TOP

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

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.