Search in sources :

Example 1 with DfSqlFileRunnerDispatcher

use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher in project dbflute-core by dbflute.

the class DfAlterCheckProcess method createSqlFileRunner.

protected DfSqlFileRunner createSqlFileRunner(final DfRunnerInformation runInfo) {
    final String loadType = getReplaceSchemaProperties().getRepsEnvType();
    final DfDataAssertProvider dataAssertProvider = new DfDataAssertProvider(loadType);
    final DfSqlFileRunnerExecute runnerExecute = new DfSqlFileRunnerExecute(runInfo, _dataSource);
    runnerExecute.setDispatcher(new DfSqlFileRunnerDispatcher() {

        public DfRunnerDispatchResult dispatch(File sqlFile, Statement st, String sql) throws SQLException {
            final DfDataAssertHandler dataAssertHandler = dataAssertProvider.provideDataAssertHandler(sql);
            if (dataAssertHandler == null) {
                return DfRunnerDispatchResult.NONE;
            }
            dataAssertHandler.handle(sqlFile, st, sql);
            return DfRunnerDispatchResult.DISPATCHED;
        }
    });
    return runnerExecute;
}
Also used : DfDataAssertHandler(org.dbflute.logic.replaceschema.dataassert.DfDataAssertHandler) DfDataAssertProvider(org.dbflute.logic.replaceschema.dataassert.DfDataAssertProvider) DfSqlFileRunnerDispatcher(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher) SQLException(java.sql.SQLException) DfAlterCheckAlterScriptSQLException(org.dbflute.exception.DfAlterCheckAlterScriptSQLException) DfSqlFileRunnerExecute(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute) Statement(java.sql.Statement) DfRunnerDispatchResult(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute.DfRunnerDispatchResult) File(java.io.File)

Example 2 with DfSqlFileRunnerDispatcher

use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher in project dbflute-core by dbflute.

the class DfAlterCheckProcess method createSqlFileRunner.

protected DfSqlFileRunner createSqlFileRunner(final DfRunnerInformation runInfo) {
    final String loadType = getReplaceSchemaProperties().getRepsEnvType();
    final DfDataAssertProvider dataAssertProvider = new DfDataAssertProvider(loadType);
    final DfSqlFileRunnerExecute runnerExecute = new DfSqlFileRunnerExecute(runInfo, _dataSource);
    runnerExecute.setDispatcher(new DfSqlFileRunnerDispatcher() {

        public DfRunnerDispatchResult dispatch(File sqlFile, Statement st, String sql) throws SQLException {
            final DfDataAssertHandler dataAssertHandler = dataAssertProvider.provideDataAssertHandler(sql);
            if (dataAssertHandler == null) {
                return DfRunnerDispatchResult.NONE;
            }
            dataAssertHandler.handle(sqlFile, st, sql);
            return DfRunnerDispatchResult.DISPATCHED;
        }
    });
    return runnerExecute;
}
Also used : DfDataAssertHandler(org.dbflute.logic.replaceschema.dataassert.DfDataAssertHandler) DfDataAssertProvider(org.dbflute.logic.replaceschema.dataassert.DfDataAssertProvider) DfSqlFileRunnerDispatcher(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher) SQLException(java.sql.SQLException) DfSqlFileRunnerExecute(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute) Statement(java.sql.Statement) DfRunnerDispatchResult(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute.DfRunnerDispatchResult) File(java.io.File)

Example 3 with DfSqlFileRunnerDispatcher

use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher in project dbflute-core by dbflute.

the class DfCraftDiffAssertSqlFire method getSqlFileRunner4CraftDiff.

protected DfSqlFileRunner getSqlFileRunner4CraftDiff(final DfRunnerInformation runInfo, final DfCraftDiffAssertProvider provider) {
    final DfSqlFileRunnerExecute runnerExecute = new DfSqlFileRunnerExecute(runInfo, _dataSource) {

        @Override
        protected String getTerminator4Tool() {
            return resolveTerminator4Tool();
        }

        @Override
        protected boolean isTargetFile(String sql) {
            return isTargetEnvTypeFile(sql);
        }
    };
    runnerExecute.setDispatcher(new DfSqlFileRunnerDispatcher() {

        public DfRunnerDispatchResult dispatch(File sqlFile, Statement st, String sql) throws SQLException {
            final DfCraftDiffAssertHandler handler = provider.provideCraftDiffAssertHandler(sqlFile, sql);
            if (handler == null) {
                throwCraftDiffNonAssertionSqlFoundException(sqlFile, sql);
            }
            handler.handle(sqlFile, st, sql);
            return DfRunnerDispatchResult.DISPATCHED;
        }
    });
    return runnerExecute;
}
Also used : DfSqlFileRunnerDispatcher(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher) SQLException(java.sql.SQLException) DfSqlFileRunnerExecute(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute) Statement(java.sql.Statement) DfRunnerDispatchResult(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute.DfRunnerDispatchResult) File(java.io.File)

