Search in sources :

Example 61 with UnifiedSchema

use of org.apache.torque.engine.database.model.UnifiedSchema in project dbflute-core by dbflute.

the class DfSchemaXmlSerializer method doHelpTableDatePrecision.

protected void doHelpTableDatePrecision(List<DfTableMeta> tableList, UnifiedSchema unifiedSchema) {
    final DfDatetimePrecisionExtractor datetimePrecisionExtractor = createDatetimePrecisionExtractor(unifiedSchema);
    if (datetimePrecisionExtractor != null) {
        final Set<String> tableSet = new HashSet<String>();
        for (DfTableMeta table : tableList) {
            tableSet.add(table.getTableName());
        }
        try {
            if (_datetimePrecisionAllMap == null) {
                _datetimePrecisionAllMap = new LinkedHashMap<UnifiedSchema, Map<String, Map<String, Integer>>>();
            }
            final Map<String, Map<String, Integer>> datetimePrecisionMap = _datetimePrecisionAllMap.get(unifiedSchema);
            final Map<String, Map<String, Integer>> extractedMap = datetimePrecisionExtractor.extractDatetimePrecisionMap(tableSet);
            if (datetimePrecisionMap == null) {
                _datetimePrecisionAllMap.put(unifiedSchema, extractedMap);
            } else {
                // basically no way, schema is unique but just in case
                // merge
                datetimePrecisionMap.putAll(extractedMap);
            }
        } catch (RuntimeException continued) {
            _log.info("Failed to extract date-time precisions: extractor=" + datetimePrecisionExtractor, continued);
        }
    }
}
Also used : DfDatetimePrecisionExtractor(org.dbflute.logic.jdbc.metadata.supplement.DfDatetimePrecisionExtractor) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfTableMeta(org.dbflute.logic.jdbc.metadata.info.DfTableMeta) 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) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 62 with UnifiedSchema

use of org.apache.torque.engine.database.model.UnifiedSchema in project dbflute-core by dbflute.

the class DfTaskControlLogic method connectMainSchema.

protected void connectMainSchema(Connection conn) throws SQLException {
    final UnifiedSchema mainSchema = _databaseResource.getMainSchema();
    final DfCurrentSchemaConnector connector = new DfCurrentSchemaConnector(mainSchema, getDatabaseTypeFacadeProp());
    connector.connectSchema(conn);
}
Also used : DfCurrentSchemaConnector(org.dbflute.logic.jdbc.connection.DfCurrentSchemaConnector) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema)

Example 63 with UnifiedSchema

use of org.apache.torque.engine.database.model.UnifiedSchema in project dbflute-core by dbflute.

the class DfTaskControlLogic method buildAdditionalSchemaDisp.

protected String buildAdditionalSchemaDisp() {
    final DfDatabaseProperties databaseProp = getDatabaseProperties();
    final List<UnifiedSchema> additionalSchemaList = databaseProp.getAdditionalSchemaList();
    String disp;
    if (additionalSchemaList.size() == 1) {
        final UnifiedSchema unifiedSchema = additionalSchemaList.get(0);
        final String identifiedSchema = unifiedSchema.getIdentifiedSchema();
        disp = identifiedSchema;
        if (unifiedSchema.isCatalogAdditionalSchema()) {
            disp = disp + "(catalog)";
        } else if (unifiedSchema.isMainSchema()) {
            // should NOT be true
            disp = disp + "(main)";
        } else if (unifiedSchema.isUnknownSchema()) {
            // should NOT be true
            disp = disp + "(unknown)";
        }
    } else {
        final StringBuilder sb = new StringBuilder();
        for (UnifiedSchema unifiedSchema : additionalSchemaList) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            final String identifiedSchema = unifiedSchema.getIdentifiedSchema();
            sb.append(identifiedSchema);
            if (unifiedSchema.isCatalogAdditionalSchema()) {
                sb.append("(catalog)");
            } else if (unifiedSchema.isMainSchema()) {
                // should NOT be true
                sb.append("(main)");
            } else if (unifiedSchema.isUnknownSchema()) {
                // should NOT be true
                sb.append("(unknown)");
            }
        }
        disp = sb.toString();
    }
    return disp;
}
Also used : UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfDatabaseProperties(org.dbflute.properties.DfDatabaseProperties)

Aggregations

UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)63 Map (java.util.Map)9 StringKeyMap (org.dbflute.helper.StringKeyMap)9 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)8 LinkedHashMap (java.util.LinkedHashMap)7 ResultSet (java.sql.ResultSet)6 DfSynonymMeta (org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta)6 DfTableMeta (org.dbflute.logic.jdbc.metadata.info.DfTableMeta)6 ArrayList (java.util.ArrayList)5 LinkedHashSet (java.util.LinkedHashSet)4 DfProcedureSupplementExtractor (org.dbflute.logic.jdbc.metadata.procedure.DfProcedureSupplementExtractor)4 List (java.util.List)3 TreeMap (java.util.TreeMap)3 TypeMap (org.apache.torque.engine.database.model.TypeMap)3 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)3 DfAdditionalSchemaInfo (org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo)3 Connection (java.sql.Connection)2 DatabaseMetaData (java.sql.DatabaseMetaData)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2