Search in sources :

Example 1 with Classification

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

the class AbstractConditionQuery method cTNumL.

protected <PROPERTY extends Number> List<PROPERTY> cTNumL(Collection<? extends Classification> col, Class<PROPERTY> type) {
    // convert to number list
    if (col == null) {
        return null;
    }
    final List<PROPERTY> list = new ArrayList<PROPERTY>();
    for (Classification cls : col) {
        if (cls != null) {
            @SuppressWarnings("unchecked") final PROPERTY value = (PROPERTY) DfTypeUtil.toNumber(cls.code(), type);
            list.add(value);
        }
    }
    return list;
}
Also used : Classification(org.dbflute.jdbc.Classification) ArrayList(java.util.ArrayList)

Example 2 with Classification

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

the class IfCommentEvaluatorTest method test_evaluate_cdef.

public void test_evaluate_cdef() {
    // ## Arrange & Act && Assert ##
    Classification cdef = new MyCDef();
    // ## Act && Assert ##
    assertTrue(createEvaluator(cdef, "pmb.code() == 'Pixy'").evaluate());
}
Also used : Classification(org.dbflute.jdbc.Classification)

Example 3 with Classification

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

the class AbstractDBMeta method ccls.

// -----------------------------------------------------
// Write Converter
// ---------------
// these are static to avoid the FindBugs headache
// (implementations of PropertyGateway can be static class)
protected static void ccls(Entity entity, ColumnInfo columnInfo, Object code) {
    // old style, for compatibility, check only on entity after Java8
    if (code == null) {
        // no check null value which means no existence on DB
        return;
    }
    final ClassificationMeta meta = columnInfo.getClassificationMeta();
    if (meta == null) {
        // no way (just in case)
        return;
    }
    final ClassificationUndefinedHandlingType undefinedHandlingType = meta.undefinedHandlingType();
    if (!undefinedHandlingType.isChecked()) {
        // basically no way (not called if no check)
        return;
    }
    final Classification classification = gcls(entity, columnInfo, code);
    if (classification == null) {
        final String tableDbName = columnInfo.getDBMeta().getTableDbName();
        final String columnDbName = columnInfo.getColumnDbName();
        final boolean allowedByOption = entity.myundefinedClassificationAccessAllowed();
        FunCustodial.handleUndefinedClassificationCode(tableDbName, columnDbName, meta, code, allowedByOption);
    }
}
Also used : ClassificationMeta(org.dbflute.jdbc.ClassificationMeta) ClassificationUndefinedHandlingType(org.dbflute.jdbc.ClassificationUndefinedHandlingType) Classification(org.dbflute.jdbc.Classification)

Example 4 with Classification

use of org.dbflute.jdbc.Classification 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)

Example 5 with Classification

use of org.dbflute.jdbc.Classification in project lastaflute by lastaflute.

the class LaClassificationUtil method nativeFindByCode.

// ===================================================================================
// Native Method
// =============
// -----------------------------------------------------
// cls.of(code)
// ------------
protected static OptionalThing<Classification> nativeFindByCode(Class<?> cdefType, Object code) {
    assertArgumentNotNull("cdefType", cdefType);
    assertArgumentNotNull("code", code);
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(cdefType);
    final String methodName = "of";
    final Method method;
    try {
        method = beanDesc.getMethod(methodName, new Class<?>[] { Object.class });
    } catch (BeanMethodNotFoundException e) {
        String msg = "Failed to get the method " + methodName + "() of the classification type: " + cdefType;
        throw new ClassificationFindByCodeMethodNotFoundException(msg, e);
    }
    @SuppressWarnings("unchecked") final OptionalThing<Classification> opt = (OptionalThing<Classification>) DfReflectionUtil.invokeStatic(method, new Object[] { code });
    return opt;
}
Also used : BeanMethodNotFoundException(org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException) OptionalThing(org.dbflute.optional.OptionalThing) BeanDesc(org.lastaflute.di.helper.beans.BeanDesc) Classification(org.dbflute.jdbc.Classification) Method(java.lang.reflect.Method)

Aggregations

Classification (org.dbflute.jdbc.Classification)7 Method (java.lang.reflect.Method)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)1 UndefinedClassificationCodeException (org.dbflute.exception.UndefinedClassificationCodeException)1 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 ClassificationCodeType (org.dbflute.jdbc.ClassificationCodeType)1 ClassificationMeta (org.dbflute.jdbc.ClassificationMeta)1 ClassificationUndefinedHandlingType (org.dbflute.jdbc.ClassificationUndefinedHandlingType)1 OptionalThing (org.dbflute.optional.OptionalThing)1 BeanDesc (org.lastaflute.di.helper.beans.BeanDesc)1 BeanMethodNotFoundException (org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException)1