Search in sources :

Example 1 with DfIllegalPropertyTypeException

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

the class DfReplaceSchemaProperties method getAdditionalDropPropertiesMap.

@SuppressWarnings("unchecked")
public Properties getAdditionalDropPropertiesMap(Map<String, Object> additionalDropMap) {
    Object obj = additionalDropMap.get("propertiesMap");
    if (obj == null) {
        return new Properties();
    }
    if (!(obj instanceof Map)) {
        String msg = "The schema should be Map<String, String>:";
        msg = msg + " propertiesMap=" + obj + " type=" + obj.getClass();
        throw new DfIllegalPropertyTypeException(msg);
    }
    final Properties prop = new Properties();
    prop.putAll((Map<String, String>) obj);
    return prop;
}
Also used : DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException) Properties(java.util.Properties) DfConnectionProperties(org.dbflute.properties.assistant.database.DfConnectionProperties) LinkedHashMap(java.util.LinkedHashMap) DfConventionalTakeAssertMap(org.dbflute.properties.assistant.reps.DfConventionalTakeAssertMap) Map(java.util.Map)

Example 2 with DfIllegalPropertyTypeException

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

the class DfDatabaseProperties method getAdditionalSchemaMap.

protected Map<String, DfAdditionalSchemaInfo> getAdditionalSchemaMap() {
    if (_additionalSchemaMap != null) {
        return _additionalSchemaMap;
    }
    assertOldStyleAdditionalSchema();
    _additionalSchemaMap = StringKeyMap.createAsCaseInsensitive();
    final Map<String, Object> additionalSchemaMap = getVairousStringKeyMap("additionalSchemaMap");
    if (additionalSchemaMap.isEmpty()) {
        return _additionalSchemaMap;
    }
    final Set<Entry<String, Object>> entrySet = additionalSchemaMap.entrySet();
    for (Entry<String, Object> entry : entrySet) {
        final String identifiedSchema = entry.getKey();
        final Object obj = entry.getValue();
        if (obj == null) {
            String msg = "The value of schema in the property 'additionalSchemaMap' should be required:";
            msg = msg + " identifiedSchema=" + identifiedSchema;
            msg = msg + " additionalSchemaMap=" + additionalSchemaMap;
            throw new DfRequiredPropertyNotFoundException(msg);
        }
        if (!(obj instanceof Map<?, ?>)) {
            String msg = "The type of schema value in the property 'additionalSchemaMap' should be Map:";
            msg = msg + " type=" + DfTypeUtil.toClassTitle(obj) + " value=" + obj;
            throw new DfIllegalPropertyTypeException(msg);
        }
        @SuppressWarnings("unchecked") final Map<String, Object> elementMap = (Map<String, Object>) obj;
        final DfAdditionalSchemaInfo info = new DfAdditionalSchemaInfo();
        final String catalog;
        final boolean explicitCatalog;
        if (identifiedSchema.contains(".")) {
            catalog = Srl.substringFirstFront(identifiedSchema, ".");
            explicitCatalog = true;
        } else {
            // as main catalog
            catalog = getDatabaseCatalog();
            explicitCatalog = false;
        }
        final String schema = filterDatabaseSchema(Srl.substringFirstRear(identifiedSchema, "."));
        final UnifiedSchema unifiedSchema = createAsAdditionalSchema(catalog, schema, explicitCatalog);
        info.setUnifiedSchema(unifiedSchema);
        setupAdditionalSchemaObjectTypeTargetList(info, elementMap);
        setupAdditionalSchemaTableExceptList(info, elementMap);
        setupAdditionalSchemaTableTargetList(info, elementMap);
        setupAdditionalSchemaColumnExceptList(info, elementMap);
        info.setSuppressCommonColumn(isProperty("isSuppressCommonColumn", false, elementMap));
        info.setSuppressProcedure(isProperty("isSuppressProcedure", false, elementMap));
        _additionalSchemaMap.put(unifiedSchema.getIdentifiedSchema(), info);
    }
    return _additionalSchemaMap;
}
Also used : DfRequiredPropertyNotFoundException(org.dbflute.exception.DfRequiredPropertyNotFoundException) Entry(java.util.Map.Entry) DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException) DfAdditionalSchemaInfo(org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap)

Example 3 with DfIllegalPropertyTypeException

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

the class DfDatabaseProperties method setupAdditionalSchemaTableExceptList.

protected void setupAdditionalSchemaTableExceptList(DfAdditionalSchemaInfo info, Map<String, Object> elementMap) {
    final Object obj = elementMap.get("tableExceptList");
    if (obj == null) {
        final List<String> tableExceptList = DfCollectionUtil.emptyList();
        final List<String> tableExceptGenOnlyList = DfCollectionUtil.emptyList();
        info.setTableExceptList(tableExceptList);
        info.setTableExceptGenOnlyList(tableExceptGenOnlyList);
    } else if (!(obj instanceof List<?>)) {
        String msg = "The type of tableExceptList 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> tableExceptList = new ArrayList<String>();
        final List<String> tableExceptGenOnlyList = new ArrayList<String>();
        setupTableOrColumnExceptList(plainList, tableExceptList, tableExceptGenOnlyList);
        info.setTableExceptList(tableExceptList);
        info.setTableExceptGenOnlyList(tableExceptGenOnlyList);
    }
}
Also used : DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with DfIllegalPropertyTypeException

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

the class DfDatabaseProperties method setupAdditionalSchemaObjectTypeTargetList.

// -----------------------------------------------------
// Additional Schema Option
// ------------------------
protected void setupAdditionalSchemaObjectTypeTargetList(DfAdditionalSchemaInfo info, Map<String, Object> elementMap) {
    final Object obj = elementMap.get("objectTypeTargetList");
    if (obj == null) {
        @SuppressWarnings("unchecked") final List<String> objectTypeTargetList = Collections.EMPTY_LIST;
        info.setObjectTypeTargetList(objectTypeTargetList);
    } else if (!(obj instanceof List<?>)) {
        String msg = "The type of objectTypeTargetList 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> objectTypeTargetList = (List<String>) obj;
        info.setObjectTypeTargetList(objectTypeTargetList);
    }
}
Also used : DfIllegalPropertyTypeException(org.dbflute.exception.DfIllegalPropertyTypeException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with DfIllegalPropertyTypeException

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

the class DfDocumentProperties method getLoadDataReverseXlsLimit.

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

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