Search in sources :

Example 11 with DfClassificationProperties

use of org.dbflute.properties.DfClassificationProperties in project dbflute-core by dbflute.

the class DfClassificationPropertiesTest method test_isTableClassificationSuppressAutoDeploy.

public void test_isTableClassificationSuppressAutoDeploy() {
    // ## Arrange ##
    final Map<String, Map<String, String>> deploymentMap = new LinkedHashMap<String, Map<String, String>>();
    final DfClassificationProperties prop = createClassificationProperties(deploymentMap);
    final Map<String, String> elementMap = new HashMap<String, String>();
    // ## Act & Assert ##
    assertFalse(prop.isElementMapSuppressAutoDeploy(elementMap));
    elementMap.put("suppressAutoDeploy", "false");
    assertFalse(prop.isElementMapSuppressAutoDeploy(elementMap));
    elementMap.put("suppressAutoDeploy", "true");
    assertTrue(prop.isElementMapSuppressAutoDeploy(elementMap));
    elementMap.put("suppressAutoDeploy", "True");
    assertTrue(prop.isElementMapSuppressAutoDeploy(elementMap));
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashMap(java.util.HashMap) DfClassificationProperties(org.dbflute.properties.DfClassificationProperties) LinkedHashMap(java.util.LinkedHashMap)

Example 12 with DfClassificationProperties

use of org.dbflute.properties.DfClassificationProperties in project dbflute-core by dbflute.

the class DfSPolicyInRepsChecker method initializeClassificationDeployment.

protected void initializeClassificationDeployment(final Database database) {
    final DfClassificationProperties clsProp = getClassificationProperties();
    clsProp.initializeClassificationDeployment(database);
}
Also used : DfClassificationProperties(org.dbflute.properties.DfClassificationProperties)

Example 13 with DfClassificationProperties

use of org.dbflute.properties.DfClassificationProperties in project dbflute-core by dbflute.

the class Column method hasCheckImplicitSetClassification.

protected boolean hasCheckImplicitSetClassification() {
    // old style
    if (!hasClassification()) {
        return false;
    }
    final String classificationName = getClassificationName();
    if (classificationName == null) {
        return false;
    }
    final DfClassificationProperties prop = getClassificationProperties();
    final DfClassificationTop classificationTop = prop.getClassificationTop(classificationName);
    return classificationTop != null && classificationTop.isCheckImplicitSet();
}
Also used : DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfClassificationProperties(org.dbflute.properties.DfClassificationProperties)

Example 14 with DfClassificationProperties

use of org.dbflute.properties.DfClassificationProperties in project dbflute-core by dbflute.

the class DfAppClsTableLoader method loadTable.

// ===================================================================================
// Load Table
// ==========
// ; resourceMap = map:{
// ; baseDir = ../src/main
// ; resourceType = APP_CLS
// ; resourceFile = ../../../dockside_appcls.properties
// }
// ; outputMap = map:{
// ; templateFile = LaAppCDef.vm
// ; outputDirectory = $$baseDir$$/java
// ; package = org.dbflute...
// ; className = unused
// }
// ; optionMap = map:{
// }
@Override
public DfFreeGenMetaData loadTable(String requestName, DfFreeGenResource resource, DfFreeGenMapProp mapProp) {
    final String resourceFile = resource.getResourceFile();
    final Map<String, Object> appClsMap = readAppClsMap(resourceFile);
    boolean hasRefCls = false;
    final DfClassificationProperties clsProp = getClassificationProperties();
    final DfClsElementLiteralArranger literalArranger = new DfClsElementLiteralArranger();
    final List<DfClassificationTop> topList = new ArrayList<DfClassificationTop>();
    for (Entry<String, Object> entry : appClsMap.entrySet()) {
        final String classificationName = entry.getKey();
        final DfClassificationTop classificationTop = new DfClassificationTop(classificationName);
        topList.add(classificationTop);
        DfRefClsElement refClsElement = null;
        @SuppressWarnings("unchecked") final List<Map<String, Object>> elementMapList = (List<Map<String, Object>>) entry.getValue();
        for (Map<String, Object> elementMap : elementMapList) {
            if (isElementMapTop(elementMap)) {
                // e.g. map:{ topComment=... ; codeType=String }
                classificationTop.acceptBasicItem(elementMap);
                classificationTop.putGroupingAll(clsProp.getElementMapGroupingMap(elementMap));
                classificationTop.putDeprecatedAll(clsProp.getElementMapDeprecatedMap(elementMap));
            } else {
                if (isElementMapRefCls(elementMap)) {
                    // e.g. map:{ refCls=maihamadb@MemberStatus ; refType=included }
                    refClsElement = arrangeRefCls(resource, classificationName, classificationTop, refClsElement, elementMap);
                } else {
                    // e.g. map:{ code=FML ; name=OneMan ; alias=ShowBase ; comment=Formalized }
                    arrangeLiteral(resource, classificationName, classificationTop, refClsElement, elementMap, literalArranger);
                }
            }
        }
        if (refClsElement != null) {
            // should be after all literal evaluation
            inheritRefClsGroup(classificationTop, refClsElement);
            refClsElement.verifyRelationshipByRefTypeIfNeeds(classificationTop);
            hasRefCls = true;
        }
    }
    final Map<String, Object> optionMap = mapProp.getOptionMap();
    // basically exists
    final String clsTheme = (String) optionMap.getOrDefault("clsTheme", getDefaultClsTheme());
    setupOptionMap(optionMap, topList, hasRefCls, clsTheme);
    // @since 1.2.5
    stopRedundantCommentIfNeeds(requestName, resourceFile, topList, optionMap);
    // for next appcls's refCls @since 1.2.5
    registerRefClsReference(requestName, clsTheme, topList, optionMap);
    // #for_now can be flexible? (table name is unused?)
    return DfFreeGenMetaData.asOnlyOne(optionMap, clsTheme, Collections.emptyList());
}
Also used : ArrayList(java.util.ArrayList) DfRefClsElement(org.dbflute.properties.assistant.classification.refcls.DfRefClsElement) DfClsElementLiteralArranger(org.dbflute.properties.assistant.classification.element.proploading.DfClsElementLiteralArranger) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) DfClassificationProperties(org.dbflute.properties.DfClassificationProperties)

Example 15 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)

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