Search in sources :

Example 46 with DfIllegalPropertySettingException

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

the class DfDispatchVariableResolver method throwNotFoundEnvironmentVariableException.

protected void throwNotFoundEnvironmentVariableException(String propTitle, String definedValue, String key, Map<String, String> map) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found the environment variable for the key");
    br.addItem("Property Title");
    br.addElement(propTitle);
    br.addItem("Defined in dfprop");
    br.addElement(definedValue);
    br.addItem("NotFound Key");
    br.addElement(key);
    br.addItem("Existing Variable");
    br.addElement(map.keySet());
    final String msg = br.buildExceptionMessage();
    throw new DfIllegalPropertySettingException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 47 with DfIllegalPropertySettingException

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

the class DfBasicProperties method getSourceCodeLineSeparator.

public String getSourceCodeLineSeparator() {
    if (_sourceCodeLineSeparator != null) {
        return _sourceCodeLineSeparator;
    }
    final String prop = getProperty("sourceCodeLineSeparator", null);
    if (prop != null) {
        // convert if specified
        _convertSourceCodeLineSeparator = true;
        if ("LF".equalsIgnoreCase(prop)) {
            _sourceCodeLineSeparator = "\n";
        } else if ("CRLF".equalsIgnoreCase(prop)) {
            _sourceCodeLineSeparator = "\r\n";
        } else {
            String msg = "Unknown line separator (only supported LF or CRLF): " + prop;
            throw new DfIllegalPropertySettingException(msg);
        }
    } else {
        // null
        final String defaultSeparator = getLanguageDependency().getSourceCodeLineSeparator();
        // as default but no convert
        _sourceCodeLineSeparator = defaultSeparator;
    }
    return _sourceCodeLineSeparator;
}
Also used : DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 48 with DfIllegalPropertySettingException

use of org.dbflute.exception.DfIllegalPropertySettingException 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 49 with DfIllegalPropertySettingException

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

the class DfLastaFluteProperties method reflectFreeGenMap.

// ===================================================================================
// FreeGen
// =======
public void reflectFreeGenMap(Map<String, Object> freeGenMap) {
    final Map<String, Object> lastafluteMap = getLastafluteMap();
    final String serviceName = findServiceName(lastafluteMap);
    if (Srl.is_Null_or_TrimmedEmpty(serviceName)) {
        // no use
        return;
    }
    show("...Loading freeGen settings from lastafluteMap: " + serviceName);
    final String domainPackage = (String) lastafluteMap.get("domainPackage");
    if (domainPackage == null) {
        throw new DfIllegalPropertySettingException("The property 'domainPackage' is required: " + lastafluteMap.keySet());
    }
    final String lastaDocDir = getLastaDocOutputDirectory();
    final DfLastaFluteFreeGenReflector reflector = createFreeGenReflector(lastafluteMap, freeGenMap, serviceName, domainPackage);
    reflector.reflectFrom(lastafluteMap, lastaDocDir);
}
Also used : DfLastaFluteFreeGenReflector(org.dbflute.properties.assistant.lastaflute.DfLastaFluteFreeGenReflector) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 50 with DfIllegalPropertySettingException

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

the class DfReplaceSchemaProperties method createAdditionalDropConnection.

public Connection createAdditionalDropConnection(Map<String, Object> additionalDropMap) throws SQLException {
    final String driver = getDatabaseProperties().getDatabaseDriver();
    String url = getAdditionalDropUrl(additionalDropMap);
    url = url != null && url.trim().length() > 0 ? url : getDatabaseProperties().getDatabaseUrl();
    String user = getAdditionalDropUser(additionalDropMap);
    final String password;
    if (user != null && user.trim().length() > 0) {
        password = getAdditionalDropPassword(additionalDropMap);
        if (password == null || password.trim().length() == 0) {
            String msg = "The password is required when the user is specified:";
            msg = msg + " user=" + user + " additionalDropMap=" + additionalDropMap;
            throw new DfIllegalPropertySettingException(msg);
        }
    } else {
        user = getDatabaseProperties().getDatabaseUser();
        password = getDatabaseProperties().getDatabasePassword();
    }
    final Properties prop = getAdditionalDropPropertiesMap(additionalDropMap);
    final Properties info = new Properties();
    info.putAll(prop);
    info.put("user", user);
    info.put("password", password);
    _log.info("...Creating a connection for additional drop");
    try {
        return createConnection(driver, url, getAdditionalDropSchema(additionalDropMap), info);
    } catch (RuntimeException e) {
        // contains connection info
        String msg = "Failed to connect the schema as additional drop: " + additionalDropMap;
        throw new SQLException(msg, e);
    }
}
Also used : SQLException(java.sql.SQLException) Properties(java.util.Properties) DfConnectionProperties(org.dbflute.properties.assistant.database.DfConnectionProperties) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Aggregations

DfIllegalPropertySettingException (org.dbflute.exception.DfIllegalPropertySettingException)76 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)58 Map (java.util.Map)9 DfClassificationTop (org.dbflute.properties.assistant.classification.DfClassificationTop)9 List (java.util.List)8 DfClassificationElement (org.dbflute.properties.assistant.classification.DfClassificationElement)8 LinkedHashMap (java.util.LinkedHashMap)6 ArrayList (java.util.ArrayList)5 StringKeyMap (org.dbflute.helper.StringKeyMap)4 DfClassificationGroup (org.dbflute.properties.assistant.classification.DfClassificationGroup)4 Collectors (java.util.stream.Collectors)3 ClassificationUndefinedHandlingType (org.dbflute.jdbc.ClassificationUndefinedHandlingType)3 DfRefClsElement (org.dbflute.properties.assistant.classification.DfRefClsElement)3 RichTextString (org.apache.poi.ss.usermodel.RichTextString)2 DfIllegalPropertyTypeException (org.dbflute.exception.DfIllegalPropertyTypeException)2 ScopeInfo (org.dbflute.util.Srl.ScopeInfo)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1