tableFinal.getName(), m_final.getDataSource().getName()}));
}
for (int i = 0, n = table.getAspectCount(); i < n; ++i)
{
Aspect aspect = m_final.findTable(table.getAspect(i).getName());
if (aspect != null && !tableFinal.hasAspect(aspect))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.extraTableAspect",
new Object[]{aspect.getName(), tableFinal.getName(), m_final.getDataSource().getName()}));
}
}
for (int i = 0, n = tableFinal.getAspectCount(); i < n; ++i)
{
Aspect aspect = m_schema.findTable(tableFinal.getAspect(i).getName());
if (aspect != null && !table.hasAspect(aspect))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.missingTableAspect",
new Object[]{aspect.getName(), tableFinal.getName(), m_final.getDataSource().getName()}));
}
}
for (int i = 0, n = table.getColumnCount(); i < n; ++i)
{
Column column = table.getColumn(i);
if (tableFinal.findColumn(column.getName()) == null)
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.extraColumn",
new Object[]{column.getName(), tableFinal.getName(), m_final.getDataSource().getName()}));
}
}
for (int i = 0, n = tableFinal.getColumnCount(); i < n; ++i)
{
Column columnFinal = tableFinal.getColumn(i);
Column column = table.findColumn(columnFinal.getName());
if (column == null)
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.missingColumn",
new Object[]{columnFinal.getName(), tableFinal.getName(), m_final.getDataSource().getName()}));
}
else
{
if (columnFinal.getType() != column.getType())
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.columnTypeMismatch",
new Object[]{columnFinal.getType().getName(), column.getType().getName(),
columnFinal.getName(), tableFinal.getName(), m_final.getDataSource().getName()}));
}
if (columnFinal.getPrecision() != column.getPrecision())
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.columnPrecisionMismatch",
new Object[]{Primitive.createInteger(columnFinal.getPrecision()),
Primitive.createInteger(column.getPrecision()), columnFinal.getName(),
tableFinal.getName(), m_final.getDataSource().getName()}));
}
if (columnFinal.getScale() != column.getScale())
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.columnScaleMismatch",
new Object[]{Primitive.createInteger(columnFinal.getScale()),
Primitive.createInteger(column.getScale()), columnFinal.getName(),
tableFinal.getName(), m_final.getDataSource().getName()}));
}
if (columnFinal.getAllocation() != column.getAllocation())
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.columnAllocationMismatch",
new Object[]{columnFinal.getAllocationString(), column.getAllocationString(),
columnFinal.getName(), tableFinal.getName(), m_final.getDataSource().getName()}));
}
if (columnFinal.isNullable() != column.isNullable())
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.columnNullabilityMismatch",
new Object[]{Boolean.valueOf(columnFinal.isNullable()),
Boolean.valueOf(column.isNullable()), columnFinal.getName(),
tableFinal.getName(), m_final.getDataSource().getName()}));
}
if (columnFinal.isCaseInsensitive() != column.isCaseInsensitive())
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.columnCaseInsensitivityMismatch",
new Object[]{Boolean.valueOf(columnFinal.isCaseInsensitive()),
Boolean.valueOf(column.isCaseInsensitive()), columnFinal.getName(),
tableFinal.getName(), m_final.getDataSource().getName()}));
}
String sConverterFinal = "";
String sConverter = "";
if (columnFinal.getConverter() != null)
{
sConverterFinal = columnFinal.getConverter().getName();
}
if (column.getConverter() != null)
{
sConverter = column.getConverter().getName();
}
if (!sConverterFinal.equals(sConverter))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.columnConverterMismatch",
new Object[]{sConverterFinal, sConverter, columnFinal.getName(),
tableFinal.getName(), m_final.getDataSource().getName()}));
}
}
}
}
}
for (Iterator indexItr = m_schema.getIndexIterator(); indexItr.hasNext();)
{
Index index = (Index)indexItr.next();
if (m_final.findIndex(index.getName()) == null)
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.extraIndex",
new Object[]{index.getName(), index.getTable().getName(), m_final.getDataSource().getName()}));
}
}
for (Iterator indexItrFinal = m_final.getIndexIterator(); indexItrFinal.hasNext();)
{
Index indexFinal = (Index)indexItrFinal.next();
Index index = m_schema.findIndex(indexFinal.getName());
if (index == null)
{
if (indexFinal.getType() >= Index.BTREE)
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.missingIndex",
new Object[]{indexFinal.getName(), indexFinal.getTable().getName(), m_final.getDataSource().getName()}));
}
}
else
{
if (!indexFinal.getTable().getName().equals(index.getTable().getName()))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.indexTableMismatch",
new Object[]{indexFinal.getTable().getName(), index.getTable().getName(),
indexFinal.getName(), m_final.getDataSource().getName()}));
}
if (indexFinal.getType() != index.getType())
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.indexTypeMismatch",
new Object[]{indexFinal.getTypeString(), index.getTypeString(), indexFinal.getName(),
indexFinal.getTable().getName(), m_final.getDataSource().getName()}));
}
if (indexFinal.isUnique() != index.isUnique())
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.indexUniquenessMismatch",
new Object[]{Boolean.valueOf(indexFinal.isUnique()), Boolean.valueOf(index.isUnique()),
indexFinal.getName(), indexFinal.getTable().getName(), m_final.getDataSource().getName()}));
}
if (indexFinal.getFill() != index.getFill())
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.indexFillMismatch",
new Object[]{Primitive.createInteger(indexFinal.getFill()), Primitive.createInteger(index.getFill()),
indexFinal.getName(), indexFinal.getTable().getName(), m_final.getDataSource().getName()}));
}
String sRelatedTableFinal = (indexFinal.getRelatedTable() == null) ? "" : indexFinal.getRelatedTable().getName();
String sRelatedTable = (index.getRelatedTable() == null) ? "" : index.getRelatedTable().getName();
if (!sRelatedTableFinal.equals(sRelatedTable))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.indexRelatedTableMismatch",
new Object[]{sRelatedTableFinal, sRelatedTable, indexFinal.getName(),
indexFinal.getTable().getName(), m_final.getDataSource().getName()}));
}
for (int i = 0, n = index.getAspectCount(); i < n; ++i)
{
Aspect aspect = m_final.findIndex(index.getAspect(i).getName());
if (aspect != null && !indexFinal.hasAspect(aspect))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.extraIndexAspect",
new Object[]{aspect.getName(), indexFinal.getName(), indexFinal.getTable().getName(),
m_final.getDataSource().getName()}));
}
}
for (int i = 0, n = indexFinal.getAspectCount(); i < n; ++i)
{
Aspect aspect = m_schema.findIndex(indexFinal.getAspect(i).getName());
if (aspect != null && !index.hasAspect(aspect))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.missingIndexAspect",
new Object[]{aspect.getName(), indexFinal.getName(), indexFinal.getTable().getName(),
m_final.getDataSource().getName()}));
}
}
if (index.getType() != Index.VIRTUAL && index.getType() != Index.QUERY)