Search in sources :

Example 41 with DfIllegalPropertySettingException

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

the class DfAppClsTableLoader method assertRefClsOnlyOne.

protected void assertRefClsOnlyOne(String classificationName, DfRefClsElement refClsElement, Map<String, Object> elementMap, DfFreeGenResource resource) {
    if (refClsElement != null) {
        // only-one refCls is supported #for_now
        final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
        br.addNotice("Duplicate refCls in the app classification.");
        br.addItem("Advice");
        br.addElement("Only-one refCls is supported in one app classification.");
        br.addItem("AppCls");
        br.addElement(classificationName);
        br.addItem("Existing refCls");
        br.addElement(refClsElement);
        br.addItem("Duplicate refCls");
        br.addElement(elementMap);
        br.addItem("dfprop File");
        br.addElement(resource.getResourceFile());
        final String msg = br.buildExceptionMessage();
        throw new DfIllegalPropertySettingException(msg);
    }
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 42 with DfIllegalPropertySettingException

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

the class DfWebClsTableLoader method assertRefClsOnlyOne.

protected void assertRefClsOnlyOne(String classificationName, DfRefClsElement refClsElement, Map<String, Object> elementMap, DfFreeGenResource resource) {
    if (refClsElement != null) {
        // only-one refCls is supported #for_now
        final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
        br.addNotice("Duplicate refCls in the web classification.");
        br.addItem("Advice");
        br.addElement("Only-one refCls is supported in one web classification.");
        br.addItem("WebCls");
        br.addElement(classificationName);
        br.addItem("Existing refCls");
        br.addElement(refClsElement);
        br.addItem("Duplicate refCls");
        br.addElement(elementMap);
        br.addItem("dfprop File");
        br.addElement(resource.getResourceFile());
        final String msg = br.buildExceptionMessage();
        throw new DfIllegalPropertySettingException(msg);
    }
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 43 with DfIllegalPropertySettingException

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

the class DfWebClsTableLoader method createRefClsElement.

protected DfRefClsElement createRefClsElement(String classificationName, Map<String, Object> elementMap, Map<String, DfClassificationTop> dbClsMap, DfFreeGenResource resource) {
    final String refCls = (String) elementMap.get(DfRefClsElement.KEY_REFCLS);
    final String projectName;
    final String refClsName;
    final String groupName;
    if (refCls.contains("@")) {
        // #hope other schema's reference
        projectName = Srl.substringFirstFront(refCls, "@");
        final String rearName = Srl.substringFirstRear(refCls, "@");
        if (rearName.contains(".")) {
            refClsName = Srl.substringFirstFront(rearName, ".");
            groupName = Srl.substringFirstRear(rearName, ".");
        } else {
            refClsName = rearName;
            groupName = null;
        }
    } else {
        projectName = null;
        if (refCls.contains(".")) {
            refClsName = Srl.substringFirstFront(refCls, ".");
            groupName = Srl.substringFirstRear(refCls, ".");
        } else {
            refClsName = refCls;
            groupName = null;
        }
    }
    final String classificationType = buildClassificationType(refClsName);
    final String refType = (String) elementMap.get(DfRefClsElement.KEY_REFTYPE);
    if (refType == null) {
        String msg = "Not found the refType in refCls elementMap: " + classificationName + " " + elementMap;
        throw new DfIllegalPropertySettingException(msg);
    }
    final DfClassificationTop dbClsTop = findDBCls(classificationName, refClsName, dbClsMap, resource);
    return new DfRefClsElement(projectName, refClsName, classificationType, groupName, refType, dbClsTop);
}
Also used : DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException) DfRefClsElement(org.dbflute.properties.assistant.classification.DfRefClsElement)

Example 44 with DfIllegalPropertySettingException

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

the class DfRefClsElement method checkRefMatches.

protected void checkRefMatches(DfClassificationTop classificationTop) {
    final List<DfClassificationElement> webElementList = classificationTop.getClassificationElementList();
    final List<DfClassificationElement> dbElementList = _dbClsTop.getClassificationElementList();
    final boolean hasNonExisting = webElementList.stream().anyMatch(webElement -> {
        return !dbElementList.stream().anyMatch(dbElement -> {
            return webElement.getCode().equals(dbElement.getCode());
        });
    });
    if (webElementList.size() != dbElementList.size() || hasNonExisting) {
        final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
        br.addNotice("Unmatched the web classification code with the DB classification");
        br.addItem("Advice");
        br.addElement("The codes of the web classification should match");
        br.addElement("with DB classification because of refType='matches'.");
        br.addElement("For example:");
        br.addElement("  (x): web(A), db(A, C)");
        br.addElement("  (x): web(A, B), db(A, C)");
        br.addElement("  (o): web(A, B), db(A, B)");
        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("Code Count");
        br.addElement("web=" + webElementList.size() + " / db=" + dbElementList.size());
        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 45 with DfIllegalPropertySettingException

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

the class DfRefClsElement method checkFormalRefType.

// ===================================================================================
// Check by RefType
// ================
public void checkFormalRefType(DfClassificationTop classificationTop) {
    if (isRefTypeIncluded() || isRefTypeExists() || isRefTypeMatches()) {
        return;
    }
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Unknown refType to DB classification in the web classification.");
    br.addItem("Advice");
    br.addElement("refType can be set: 'included', 'exists', 'matches'");
    br.addElement("  included : DB classification codes are included as web classification");
    br.addElement("  exists   : web classification codes should exist in DB classification");
    br.addElement("  matches  : web classification codes matches with DB classification");
    br.addItem("WebCls");
    br.addElement(classificationTop.getClassificationName());
    br.addItem("Unknown refType");
    br.addElement(_refType);
    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