use of org.entando.entando.aps.system.init.model.ExtendedColumnDefinition in project entando-core by entando.
the class TableFactory method createTable.
private void createTable(Class tableClass, ConnectionSource connectionSource) throws Throwable {
int result = 0;
String logTableName = this.getDatabaseName() + "/" + getTableName(tableClass);
try {
result = ApsTableUtils.createTable(connectionSource, tableClass);
if (result > 0) {
_logger.info("Created table - {}", logTableName);
Object tableModel = tableClass.newInstance();
if (tableModel instanceof ExtendedColumnDefinition) {
String[] extensions = ((ExtendedColumnDefinition) tableModel).extensions(this.getType());
if (null != extensions && extensions.length > 0) {
Dao dao = DaoManager.createDao(connectionSource, tableClass);
for (int i = 0; i < extensions.length; i++) {
String query = extensions[i];
dao.executeRaw(query);
}
}
}
} else {
throw new RuntimeException("Error creating table from class " + logTableName);
}
} catch (Throwable t) {
_logger.error("Error creating table {}", logTableName, t);
if (result > 0) {
TableUtils.dropTable(connectionSource, tableClass, true);
}
throw new ApsSystemException("Error creating table " + logTableName, t);
}
}
Aggregations