Search in sources :

Example 6 with DfIllegalPropertyTypeException

use of org.dbflute.exception.DfIllegalPropertyTypeException in project dbflute-core by dbflute.

the class DfDocumentProperties method getLoadDataReverseCellLengthLimit.

public Integer getLoadDataReverseCellLengthLimit() {
    final Map<String, Object> loadDataReverseMap = getLoadDataReverseMap();
    String limitExp = null;
    if (!loadDataReverseMap.isEmpty()) {
        limitExp = (String) loadDataReverseMap.get("cellLengthLimit");
    }
    if (limitExp == null) {
        // if null, default limit
        return null;
    }
    try {
        return Integer.valueOf(limitExp);
    } catch (NumberFormatException e) {
        String msg = "The property 'cellLengthLimit' of loadDataReverse in " + KEY_oldDocumentMap;
        msg = msg + " should be number but: value=" + limitExp;
        throw new DfIllegalPropertyTypeException(msg, e);
    }
}
Also used : DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException)

Example 7 with DfIllegalPropertyTypeException

use of org.dbflute.exception.DfIllegalPropertyTypeException in project dbflute-core by dbflute.

the class DfIncludeQueryProperties method extractColumnDrivenInterfaceMap.

protected Map<String, Map<String, List<String>>> extractColumnDrivenInterfaceMap(Map<String, Object> targetMap) {
    // ; $MEMBER = map:{
    // ; BIRTHDATE(Date) = list:{ !GreaterThan ; !LessThan }
    // ; MEMBER_NAME(String) = list:{}
    // }
    final Map<String, Map<String, List<String>>> interfaceMap = newLinkedHashMap();
    for (Entry<String, Object> propEntry : targetMap.entrySet()) {
        final String propType = propEntry.getKey();
        final Object value = propEntry.getValue();
        if (!(value instanceof Map)) {
            String msg = "The key '" + KEY_conditionBeanMap + "' should have map value:";
            msg = msg + " key=" + propType + " value=" + value + " targetMap=" + targetMap;
            throw new DfIllegalPropertyTypeException(msg);
        }
        if (!propType.startsWith("$")) {
            continue;
        }
        final String tableName = Srl.substringFirstRear(propType, "$");
        @SuppressWarnings("unchecked") final Map<String, List<String>> columnCKeyMap = (Map<String, List<String>>) value;
        Set<Entry<String, List<String>>> entrySet = columnCKeyMap.entrySet();
        for (Entry<String, List<String>> entry : entrySet) {
            final String columnExp = entry.getKey();
            final List<String> ckeyList = entry.getValue();
            if (!ckeyList.isEmpty()) {
                columnCKeyMap.put(columnExp, ckeyList);
            } else {
                final ScopeInfo scopeFirst = Srl.extractScopeFirst(columnExp, "(", ")");
                if (scopeFirst == null) {
                    String msg = "The column expression should be e.g. Member(Date) but: " + columnExp;
                    throw new DfIllegalPropertySettingException(msg);
                }
                final String currentPropType = scopeFirst.getContent().trim();
                final Set<String> ckeySet = _ckeySetMap.get(currentPropType);
                if (ckeySet == null) {
                    String msg = "Unknown condition-key: " + currentPropType + ", expected=" + _ckeySetMap.keySet();
                    throw new DfIllegalPropertySettingException(msg);
                }
                final List<String> allCKeyList = new ArrayList<String>();
                for (String ckey : ckeySet) {
                    allCKeyList.add("!" + ckey);
                }
                columnCKeyMap.put(columnExp, allCKeyList);
            }
        }
        interfaceMap.put(tableName, columnCKeyMap);
    }
    return interfaceMap;
}
Also used : ArrayList(java.util.ArrayList) ScopeInfo(org.dbflute.util.Srl.ScopeInfo) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException) DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap)

Example 8 with DfIllegalPropertyTypeException

use of org.dbflute.exception.DfIllegalPropertyTypeException in project dbflute-core by dbflute.

the class DfOutsideSqlProperties method getSqlLocationList.

