Search in sources :

Example 1 with DfUrlAnalyzerFactory

use of org.dbflute.logic.jdbc.urlanalyzer.factory.DfUrlAnalyzerFactory in project dbflute-core by dbflute.

the class DfReplaceSchemaProperties method getAdditionalDropSchema.

public UnifiedSchema getAdditionalDropSchema(Map<String, Object> additionalDropMap) {
    final String url = getAdditionalDropUrl(additionalDropMap);
    final String catalog;
    if (Srl.is_NotNull_and_NotTrimmedEmpty(url)) {
        final DfUrlAnalyzerFactory factory = new DfUrlAnalyzerFactory(getBasicProperties(), url);
        final DfUrlAnalyzer analyzer = factory.createAnalyzer();
        catalog = analyzer.extractCatalog();
    } else {
        catalog = getDatabaseProperties().getDatabaseCatalog();
    }
    final Object obj = additionalDropMap.get("schema");
    if (obj == null) {
        if (!isDatabaseAsSchemaSpecificationOmittable()) {
            String msg = "The schema is required:";
            msg = msg + " additionalDropMap=" + additionalDropMap;
            throw new DfRequiredPropertyNotFoundException(msg);
        }
        return null;
    }
    final String schema = castToString(obj, "additionalDropMapList.schema");
    final UnifiedSchema unifiedSchema = UnifiedSchema.createAsDynamicSchema(catalog, schema);
    return unifiedSchema;
}
Also used : DfUrlAnalyzer(org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer) DfRequiredPropertyNotFoundException(org.dbflute.exception.DfRequiredPropertyNotFoundException) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfUrlAnalyzerFactory(org.dbflute.logic.jdbc.urlanalyzer.factory.DfUrlAnalyzerFactory)

Example 2 with DfUrlAnalyzerFactory

use of org.dbflute.logic.jdbc.urlanalyzer.factory.DfUrlAnalyzerFactory in project dbflute-core by dbflute.

the class DfReplaceSchemaProperties method createAdditionalUserConnection.

public Connection createAdditionalUserConnection(String additonalUser) {
    final Map<String, String> propertyMap = getAdditionalUserPropertyMap(additonalUser);
    if (propertyMap == null) {
        return null;
    }
    final String title = "replaceSchemaDefinitionMap#additionalUserMap$";
    final String driver = getDatabaseProperties().getDatabaseDriver();
    final String url;
    {
        String property = resolveDispatchVariable(title + "url", propertyMap.get("url"));
        if (property != null && property.trim().length() > 0) {
            url = property;
        } else {
            url = getDatabaseProperties().getDatabaseUrl();
        }
    }
    final DfUrlAnalyzerFactory factory = new DfUrlAnalyzerFactory(getBasicProperties(), url);
    final DfUrlAnalyzer analyzer = factory.createAnalyzer();
    final String catalog = analyzer.extractCatalog();
    final String schema = propertyMap.get("schema");
    final UnifiedSchema unifiedSchema = UnifiedSchema.createAsDynamicSchema(catalog, schema);
    final String user = resolveDispatchVariable(title + "user", propertyMap.get("user"));
    final String password = resolvePasswordVariable(title + "password", additonalUser, propertyMap.get("password"));
    final Properties prop = getDatabaseProperties().getConnectionProperties();
    prop.setProperty("user", user);
    prop.setProperty("password", password);
    _log.info("...Creating a connection for additional user: " + user);
    return createConnection(driver, url, unifiedSchema, prop);
}
Also used : DfUrlAnalyzer(org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) Properties(java.util.Properties) DfConnectionProperties(org.dbflute.properties.assistant.database.DfConnectionProperties) DfUrlAnalyzerFactory(org.dbflute.logic.jdbc.urlanalyzer.factory.DfUrlAnalyzerFactory)

Example 3 with DfUrlAnalyzerFactory

use of org.dbflute.logic.jdbc.urlanalyzer.factory.DfUrlAnalyzerFactory in project dbflute-core by dbflute.

the class DfDatabaseProperties method extractCatalogFromUrl.

public String extractCatalogFromUrl(String url) {
    final DfUrlAnalyzerFactory factory = new DfUrlAnalyzerFactory(getBasicProperties(), url);
    final DfUrlAnalyzer analyzer = factory.createAnalyzer();
    final String extracted = analyzer.extractCatalog();
    return Srl.is_NotNull_and_NotTrimmedEmpty(extracted) ? extracted : null;
}
Also used : DfUrlAnalyzer(org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer) DfUrlAnalyzerFactory(org.dbflute.logic.jdbc.urlanalyzer.factory.DfUrlAnalyzerFactory)

Aggregations

DfUrlAnalyzer (org.dbflute.logic.jdbc.urlanalyzer.DfUrlAnalyzer)3 DfUrlAnalyzerFactory (org.dbflute.logic.jdbc.urlanalyzer.factory.DfUrlAnalyzerFactory)3 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)2 Properties (java.util.Properties)1 DfRequiredPropertyNotFoundException (org.dbflute.exception.DfRequiredPropertyNotFoundException)1 DfConnectionProperties (org.dbflute.properties.assistant.database.DfConnectionProperties)1