Search in sources :

Example 1 with DfDataAssertHandler

use of org.dbflute.logic.replaceschema.dataassert.DfDataAssertHandler 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 DfDataAssertHandler

use of org.dbflute.logic.replaceschema.dataassert.DfDataAssertHandler 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 DfDataAssertHandler

use of org.dbflute.logic.replaceschema.dataassert.DfDataAssertHandler 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)3 SQLException (java.sql.SQLException)3 Statement (java.sql.Statement)3 DfSqlFileRunnerDispatcher (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher)3 DfSqlFileRunnerExecute (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute)3 DfRunnerDispatchResult (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute.DfRunnerDispatchResult)3 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