Search in sources :

Example 1 with UndefinedClassificationCodeException

use of org.dbflute.exception.UndefinedClassificationCodeException in project dbflute-core by dbflute.

the class FunCustodial method throwUndefinedClassificationCodeException.

protected static void throwUndefinedClassificationCodeException(String tableDbName, String columnDbName, ClassificationMeta meta, Object code) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Undefined classification code was set to the entity.");
    br.addItem("Advice");
    br.addElement("Confirm the value of the classification column on your database,");
    br.addElement("or setting value to your entity.");
    br.addElement("The code is NOT one of classification code defined on DBFlute.");
    br.addElement("");
    br.addElement("_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/");
    br.addElement(" Use formal code!");
    br.addElement("  Or add the code to classification definition.");
    br.addElement("_/_/_/_/_/_/_/_/_/_/");
    br.addElement("");
    br.addElement("Or if you (reluctantly) need to allow it, change the option like this:");
    br.addElement("but *Deprecated");
    br.addElement("(classificationDefinitionMap.dfprop)");
    br.addElement("    ; [classification-name] = list:{");
    br.addElement("        ; map:{");
    br.addElement("            ; topComment=...; codeType=...");
    br.addElement("            ; undefinedHandlingType=ALLOWED");
    br.addElement("        }");
    br.addElement("        map:{...}");
    br.addElement("    }");
    br.addElement("*for your information, the default of undefinedHandlingType is LOGGING");
    br.addItem("Table");
    br.addElement(tableDbName);
    br.addItem("Column");
    br.addElement(columnDbName);
    br.addItem("Classification");
    br.addElement(meta.classificationName());
    final List<Classification> listAll = meta.listAll();
    final StringBuilder sb = new StringBuilder();
    for (Classification cls : listAll) {
        if (sb.length() > 0) {
            sb.append(", ");
        }
        sb.append(cls.name()).append("(").append(cls.code()).append(")");
    }
    br.addElement(sb.toString());
    br.addItem("Undefined Code");
    br.addElement(code);
    final String msg = br.buildExceptionMessage();
    throw new UndefinedClassificationCodeException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) Classification(org.dbflute.jdbc.Classification) UndefinedClassificationCodeException(org.dbflute.exception.UndefinedClassificationCodeException)

Aggregations

UndefinedClassificationCodeException (org.dbflute.exception.UndefinedClassificationCodeException)1 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 Classification (org.dbflute.jdbc.Classification)1