Search in sources :

Example 11 with HandyDate

use of org.dbflute.helper.HandyDate in project dbflute-core by dbflute.

the class DfLReverseOriginDateSynchronizer method handleOriginDateSyncLine.

protected boolean handleOriginDateSyncLine(File mapFile, StringBuilder sb, String line, StringBuilder resultSb) {
    final String keyOriginDate = DfLoadingControlProp.KEY_ORIGIN_DATE;
    boolean handled = false;
    if (!line.trim().startsWith("#") && line.contains(keyOriginDate)) {
        final String frontStr = Srl.substringFirstFront(line, keyOriginDate);
        final String rearStr = Srl.substringFirstRear(line, keyOriginDate).trim();
        if (!rearStr.startsWith("=")) {
            throwLoadingControlMapOriginDateParseFailureException(mapFile, line);
        }
        // keep space e.g. 2013/04/12 ...
        final String equalRear = Srl.substringFirstRear(rearStr, "=");
        // e.g. 2013/04/12
        final String originDate = Srl.substringFirstFront(equalRear, ";", "}").trim();
        // keep space e.g. "; ...", "}"
        final String lastRearStr = Srl.substringFirstRear(equalRear, originDate);
        if (originDate.trim().length() == 0) {
            throwLoadingControlMapOriginDateParseFailureException(mapFile, line);
        }
        // can be synchronized here
        final Date currentDate = DBFluteSystem.currentDate();
        final String newDateExp = new HandyDate(currentDate).toDisp("yyyy/MM/dd");
        sb.append(frontStr).append(keyOriginDate).append(" = ").append(newDateExp);
        sb.append(lastRearStr);
        handled = true;
        resultSb.append(originDate).append(" -> ").append(newDateExp);
    } else {
        sb.append(line);
    }
    sb.append("\n");
    return handled;
}
Also used : HandyDate(org.dbflute.helper.HandyDate) Date(java.util.Date) HandyDate(org.dbflute.helper.HandyDate)

Example 12 with HandyDate

use of org.dbflute.helper.HandyDate in project dbflute-core by dbflute.

the class DfDecoMapFile method mappingToDecoMapMapping.

// done hakiba cast check by hakiba (2017/07/29)
private DfDecoMapMapping mappingToDecoMapMapping(Map<String, Object> map) {
    String formatVersion = (String) map.get("formatVersion");
    String oldTableName = (String) map.get("oldTableName");
    String oldColumnName = (String) map.get("oldColumnName");
    String newTableName = (String) map.get("newTableName");
    String newColumnName = (String) map.get("newColumnName");
    DfDecoMapPieceTargetType targetType = DfDecoMapPieceTargetType.of(map.get("targetType")).get();
    @SuppressWarnings("unchecked") List<String> authorList = (List<String>) map.get("authorList");
    String mappingCode = (String) map.get("mappingCode");
    LocalDateTime mappingDatetime = new HandyDate((String) map.get("mappingDatetime")).getLocalDateTime();
    String mappingOwner = (String) map.get("mappingOwner");
    @SuppressWarnings("unchecked") List<String> previousMappingList = (List<String>) map.get("previousMappingList");
    return new DfDecoMapMapping(formatVersion, oldTableName, oldColumnName, newTableName, newColumnName, targetType, authorList, mappingCode, mappingOwner, mappingDatetime, previousMappingList);
}
Also used : LocalDateTime(java.time.LocalDateTime) HandyDate(org.dbflute.helper.HandyDate) ArrayList(java.util.ArrayList) List(java.util.List)

Example 13 with HandyDate

use of org.dbflute.helper.HandyDate in project dbflute-core by dbflute.

the class DfDecoMapFile method mappingToDecoMapPiece.

// done hakiba cast check by hakiba (2017/07/29)
private DfDecoMapPiece mappingToDecoMapPiece(Map<String, Object> map) {
    String formatVersion = (String) map.get("formatVersion");
    String tableName = (String) map.get("tableName");
    String columnName = (String) map.get("columnName");
    DfDecoMapPieceTargetType targetType = DfDecoMapPieceTargetType.of(map.get("targetType")).get();
    String decomment = (String) map.get("decomment");
    String databaseComment = (String) map.get("databaseComment");
    Long commentVersion = Long.valueOf(map.get("commentVersion").toString());
    @SuppressWarnings("unchecked") List<String> authorList = (List<String>) map.get("authorList");
    String pieceCode = (String) map.get("pieceCode");
    LocalDateTime pieceDatetime = new HandyDate((String) map.get("pieceDatetime")).getLocalDateTime();
    String pieceOwner = (String) map.get("pieceOwner");
    String pieceGitBranch = (String) map.get("pieceGitBranch");
    @SuppressWarnings("unchecked") List<String> previousPieceList = (List<String>) map.get("previousPieceList");
    return new DfDecoMapPiece(formatVersion, tableName, columnName, targetType, decomment, databaseComment, commentVersion, authorList, pieceCode, pieceDatetime, pieceOwner, pieceGitBranch, previousPieceList);
}
Also used : LocalDateTime(java.time.LocalDateTime) HandyDate(org.dbflute.helper.HandyDate) ArrayList(java.util.ArrayList) List(java.util.List)

