Search in sources :

Example 6 with DbProperty

use of org.alfresco.util.schemacomp.DbProperty in project alfresco-repository by Alfresco.

the class PrimaryKey method doDiff.

@Override
protected void doDiff(DbObject right, DiffContext ctx) {
    checkColumnOrders();
    PrimaryKey rightPK = (PrimaryKey) right;
    comparisonUtils.compareSimpleOrderedLists(new DbProperty(this, "columnNames"), new DbProperty(rightPK, "columnNames"), ctx);
    comparisonUtils.compareSimpleOrderedLists(new DbProperty(this, "columnOrders"), new DbProperty(rightPK, "columnOrders"), ctx);
}
Also used : DbProperty(org.alfresco.util.schemacomp.DbProperty)

Example 7 with DbProperty

use of org.alfresco.util.schemacomp.DbProperty in project alfresco-repository by Alfresco.

the class Schema method doDiff.

@Override
protected void doDiff(DbObject right, DiffContext ctx) {
    Schema rightSchema = (Schema) right;
    comparisonUtils.compareSimple(new DbProperty(this, "version"), new DbProperty(rightSchema, "version"), ctx);
    comparisonUtils.compareCollections(objects, rightSchema.objects, ctx);
}
Also used : DbProperty(org.alfresco.util.schemacomp.DbProperty)

Example 8 with DbProperty

use of org.alfresco.util.schemacomp.DbProperty in project alfresco-repository by Alfresco.

the class NameValidator method validate.

@Override
public void validate(DbObject reference, DbObject target, DiffContext ctx) {
    String name = target.getName();
    if (log.isDebugEnabled()) {
        log.debug("Validating: pattern: [" + pattern + "], reference: " + reference + ", target: " + target);
    }
    if (pattern != null && !pattern.matcher(name).matches()) {
        if (log.isDebugEnabled()) {
            log.debug("Pattern [" + pattern + "] not matched.");
        }
        String message = I18NUtil.getMessage("system.schema_comp.name_validator", pattern);
        ValidationResult result = new ValidationResult(new DbProperty(target, "name"), message);
        ctx.getComparisonResults().add(result);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Pattern [" + pattern + "] matched OK.");
        }
    }
}
Also used : ValidationResult(org.alfresco.util.schemacomp.ValidationResult) DbProperty(org.alfresco.util.schemacomp.DbProperty)

Example 9 with DbProperty

use of org.alfresco.util.schemacomp.DbProperty in project alfresco-repository by Alfresco.

the class AbstractDbObject method diff.

/**
 * Provides an implementation of {@link DbObject#diff(DbObject, DiffContext)}. The template
 * method {@link #doDiff(DbObject, DiffContext)} provides the subclass specific diffing logic,
 * whilst this method handles the workflow required in most cases: set the path's prefix that will be
 * used to explain where differences occur; compare the name fields of the two objects; delegate to the
 * subclass specific diffing (if any); remove the last path addition ready for the next object to perform
 * its diff correctly.
 */
@Override
public void diff(DbObject right, DiffContext ctx) {
    DbProperty leftNameProp = new DbProperty(this, "name");
    DbProperty rightNameProp = new DbProperty(right, "name");
    comparisonUtils.compareSimple(leftNameProp, rightNameProp, ctx);
    doDiff(right, ctx);
}
Also used : DbProperty(org.alfresco.util.schemacomp.DbProperty)

Example 10 with DbProperty

use of org.alfresco.util.schemacomp.DbProperty in project alfresco-repository by Alfresco.

the class Index method doDiff.

@Override
protected void doDiff(DbObject right, DiffContext ctx) {
    Index rightIndex = (Index) right;
    // DatabaseMetaData provides the columns in the correct order for the index.
    // So compare as ordered collections...
    comparisonUtils.compareSimpleOrderedLists(new DbProperty(this, "columnNames"), new DbProperty(rightIndex, "columnNames"), ctx);
    comparisonUtils.compareSimple(new DbProperty(this, "unique"), new DbProperty(rightIndex, "unique"), ctx);
}
Also used : DbProperty(org.alfresco.util.schemacomp.DbProperty)

Aggregations

DbProperty (org.alfresco.util.schemacomp.DbProperty)17 ValidationResult (org.alfresco.util.schemacomp.ValidationResult)4 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 Test (org.junit.Test)2 Column (org.alfresco.util.schemacomp.model.Column)1 Index (org.alfresco.util.schemacomp.model.Index)1 Schema (org.alfresco.util.schemacomp.model.Schema)1 InOrder (org.mockito.InOrder)1