}
}
for (Iterator tableItr = m_schema.getTableIterator(); tableItr.hasNext();)
{
Table table = (Table)tableItr.next();
if (m_final.findTable(table.getName()) == null)
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.extraTable",
new Object[]{table.getName(), m_final.getDataSource().getName()}));
}
}
for (Iterator tableItrFinal = m_final.getTableIterator(); tableItrFinal.hasNext();)
{
Table tableFinal = (Table)tableItrFinal.next();
Table table = m_schema.findTable(tableFinal.getName());
if (table == null)
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.missingTable",
new Object[]{tableFinal.getName(), m_final.getDataSource().getName()}));
}
else
{
if (!tableFinal.getQuotedName().equals(table.getQuotedName()))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.tableAliasMismatch",
new Object[]{tableFinal.getQuotedName(), table.getQuotedName(),
tableFinal.getName(), m_final.getDataSource().getName()}));
}
if (!ObjUtil.equal(tableFinal.getOwnerName(), table.getOwnerName()))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.tableOwnerMismatch",
new Object[]{tableFinal.getOwnerName(), table.getOwnerName(),
tableFinal.getName(), m_final.getDataSource().getName()}));
}
if (tableFinal.getType() != table.getType())
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.tableTypeMismatch",
new Object[]{tableFinal.getTypeString(), table.getTypeString(), tableFinal.getName(),
m_final.getDataSource().getName()}));
}
if (table.getType() == Table.QUERY || table.getType() == Table.VIEW)
{
// ensure view SQL scripts are identical
if (!table.getViewScript().equals(tableFinal.getViewScript()))
{
eh = addException(
eh,
new MetadataException(
"err.meta.upgrade.sql.viewTableMismatch",
new Object[]{table.getName(), m_final.getDataSource().getName()}));
}
if (table.isViewAutoUpdated() != tableFinal.isViewAutoUpdated())
{
eh = addException(
eh,
new MetadataException(
"err.meta.upgrade.sql.viewUpdatedMismatch",
new Object[]{table.getName(), m_final.getDataSource().getName()}));
}
}
// validate disabled hints
for (Iterator/*<String>*/ hintItr = table.getHintIterator(); hintItr.hasNext();)
{
Object hint = hintItr.next();
if (!tableFinal.isHintEnabled(hint.toString()))
{
eh = addException(
eh,
new MetadataException("err.meta.upgrade.sql.tableHintMismatch",
new Object[]{
hint, Boolean.FALSE, table.getName(), m_final.getDataSource().getName()}));
}
}
// validate enabled hints
for (Iterator/*<String>*/ hintItr = tableFinal.getHintIterator(); hintItr.hasNext();)
{
Object hint = hintItr.next();
if (!table.isHintEnabled(hint.toString()))
{
eh = addException(
eh,
new MetadataException("err.meta.upgrade.sql.tableHintMismatch",
new Object[]{
hint, Boolean.TRUE, table.getName(), m_final.getDataSource().getName()}));
}
}
if (!ObjUtil.equal(tableFinal.getTablespaceName(), table.getTablespaceName()))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.tableTablespaceMismatch",
new Object[]{(tableFinal.getTablespaceName() == null) ? "" : tableFinal.getTablespaceName(),
(table.getTablespaceName() == null) ? "" : table.getTablespaceName(),
tableFinal.getName(), m_final.getDataSource().getName()}));
}
if (!ObjUtil.equal(tableFinal.getIndexspaceName(), table.getIndexspaceName()))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.tableIndexspaceMismatch",
new Object[]{(tableFinal.getIndexspaceName() == null) ? "" : tableFinal.getIndexspaceName(),
(table.getIndexspaceName() == null) ? "" : table.getIndexspaceName(),
tableFinal.getName(), m_final.getDataSource().getName()}));
}
if (!ObjUtil.equal(tableFinal.getLongspaceName(), table.getLongspaceName()))
{
eh = addException(eh, new MetadataException("err.meta.upgrade.sql.tableLongspaceMismatch",
new Object[]{(tableFinal.getLongspaceName() == null) ? "" : tableFinal.getLongspaceName(),
(table.getLongspaceName() == null) ? "" : table.getLongspaceName(),
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()}));