Example 14 with HandyDate

use of org.dbflute.helper.HandyDate in project dbflute-core by dbflute.

the class DfHacoMapFile method mappingToDecoMapPiece.

// done hakiba cast check by hakiba (2017/07/29)
private DfHacoMapPiece mappingToDecoMapPiece(Map<String, Object> map) {
    String diffCode = (String) map.get("diffCode");
    String diffdate = (String) map.get("diffDate");
    String hacomment = (String) map.get("hacomment");
    String diffComment = (String) map.get("diffComment");
    @SuppressWarnings("unchecked") List<String> authorList = (List<String>) map.get("authorList");
    String pieceCode = (String) map.get("pieceCode");
    LocalDateTime pieceDatetime = new HandyDate((String) map.get("pieceDatetime")).getLocalDateTime();
    String pieceOwner = (String) map.get("pieceOwner");
    @SuppressWarnings("unchecked") List<String> previousPieceList = (List<String>) map.get("previousPieceList");
    return new DfHacoMapPiece(diffCode, diffdate, hacomment, diffComment, authorList, pieceCode, pieceOwner, pieceDatetime, previousPieceList);
}
Also used : LocalDateTime(java.time.LocalDateTime) HandyDate(org.dbflute.helper.HandyDate) ArrayList(java.util.ArrayList) List(java.util.List)

Example 15 with HandyDate

use of org.dbflute.helper.HandyDate in project dbflute-core by dbflute.

the class DfConventionalTakeAsserter method doAssertEmptyTable.

// ===================================================================================
// Empty Table
// ===========
protected void doAssertEmptyTable(DfConventionalTakeAssertMap propMap) {
    final List<DfTableMeta> allTableList = extractTableList();
    final List<DfTableMeta> emptyTableList = DfCollectionUtil.newArrayList();
    // null allowed
    final Date targetDate = propMap.getErrorIfFirstDateAfter();
    if (targetDate != null) {
        _log.info("...Using first-date for targeting of empty tables: targetDate=" + new HandyDate(targetDate).toString());
    }
    for (DfTableMeta tableMeta : allTableList) {
        if (!propMap.isEmptyTableTarget(tableMeta.getTableDbName())) {
            continue;
        }
        if (!determineEmptyTable(tableMeta)) {
            continue;
        }
        // empty table here
        if (targetDate != null) {
            // more determination
            if (isTableFirstDateAfter(tableMeta, targetDate)) {
                // new table: is target so keep
                emptyTableList.add(tableMeta);
            } else {
                _log.info("...Skipping the empty table by first-date: old-table=" + tableMeta.toString());
            }
        } else {
            // fixedly keep
            emptyTableList.add(tableMeta);
        }
    }
    if (!emptyTableList.isEmpty()) {
        throwTakeFinallyAssertionFailureEmptyTableException(emptyTableList);
    }
}
Also used : HandyDate(org.dbflute.helper.HandyDate) DfTableMeta(org.dbflute.logic.jdbc.metadata.info.DfTableMeta) Date(java.util.Date) HandyDate(org.dbflute.helper.HandyDate)

Aggregations

HandyDate (org.dbflute.helper.HandyDate)17 Date (java.util.Date)5 Method (java.lang.reflect.Method)3 LocalDateTime (java.time.LocalDateTime)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ParseDateExpressionFailureException (org.dbflute.exception.ParseDateExpressionFailureException)3 ReflectionFailureException (org.dbflute.util.DfReflectionUtil.ReflectionFailureException)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 StringKeyMap (org.dbflute.helper.StringKeyMap)2 DfTableMeta (org.dbflute.logic.jdbc.metadata.info.DfTableMeta)1 ScopeInfo (org.dbflute.util.Srl.ScopeInfo)1