Search in sources :

Example 6 with DfClassificationGroup

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

the class DfClsTopGroupListArranger method arrangeGroupList.

// ===================================================================================
// Group List
// ==========
public List<DfClassificationGroup> arrangeGroupList() {
    final List<DfClassificationGroup> groupList = new ArrayList<DfClassificationGroup>();
    for (Entry<String, Map<String, Object>> entry : _groupingMap.entrySet()) {
        final String groupName = entry.getKey();
        final Map<String, Object> attrMap = entry.getValue();
        // #for_now jflute not required for a long time but required better? (2021/07/05)
        final String groupComment = (String) attrMap.get(KEY_GROUP_COMMENT);
        @SuppressWarnings("unchecked") final List<String> elementList = (List<String>) attrMap.get(KEY_ELEMENT_LIST);
        if (elementList == null) {
            String msg = "The elementList in grouping map is required: " + _classificationTop.getClassificationName();
            throw new DfClassificationRequiredAttributeNotFoundException(msg);
        }
        final String docOnly = (String) attrMap.get(KEY_USE_DOCUMENT_ONLY);
        final DfClassificationGroup group = new DfClassificationGroup(_classificationTop, groupName);
        group.setGroupComment(groupComment);
        group.setElementNameList(elementList);
        group.setUseDocumentOnly(docOnly != null && docOnly.trim().equalsIgnoreCase("true"));
        groupList.add(group);
    }
    resolveGroupVariable(groupList);
    return filterTaskMatchingList(groupList);
}
Also used : DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DfClassificationRequiredAttributeNotFoundException(org.dbflute.exception.DfClassificationRequiredAttributeNotFoundException) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 7 with DfClassificationGroup

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

the class DfClsTopGroupListArranger method filterTaskMatchingList.

// -----------------------------------------------------
// Task-Matching List
// ------------------
protected List<DfClassificationGroup> filterTaskMatchingList(List<DfClassificationGroup> groupList) {
    final List<DfClassificationGroup> realList = new ArrayList<DfClassificationGroup>();
    final boolean docOnly = isDocOnlyTaskNow();
    for (DfClassificationGroup group : groupList) {
        if (!docOnly && group.isUseDocumentOnly()) {
            continue;
        }
        realList.add(group);
    }
    return realList;
}
Also used : DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) ArrayList(java.util.ArrayList)

Example 8 with DfClassificationGroup

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

the class DfFixedConditionDynamicAnalyzer method doExtractEmbeddedCommentClassificationGroupCode.

protected String doExtractEmbeddedCommentClassificationGroupCode(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)

Example 9 with DfClassificationGroup

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

the class DfRefClsLoadingHandler method createRefClsElement.

public DfRefClsElement createRefClsElement(String classificationName, Map<String, Object> elementMap, DfFreeGenResource resource) {
    // e.g. map:{ refCls=maihamadb@MemberStatus ; refType=included }
    final String refAttr = (String) elementMap.get(DfRefClsElement.KEY_REFCLS);
    // of e.g. DB or "appcls" or namedcls's name
    final String refClsTheme;
    // classification name
    final String refClsName;
    final String refGroupName;
    if (refAttr.contains("@")) {
        // #hope other schema's reference
        refClsTheme = Srl.substringFirstFront(refAttr, "@");
        final String rearName = Srl.substringFirstRear(refAttr, "@");
        if (rearName.contains(".")) {
            refClsName = Srl.substringFirstFront(rearName, ".");
            refGroupName = Srl.substringFirstRear(rearName, ".");
        } else {
            refClsName = rearName;
            refGroupName = null;
        }
    } else {
        // current DB as default
        refClsTheme = getBasicProperties().getProjectName();
        if (refAttr.contains(".")) {
            refClsName = Srl.substringFirstFront(refAttr, ".");
            refGroupName = Srl.substringFirstRear(refAttr, ".");
        } else {
            refClsName = refAttr;
            refGroupName = null;
        }
    }
    final String refType = extractRefType(classificationName, elementMap);
    final DfClassificationTop referredClsTop = findReferredClsTop(classificationName, refAttr, refClsTheme, refClsName, resource);
    final DfRefClsReferredCDef referredCDef = findReferredCDef(classificationName, refAttr, refClsTheme, refClsName, resource);
    final DfClassificationGroup referredGroup = findReferredGroup(classificationName, refAttr, refClsTheme, refClsName, refGroupName, referredClsTop, resource);
    final String resourceFile = resource.getResourceFile();
    return new DfRefClsElement(refClsTheme, refClsName, refGroupName, refType, referredClsTop, referredCDef, referredGroup, resourceFile);
}
Also used : DfClassificationGroup(org.dbflute.properties.assistant.classification.DfClassificationGroup) DfClassificationTop(org.dbflute.properties.assistant.classification.DfClassificationTop) DfRefClsReferredCDef(org.dbflute.properties.assistant.classification.refcls.DfRefClsReferredCDef) DfRefClsElement(org.dbflute.properties.assistant.classification.refcls.DfRefClsElement)

Example 10 with DfClassificationGroup

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

the class DfClsTopGroupInheritanceArranger method inheritRefClsGroup.

// ===================================================================================
// Inherit Group
// =============
public void inheritRefClsGroup(Map<String, Map<String, Object>> groupingMap) {
    // for e.g. appcls
    if (_classificationTop.isAlreadyGroupArranged()) {
        // basically no way
        throw new IllegalStateException("Group objects are already arranged so too late: " + _classificationTop);
    }
    final List<DfClassificationGroup> referredGroupList = _referredClsTop.getGroupList();
    for (DfClassificationGroup referredGroup : referredGroupList) {
        if (groupingMap.containsKey(referredGroup.getGroupName())) {
            throwClassificationReferredGroupingMapConflictException(referredGroup);
        }
        final List<String> translatedElementNameList = translateElementNameList(referredGroup);
        if (translatedElementNameList.isEmpty()) {
            // when completely not related to the group elements
            continue;
        }
        final Map<String, Object> contentMap = new LinkedHashMap<>();
        contentMap.put(DfClsTopGroupListArranger.KEY_GROUP_COMMENT, referredGroup.getGroupComment());
        contentMap.put(DfClsTopGroupListArranger.KEY_ELEMENT_LIST, translatedElementNameList);
        contentMap.put(DfClsTopGroupListArranger.KEY_USE_DOCUMENT_ONLY, String.valueOf(referredGroup.isUseDocumentOnly()));
        groupingMap.put(referredGroup.getGroupName(), contentMap);
    }
}
Also used : 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