Search in sources :

Example 1 with DfClassificationGroup

use of org.dbflute.properties.assistant.classification.DfClassificationGroup in project dbflute-core by dbflute.

the class ForeignKey method doExtractFixedConditionEmbeddedCommentClassificationGroupCode.

protected String doExtractFixedConditionEmbeddedCommentClassificationGroupCode(DfClassificationTop classificationTop, String elementName) {
    String code = null;
    final List<DfClassificationGroup> groupList = classificationTop.getGroupList();
    for (DfClassificationGroup group : groupList) {
        final String groupName = group.getGroupName();
        if (elementName.equals(groupName)) {
            final List<DfClassificationElement> groupElementList = group.getElementList();
            StringBuilder sb = new StringBuilder();
            for (DfClassificationElement groupelement : groupElementList) {
                if (sb.length() > 0) {
                    sb.append(", ");
                }
                sb.append(quoteClassifiationElementIfNeeds(classificationTop, groupelement.getCode()));
            }
            sb.insert(0, "(").append(")");
            code = sb.toString();
            break;
        }
    }
    return code;
}
Also used : DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) DfClassificationElement(org.dbflute.properties.assistant.classification.DfClassificationElement) DfColumnListToStringBuilder(org.dbflute.logic.generate.column.DfColumnListToStringBuilder)

Example 2 with DfClassificationGroup

use of org.dbflute.properties.assistant.classification.DfClassificationGroup in project dbflute-core by dbflute.

the class DfAppClsTableLoader method handleRefCls.

protected void handleRefCls(DfClassificationTop classificationTop, DfRefClsElement refClsElement) {
    refClsElement.checkFormalRefType(classificationTop);
    classificationTop.addRefClsElement(refClsElement);
    if (refClsElement.isRefTypeIncluded()) {
        final DfClassificationTop dbClsTop = refClsElement.getDBClsTop();
        final String groupName = refClsElement.getGroupName();
        if (groupName != null) {
            final DfClassificationGroup group = dbClsTop.getGroupList().stream().filter(gr -> {
                return gr.getGroupName().equals(groupName);
            }).findFirst().orElseThrow(() -> {
                String msg = "Not found the group name: " + refClsElement.getClassificationName() + "." + groupName;
                return new DfIllegalPropertySettingException(msg);
            });
            classificationTop.addClassificationElementAll(group.getElementList());
        } else {
            final List<DfClassificationElement> dbElementList = dbClsTop.getClassificationElementList();
            classificationTop.addClassificationElementAll(dbElementList);
            classificationTop.acceptGroupList(dbClsTop.getGroupList());
        }
    }
}
Also used : DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) DfClassificationElement(org.dbflute.properties.assistant.classification.DfClassificationElement) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 3 with DfClassificationGroup

use of org.dbflute.properties.assistant.classification.DfClassificationGroup in project dbflute-core by dbflute.

the class DfWebClsTableLoader method handleRefCls.

protected void handleRefCls(DfClassificationTop classificationTop, DfRefClsElement refClsElement) {
    refClsElement.checkFormalRefType(classificationTop);
    classificationTop.addRefClsElement(refClsElement);
    if (refClsElement.isRefTypeIncluded()) {
        final DfClassificationTop dbClsTop = refClsElement.getDBClsTop();
        final String groupName = refClsElement.getGroupName();
        if (groupName != null) {
            final DfClassificationGroup group = dbClsTop.getGroupList().stream().filter(gr -> {
                return gr.getGroupName().equals(groupName);
            }).findFirst().orElseThrow(() -> {
                String msg = "Not found the group name: " + refClsElement.getClassificationName() + "." + groupName;
                return new DfIllegalPropertySettingException(msg);
            });
            classificationTop.addClassificationElementAll(group.getElementList());
        } else {
            final List<DfClassificationElement> dbElementList = dbClsTop.getClassificationElementList();
            classificationTop.addClassificationElementAll(dbElementList);
            classificationTop.acceptGroupList(dbClsTop.getGroupList());
        }
    }
}
Also used : DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) DfClassificationElement(org.dbflute.properties.assistant.classification.DfClassificationElement) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 4 with DfClassificationGroup

use of org.dbflute.properties.assistant.classification.DfClassificationGroup in project dbflute-core by dbflute.

the class DfClsTopGroupListArranger method throwClassificationGroupingMapReferenceNotFoundException.

protected void throwClassificationGroupingMapReferenceNotFoundException(List<DfClassificationGroup> groupList, DfClassificationGroup group, String refName) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found the refenrece in the grouping map.");
    br.addItem("Classification Name");
    br.addElement(group.getClassificationName());
    br.addItem("Group Name");
    br.addElement(group.getGroupName());
    br.addItem("NotFound Name");
    br.addElement(refName);
    br.addItem("Defined Group");
    for (DfClassificationGroup defined : groupList) {
        br.addElement(defined);
    }
    final String msg = br.buildExceptionMessage();
    throw new DfIllegalPropertySettingException(msg);
}
Also used : DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Example 5 with DfClassificationGroup

use of org.dbflute.properties.assistant.classification.DfClassificationGroup in project dbflute-core by dbflute.

the class DfClsTopGroupListArranger method resolveGroupVariable.

// -----------------------------------------------------
// Group Variable
// --------------
protected void resolveGroupVariable(List<DfClassificationGroup> groupList) {
    final Map<String, DfClassificationGroup> groupMap = new LinkedHashMap<String, DfClassificationGroup>();
    for (DfClassificationGroup group : groupList) {
        groupMap.put(group.getGroupName(), group);
    }
    // e.g.
    // ; servicePlus = map:{
    // ; elementList = list:{ $$ref$$.serviceAvailable ; Withdrawal }
    // }
    final String refPrefix = "$$ref$$.";
    for (DfClassificationGroup group : groupList) {
        final List<String> elementNameList = group.getElementNameList();
        final Set<String> resolvedNameSet = new LinkedHashSet<String>();
        for (String elementName : elementNameList) {
            if (Srl.startsWith(elementName, refPrefix)) {
                final String refName = Srl.substringFirstRear(elementName, refPrefix).trim();
                final DfClassificationGroup refGroup = groupMap.get(refName);
                if (refGroup == null) {
                    throwClassificationGroupingMapReferenceNotFoundException(groupList, group, refName);
                }
                resolvedNameSet.addAll(refGroup.getElementNameList());
            } else {
                resolvedNameSet.add(elementName);
            }
        }
        if (elementNameList.size() < resolvedNameSet.size()) {
            group.setElementNameList(new ArrayList<String>(resolvedNameSet));
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

DfClassificationGroup (org.dbflute.properties.assistant.classification.DfClassificationGroup)10 DfClassificationElement (org.dbflute.properties.assistant.classification.DfClassificationElement)4 LinkedHashMap (java.util.LinkedHashMap)3 DfIllegalPropertySettingException (org.dbflute.exception.DfIllegalPropertySettingException)3 DfClassificationTop (org.dbflute.properties.assistant.classification.DfClassificationTop)3 ArrayList (java.util.ArrayList)2 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 DfClassificationRequiredAttributeNotFoundException (org.dbflute.exception.DfClassificationRequiredAttributeNotFoundException)1 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 DfColumnListToStringBuilder (org.dbflute.logic.generate.column.DfColumnListToStringBuilder)1 DfRefClsElement (org.dbflute.properties.assistant.classification.refcls.DfRefClsElement)1 DfRefClsReferredCDef (org.dbflute.properties.assistant.classification.refcls.DfRefClsReferredCDef)1