use of org.dbflute.properties.DfAdditionalTableProperties in project dbflute-core by dbflute.
the class DfSchemaXmlSerializer method setupAddtionalTableIfNeeds.
// ===================================================================================
// Additional Table
// ================
protected boolean setupAddtionalTableIfNeeds() {
boolean exists = false;
final String tableType = "TABLE";
final DfAdditionalTableProperties prop = getProperties().getAdditionalTableProperties();
final Map<String, Object> tableMap = prop.getAdditionalTableMap();
final Set<String> tableNameKey = tableMap.keySet();
for (String tableName : tableNameKey) {
_log.info("...Processing additional table: " + tableName + "(" + tableType + ")");
final Element tableElement = _doc.createElement("table");
tableElement.setAttribute("name", tableName);
tableElement.setAttribute("type", tableType);
final Map<String, Map<String, String>> columnMap = prop.findColumnMap(tableName);
final String tableComment = prop.findTableComment(tableName);
if (tableComment != null && tableComment.trim().length() > 0) {
tableElement.setAttribute("comment", tableComment);
}
final Set<String> columnNameKey = columnMap.keySet();
for (String columnName : columnNameKey) {
final Element columnElement = _doc.createElement("column");
columnElement.setAttribute("name", columnName);
final String columnType = prop.findColumnType(tableName, columnName);
final String columnDbType = prop.findColumnDbType(tableName, columnName);
final String columnSize = prop.findColumnSize(tableName, columnName);
final boolean required = prop.isColumnRequired(tableName, columnName);
final boolean primaryKey = prop.isColumnPrimaryKey(tableName, columnName);
final String pkName = prop.findColumnPKName(tableName, columnName);
final boolean autoIncrement = prop.isColumnAutoIncrement(tableName, columnName);
final String columnDefault = prop.findColumnDefault(tableName, columnName);
final String columnComment = prop.findColumnComment(tableName, columnName);
setupAdditionalTableColumnAttribute(columnElement, "type", columnType);
setupAdditionalTableColumnAttribute(columnElement, "dbType", columnDbType);
setupAdditionalTableColumnAttribute(columnElement, "size", columnSize);
setupAdditionalTableColumnAttribute(columnElement, "required", String.valueOf(required));
setupAdditionalTableColumnAttribute(columnElement, "primaryKey", String.valueOf(primaryKey));
setupAdditionalTableColumnAttribute(columnElement, "pkName", pkName);
setupAdditionalTableColumnAttribute(columnElement, "autoIncrement", String.valueOf(autoIncrement));
setupAdditionalTableColumnAttribute(columnElement, "default", columnDefault);
setupAdditionalTableColumnAttribute(columnElement, "comment", columnComment);
tableElement.appendChild(columnElement);
}
exists = true;
_databaseNode.appendChild(tableElement);
}
return exists;
}
Aggregations