Search in sources :

Example 1 with ClassificationMeta

use of org.dbflute.jdbc.ClassificationMeta 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 2 with ClassificationMeta

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

the class LaClassificationUtil method nativeFindMeta.

// -----------------------------------------------------
// meta.find(name)
// ---------------
protected static OptionalThing<ClassificationMeta> nativeFindMeta(Class<?> defmetaType, String classificationName) {
    // old method
    assertArgumentNotNull("defmetaType", defmetaType);
    assertArgumentNotNull("classificationName", classificationName);
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(defmetaType);
    final String methodName = "find";
    final Method method;
    try {
        method = beanDesc.getMethod(methodName, new Class<?>[] { String.class });
    } catch (BeanMethodNotFoundException e) {
        String msg = "Failed to get the method " + methodName + "() of the def-meta type: " + defmetaType;
        throw new ClassificationMetaFindMethodNotFoundException(msg, e);
    }
    @SuppressWarnings("unchecked") OptionalThing<ClassificationMeta> opt = (OptionalThing<ClassificationMeta>) DfReflectionUtil.invokeStatic(method, new Object[] { classificationName });
    return opt;
}
Also used : BeanMethodNotFoundException(org.lastaflute.di.helper.beans.exception.BeanMethodNotFoundException) ClassificationMeta(org.dbflute.jdbc.ClassificationMeta) OptionalThing(org.dbflute.optional.OptionalThing) BeanDesc(org.lastaflute.di.helper.beans.BeanDesc) Method(java.lang.reflect.Method)

Aggregations

ClassificationMeta (org.dbflute.jdbc.ClassificationMeta)2 Method (java.lang.reflect.Method)1 Classification (org.dbflute.jdbc.Classification)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