use of org.jumpmind.db.platform.DdlException in project symmetric-ds by JumpMind.
the class AddColumnChange method apply.
/**
* {@inheritDoc}
*/
public void apply(Database database, boolean caseSensitive) {
Column newColumn = null;
try {
newColumn = (Column) _newColumn.clone();
} catch (CloneNotSupportedException ex) {
throw new DdlException(ex);
}
Table table = database.findTable(getChangedTable().getName(), caseSensitive);
if ((_previousColumn != null) && (_nextColumn != null)) {
int idx = table.getColumnIndex(_previousColumn) + 1;
table.addColumn(idx, newColumn);
} else {
table.addColumn(newColumn);
}
}
use of org.jumpmind.db.platform.DdlException in project symmetric-ds by JumpMind.
the class AddForeignKeyChange method apply.
/**
* {@inheritDoc}
*/
public void apply(Database database, boolean caseSensitive) {
ForeignKey newFK = null;
try {
newFK = (ForeignKey) _newForeignKey.clone();
newFK.setForeignTable(database.findTable(_newForeignKey.getForeignTableName(), caseSensitive));
} catch (CloneNotSupportedException ex) {
throw new DdlException(ex);
}
database.findTable(getChangedTable().getName()).addForeignKey(newFK);
}
use of org.jumpmind.db.platform.DdlException in project symmetric-ds by JumpMind.
the class CallbackClosure method execute.
/**
* {@inheritDoc}
*/
public void execute(Object obj) throws DdlException {
LinkedList queue = new LinkedList();
queue.add(obj.getClass());
while (!queue.isEmpty()) {
Class type = (Class) queue.removeFirst();
Method callback = (Method) _callbacks.get(type);
if (callback != null) {
try {
_parameters[_callbackTypePos] = obj;
callback.invoke(_callee, _parameters);
return;
} catch (InvocationTargetException ex) {
throw new DdlException(ex.getTargetException());
} catch (IllegalAccessException ex) {
throw new DdlException(ex);
}
}
if ((type.getSuperclass() != null) && !type.getSuperclass().equals(Object.class)) {
queue.add(type.getSuperclass());
}
Class[] baseInterfaces = type.getInterfaces();
if (baseInterfaces != null) {
for (int idx = 0; idx < baseInterfaces.length; idx++) {
queue.add(baseInterfaces[idx]);
}
}
}
}
use of org.jumpmind.db.platform.DdlException in project symmetric-ds by JumpMind.
the class MsSqlDdlReader method existsPKWithName.
/*
* Determines whether there is a pk for the table with the given name.
*
* @param metaData The database metadata
*
* @param table The table
*
* @param name The pk name
*
* @return <code>true</code> if there is such a pk
*/
private boolean existsPKWithName(DatabaseMetaDataWrapper metaData, Table table, String name) {
try {
ResultSet pks = metaData.getPrimaryKeys(table.getName());
boolean found = false;
while (pks.next() && !found) {
if (name.equals(pks.getString("PK_NAME"))) {
found = true;
}
}
pks.close();
return found;
} catch (SQLException ex) {
throw new DdlException(ex);
}
}
use of org.jumpmind.db.platform.DdlException in project symmetric-ds by JumpMind.
the class AddIndexChange method apply.
/**
* {@inheritDoc}
*/
public void apply(Database database, boolean caseSensitive) {
IIndex newIndex = null;
try {
newIndex = (IIndex) _newIndex.clone();
} catch (CloneNotSupportedException ex) {
throw new DdlException(ex);
}
database.findTable(getChangedTable().getName(), caseSensitive).addIndex(newIndex);
}
Aggregations