Search in sources :

Example 71 with DfIllegalPropertySettingException

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

the class DfJsonFreeAgent method throwKeyPathExpectedStringListButNotStringException.

protected void throwKeyPathExpectedStringListButNotStringException(String requestName, DfFreeGenResource resource, String keyPath, String targetPath, List<Object> currentList, Object element) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The key path expects string type in list but not string. (FreeGen)");
    br.addItem("Request Name");
    br.addElement(requestName);
    br.addItem("JSON File");
    br.addElement(resource.getResourceFile());
    br.addItem("keyPath");
    br.addElement(keyPath);
    br.addItem("Target Path Element");
    br.addElement(targetPath);
    br.addItem("List Object");
    br.addElement(currentList != null ? currentList.getClass().getName() : null);
    br.addElement(currentList);
    br.addItem("Actual Element");
    br.addElement(element != null ? element.getClass().getName() : null);
    br.addElement(element);
    final String msg = br.buildExceptionMessage();
    throw new DfIllegalPropertySettingException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 72 with DfIllegalPropertySettingException

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

the class DfJsonFreeAgent method throwJsonMapKeyNotFoundException.

protected void throwJsonMapKeyNotFoundException(String requestName, DfFreeGenResource resource, String tracePath, Map<String, Object> currentMap, String pathElement) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found the key in the map. (FreeGen)");
    br.addItem("Request Name");
    br.addElement(requestName);
    br.addItem("JSON File");
    br.addElement(resource.getResourceFile());
    br.addItem("Trace Path");
    br.addElement(tracePath);
    br.addItem("Current Map keySet()");
    br.addElement(currentMap.keySet());
    br.addItem("Path Element");
    br.addElement(pathElement);
    final String msg = br.buildExceptionMessage();
    throw new DfIllegalPropertySettingException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 73 with DfIllegalPropertySettingException

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

the class DfFreeGenInitializer method throwFreeGenResourceTypeUnknownException.

// -----------------------------------------------------
// ResourceType Unknown
// --------------------
protected void throwFreeGenResourceTypeUnknownException(String requestName, DfFreeGenResource resource) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Unknown resource type for FreeGen.");
    br.addItem("Request Name");
    br.addElement(requestName);
    br.addItem("Resource Type");
    br.addElement(resource.getResourceType());
    final String msg = br.buildExceptionMessage();
    throw new DfIllegalPropertySettingException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 74 with DfIllegalPropertySettingException

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

the class DfAdditionalForeignKeyInitializer method processAllTableFK.

protected void processAllTableFK(String foreignKeyName, String foreignTableName, List<String> foreignColumnNameList, DfAdditionalForeignKeyOption option) {
    if (option.isFixedOnlyJoin()) {
        String msg = "Cannot use fixedOnlyJoin when all-table FK: " + foreignKeyName;
        throw new DfIllegalPropertySettingException(msg);
    }
    // for check about same-column self reference
    final Table foreignTable = getTable(foreignTableName);
    final StringSet foreignColumnSet = StringSet.createAsFlexible();
    foreignColumnSet.addAll(foreignColumnNameList);
    for (Table table : getTableList()) {
        final String localTableName = table.getTableDbName();
        final List<String> localColumnNameList = getLocalColumnNameList(table, foreignKeyName, foreignTableName, foreignColumnNameList, localTableName, option, true, false);
        if (!table.containsColumn(localColumnNameList)) {
            continue;
        }
        // check same-column self reference
        final StringSet localColumnSet = StringSet.createAsFlexible();
        localColumnSet.addAll(localColumnNameList);
        final boolean selfReference = table.getTableDbName().equals(foreignTable.getTableDbName());
        if (selfReference && localColumnSet.equalsUnderCharOption(foreignColumnSet)) {
            continue;
        }
        // check same foreign key existence
        final String fixedSuffix = option.getFixedSuffix();
        final ForeignKey existingFK = table.findExistingForeignKey(foreignTableName, localColumnNameList, foreignColumnNameList, fixedSuffix);
        if (existingFK != null) {
            _log.info("The foreign key has already set up: " + foreignKeyName + "(" + fixedSuffix + ")");
            reflectOptionToExistingFKIfNeeds(foreignKeyName, option, existingFK);
            continue;
        }
        final String currentForeignKeyName = foreignKeyName + "_" + toConstraintPart(localTableName);
        setupForeignKeyToTable(currentForeignKeyName, foreignTableName, foreignColumnNameList, table, localColumnNameList, option);
        showResult(foreignTableName, foreignColumnNameList, table, localColumnNameList, option);
    }
}
Also used : Table(org.apache.torque.engine.database.model.Table) StringSet(org.dbflute.helper.StringSet) ForeignKey(org.apache.torque.engine.database.model.ForeignKey) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 75 with DfIllegalPropertySettingException

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

the class DfAdditionalForeignKeyInitializer method assertLocalTableColumn.

protected void assertLocalTableColumn(final String foreignKeyName, final String localTableName, List<String> localColumnNameList, DfAdditionalForeignKeyOption resource) {
    if (resource.isFixedOnlyJoin()) {
        if (!localColumnNameList.isEmpty()) {
            final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
            br.addNotice("The localColumn should be omitted when fixedOnlyJoin is true.");
            br.addItem("Additional FK");
            br.addElement(foreignKeyName);
            br.addItem("Local Table");
            br.addElement(localTableName);
            br.addItem("Column List");
            br.addElement(localColumnNameList);
            final String msg = br.buildExceptionMessage();
            throw new DfIllegalPropertySettingException(msg);
        }
    } else {
        if (!getTable(localTableName).containsColumn(localColumnNameList)) {
            final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
            br.addNotice("Not found column by the localColumnName of additionalForeignKey.");
            br.addElement("Make sure your additionalForeignKeyMap.dfprop");
            br.addElement("For example:");
            br.addElement("  (x):");
            br.addElement("     ; FK_MEMBER_MEMBER_ADDRESS_VALID = map:{");
            br.addElement("         ; localTableName = ... ; foreignTableName = ...");
            br.addElement("         ; localColumnName = NOEXISTING_ID ; foreignColumnName = MEMBER_ID // *NG");
            br.addElement("         ...");
            br.addElement("     }");
            br.addElement("  (o):");
            br.addElement("     ; FK_MEMBER_MEMBER_ADDRESS_VALID = map:{");
            br.addElement("         ; localTableName = ... ; foreignTableName = MEMBER_ADDRESS");
            br.addElement("         ; localColumnName = MEMBER_ID ; foreignColumnName = MEMBER_ID     // OK");
            br.addElement("         ...");
            br.addElement("     }");
            br.addItem("Additional FK");
            br.addElement(foreignKeyName);
            br.addItem("Local Table");
            br.addElement(localTableName);
            br.addItem("NotFound Column");
            br.addElement(localColumnNameList);
            final String msg = br.buildExceptionMessage();
            throw new DfPropertySettingColumnNotFoundException(msg);
        }
    }
}
Also used : DfPropertySettingColumnNotFoundException(org.dbflute.exception.DfPropertySettingColumnNotFoundException) 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