use of org.dbflute.exception.ParseDateExpressionFailureException in project dbflute-core by dbflute.
the class DfLoadingControlProp method analyzeDateAdjustmentMap.
protected void analyzeDateAdjustmentMap(String dataDirectory, Map<String, Object> analyzedMap, String key, Object value) {
// ; df:originDate = 2013/03/09
// ; $$ALL$$ = addDay($distance)
// ; MEMBER = map:{
// ; BIRTHDATE = addDay(6)
// }
final Map<String, Object> flTableMap = StringKeyMap.createAsFlexibleOrdered();
@SuppressWarnings("unchecked") final Map<String, Object> elementTableMap = (Map<String, Object>) value;
for (Entry<String, Object> elementTableEntry : elementTableMap.entrySet()) {
final String tableName = elementTableEntry.getKey();
final Object elementTableValue = elementTableEntry.getValue();
final Object registeredTableValue;
if (elementTableValue != null) {
if (KEY_ORIGIN_DATE.equalsIgnoreCase(tableName)) {
final String originExp = elementTableValue.toString();
final HandyDate originDate;
try {
originDate = new HandyDate(originExp);
} catch (ParseDateExpressionFailureException e) {
throwLoadingControlOriginDateParseFailureException(dataDirectory, originExp, e);
// unreachable
return;
}
final java.util.Date currentDate = DBFluteSystem.currentDate();
registeredTableValue = originDate.getDate();
flTableMap.put(KEY_DISTANCE_YEARS, originDate.calculateCalendarDistanceYears(currentDate));
flTableMap.put(KEY_DISTANCE_MONTHS, originDate.calculateCalendarDistanceMonths(currentDate));
flTableMap.put(KEY_DISTANCE_DAYS, originDate.calculateCalendarDistanceDays(currentDate));
} else if (KEY_MILLIS_COLUMN_LIST.equalsIgnoreCase(tableName)) {
// not need filter
registeredTableValue = elementTableValue;
} else {
@SuppressWarnings("unchecked") final Map<String, Object> elementColumnMap = (Map<String, Object>) elementTableValue;
final Map<String, Object> flColumnMap = StringKeyMap.createAsFlexibleOrdered();
flColumnMap.putAll(elementColumnMap);
registeredTableValue = flColumnMap;
}
} else {
registeredTableValue = null;
}
flTableMap.put(tableName, registeredTableValue);
}
analyzedMap.put(key, flTableMap);
}
use of org.dbflute.exception.ParseDateExpressionFailureException in project dbflute-core by dbflute.
the class HandyDate method throwParseDateExpressionFailureException.
protected void throwParseDateExpressionFailureException(String exp, ParseDateException e) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Failed to parse the expression as date.");
br.addItem("Expression");
br.addElement(exp);
final String msg = br.buildExceptionMessage();
throw new ParseDateExpressionFailureException(msg, e);
}
use of org.dbflute.exception.ParseDateExpressionFailureException in project dbflute-core by dbflute.
the class DfSPolicyFirstDateSecretary method doDetermineFirstDate.
protected boolean doDetermineFirstDate(DfSPolicyStatement statement, String ifValue, boolean notIfValue, Predicate<Date> determiner) {
if (notIfValue) {
// "is not" is unsupported for firstDate
throwSchemaPolicyCheckIllegalFirstDateException(statement, ifValue);
// unreachable
return false;
}
if (ifValue.startsWith("after:")) {
// e.g. if firstDate is after:2018/05/03
final String dateExp = Srl.substringFirstRear(ifValue, "after:").trim();
if (dateExp.length() > EXAMPLE_DATE_EXPRESSION.length()) {
// e.g. has time part
throwSchemaPolicyCheckIllegalDateExpressionFormatException(statement, dateExp, null);
}
final Date targetDate;
try {
targetDate = new HandyDate(dateExp).getDate();
} catch (ParseDateExpressionFailureException e) {
throwSchemaPolicyCheckIllegalDateExpressionFormatException(statement, dateExp, e);
// unreachable
return false;
}
return determiner.test(targetDate);
} else {
// only "after:" supported because other patterns might not be needed
// (and difficult logic needs because of no-existing firstDate tables)
throwSchemaPolicyCheckIllegalFirstDateException(statement, ifValue);
// unreachable
return false;
}
}
use of org.dbflute.exception.ParseDateExpressionFailureException in project dbflute-core by dbflute.
the class DfLoadingControlProp method analyzeDateAdjustmentMap.
protected void analyzeDateAdjustmentMap(String dataDirectory, Map<String, Object> analyzedMap, String key, Object value) {
// ; df:originDate = 2013/03/09
// ; $$ALL$$ = addDay($distance)
// ; MEMBER = map:{
// ; BIRTHDATE = addDay(6)
// }
final Map<String, Object> flTableMap = StringKeyMap.createAsFlexibleOrdered();
@SuppressWarnings("unchecked") final Map<String, Object> elementTableMap = (Map<String, Object>) value;
for (Entry<String, Object> elementTableEntry : elementTableMap.entrySet()) {
final String tableName = elementTableEntry.getKey();
final Object elementTableValue = elementTableEntry.getValue();
final Object registeredTableValue;
if (elementTableValue != null) {
if (KEY_ORIGIN_DATE.equalsIgnoreCase(tableName)) {
final String originExp = elementTableValue.toString();
final HandyDate originDate;
try {
originDate = new HandyDate(originExp);
} catch (ParseDateExpressionFailureException e) {
throwLoadingControlOriginDateParseFailureException(dataDirectory, originExp, e);
// unreachable
return;
}
final java.util.Date currentDate = DBFluteSystem.currentDate();
registeredTableValue = originDate.getDate();
flTableMap.put(KEY_DISTANCE_YEARS, originDate.calculateCalendarDistanceYears(currentDate));
flTableMap.put(KEY_DISTANCE_MONTHS, originDate.calculateCalendarDistanceMonths(currentDate));
flTableMap.put(KEY_DISTANCE_DAYS, originDate.calculateCalendarDistanceDays(currentDate));
} else if (KEY_MILLIS_COLUMN_LIST.equalsIgnoreCase(tableName)) {
// not need filter
registeredTableValue = elementTableValue;
} else {
@SuppressWarnings("unchecked") final Map<String, Object> elementColumnMap = (Map<String, Object>) elementTableValue;
final Map<String, Object> flColumnMap = StringKeyMap.createAsFlexibleOrdered();
flColumnMap.putAll(elementColumnMap);
registeredTableValue = flColumnMap;
}
} else {
registeredTableValue = null;
}
flTableMap.put(tableName, registeredTableValue);
}
analyzedMap.put(key, flTableMap);
}
Aggregations