Search in sources :

Example 1 with DfSchemaSource

use of org.dbflute.helper.jdbc.context.DfSchemaSource in project dbflute-core by dbflute.

the class Table method getSequenceMaximumValue.

public BigDecimal getSequenceMaximumValue() {
    if (!isUseSequence()) {
        return null;
    }
    final DfSequenceIdentityProperties prop = getSequenceIdentityProperties();
    final DfSchemaSource ds = getDatabase().getDataSource();
    BigDecimal value = prop.getSequenceMaximumValueByTableName(ds, getUnifiedSchema(), getTableDbName());
    if (value == null) {
        final String sequenceName = extractPostgreSQLSerialSequenceName();
        if (sequenceName != null && sequenceName.trim().length() > 0) {
            value = prop.getSequenceMaximumValueBySequenceName(ds, getUnifiedSchema(), sequenceName);
        }
    }
    return value;
}
Also used : DfSchemaSource(org.dbflute.helper.jdbc.context.DfSchemaSource) DfSequenceIdentityProperties(org.dbflute.properties.DfSequenceIdentityProperties) BigDecimal(java.math.BigDecimal)

Example 2 with DfSchemaSource

use of org.dbflute.helper.jdbc.context.DfSchemaSource in project dbflute-core by dbflute.

the class Table method getSequenceIncrementSize.

public Integer getSequenceIncrementSize() {
    if (!isUseSequence()) {
        return null;
    }
    final DfSequenceIdentityProperties prop = getSequenceIdentityProperties();
    final DfSchemaSource ds = getDatabase().getDataSource();
    Integer size = prop.getSequenceIncrementSizeByTableName(ds, getUnifiedSchema(), getTableDbName());
    if (size == null) {
        final String sequenceName = extractPostgreSQLSerialSequenceName();
        if (sequenceName != null && sequenceName.trim().length() > 0) {
            size = prop.getSequenceIncrementSizeBySequenceName(ds, getUnifiedSchema(), sequenceName);
        }
    }
    return size;
}
Also used : DfSchemaSource(org.dbflute.helper.jdbc.context.DfSchemaSource) DfSequenceIdentityProperties(org.dbflute.properties.DfSequenceIdentityProperties)

Example 3 with DfSchemaSource

use of org.dbflute.helper.jdbc.context.DfSchemaSource in project dbflute-core by dbflute.

the class DfSchemaSyncChecker method createTargetSerializer.

// ===================================================================================
// Serializer
// ==========
protected DfSchemaXmlSerializer createTargetSerializer(DataSource targetDs) {
    // as previous
    final UnifiedSchema targetSchema = getDocumentProperties().getSchemaSyncCheckDatabaseSchema();
    _log.info("schema: " + targetSchema);
    // to make only schemaXml as target (previous)
    final String historyFile = /*historyFile*/
    null;
    return doCreateSerializer(new DfSchemaSource(targetDs, targetSchema), historyFile);
}
Also used : DfSchemaSource(org.dbflute.helper.jdbc.context.DfSchemaSource) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema)

Example 4 with DfSchemaSource

use of org.dbflute.helper.jdbc.context.DfSchemaSource in project dbflute-core by dbflute.

the class DfTaskControlLogic method getSchemaSource.

/**
 * Get schema source for main connection. <br>
 * It returns valid data source after setupDataSource() success. <br>
 * Basically not null but when data source does not exist on thread, it returns null.
 * @return The schema source. (NullAllowed: when data source does not exist on thread, e.g. lazy connection)
 */
protected DfSchemaSource getSchemaSource() {
    final DataSource dataSource = DfDataSourceContext.getDataSource();
    if (dataSource == null) {
        // basically when lazy connection
        return null;
    }
    final UnifiedSchema mainSchema = _databaseResource.getMainSchema();
    return new DfSchemaSource(dataSource, mainSchema);
}
Also used : DfSchemaSource(org.dbflute.helper.jdbc.context.DfSchemaSource) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DataSource(javax.sql.DataSource)

Example 5 with DfSchemaSource

use of org.dbflute.helper.jdbc.context.DfSchemaSource in project dbflute-core by dbflute.

the class DfSchemaHtmlProcedure method getAvailableProcedureList.

// ===================================================================================
// Available Procedure
// ===================
public List<DfProcedureMeta> getAvailableProcedureList(Supplier<DfSchemaSource> dataSourceProvider) throws SQLException {
    if (_procedureMetaInfoList != null) {
        return _procedureMetaInfoList;
    }
    _log.info(" ");
    _log.info("...Setting up procedures for documents");
    final DfProcedureExtractor handler = new DfProcedureExtractor();
    final DfSchemaSource dataSource = dataSourceProvider.get();
    handler.includeProcedureSynonym(dataSource);
    handler.includeProcedureToDBLink(dataSource);
    if (getDocumentProperties().isShowSchemaHtmlProcedureRegardlessOfGeneration()) {
        handler.suppressGenerationRestriction();
    }
    // ordered by schema
    _procedureMetaInfoList = handler.getAvailableProcedureList(dataSource);
    return _procedureMetaInfoList;
}
Also used : DfSchemaSource(org.dbflute.helper.jdbc.context.DfSchemaSource) DfProcedureExtractor(org.dbflute.logic.jdbc.metadata.basic.DfProcedureExtractor)

Aggregations

DfSchemaSource (org.dbflute.helper.jdbc.context.DfSchemaSource)8 DfSequenceIdentityProperties (org.dbflute.properties.DfSequenceIdentityProperties)4 BigDecimal (java.math.BigDecimal)2 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)2 DfProcedureExtractor (org.dbflute.logic.jdbc.metadata.basic.DfProcedureExtractor)2 DataSource (javax.sql.DataSource)1