Search in sources :

Example 1 with DfSPolicyParsedPolicyPart

use of org.dbflute.logic.doc.spolicy.parsed.DfSPolicyParsedPolicy.DfSPolicyParsedPolicyPart in project dbflute-core by dbflute.

the class DfSPolicyChecker method parsePolicy.

// ===================================================================================
// Parse Policy
// ============
protected DfSPolicyParsedPolicy parsePolicy() {
    _log.info("...Parsing schema policy map: " + _policyMap.keySet());
    DfSPolicyParsedPolicyPart wholePolicyPart = null;
    DfSPolicyParsedPolicyPart tablePolicyPart = null;
    DfSPolicyParsedPolicyPart columnPolicyPart = null;
    for (Entry<String, Object> entry : _policyMap.entrySet()) {
        final String key = entry.getKey();
        final Object value = entry.getValue();
        if (key.equals("wholeMap")) {
            @SuppressWarnings("unchecked") final Map<String, Object> wholeMap = (Map<String, Object>) value;
            final List<String> themeList = extractThemeList(wholeMap);
            wholePolicyPart = new DfSPolicyParsedPolicyPart(themeList, Collections.emptyList());
        } else if (key.equals("tableMap")) {
            @SuppressWarnings("unchecked") final Map<String, Object> tableMap = (Map<String, Object>) value;
            final List<String> themeList = extractThemeList(tableMap);
            tablePolicyPart = new DfSPolicyParsedPolicyPart(themeList, extractStatementList(tableMap));
        } else if (key.equals("columnMap")) {
            @SuppressWarnings("unchecked") final Map<String, Object> columnMap = (Map<String, Object>) value;
            final List<String> themeList = extractThemeList(columnMap);
            columnPolicyPart = new DfSPolicyParsedPolicyPart(themeList, extractStatementList(columnMap));
        } else {
            if (!Srl.equalsPlain(key, "tableExceptList", "tableTargetList", "columnExceptMap", "isMainSchemaOnly")) {
                _logicalSecretary.throwSchemaPolicyCheckUnknownPropertyException(key);
            }
        }
    }
    if (wholePolicyPart == null) {
        wholePolicyPart = new DfSPolicyParsedPolicyPart(Collections.emptyList(), Collections.emptyList());
    }
    if (tablePolicyPart == null) {
        tablePolicyPart = new DfSPolicyParsedPolicyPart(Collections.emptyList(), Collections.emptyList());
    }
    if (columnPolicyPart == null) {
        columnPolicyPart = new DfSPolicyParsedPolicyPart(Collections.emptyList(), Collections.emptyList());
    }
    return new DfSPolicyParsedPolicy(wholePolicyPart, tablePolicyPart, columnPolicyPart);
}
Also used : DfSPolicyParsedPolicyPart(org.dbflute.logic.doc.spolicy.parsed.DfSPolicyParsedPolicy.DfSPolicyParsedPolicyPart) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) DfSPolicyParsedPolicy(org.dbflute.logic.doc.spolicy.parsed.DfSPolicyParsedPolicy)

Example 2 with DfSPolicyParsedPolicyPart

use of org.dbflute.logic.doc.spolicy.parsed.DfSPolicyParsedPolicy.DfSPolicyParsedPolicyPart in project dbflute-core by dbflute.

the class DfSPolicyChecker method doCheckTableColumn.

protected void doCheckTableColumn(DfSPolicyParsedPolicy policy, DfSPolicyResult result, Table table) {
    final DfSPolicyParsedPolicyPart tablePolicyPart = policy.getTablePolicyPart();
    _tableThemeChecker.checkTableTheme(tablePolicyPart.getThemeList(), result, table);
    _tableStatementChecker.checkTableStatement(tablePolicyPart.getStatementList(), result, table);
    final List<Column> columnList = table.getColumnList();
    final DfSPolicyParsedPolicyPart columnPolicyPart = policy.getColumnPolicyPart();
    for (Column column : columnList) {
        if (!isTargetColumn(column)) {
            continue;
        }
        _columnThemeChecker.checkColumnTheme(columnPolicyPart.getThemeList(), result, column);
        _columnStatementChecker.checkColumnStatement(columnPolicyPart.getStatementList(), result, column);
    }
}
Also used : Column(org.apache.torque.engine.database.model.Column) DfSPolicyParsedPolicyPart(org.dbflute.logic.doc.spolicy.parsed.DfSPolicyParsedPolicy.DfSPolicyParsedPolicyPart)

Aggregations

DfSPolicyParsedPolicyPart (org.dbflute.logic.doc.spolicy.parsed.DfSPolicyParsedPolicy.DfSPolicyParsedPolicyPart)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Column (org.apache.torque.engine.database.model.Column)1 DfSPolicyParsedPolicy (org.dbflute.logic.doc.spolicy.parsed.DfSPolicyParsedPolicy)1