use of org.dbflute.properties.DfClassificationProperties in project dbflute-core by dbflute.
the class DfClassificationPropertiesTest method test_getAllClassificationName_ByHint.
public void test_getAllClassificationName_ByHint() {
// ## Arrange ##
final Map<String, Map<String, String>> deploymentMap = new LinkedHashMap<String, Map<String, String>>();
{
final Map<String, String> columnClassificationMap = new LinkedHashMap<String, String>();
columnClassificationMap.put("ABC", "abc");
columnClassificationMap.put("suffix:_FLG", "Flg");
columnClassificationMap.put("DEF", "def");
deploymentMap.put(ALL_MARK, columnClassificationMap);
}
final DfClassificationProperties prop = createClassificationProperties(deploymentMap);
// ## Act & Assert ##
assertEquals("Flg", prop.getAllClassificationName("DELETE_FLG"));
assertEquals("Flg", prop.getAllClassificationName("delete_flg"));
assertEquals("Flg", prop.getAllClassificationName("VALID_FLG"));
assertEquals("Flg", prop.getAllClassificationName("valid_flg"));
}
use of org.dbflute.properties.DfClassificationProperties in project dbflute-core by dbflute.
the class DfPmbMetaData method createPropertyOptionClassification.
protected DfPmbPropertyOptionClassification createPropertyOptionClassification(String propertyName) {
DfPmbPropertyOptionClassification optionClassification = _optionClsMap.get(propertyName);
if (optionClassification != null) {
return optionClassification;
}
final DfPmbPropertyOptionFinder finder = createPropertyOptionFinder(propertyName);
final DfClassificationProperties clsProp = getClassificationProperties();
optionClassification = new DfPmbPropertyOptionClassification(this, propertyName, clsProp, finder);
_optionClsMap.put(propertyName, optionClassification);
return _optionClsMap.get(propertyName);
}
use of org.dbflute.properties.DfClassificationProperties in project dbflute-core by dbflute.
the class Database method initializeClassificationDeployment.
// -----------------------------------------------------
// ClassificationDeployment
// ------------------------
public void initializeClassificationDeployment() {
// also called by control velocity file (Sql2Entity)
final DfClassificationProperties clsProp = getClassificationProperties();
// Initialize classification definition before initializing deployment.
// Together!
clsProp.initializeClassificationDefinition();
// Initialize current target database.
clsProp.initializeClassificationDeployment(this);
// If this is in sql2entity task, initialize schema database.
if (_sql2entitySchemaData != null) {
clsProp.initializeClassificationDeployment(_sql2entitySchemaData.getDatabase());
}
}
use of org.dbflute.properties.DfClassificationProperties 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.properties.DfClassificationProperties in project dbflute-core by dbflute.
the class DfClassificationPropertiesTest method test_isAllClassificationColumn_ByHint.
public void test_isAllClassificationColumn_ByHint() {
// ## Arrange ##
final Map<String, Map<String, String>> deploymentMap = new LinkedHashMap<String, Map<String, String>>();
{
final Map<String, String> columnClassificationMap = new LinkedHashMap<String, String>();
columnClassificationMap.put("ABC", "abc");
columnClassificationMap.put("suffix:_FLG", "Flg");
columnClassificationMap.put("DEF", "def");
deploymentMap.put(ALL_MARK, columnClassificationMap);
}
final DfClassificationProperties prop = createClassificationProperties(deploymentMap);
// ## Act & Assert ##
assertTrue(prop.isAllClassificationColumn("DELETE_FLG"));
assertTrue(prop.isAllClassificationColumn("delete_flg"));
assertTrue(prop.isAllClassificationColumn("VALID_FLG"));
assertTrue(prop.isAllClassificationColumn("valid_flg"));
}
Aggregations