mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Schema comparator: added optional <schema> level attribute to allow ignoring of table column ordering during schema validation.
<schema ... tablecolumnorder="false"> The above snippet will disable column order checking for tables. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@46517 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -33,7 +33,7 @@ public class Column extends AbstractDbObject
|
||||
private boolean nullable;
|
||||
private boolean autoIncrement;
|
||||
private int order;
|
||||
|
||||
private boolean compareOrder = true;
|
||||
|
||||
public Column(String name)
|
||||
{
|
||||
@@ -122,12 +122,32 @@ public class Column extends AbstractDbObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the compareOrder
|
||||
*/
|
||||
public boolean isCompareOrder()
|
||||
{
|
||||
return this.compareOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param compareOrder the compareOrder to set
|
||||
*/
|
||||
public void setCompareOrder(boolean compareOrder)
|
||||
{
|
||||
this.compareOrder = compareOrder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + (this.autoIncrement ? 1231 : 1237);
|
||||
result = prime * result + (this.compareOrder ? 1231 : 1237);
|
||||
result = prime * result + (this.nullable ? 1231 : 1237);
|
||||
result = prime * result + this.order;
|
||||
result = prime * result + ((this.type == null) ? 0 : this.type.hashCode());
|
||||
@@ -142,6 +162,7 @@ public class Column extends AbstractDbObject
|
||||
if (getClass() != obj.getClass()) return false;
|
||||
Column other = (Column) obj;
|
||||
if (this.autoIncrement != other.autoIncrement) return false;
|
||||
if (this.compareOrder != other.compareOrder) return false;
|
||||
if (this.nullable != other.nullable) return false;
|
||||
if (this.order != other.order) return false;
|
||||
if (this.type == null)
|
||||
@@ -167,8 +188,11 @@ public class Column extends AbstractDbObject
|
||||
DbProperty thatAutoIncProp = new DbProperty(thatColumn, "autoIncrement");
|
||||
|
||||
comparisonUtils.compareSimple(thisTypeProp, thatTypeProp, ctx);
|
||||
comparisonUtils.compareSimple(thisNullableProp, thatNullableProp, ctx);
|
||||
comparisonUtils.compareSimple(thisOrderProp, thatOrderProp, ctx);
|
||||
comparisonUtils.compareSimple(thisNullableProp, thatNullableProp, ctx);
|
||||
if (compareOrder)
|
||||
{
|
||||
comparisonUtils.compareSimple(thisOrderProp, thatOrderProp, ctx);
|
||||
}
|
||||
comparisonUtils.compareSimple(thisAutoIncProp, thatAutoIncProp, ctx);
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,7 @@ public class Schema extends AbstractDbObject implements Iterable<DbObject>
|
||||
protected final List<DbObject> objects = new ArrayList<DbObject>();
|
||||
protected final String dbPrefix;
|
||||
protected final int version;
|
||||
protected final boolean checkTableColumnOrder;
|
||||
|
||||
/**
|
||||
* Construct a schema with the given name and no database prefix.
|
||||
@@ -48,7 +49,7 @@ public class Schema extends AbstractDbObject implements Iterable<DbObject>
|
||||
*/
|
||||
public Schema(String name)
|
||||
{
|
||||
this(name, "", 0);
|
||||
this(name, "", 0, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,12 +62,13 @@ public class Schema extends AbstractDbObject implements Iterable<DbObject>
|
||||
* @param name
|
||||
* @param dbPrefix
|
||||
*/
|
||||
public Schema(String name, String dbPrefix, int schemaVersion)
|
||||
public Schema(String name, String dbPrefix, int schemaVersion, boolean checkTableColumnOrder)
|
||||
{
|
||||
super(null, name);
|
||||
ParameterCheck.mandatory("dbPrefix", dbPrefix);
|
||||
this.dbPrefix = dbPrefix;
|
||||
this.version = schemaVersion;
|
||||
this.checkTableColumnOrder = checkTableColumnOrder;
|
||||
|
||||
addDefaultValidators();
|
||||
}
|
||||
@@ -129,6 +131,14 @@ public class Schema extends AbstractDbObject implements Iterable<DbObject>
|
||||
return this.version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the checkTableColumnOrder
|
||||
*/
|
||||
public boolean isCheckTableColumnOrder()
|
||||
{
|
||||
return this.checkTableColumnOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
|
Reference in New Issue
Block a user