public List<DfOutsideSqlLocation> getSqlLocationList() {
    if (_outsideSqlLocationList != null) {
        return _outsideSqlLocationList;
    }
    _outsideSqlLocationList = new ArrayList<DfOutsideSqlLocation>();
    // basically unused
    final String mainProjectName = "main";
    final String mainDir = getMainSqlDirectory();
    final String mainOutput = getSql2EntityOutputDirectory();
    _outsideSqlLocationList.add(createOutsideSqlLocation(mainProjectName, mainDir, mainOutput, false, false));
    final Object obj = getApplicationOutsideSqlMap();
    if (!(obj instanceof Map<?, ?>)) {
        String msg = "The property 'applicationOutsideSqlMap' should be Map: " + obj.getClass();
        throw new DfIllegalPropertyTypeException(msg);
    }
    @SuppressWarnings("unchecked") final Map<String, Map<String, String>> sqlApMap = (Map<String, Map<String, String>>) obj;
    if (sqlApMap.isEmpty()) {
        return _outsideSqlLocationList;
    }
    final DfLanguageDependency lang = getBasicProperties().getLanguageDependency();
    final String defaultSqlDirectory = lang.getOutsideSqlDirectory();
    final String defaultMainProgramDirectory = lang.getMainProgramDirectory();
    for (Entry<String, Map<String, String>> entry : sqlApMap.entrySet()) {
        final String applicationDir = entry.getKey();
        final Map<String, String> elementMap = entry.getValue();
        // basically for display
        final String projectName;
        {
            final String lastName = Srl.substringLastRear(applicationDir, "/");
            if (Srl.is_Null_or_TrimmedEmpty(lastName) || Srl.equalsPlain(lastName, ".", "..")) {
                projectName = applicationDir;
            } else {
                projectName = lastName;
            }
        }
        final String sqlDirectory;
        {
            String plainDir = elementMap.get("sqlDirectory");
            if (Srl.is_Null_or_TrimmedEmpty(plainDir)) {
                plainDir = defaultSqlDirectory;
            }
            sqlDirectory = doGetSqlDirectory(applicationDir + "/" + plainDir);
        }
        final String sql2EntityOutputDirectory;
        {
            String plainDir = elementMap.get("sql2EntityOutputDirectory");
            if (Srl.is_Null_or_TrimmedEmpty(plainDir)) {
                plainDir = defaultMainProgramDirectory;
            }
            sql2EntityOutputDirectory = applicationDir + "/" + plainDir;
        }
        final boolean suppressDirectoryCheck;
        {
            String value = elementMap.get("isSuppressDirectoryCheck");
            if (Srl.is_NotNull_and_NotTrimmedEmpty(value) && value.trim().equalsIgnoreCase("true")) {
                suppressDirectoryCheck = true;
            } else {
                suppressDirectoryCheck = false;
            }
        }
        final DfOutsideSqlLocation sqlApLocation = createOutsideSqlLocation(projectName, sqlDirectory, sql2EntityOutputDirectory, true, suppressDirectoryCheck);
        _outsideSqlLocationList.add(sqlApLocation);
    }
    return _outsideSqlLocationList;
}
Also used : DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException) DfOutsideSqlLocation(org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlLocation) Map(java.util.Map) DfLanguageDependency(org.dbflute.logic.generate.language.DfLanguageDependency)

Example 9 with DfIllegalPropertyTypeException

use of org.dbflute.exception.DfIllegalPropertyTypeException in project dbflute-core by dbflute.

the class DfDatabaseProperties method setupAdditionalSchemaTableTargetList.

