use of org.apache.cayenne.dbsync.merge.token.db.AbstractToDbToken in project cayenne by apache.
the class MergeCase method dropTableIfPresent.
protected void dropTableIfPresent(String tableName) throws Exception {
// must have a dummy datamap for the dummy table for the downstream code
// to work
DataMap map = new DataMap("dummy");
map.setQuotingSQLIdentifiers(map.isQuotingSQLIdentifiers());
DbEntity entity = new DbEntity(tableName);
map.addDbEntity(entity);
AbstractToDbToken t = (AbstractToDbToken) mergerFactory().createDropTableToDb(entity);
for (String sql : t.createSql(node.getAdapter())) {
try {
executeSql(sql);
} catch (Exception e) {
logger.info("Exception dropping table " + tableName + ", probably abscent..");
}
}
}
use of org.apache.cayenne.dbsync.merge.token.db.AbstractToDbToken in project cayenne by apache.
the class MergerOptions method createSQL.
/**
* Returns SQL statements generated for selected schema generation options.
*/
protected void createSQL() {
// convert them to string representation for display
StringBuilder buf = new StringBuilder();
Iterator<MergerToken> it = tokens.getSelectedTokens().iterator();
String batchTerminator = adapter.getBatchTerminator();
String lineEnd = batchTerminator != null ? "\n" + batchTerminator + "\n\n" : "\n\n";
while (it.hasNext()) {
MergerToken token = it.next();
if (token instanceof AbstractToDbToken) {
AbstractToDbToken tdb = (AbstractToDbToken) token;
for (String sql : tdb.createSql(adapter)) {
buf.append(sql);
buf.append(lineEnd);
}
}
}
textForSQL = buf.toString();
}
Aggregations