Search in sources :

Example 6 with DfSqlFileFireResult

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

the class DfAlterCheckProcess method executeAlterSql.

// -----------------------------------------------------
// Alter Fire
// ----------
protected void executeAlterSql(DfAlterCheckFinalInfo finalInfo) {
    List<File> alterSqlFileList = getMigrationAlterSqlFileList();
    if (alterSqlFileList.isEmpty()) {
        restoreLatestCheckedAlterSql();
        alterSqlFileList = getMigrationAlterSqlFileList();
        if (alterSqlFileList.isEmpty()) {
            createEmptyAlterSqlFileIfNotExists();
            alterSqlFileList = getMigrationAlterSqlFileList();
            if (alterSqlFileList.isEmpty()) {
                // no way
                throwAlterCheckAlterSqlNotFoundException();
            }
        }
    }
    final DfRunnerInformation runInfo = createRunnerInformation();
    final DfSqlFileFireMan fireMan = createSqlFileFireMan();
    fireMan.setExecutorName("Alter Schema");
    final DfSqlFileRunner runner = createSqlFileRunner(runInfo);
    finalInfo.addAlterSqlFileAll(alterSqlFileList);
    try {
        final DfSqlFileFireResult result = fireMan.fire(runner, alterSqlFileList);
        reflectAlterResultToFinalInfo(finalInfo, result);
    } catch (DfTakeFinallyAssertionFailureException e) {
        handleTakeFinallyAssertionFailureException(finalInfo, e);
    }
}
Also used : DfTakeFinallyAssertionFailureException(org.dbflute.exception.DfTakeFinallyAssertionFailureException) DfSqlFileFireMan(org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireMan) DfSqlFileFireResult(org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireResult) DfSqlFileRunner(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunner) File(java.io.File) DfRunnerInformation(org.dbflute.helper.jdbc.DfRunnerInformation)

Example 7 with DfSqlFileFireResult

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

the class DfTakeFinallyProcess method takeFinally.

// ===================================================================================
// Take Finally
// ============
protected DfSqlFileFireResult takeFinally(DfRunnerInformation runInfo) {
    _log.info("");
    _log.info("* * * * * * * **");
    _log.info("*              *");
    _log.info("* Take Finally *");
    _log.info("*              *");
    _log.info("* * * * * * * **");
    final DfSqlFileFireMan fireMan = createSqlFileFireMan();
    final DfSqlFileFireResult result = fireMan.fire(getSqlFileRunner4TakeFinally(runInfo), getTakeFinallySqlFileList());
    conventionalTakeAssertIfNeeds();
    return result;
}
Also used : DfSqlFileFireMan(org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireMan) DfSqlFileFireResult(org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireResult)

Example 8 with DfSqlFileFireResult

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

the class DfOutsideSqlTestTask method buildFinalMessage.

protected String buildFinalMessage() {
    if (_fireResult == null) {
        return null;
    }
    final DfSqlFileFireResult fireResult = _fireResult;
    int countOK = 0;
    int countSkipped = 0;
    int countFailure = 0;
    final StringBuilder sb = new StringBuilder();
    sb.append(" {Checked SQL}");
    final List<DfSqlFileRunnerResult> runnerResultList = fireResult.getRunnerResultList();
    for (DfSqlFileRunnerResult runnerResult : runnerResultList) {
        final File sqlFile = runnerResult.getSqlFile();
        final List<ErrorContinuedSql> continuedSqlList = runnerResult.getErrorContinuedSqlList();
        sb.append(ln());
        if (continuedSqlList.isEmpty()) {
            if (_nonTargetSqlFileSet.contains(sqlFile)) {
                // accurately 'v' means the SQL file may have skipped SQLs
                // however SQL file for OutsideSqlTest has only one SQL normally
                sb.append("  v ");
                ++countSkipped;
            } else {
                sb.append("  o ");
                ++countOK;
            }
        } else {
            // you can say same as 'v'
            // (anyway, look at the log for detail)
            sb.append("  x ");
            ++countFailure;
        }
        sb.append(sqlFile.getName());
        for (ErrorContinuedSql errorContinuedSql : continuedSqlList) {
            final SQLException sqlEx = errorContinuedSql.getSqlEx();
            String sqlMsg = sqlEx.getMessage();
            if (sqlMsg != null) {
                sqlMsg = sqlMsg.trim();
                if (sqlMsg.contains(ln())) {
                    sqlMsg = Srl.substringFirstFront(sqlMsg, ln()).trim() + "...";
                }
            }
            sb.append(ln()).append("   -> ").append(sqlMsg);
        }
    }
    if (!runnerResultList.isEmpty()) {
        sb.append(ln());
        sb.append(ln()).append("   o: OK (").append(countOK).append(")");
        if (countSkipped > 0) {
            sb.append(ln()).append("   v: Skipped exists (").append(countSkipped).append(")");
        }
        if (countFailure > 0) {
            sb.append(ln()).append("   x: Failure exists (").append(countFailure).append(")");
        }
    }
    return sb.toString();
}
Also used : ErrorContinuedSql(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult.ErrorContinuedSql) SQLException(java.sql.SQLException) DfSqlFileFireResult(org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireResult) DfSqlFileRunnerResult(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult) File(java.io.File) DfSpecifiedSqlFile(org.dbflute.task.bs.assistant.DfSpecifiedSqlFile)

Aggregations

DfSqlFileFireResult (org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireResult)8 File (java.io.File)4 DfRunnerInformation (org.dbflute.helper.jdbc.DfRunnerInformation)4 DfSqlFileFireMan (org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireMan)4 DfTakeFinallyAssertionFailureException (org.dbflute.exception.DfTakeFinallyAssertionFailureException)3 DfSqlFileRunner (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunner)2 SQLException (java.sql.SQLException)1 DfSqlFileRunnerResult (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult)1 ErrorContinuedSql (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult.ErrorContinuedSql)1 DfTakeFinallyFinalInfo (org.dbflute.logic.replaceschema.finalinfo.DfTakeFinallyFinalInfo)1 DfSpecifiedSqlFile (org.dbflute.task.bs.assistant.DfSpecifiedSqlFile)1