use of org.dbflute.helper.process.SystemScript in project dbflute-core by dbflute.
the class DfAlterCheckProcess method createSqlFileFireMan.
protected DfSqlFileFireMan createSqlFileFireMan() {
final String[] scriptExtAry = SystemScript.getSupportedExtList().toArray(new String[] {});
final SystemScript script = new SystemScript();
return new DfSqlFileFireMan() {
@Override
protected DfSqlFileRunnerResult processSqlFile(DfSqlFileRunner runner, File sqlFile) {
_executedAlterSqlFileList.add(sqlFile);
final String path = resolvePath(sqlFile);
if (!Srl.endsWith(path, scriptExtAry)) {
// SQL file
return super.processSqlFile(runner, sqlFile);
}
// script file
final String baseDir = Srl.substringLastFront(path, "/");
final String scriptName = Srl.substringLastRear(path, "/");
_log.info("...Executing the script: " + path);
final ProcessResult processResult;
try {
processResult = script.execute(new File(baseDir), scriptName);
} catch (SystemScriptUnsupportedScriptException ignored) {
_log.info("Skipped the script for system mismatch: " + scriptName);
return null;
}
final String console = processResult.getConsole();
if (Srl.is_NotNull_and_NotTrimmedEmpty(console)) {
_log.info("Catched the console for " + scriptName + ":" + ln() + console);
}
final DfSqlFileRunnerResult runnerResult = new DfSqlFileRunnerResult(sqlFile);
runnerResult.setTotalSqlCount(1);
final int exitCode = processResult.getExitCode();
if (exitCode != 0) {
final String msg = "The script failed: " + scriptName + " exitCode=" + exitCode;
final SQLException sqlEx = new DfAlterCheckAlterScriptSQLException(msg);
final String sqlExp = "(commands on the script)";
runnerResult.addErrorContinuedSql(sqlExp, sqlEx);
return runnerResult;
} else {
runnerResult.setGoodSqlCount(1);
return runnerResult;
}
}
};
}
use of org.dbflute.helper.process.SystemScript in project dbflute-core by dbflute.
the class DfArrangeBeforeRepsProcess method arrangeScript.
// ===================================================================================
// Script
// ======
protected void arrangeScript(String path) {
final SystemScript script = new SystemScript();
final String baseDir = Srl.substringLastFront(path, "/");
final String scriptName = Srl.substringLastRear(path, "/");
_log.info("...Executing the script: " + path);
final ProcessResult processResult;
try {
processResult = script.execute(new File(baseDir), scriptName);
} catch (SystemScriptUnsupportedScriptException ignored) {
_log.info("Skipped the script for system mismatch: " + scriptName);
return;
}
final String console = processResult.getConsole();
if (Srl.is_NotNull_and_NotTrimmedEmpty(console)) {
_log.info("Catched the console for " + scriptName + ":" + ln() + console);
}
final int exitCode = processResult.getExitCode();
if (exitCode != 0) {
throwRepsArrangeScriptFailureException(path, exitCode);
}
}
use of org.dbflute.helper.process.SystemScript in project dbflute-core by dbflute.
the class DfTakeFinallyProcess method createSqlFileFireMan.
protected DfSqlFileFireMan createSqlFileFireMan() {
// similar to alter check
final String[] scriptExtAry = SystemScript.getSupportedExtList().toArray(new String[] {});
final SystemScript script = new SystemScript();
final DfSqlFileFireMan fireMan = new DfSqlFileFireMan() {
@Override
protected DfSqlFileRunnerResult processSqlFile(DfSqlFileRunner runner, File sqlFile) {
_executedSqlFileList.add(sqlFile);
if (isScriptFile(sqlFile, scriptExtAry)) {
return processScriptFile(runner, script, sqlFile);
} else {
// mainly here
return super.processSqlFile(runner, sqlFile);
}
}
};
fireMan.setExecutorName("Take Finally");
return fireMan;
}
use of org.dbflute.helper.process.SystemScript in project dbflute-core by dbflute.
the class DfAlterCheckProcess method createSqlFileFireMan.
protected DfSqlFileFireMan createSqlFileFireMan() {
final String[] scriptExtAry = SystemScript.getSupportedExtList().toArray(new String[] {});
final SystemScript script = new SystemScript();
final DfSqlFileFireMan fireMan = new DfSqlFileFireMan() {
@Override
protected DfSqlFileRunnerResult processSqlFile(DfSqlFileRunner runner, File sqlFile) {
_executedAlterSqlFileList.add(sqlFile);
if (isScriptFile(sqlFile, scriptExtAry)) {
return processScriptFile(runner, script, sqlFile);
} else {
// mainly here
return super.processSqlFile(runner, sqlFile);
}
}
};
fireMan.setExecutorName("Alter Schema");
return fireMan;
}
use of org.dbflute.helper.process.SystemScript in project dbflute-core by dbflute.
the class DfArrangeBeforeRepsProcess method arrangeScript.
// ===================================================================================
// Script
// ======
protected void arrangeScript(String path) {
final SystemScript script = new SystemScript();
final String baseDir = Srl.substringLastFront(path, "/");
final String scriptName = Srl.substringLastRear(path, "/");
_log.info("...Executing the script: " + path);
final ProcessResult processResult;
try {
processResult = script.execute(new File(baseDir), scriptName);
} catch (SystemScriptUnsupportedScriptException ignored) {
_log.info("Skipped the script for system mismatch: " + scriptName);
return;
}
final String console = processResult.getConsole();
if (Srl.is_NotNull_and_NotTrimmedEmpty(console)) {
_log.info("Catched the console for " + scriptName + ":" + ln() + console);
}
final int exitCode = processResult.getExitCode();
if (exitCode != 0) {
throwRepsArrangeScriptFailureException(path, exitCode);
}
}
Aggregations