Search in sources :

Example 6 with DfClassificationProperties

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"));
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashMap(java.util.HashMap) DfClassificationProperties(org.dbflute.properties.DfClassificationProperties) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with DfClassificationProperties

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);
}
Also used : DfClassificationProperties(org.dbflute.properties.DfClassificationProperties)

Example 8 with DfClassificationProperties

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());
    }
}
Also used : DfClassificationProperties(org.dbflute.properties.DfClassificationProperties)

Example 9 with DfClassificationProperties

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();
        }
    }
}
Also used : ClassificationUndefinedHandlingType(org.dbflute.jdbc.ClassificationUndefinedHandlingType) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) DfClassificationProperties(org.dbflute.properties.DfClassificationProperties)

Example 10 with DfClassificationProperties

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"));
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashMap(java.util.HashMap) DfClassificationProperties(org.dbflute.properties.DfClassificationProperties) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

DfClassificationProperties (org.dbflute.properties.DfClassificationProperties)15 Map (java.util.Map)9 HashMap (java.util.HashMap)7 LinkedHashMap (java.util.LinkedHashMap)7 DfClassificationTop (org.dbflute.properties.assistant.classification.DfClassificationTop)5 ArrayList (java.util.ArrayList)4 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 List (java.util.List)2 ClassificationUndefinedHandlingType (org.dbflute.jdbc.ClassificationUndefinedHandlingType)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 DfIllegalPropertySettingException (org.dbflute.exception.DfIllegalPropertySettingException)1 MapListFile (org.dbflute.helper.mapstring.MapListFile)1 DfClassificationElement (org.dbflute.properties.assistant.classification.DfClassificationElement)1 DfClassificationLiteralArranger (org.dbflute.properties.assistant.classification.DfClassificationLiteralArranger)1 DfRefClsElement (org.dbflute.properties.assistant.classification.DfRefClsElement)1 DfClsElementLiteralArranger (org.dbflute.properties.assistant.classification.element.proploading.DfClsElementLiteralArranger)1 DfRefClsElement (org.dbflute.properties.assistant.classification.refcls.DfRefClsElement)1