Search in sources :

Example 11 with DfPrimaryKeyMeta

use of org.dbflute.logic.jdbc.metadata.info.DfPrimaryKeyMeta in project dbflute-core by dbflute.

the class DfSchemaXmlSerializer method doProcessTable.

protected boolean doProcessTable(Connection conn, DatabaseMetaData metaData, DfTableMeta tableMeta) throws SQLException {
    final String tableFullQualifiedName = tableMeta.getTableFullQualifiedName();
    if (tableMeta.isOutOfGenerateTarget()) {
        // for example, sequence synonym and so on...
        _log.info("$ " + tableFullQualifiedName + " is out of generation target!");
        return false;
    }
    _log.info("$ " + tableMeta.toString());
    final Element tableElement = _doc.createElement("table");
    tableElement.setAttribute("name", tableMeta.getTableName());
    tableElement.setAttribute("type", tableMeta.getTableType());
    final UnifiedSchema unifiedSchema = tableMeta.getUnifiedSchema();
    if (unifiedSchema.hasSchema()) {
        tableElement.setAttribute("schema", unifiedSchema.getIdentifiedSchema());
    }
    final String tableComment = tableMeta.getTableComment();
    if (Srl.is_NotNull_and_NotTrimmedEmpty(tableComment)) {
        tableElement.setAttribute("comment", tableComment);
    }
    final DfPrimaryKeyMeta pkInfo = getPrimaryColumnMetaInfo(metaData, tableMeta);
    final List<DfColumnMeta> columns = getColumns(metaData, tableMeta);
    for (int j = 0; j < columns.size(); j++) {
        final DfColumnMeta columnMeta = columns.get(j);
        final Element columnElement = _doc.createElement("column");
        processColumnName(columnMeta, columnElement);
        processColumnType(columnMeta, columnElement);
        processColumnDbType(columnMeta, columnElement);
        processColumnJavaType(columnMeta, columnElement);
        processColumnSize(columnMeta, columnElement);
        processDatetimePrecision(columnMeta, columnElement);
        processRequired(columnMeta, columnElement);
        processPrimaryKey(columnMeta, pkInfo, columnElement);
        processColumnComment(columnMeta, columnElement);
        processDefaultValue(columnMeta, columnElement);
        processAutoIncrement(tableMeta, columnMeta, pkInfo, conn, columnElement);
        tableElement.appendChild(columnElement);
    }
    processForeignKey(conn, metaData, tableMeta, tableElement);
    final Map<String, Map<Integer, String>> uniqueKeyMap = processUniqueKey(metaData, tableMeta, pkInfo, tableElement);
    processIndex(metaData, tableMeta, tableElement, uniqueKeyMap);
    _tableElementStagingMap.put(tableFullQualifiedName, tableElement);
    return true;
}
Also used : DfPrimaryKeyMeta(org.dbflute.logic.jdbc.metadata.info.DfPrimaryKeyMeta) DfColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfColumnMeta) Element(org.w3c.dom.Element) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) Map(java.util.Map) TypeMap(org.apache.torque.engine.database.model.TypeMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) StringKeyMap(org.dbflute.helper.StringKeyMap) Constraint(org.apache.torque.engine.database.model.Constraint)

Aggregations

DfPrimaryKeyMeta (org.dbflute.logic.jdbc.metadata.info.DfPrimaryKeyMeta)11 SQLException (java.sql.SQLException)5 Statement (java.sql.Statement)5 Connection (java.sql.Connection)4 Entry (java.util.Map.Entry)4 DfTableMeta (org.dbflute.logic.jdbc.metadata.info.DfTableMeta)4 DatabaseMetaData (java.sql.DatabaseMetaData)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 StringKeyMap (org.dbflute.helper.StringKeyMap)3 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)3 ResultSet (java.sql.ResultSet)2 List (java.util.List)2 TreeMap (java.util.TreeMap)2 StringSet (org.dbflute.helper.StringSet)2 DfAutoIncrementExtractor (org.dbflute.logic.jdbc.metadata.basic.DfAutoIncrementExtractor)2 DfColumnExtractor (org.dbflute.logic.jdbc.metadata.basic.DfColumnExtractor)2 HashMap (java.util.HashMap)1 Constraint (org.apache.torque.engine.database.model.Constraint)1 TypeMap (org.apache.torque.engine.database.model.TypeMap)1