protected void setupAdditionalSchemaTableTargetList(DfAdditionalSchemaInfo info, Map<String, Object> elementMap) {
    final Object obj = elementMap.get("tableTargetList");
    if (obj == null) {
        final List<String> tableTargetList = DfCollectionUtil.emptyList();
        final List<String> tableTargetGenOnlyList = DfCollectionUtil.emptyList();
        info.setTableTargetList(tableTargetList);
        info.setTableTargetGenOnlyList(tableTargetGenOnlyList);
    } else if (!(obj instanceof List<?>)) {
        String msg = "The type of tableTargetList in the property 'additionalSchemaMap' should be List:";
        msg = msg + " type=" + DfTypeUtil.toClassTitle(obj) + " value=" + obj;
        throw new DfIllegalPropertyTypeException(msg);
    } else {
        @SuppressWarnings("unchecked") final List<String> plainList = (List<String>) obj;
        final List<String> tableTargetList = new ArrayList<String>();
        final List<String> tableTargetGenOnlyList = new ArrayList<String>();
        setupTableOrColumnTargetList(plainList, tableTargetList, tableTargetGenOnlyList);
        info.setTableTargetList(tableTargetList);
        info.setTableTargetGenOnlyList(tableTargetGenOnlyList);
    }
}
Also used : DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with DfIllegalPropertyTypeException

use of org.dbflute.exception.DfIllegalPropertyTypeException in project dbflute-core by dbflute.

the class DfDatabaseProperties method setupAdditionalSchemaColumnExceptList.

protected void setupAdditionalSchemaColumnExceptList(DfAdditionalSchemaInfo info, Map<String, Object> elementMap) {
    final Object obj = elementMap.get("columnExceptMap");
    if (obj == null) {
        final Map<String, List<String>> columnExceptMap = DfCollectionUtil.emptyMap();
        final Map<String, List<String>> columnExceptGenOnlyMap = DfCollectionUtil.emptyMap();
        info.setColumnExceptMap(columnExceptMap);
        info.setColumnExceptGenOnlyMap(columnExceptGenOnlyMap);
    } else if (!(obj instanceof Map<?, ?>)) {
        String msg = "The type of columnExceptMap in the property 'additionalSchemaMap' should be Map:";
        msg = msg + " type=" + DfTypeUtil.toClassTitle(obj) + " value=" + obj;
        throw new DfIllegalPropertyTypeException(msg);
    } else {
        @SuppressWarnings("unchecked") final Map<String, List<String>> plainMap = (Map<String, List<String>>) obj;
        final Map<String, List<String>> columnExceptMap = StringKeyMap.createAsFlexible();
        final Map<String, List<String>> columnExceptGenOnlyMap = StringKeyMap.createAsFlexible();
        for (Entry<String, List<String>> entry : plainMap.entrySet()) {
            final String key = entry.getKey();
            final List<String> plainList = entry.getValue();
            final List<String> colummExceptList = new ArrayList<String>();
            final List<String> columnExceptGenOnlyList = new ArrayList<String>();
            setupTableOrColumnExceptList(plainList, colummExceptList, columnExceptGenOnlyList);
            columnExceptMap.put(key, colummExceptList);
            columnExceptGenOnlyMap.put(key, columnExceptGenOnlyList);
        }
        info.setColumnExceptMap(columnExceptMap);
        info.setColumnExceptGenOnlyMap(columnExceptGenOnlyMap);
    }
}
Also used : DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap)

Aggregations

DfIllegalPropertyTypeException (org.dbflute.exception.DfIllegalPropertyTypeException)11 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Map (java.util.Map)5 LinkedHashMap (java.util.LinkedHashMap)4 Entry (java.util.Map.Entry)3 StringKeyMap (org.dbflute.helper.StringKeyMap)3 DfIllegalPropertySettingException (org.dbflute.exception.DfIllegalPropertySettingException)2 Properties (java.util.Properties)1 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)1 DfRequiredPropertyNotFoundException (org.dbflute.exception.DfRequiredPropertyNotFoundException)1 DfLanguageDependency (org.dbflute.logic.generate.language.DfLanguageDependency)1 DfOutsideSqlLocation (org.dbflute.logic.sql2entity.analyzer.DfOutsideSqlLocation)1 DfAdditionalSchemaInfo (org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo)1 DfConnectionProperties (org.dbflute.properties.assistant.database.DfConnectionProperties)1 DfConventionalTakeAssertMap (org.dbflute.properties.assistant.reps.DfConventionalTakeAssertMap)1 ScopeInfo (org.dbflute.util.Srl.ScopeInfo)1