Search in sources :

Example 26 with DfClassificationElement

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

the class DfClsTopSubItemHandler method arrangeRegularSubItemList.

// ===================================================================================
// Regular SubItem
// ===============
// Regular SubItem means existing in all elements
public List<DfClsTopRegularSubItem> arrangeRegularSubItemList() {
    final List<DfClassificationElement> elementList = _classificationTop.getClassificationElementList();
    final Map<String, List<Object>> subItemListMap = new LinkedHashMap<String, List<Object>>();
    for (DfClassificationElement element : elementList) {
        final Map<String, Object> subItemMap = element.getSubItemMap();
        if (subItemMap == null || subItemMap.isEmpty()) {
            continue;
        }
        for (Entry<String, Object> entry : subItemMap.entrySet()) {
            final String subItemKey = entry.getKey();
            final Object subItemValue = entry.getValue();
            List<Object> subItemList = subItemListMap.get(subItemKey);
            if (subItemList == null) {
                subItemList = new ArrayList<Object>();
                subItemListMap.put(subItemKey, subItemList);
            }
            subItemList.add(subItemValue);
        }
    }
    final String typeObject = DfClsTopRegularSubItem.TYPE_OBJECT;
    final String typeString = DfClsTopRegularSubItem.TYPE_STRING;
    final List<DfClsTopRegularSubItem> regularSubItemList = new ArrayList<DfClsTopRegularSubItem>();
    final int elementSize = elementList.size();
    for (Entry<String, List<Object>> entry : subItemListMap.entrySet()) {
        final String subItemKey = entry.getKey();
        final List<Object> subItemList = entry.getValue();
        if (subItemList != null && subItemList.size() == elementSize) {
            String subItemType = null;
            for (Object value : subItemList) {
                if (value == null) {
                    continue;
                }
                if (!(value instanceof String)) {
                    subItemType = typeObject;
                    break;
                } else if (Srl.startsWith((String) value, "map:", "list:")) {
                    subItemType = typeObject;
                    break;
                }
            }
            if (subItemType == null) {
                subItemType = typeString;
            }
            regularSubItemList.add(new DfClsTopRegularSubItem(subItemKey, subItemType));
        }
    }
    return regularSubItemList;
}
Also used : ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) DfClassificationElement(org.dbflute.properties.assistant.classification.DfClassificationElement) List(java.util.List) ArrayList(java.util.ArrayList)

Example 27 with DfClassificationElement

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

the class DfClsTableClassificationArranger method createBasicElement.

protected DfClassificationElement createBasicElement(DfClassificationTop classificationTop, Map<String, Object> elementMap, String table) {
    final DfClassificationElement metaElement = new DfClassificationElement();
    metaElement.setClassificationName(classificationTop.getClassificationName());
    metaElement.setTable(table);
    metaElement.acceptBasicItemMap(elementMap);
    return metaElement;
}
Also used : DfClassificationElement(org.dbflute.properties.assistant.classification.DfClassificationElement)

Example 28 with DfClassificationElement

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

the class DfFixedConditionDynamicAnalyzer method throwFixedConditionEmbeddedCommentClassificationElementNotFoundException.

protected void throwFixedConditionEmbeddedCommentClassificationElementNotFoundException(DfClassificationTop classificationTop, String elementName) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found the classification element in fixed condition.");
    br.addItem("Foreign Key");
    br.addElement(_foreignKey.getName());
    br.addItem("Classification Name");
    br.addElement(classificationTop.getClassificationName());
    br.addItem("NotFound Element");
    br.addElement(elementName);
    br.addItem("Defined Element");
    final List<DfClassificationElement> elementList = classificationTop.getClassificationElementList();
    for (DfClassificationElement element : elementList) {
        br.addElement(element);
    }
    final String msg = br.buildExceptionMessage();
    throw new DfFixedConditionInvalidClassificationEmbeddedCommentException(msg);
}
Also used : DfClassificationElement(org.dbflute.properties.assistant.classification.DfClassificationElement) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfFixedConditionInvalidClassificationEmbeddedCommentException(org.dbflute.exception.DfFixedConditionInvalidClassificationEmbeddedCommentException)

Example 29 with DfClassificationElement

use of org.dbflute.properties.assistant.classification.DfClassificationElement 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 30 with DfClassificationElement

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

the class DfClsTopGroupElementHandling method throwClassificationGroupingMapElementNotFoundException.

protected void throwClassificationGroupingMapElementNotFoundException(String elementName) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found the classification element in the grouping map.");
    br.addItem("Classification Name");
    br.addElement(_classificationTop.getClassificationName());
    br.addItem("Group Name");
    br.addElement(_groupName);
    br.addItem("NotFound Name");
    br.addElement(elementName);
    br.addItem("Defined Element");
    final List<DfClassificationElement> elementList = _classificationTop.getClassificationElementList();
    for (DfClassificationElement element : elementList) {
        br.addElement(element);
    }
    final String msg = br.buildExceptionMessage();
    throw new DfIllegalPropertySettingException(msg);
}
Also used : DfClassificationElement(org.dbflute.properties.assistant.classification.DfClassificationElement) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfIllegalPropertySettingException(org.dbflute.exception.DfIllegalPropertySettingException)

Aggregations

DfClassificationElement (org.dbflute.properties.assistant.classification.DfClassificationElement)30 DfClassificationTop (org.dbflute.properties.assistant.classification.DfClassificationTop)10 DfIllegalPropertySettingException (org.dbflute.exception.DfIllegalPropertySettingException)8 ArrayList (java.util.ArrayList)6 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)6 LinkedHashMap (java.util.LinkedHashMap)5 List (java.util.List)5 DfClassificationGroup (org.dbflute.properties.assistant.classification.DfClassificationGroup)5 Map (java.util.Map)4 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 DfFixedConditionInvalidClassificationEmbeddedCommentException (org.dbflute.exception.DfFixedConditionInvalidClassificationEmbeddedCommentException)2 SQLFailureException (org.dbflute.exception.SQLFailureException)2 StringKeyMap (org.dbflute.helper.StringKeyMap)2 DfClassificationJdbcCloser (org.dbflute.properties.assistant.classification.coins.DfClassificationJdbcCloser)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Connection (java.sql.Connection)1