use of org.dbflute.jdbc.ClassificationUndefinedHandlingType in project dbflute-core by dbflute.
the class DfImplicitClassificationChecker method check.
public void check(File file, String tableDbName, String columnDbName, Connection conn) throws SQLException {
final DfClassificationProperties prop = getClassificationProperties();
final String classificationName = prop.getClassificationName(tableDbName, columnDbName);
final DfClassificationTop classificationTop = prop.getClassificationTop(classificationName);
if (classificationTop == null) {
// no way (just in case)
return;
}
if (classificationTop.isTableClassification()) {
// basically checked by FK constraint
return;
}
if (!classificationTop.isCheckClassificationCode() && !classificationTop.isCheckImplicitSet()) {
// no option
return;
}
final ClassificationUndefinedHandlingType undefinedHandlingType = classificationTop.getUndefinedHandlingType();
if (undefinedHandlingType == null) {
// no way (just in case)
return;
}
if (!undefinedHandlingType.isChecked()) {
// no handling option
return;
}
final boolean quote = prop.isCodeTypeNeedsQuoted(classificationName);
final List<String> codeList = prop.getClassificationElementCodeList(classificationName);
final String sql = buildDistinctSql(tableDbName, columnDbName, quote, codeList);
PreparedStatement ps = null;
ResultSet rs = null;
try {
_log.info(sql);
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
final List<String> illegalCodeList = new ArrayList<String>();
while (rs.next()) {
illegalCodeList.add(rs.getString(1));
}
if (!illegalCodeList.isEmpty()) {
handleLoadDataIllegalImplicitClassificationValueException(file, tableDbName, columnDbName, classificationName, codeList, illegalCodeList, undefinedHandlingType);
}
} finally {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
}
}
use of org.dbflute.jdbc.ClassificationUndefinedHandlingType in project dbflute-core by dbflute.
the class DfClassificationProperties method getElementMapUndefinedHandlingType.
@SuppressWarnings("unchecked")
protected ClassificationUndefinedHandlingType getElementMapUndefinedHandlingType(Map<?, ?> elementMap) {
if (isElementMapCheckImplicitSet(elementMap)) {
return ClassificationUndefinedHandlingType.EXCEPTION;
}
final String key = DfClassificationTop.KEY_UNDEFINED_HANDLING_TYPE;
final DfLittleAdjustmentProperties prop = getLittleAdjustmentProperties();
final ClassificationUndefinedHandlingType defaultType = prop.getClassificationUndefinedHandlingType();
final String defaultValue = defaultType.code();
final String code = getProperty(key, defaultValue, (Map<String, ? extends Object>) elementMap);
final ClassificationUndefinedHandlingType handlingType = ClassificationUndefinedHandlingType.codeOf(code);
if (handlingType == null) {
throwUnknownClassificationUndefinedCodeHandlingTypeException(code);
}
return handlingType;
}
use of org.dbflute.jdbc.ClassificationUndefinedHandlingType in project dbflute-core by dbflute.
the class DfImplicitClassificationChecker method check.
public void check(File file, String tableDbName, String columnDbName, Connection conn) throws SQLException {
final DfClassificationProperties prop = getClassificationProperties();
final String classificationName = prop.getClassificationName(tableDbName, columnDbName);
final DfClassificationTop classificationTop = prop.getClassificationTop(classificationName);
if (classificationTop == null) {
// no way (just in case)
return;
}
if (classificationTop.isTableClassification()) {
// basically checked by FK constraint
return;
}
if (!classificationTop.isCheckClassificationCode() && !classificationTop.isCheckImplicitSet()) {
// no option
return;
}
final ClassificationUndefinedHandlingType undefinedHandlingType = classificationTop.getUndefinedHandlingType();
if (undefinedHandlingType == null) {
// no way (just in case)
return;
}
if (!undefinedHandlingType.isChecked()) {
// no handling option
return;
}
final boolean quote = prop.isCodeTypeNeedsQuoted(classificationName);
final List<String> codeList = prop.getClassificationElementCodeList(classificationName);
final String sql = buildDistinctSql(tableDbName, columnDbName, quote, codeList);
PreparedStatement ps = null;
ResultSet rs = null;
try {
_log.info(sql);
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
final List<String> illegalCodeList = new ArrayList<String>();
while (rs.next()) {
illegalCodeList.add(rs.getString(1));
}
if (!illegalCodeList.isEmpty()) {
handleLoadDataIllegalImplicitClassificationValueException(file, tableDbName, columnDbName, classificationName, codeList, illegalCodeList, undefinedHandlingType);
}
} finally {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
}
}
use of org.dbflute.jdbc.ClassificationUndefinedHandlingType in project dbflute-core by dbflute.
the class DfLittleAdjustmentProperties method throwUnknownClassificationUndefinedHandlingTypeException.
protected void throwUnknownClassificationUndefinedHandlingTypeException(String code, String dfpropFile) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Unknown handling type of classification undefined code.");
br.addItem("Advice");
br.addElement("You can specify following types:");
for (ClassificationUndefinedHandlingType handlingType : ClassificationUndefinedHandlingType.values()) {
br.addElement(" " + handlingType.code());
}
final String exampleCode = ClassificationUndefinedHandlingType.EXCEPTION.code();
br.addElement("");
br.addElement("For example: (littleAdjustmentMap.dfprop)");
br.addElement("map:{");
br.addElement(" ...");
br.addElement(" ");
br.addElement(" ; classificationUndefinedCodeHandlingType = " + exampleCode);
br.addElement(" ...");
br.addElement("}");
br.addItem("Specified Unknown Type");
br.addElement(code);
br.addItem("dfprop File");
br.addElement(dfpropFile);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
use of org.dbflute.jdbc.ClassificationUndefinedHandlingType in project dbflute-core by dbflute.
the class DfClsTopLiteralArranger method getElementMapUndefinedHandlingType.
@SuppressWarnings("unchecked")
protected ClassificationUndefinedHandlingType getElementMapUndefinedHandlingType(Map<?, ?> elementMap) {
if (isElementMapCheckImplicitSet(elementMap)) {
return ClassificationUndefinedHandlingType.EXCEPTION;
}
final String key = DfClassificationTop.KEY_UNDEFINED_HANDLING_TYPE;
final DfLittleAdjustmentProperties prop = getLittleAdjustmentProperties();
final ClassificationUndefinedHandlingType defaultType = prop.getClassificationUndefinedHandlingType();
final String defaultValue = defaultType.code();
final String code = getProperty(key, defaultValue, (Map<String, ? extends Object>) elementMap);
final ClassificationUndefinedHandlingType handlingType = ClassificationUndefinedHandlingType.codeOf(code);
if (handlingType == null) {
throwUnknownClassificationUndefinedCodeHandlingTypeException(code);
}
return handlingType;
}
Aggregations