Search in sources :

Example 11 with DfIllegalPropertySettingException

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);
    }
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException) List(java.util.List) Collectors(java.util.stream.Collectors) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 12 with DfIllegalPropertySettingException

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;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ScopeInfo(org.dbflute.util.Srl.ScopeInfo) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 13 with DfIllegalPropertySettingException

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);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 14 with DfIllegalPropertySettingException

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);
    }
}
Also used : Database(org.apache.torque.engine.database.model.Database) DfSchemaXmlReader(org.dbflute.logic.jdbc.schemaxml.DfSchemaXmlReader) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 15 with DfIllegalPropertySettingException

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);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) 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