use of org.alfresco.util.schemacomp.Difference.Where in project alfresco-repository by Alfresco.
the class DefaultComparisonUtils method compareSimple.
@Override
public void compareSimple(DbProperty leftProperty, DbProperty rightProperty, DiffContext ctx) {
// Check whether the leftProperty should be compared to the rightProperty
DbObject leftDbObject = leftProperty.getDbObject();
if (leftDbObject.hasValidators()) {
for (DbValidator validator : leftDbObject.getValidators()) {
if (validator.validates(leftProperty.getPropertyName())) {
// Don't perform differencing on this property - a validator will handle it.
return;
}
}
}
Where where = null;
Object left = leftProperty.getPropertyValue();
checkNotDbObject(left);
Object right = rightProperty.getPropertyValue();
checkNotDbObject(right);
if (left == right) {
// Same object, or both nulls
where = Where.IN_BOTH_NO_DIFFERENCE;
} else if (left == null) {
// right can't be null, or left == right would have been true
where = Where.ONLY_IN_TARGET;
} else if (right == null) {
// left can't be null, or left == right would have been true
where = Where.ONLY_IN_REFERENCE;
} else {
// neither are null
boolean objectsAreEqual;
// Strings are compared case-insensitively, e.g. table names.
if (left instanceof String && right instanceof String) {
objectsAreEqual = ((String) left).equalsIgnoreCase((String) right);
} else {
objectsAreEqual = left.equals(right);
}
if (objectsAreEqual) {
where = Where.IN_BOTH_NO_DIFFERENCE;
} else {
where = Where.IN_BOTH_BUT_DIFFERENCE;
}
}
ctx.getComparisonResults().add(where, leftProperty, rightProperty);
}
Aggregations