use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfRefClsElement method checkRefExists.
protected void checkRefExists(DfClassificationTop classificationTop) {
final List<DfClassificationElement> webElementList = classificationTop.getClassificationElementList();
final List<DfClassificationElement> dbElementList = _dbClsTop.getClassificationElementList();
final List<DfClassificationElement> nonExistingList = webElementList.stream().filter(webElement -> {
return !dbElementList.stream().anyMatch(dbElement -> {
return webElement.getCode().equals(dbElement.getCode());
});
}).collect(Collectors.toList());
if (!nonExistingList.isEmpty()) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not found the web classification code in the DB classification");
br.addItem("Advice");
br.addElement("The codes of the web classification should be included");
br.addElement("in the DB classification because of refType='exists'.");
br.addElement("For example:");
br.addElement(" (x): web(A), db(B, C)");
br.addElement(" (x): web(A, B), db(A, C)");
br.addElement(" (x): web(A, B, C), db(A, B)");
br.addElement(" (o): web(A), db(A, B)");
br.addElement(" (o): web(A, B), db(A, B, C)");
br.addElement(" (o): web(A, B, C), db(A, B, C)");
br.addItem("WebCls");
final String webCodes = classificationTop.getClassificationElementList().stream().map(element -> {
return element.getCode();
}).collect(Collectors.joining(", "));
br.addElement(classificationTop.getClassificationName() + ": " + webCodes);
br.addItem("DBCls");
final String dbCodes = _dbClsTop.getClassificationElementList().stream().map(element -> {
return element.getCode();
}).collect(Collectors.joining(", "));
br.addElement(_dbClsTop.getClassificationName() + ": " + dbCodes);
br.addItem("Ref Type");
br.addElement(_refType);
br.addItem("Non-Existing Code");
br.addElement(nonExistingList.stream().map(element -> {
return element.getCode();
}).collect(Collectors.joining(", ")));
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfIncludeQueryProperties method extractColumnDrivenTranslatedMap.
protected Map<String, Map<String, Map<String, List<String>>>> extractColumnDrivenTranslatedMap(Map<String, Object> plainMap) {
final Map<String, Map<String, List<String>>> interfaceMap = extractColumnDrivenInterfaceMap(plainMap);
final Map<String, Map<String, Map<String, List<String>>>> translatedMap = newLinkedHashMap();
for (Entry<String, Map<String, List<String>>> tableEntry : interfaceMap.entrySet()) {
final String tableName = tableEntry.getKey();
final Map<String, List<String>> columnTypeCKeyMap = tableEntry.getValue();
for (Entry<String, List<String>> columnTypeCKeyEntry : columnTypeCKeyMap.entrySet()) {
final String columnExp = columnTypeCKeyEntry.getKey();
final String columnName = Srl.substringFirstFront(columnExp, "(").trim();
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);
}
// e.g. String, OrderBy
final String propType = scopeFirst.getContent().trim();
final List<String> ckeyList = columnTypeCKeyEntry.getValue();
Map<String, Map<String, List<String>>> ckeyColumnMap = translatedMap.get(propType);
if (ckeyColumnMap == null) {
ckeyColumnMap = newLinkedHashMap();
translatedMap.put(propType, ckeyColumnMap);
}
for (String ckey : ckeyList) {
Map<String, List<String>> tableColumnMap = ckeyColumnMap.get(ckey);
if (tableColumnMap == null) {
tableColumnMap = newLinkedHashMap();
ckeyColumnMap.put(ckey, tableColumnMap);
}
List<String> columnList = tableColumnMap.get(tableName);
if (columnList == null) {
columnList = new ArrayList<String>();
tableColumnMap.put(tableName, columnList);
}
columnList.add(columnName);
}
}
}
return translatedMap;
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfFreeGenInitializer method throwFreeGenRequestLoadingFailureException.
// -----------------------------------------------------
// Loading Failure
// ---------------
protected void throwFreeGenRequestLoadingFailureException(String requestName, DfFreeGenResource resource, DfFreeGenTableLoader tableLoader, RuntimeException e) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Failed to load the FreeGen request.");
br.addItem("Request Name");
br.addElement(requestName);
br.addItem("Resource");
br.addElement(resource);
br.addItem("Table Loader");
br.addElement(tableLoader);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg, e);
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfFreeGenInitializer method setupReservedOption.
// ===================================================================================
// Reserved Option
// ===============
protected void setupReservedOption(String requestName, Map<String, Object> optionMap) {
@SuppressWarnings("unchecked") final Map<String, Object> databaseMap = (Map<String, Object>) optionMap.get("databaseMap");
if (databaseMap == null) {
return;
}
for (Entry<String, Object> entry : databaseMap.entrySet()) {
final String databaseName = entry.getKey();
@SuppressWarnings("unchecked") final Map<String, Object> settingsMap = (Map<String, Object>) entry.getValue();
final String schemaDir = (String) settingsMap.get("schemaDir");
final String schemaXml;
if (Srl.is_NotNull_and_NotTrimmedEmpty(schemaDir)) {
schemaXml = schemaDir + "/project-schema-" + databaseName + ".xml";
} else {
final String schemaFile = (String) settingsMap.get("schemaFile");
if (Srl.is_Null_or_TrimmedEmpty(schemaFile)) {
String msg = "Not found the schemaDir or schemaFile property in the " + databaseName + " for " + requestName;
throw new DfIllegalPropertySettingException(msg);
}
schemaXml = schemaFile;
}
final DfSchemaXmlReader reader = DfSchemaXmlReader.createAsFlexibleToManage(schemaXml);
final Database database = prepareDatabase(reader);
settingsMap.put("instance", database);
}
}
use of org.dbflute.exception.DfIllegalPropertySettingException in project dbflute-core by dbflute.
the class DfPropHtmlManager method assertPropHtmlPropertiesFileDirectoryExists.
protected void assertPropHtmlPropertiesFileDirectoryExists(File targetDir, String requestName, String propertiesFile) {
if (targetDir.exists()) {
return;
}
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not found the directory for the file for PropertiesHtml.");
br.addItem("Request Name");
br.addElement(requestName);
br.addItem("Properties File");
br.addElement(propertiesFile);
final String msg = br.buildExceptionMessage();
throw new DfIllegalPropertySettingException(msg);
}
Aggregations