Package org.databene.jdbacl.model

Examples of org.databene.jdbacl.model.DBConstraint


    while (subChangeIterator.hasNext()) {
      StructuralChange<? extends DBObject> change = subChangeIterator.next();
      if (change instanceof ConstraintDeletion) {
        // check all dropped constraints of the table if there is one created with the same name
        ConstraintDeletion<?> deletion = (ConstraintDeletion<?>) change;
        DBConstraint constraint1 = deletion.getAffectedObject();
        ConstraintCreation<?> creation = tableChange.getSubChange(ConstraintCreation.class, constraint1.getName());
        if (creation != null && deletion.getAffectedObject().getClass().equals(creation.getAffectedObject().getClass())) {
          // So there are two constraint of same name and type
          // and the TableComparator already has sieved out cases with pure column reordering
          String[] colNames1 = constraint1.getColumnNames();
          DBConstraint constraint2 = creation.getAffectedObject();
          String[] colNames2 = constraint2.getColumnNames();
          if (ArrayUtil.containsAll(colNames2, colNames1)) {
            // columns were removed from the constraint
            String[] removedColumns = diff(colNames1, colNames2);
            changesToAdd.add(new ConstraintColumnsRemoval(constraint1, removedColumns));
            creationsToRemove.add(creation);
View Full Code Here


 
  public void process(SchemaChange schemaChange) {
    // check all new and modified constraints...
    Filter<StructuralChange<?>> filter = new ConstraintOperationFilter();
    for (StructuralChange<?> constraintOperation : schemaChange.getSubChanges(filter)) {
      DBConstraint constraint = (DBConstraint) constraintOperation.getAffectedObject();
      String[] columns = (constraintOperation instanceof CheckConstraintChange ? ((CheckConstraintChange) constraintOperation).getNewCheck().getColumnNames() : constraint.getColumnNames());
      String tableName = constraint.getTable().getName();
      TableChange tableChange = schemaChange.getSubChange(TableChange.class, tableName);
      boolean containsNewColumn = false;
      boolean containsNewMandatoryColumn = false;
      for (ColumnCreation columnCreation : tableChange.getSubChanges(ColumnCreation.class)) {
        boolean newColumn = ArrayUtil.contains(columnCreation.getAffectedObject().getName(), columns);
View Full Code Here

    while (subChangeIterator.hasNext()) {
      StructuralChange<? extends DBObject> change = subChangeIterator.next();
      if (change instanceof ConstraintCreation) {
        // check through all constraints of the table...
        ConstraintCreation<?> constraintCreation = (ConstraintCreation<?>) change;
        DBConstraint constraint = constraintCreation.getAffectedObject();
        String[] columnNames = constraint.getColumnNames();
        if (columnNames.length == 1) {
          ColumnCreation columnCreation = tableChange.getSubChange(ColumnCreation.class, columnNames[0]);
          if (columnCreation != null) {
            // ...and if a constraint relates to a single column which is new, then make it a subChange of that column
            columnCreation.addConstraintCreation(constraintCreation);
View Full Code Here

TOP

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

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.