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);
}
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;
}
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;
}
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);
}
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);
}
}
Aggregations