Example 4 with DfSqlFileRunnerDispatcher

use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher in project dbflute-core by dbflute.

the class DfTakeFinallyProcess method getSqlFileRunner4TakeFinally.

protected DfSqlFileRunner getSqlFileRunner4TakeFinally(final DfRunnerInformation runInfo) {
    final DfReplaceSchemaProperties prop = getReplaceSchemaProperties();
    final DfSqlFileRunnerExecute runnerExecute = new DfSqlFileRunnerExecute(runInfo, _dataSource) {

        @Override
        protected String filterSql(String sql) {
            sql = super.filterSql(sql);
            sql = prop.resolveFilterVariablesIfNeeds(sql);
            return sql;
        }

        @Override
        protected boolean isHandlingCommentOnLineSeparator() {
            return true;
        }

        @Override
        protected boolean isDbCommentLine(String line) {
            final boolean commentLine = super.isDbCommentLine(line);
            if (commentLine) {
                return commentLine;
            }
            // for irregular pattern
            return isDbCommentLineForIrregularPattern(line);
        }

        @Override
        protected String getTerminator4Tool() {
            return resolveTerminator4Tool();
        }

        @Override
        protected boolean isTargetFile(String sql) {
            return getReplaceSchemaProperties().isTargetRepsFile(sql);
        }
    };
    final String loadType = getReplaceSchemaProperties().getRepsEnvType();
    final DfDataAssertProvider dataAssertProvider = new DfDataAssertProvider(loadType);
    runnerExecute.setDispatcher(new DfSqlFileRunnerDispatcher() {

        public DfRunnerDispatchResult dispatch(File sqlFile, Statement st, String sql) throws SQLException {
            final DfDataAssertHandler dataAssertHandler = dataAssertProvider.provideDataAssertHandler(sql);
            if (dataAssertHandler == null) {
                if (_skipIfNonAssetionSql) {
                    _log.info("*Skipped the statement because of not assertion SQL");
                    return DfRunnerDispatchResult.SKIPPED;
                } else if (_restrictIfNonAssetionSql) {
                    throwTakeFinallyNonAssertionSqlFoundException(sqlFile, sql);
                } else {
                    return DfRunnerDispatchResult.NONE;
                }
            }
            try {
                dataAssertHandler.handle(sqlFile, st, sql);
            } catch (DfTakeFinallyAssertionFailureException e) {
                handleAssertionFailureException(e);
            }
            return DfRunnerDispatchResult.DISPATCHED;
        }
    });
    return runnerExecute;
}
Also used : DfDataAssertHandler(org.dbflute.logic.replaceschema.dataassert.DfDataAssertHandler) DfTakeFinallyAssertionFailureException(org.dbflute.exception.DfTakeFinallyAssertionFailureException) DfReplaceSchemaProperties(org.dbflute.properties.DfReplaceSchemaProperties) DfDataAssertProvider(org.dbflute.logic.replaceschema.dataassert.DfDataAssertProvider) DfSqlFileRunnerDispatcher(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher) SQLException(java.sql.SQLException) DfSqlFileRunnerExecute(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute) Statement(java.sql.Statement) DfRunnerDispatchResult(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute.DfRunnerDispatchResult) File(java.io.File)

Aggregations

File (java.io.File)4 SQLException (java.sql.SQLException)4 Statement (java.sql.Statement)4 DfSqlFileRunnerDispatcher (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher)4 DfSqlFileRunnerExecute (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute)4 DfRunnerDispatchResult (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute.DfRunnerDispatchResult)4 DfDataAssertHandler (org.dbflute.logic.replaceschema.dataassert.DfDataAssertHandler)3 DfDataAssertProvider (org.dbflute.logic.replaceschema.dataassert.DfDataAssertProvider)3 DfAlterCheckAlterScriptSQLException (org.dbflute.exception.DfAlterCheckAlterScriptSQLException)1 DfTakeFinallyAssertionFailureException (org.dbflute.exception.DfTakeFinallyAssertionFailureException)1 DfReplaceSchemaProperties (org.dbflute.properties.DfReplaceSchemaProperties)1