use of org.dbflute.exception.DfTakeFinallyAssertionFailureException 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);
}
}
use of org.dbflute.exception.DfTakeFinallyAssertionFailureException 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;
}
use of org.dbflute.exception.DfTakeFinallyAssertionFailureException in project dbflute-core by dbflute.
the class DfAlterCheckProcess method reflectTakeFinallyResultToFinalInfo.
protected void reflectTakeFinallyResultToFinalInfo(DfAlterCheckFinalInfo finalInfo, DfTakeFinallyFinalInfo takeFinally) {
final List<String> detailMessageList = takeFinally.getDetailMessageList();
for (String detailMessage : detailMessageList) {
finalInfo.addDetailMessage(detailMessage);
}
final SQLFailureException breakCause = takeFinally.getBreakCause();
if (breakCause != null) {
finalInfo.setBreakCause(breakCause);
}
final DfTakeFinallyAssertionFailureException assertionEx = takeFinally.getAssertionEx();
if (assertionEx != null) {
finalInfo.setTakeFinallyAssertionEx(assertionEx);
}
if (takeFinally.isFailure()) {
finalInfo.setFailure(true);
}
}
use of org.dbflute.exception.DfTakeFinallyAssertionFailureException in project dbflute-core by dbflute.
the class DfReplaceSchemaTask method takeFinally.
// -----------------------------------------------------
// Take Finally
// ------------
protected void takeFinally(String sqlRootDir, boolean previous) {
final DfTakeFinallyProcess process = createTakeFinallyProcess(sqlRootDir, previous);
_takeFinallyFinalInfo = process.execute();
final SQLFailureException breakCause = _takeFinallyFinalInfo.getBreakCause();
if (breakCause != null) {
// high priority exception
throw breakCause;
}
final DfTakeFinallyAssertionFailureException assertionEx = _takeFinallyFinalInfo.getAssertionEx();
if (assertionEx != null) {
// high priority exception
throw assertionEx;
}
}
Aggregations