Search in sources :

Example 1 with DfLoadDataFinalInfo

use of org.dbflute.logic.replaceschema.finalinfo.DfLoadDataFinalInfo in project dbflute-core by dbflute.

the class DfLoadDataProcess method createFinalInfo.

// ===================================================================================
// Final Info
// ==========
protected DfLoadDataFinalInfo createFinalInfo(RuntimeException loadEx, long processPerformanceMillis) {
    final DfLoadDataFinalInfo finalInfo = new DfLoadDataFinalInfo();
    finalInfo.setResultMessage("Load Data" + ": " + buildEnvTypeCountExp());
    final List<DfLoadedFile> loadedFileList = _loadedDataInfo.getLoadedFileList();
    final int loadedFileCount = loadedFileList.size();
    final boolean failure;
    final List<String> detailMessageList = new ArrayList<String>();
    if (_success) {
        failure = false;
        if (loadedFileCount > 0) {
            // has the last line separator
            setupDetailMessage(detailMessageList);
        } else {
            detailMessageList.add("- (no data file)");
        }
    } else {
        // it is the precondition that LoadData stops at the first failure
        failure = true;
        if (loadedFileCount > 0) {
            // has the last line separator
            setupDetailMessage(detailMessageList);
        }
        detailMessageList.add("x (failed: Look at the exception message)");
    }
    for (String detailMessage : detailMessageList) {
        finalInfo.addDetailMessage(detailMessage);
    }
    finalInfo.setFailure(failure);
    finalInfo.setLoadEx(loadEx);
    finalInfo.setProcessPerformanceMillis(processPerformanceMillis);
    return finalInfo;
}
Also used : DfLoadDataFinalInfo(org.dbflute.logic.replaceschema.finalinfo.DfLoadDataFinalInfo) DfLoadedFile(org.dbflute.logic.replaceschema.loaddata.base.DfLoadedFile) ArrayList(java.util.ArrayList)

Example 2 with DfLoadDataFinalInfo

use of org.dbflute.logic.replaceschema.finalinfo.DfLoadDataFinalInfo in project dbflute-core by dbflute.

the class DfLoadDataProcess method createFinalInfo.

// ===================================================================================
// Final Info
// ==========
protected DfLoadDataFinalInfo createFinalInfo(RuntimeException loadEx) {
    final DfLoadDataFinalInfo finalInfo = new DfLoadDataFinalInfo();
    final List<DfLoadedFile> loadedFileList = _loadedDataInfo.getLoadedFileList();
    final int loadedFileCount = loadedFileList.size();
    final String title = "{Load Data}";
    final String resultMessage = title + ": loaded-files=" + loadedFileCount;
    final boolean failure;
    final List<String> detailMessageList = new ArrayList<String>();
    if (_success) {
        failure = false;
        if (loadedFileCount > 0) {
            // has the last line separator
            setupDetailMessage(detailMessageList);
        } else {
            detailMessageList.add("- (no data file)");
        }
    } else {
        // it is the precondition that LoadData stops at the first failure
        failure = true;
        if (loadedFileCount > 0) {
            // has the last line separator
            setupDetailMessage(detailMessageList);
        }
        detailMessageList.add("x (failed: Look at the exception message)");
    }
    finalInfo.setResultMessage(resultMessage);
    for (String detailMessage : detailMessageList) {
        finalInfo.addDetailMessage(detailMessage);
    }
    finalInfo.setFailure(failure);
    finalInfo.setLoadEx(loadEx);
    return finalInfo;
}
Also used : DfLoadDataFinalInfo(org.dbflute.logic.replaceschema.finalinfo.DfLoadDataFinalInfo) DfLoadedFile(org.dbflute.logic.replaceschema.loaddata.DfLoadedFile) ArrayList(java.util.ArrayList)

Example 3 with DfLoadDataFinalInfo

use of org.dbflute.logic.replaceschema.finalinfo.DfLoadDataFinalInfo in project dbflute-core by dbflute.

the class DfReplaceSchemaTask method buildReplaceSchemaFinalMessage.

