Search in sources :

Example 1 with ClassificationCodeType

use of org.dbflute.jdbc.ClassificationCodeType in project dbflute-core by dbflute.

the class ManualOrderOption method handleClassificationOrderValue.

// -----------------------------------------------------
// Classification
// --------------
protected Object handleClassificationOrderValue(Classification cls) {
    final Object orderValue;
    final String plainCode = cls.code();
    final ClassificationCodeType codeType = cls.meta().codeType();
    if (ClassificationCodeType.Number.equals(codeType)) {
        if ("true".equalsIgnoreCase(plainCode) || "false".equalsIgnoreCase(plainCode)) {
            // true or false of Number, e.g. MySQL's Boolean
            orderValue = toClassificationBooleanValue(plainCode);
        } else {
            orderValue = toClassificationIntegerValue(plainCode);
        }
    } else if (ClassificationCodeType.Boolean.equals(codeType)) {
        orderValue = toClassificationBooleanValue(plainCode);
    } else {
        orderValue = plainCode;
    }
    return orderValue;
}
Also used : ClassificationCodeType(org.dbflute.jdbc.ClassificationCodeType)

Example 2 with ClassificationCodeType

use of org.dbflute.jdbc.ClassificationCodeType in project dbflute-core by dbflute.

the class ManualOrderOption method resolveBoundValue.

// -----------------------------------------------------
// Resolve Bound
// -------------
protected Object resolveBoundValue(HpManualOrderThemeListHandler handler, Object plainValue, boolean suppressBinding) {
    if (plainValue == null) {
        return null;
    }
    if (plainValue instanceof SpecifiedColumn) {
        return resolveDreamCruiseExp(plainValue);
    }
    ClassificationCodeType codeType = null;
    if (plainValue instanceof Classification) {
        final Classification cls = (Classification) plainValue;
        plainValue = handleClassificationOrderValue(cls);
        codeType = cls.meta().codeType();
    }
    final Object boundExp;
    if (suppressBinding) {
        if (plainValue instanceof String) {
            if (canBeLiteralClassificationCodeType(codeType)) {
                boundExp = plainValue;
            } else {
                String notice = "The binding of string value is unsupported on the DBMS.";
                throwUnsupportedTypeSpecifiedException(notice, plainValue);
                // unreachable
                boundExp = null;
            }
        } else if (plainValue instanceof Number) {
            boundExp = buildLiteralNumberExpression(plainValue);
        } else if (isAnyLocalDate(plainValue) || plainValue instanceof Date) {
            // #date_parade
            boundExp = buildLiteralDateExpression(plainValue);
        } else {
            String notice = "The binding of the type is unsupported on the DBMS.";
            throwUnsupportedTypeSpecifiedException(notice, plainValue);
            // unreachable
            boundExp = null;
        }
    } else {
        boundExp = handler.register(THEME_KEY, plainValue);
    }
    return boundExp;
}
Also used : ClassificationCodeType(org.dbflute.jdbc.ClassificationCodeType) Classification(org.dbflute.jdbc.Classification) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn) Date(java.util.Date) LocalDate(java.time.LocalDate)

Aggregations

ClassificationCodeType (org.dbflute.jdbc.ClassificationCodeType)2 LocalDate (java.time.LocalDate)1 Date (java.util.Date)1 SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)1 Classification (org.dbflute.jdbc.Classification)1