protected String buildReplaceSchemaFinalMessage() {
    final StringBuilder sb = new StringBuilder();
    if (_cancelled) {
        sb.append("    * * * * * * *").append(ln());
        sb.append("    * Cancelled *").append(ln());
        sb.append("    * * * * * * *");
        return sb.toString();
    }
    // null allowed
    final DfReplaceSchemaFinalInfo finalInfo = _replaceSchemaFinalInfo;
    boolean firstDone = false;
    // AlterFailure
    boolean alterFailure = false;
    {
        final DfAlterCheckFinalInfo alterCheckFinalInfo = _alterCheckFinalInfo;
        if (alterCheckFinalInfo != null && alterCheckFinalInfo.isValidInfo()) {
            alterFailure = alterCheckFinalInfo.isFailure();
        }
    }
    // CreateSchema
    if (finalInfo != null) {
        final DfCreateSchemaFinalInfo createSchemaFinalInfo = finalInfo.getCreateSchemaFinalInfo();
        if (createSchemaFinalInfo != null && createSchemaFinalInfo.isValidInfo()) {
            if (!alterFailure || createSchemaFinalInfo.isFailure()) {
                if (firstDone) {
                    sb.append(ln()).append(ln());
                }
                firstDone = true;
                buildSchemaTaskContents(sb, createSchemaFinalInfo);
            }
        }
    }
    // LoadData
    if (finalInfo != null) {
        final DfLoadDataFinalInfo loadDataFinalInfo = finalInfo.getLoadDataFinalInfo();
        if (loadDataFinalInfo != null && loadDataFinalInfo.isValidInfo()) {
            if (!alterFailure || loadDataFinalInfo.isFailure()) {
                if (firstDone) {
                    sb.append(ln()).append(ln());
                }
                firstDone = true;
                buildSchemaTaskContents(sb, loadDataFinalInfo);
            }
        }
    }
    // TakeFinally
    boolean assertionFailure = false;
    if (finalInfo != null) {
        final DfTakeFinallyFinalInfo takeFinallyFinalInfo = finalInfo.getTakeFinallyFinalInfo();
        if (takeFinallyFinalInfo != null) {
            assertionFailure = (takeFinallyFinalInfo.getAssertionEx() != null);
            if (takeFinallyFinalInfo.isValidInfo()) {
                if (!alterFailure || takeFinallyFinalInfo.isFailure()) {
                    if (firstDone) {
                        sb.append(ln()).append(ln());
                    }
                    firstDone = true;
                    buildSchemaTaskContents(sb, takeFinallyFinalInfo);
                }
            }
        }
    }
    // AlterCheck (AlterSchema, SavePrevious)
    {
        final DfAlterCheckFinalInfo alterCheckFinalInfo = _alterCheckFinalInfo;
        if (alterCheckFinalInfo != null && alterCheckFinalInfo.isValidInfo()) {
            if (firstDone) {
                sb.append(ln()).append(ln());
            }
            firstDone = true;
            buildSchemaTaskContents(sb, alterCheckFinalInfo);
        }
    }
    if (alterFailure) {
        // alter or create in AlterCheck
        sb.append(ln()).append("    * * * * * * * * * * *");
        sb.append(ln()).append("    * Migration Failure *");
        sb.append(ln()).append("    * * * * * * * * * * *");
    } else if (assertionFailure) {
        // assertion in normal time
        sb.append(ln()).append("    * * * * * * * * * * *");
        sb.append(ln()).append("    * Assertion Failure *");
        sb.append(ln()).append("    * * * * * * * * * * *");
    } else if (finalInfo != null && finalInfo.hasFailure()) {
        // as default
        sb.append(ln()).append("    * * * * * *");
        sb.append(ln()).append("    * Failure *");
        sb.append(ln()).append("    * * * * * *");
    }
    return sb.toString();
}
Also used : DfLoadDataFinalInfo(org.dbflute.logic.replaceschema.finalinfo.DfLoadDataFinalInfo) DfTakeFinallyFinalInfo(org.dbflute.logic.replaceschema.finalinfo.DfTakeFinallyFinalInfo) DfReplaceSchemaFinalInfo(org.dbflute.logic.replaceschema.finalinfo.DfReplaceSchemaFinalInfo) DfAlterCheckFinalInfo(org.dbflute.logic.replaceschema.finalinfo.DfAlterCheckFinalInfo) DfCreateSchemaFinalInfo(org.dbflute.logic.replaceschema.finalinfo.DfCreateSchemaFinalInfo)

Aggregations

DfLoadDataFinalInfo (org.dbflute.logic.replaceschema.finalinfo.DfLoadDataFinalInfo)3 ArrayList (java.util.ArrayList)2 DfAlterCheckFinalInfo (org.dbflute.logic.replaceschema.finalinfo.DfAlterCheckFinalInfo)1 DfCreateSchemaFinalInfo (org.dbflute.logic.replaceschema.finalinfo.DfCreateSchemaFinalInfo)1 DfReplaceSchemaFinalInfo (org.dbflute.logic.replaceschema.finalinfo.DfReplaceSchemaFinalInfo)1 DfTakeFinallyFinalInfo (org.dbflute.logic.replaceschema.finalinfo.DfTakeFinallyFinalInfo)1 DfLoadedFile (org.dbflute.logic.replaceschema.loaddata.DfLoadedFile)1 DfLoadedFile (org.dbflute.logic.replaceschema.loaddata.base.DfLoadedFile)1