# Generator script - writes the complete DD document
import os

path = '.codewiki/dd/FUW00927SFBean/storeModelData.md'

S = []
def w(line=''):
    S.append(line)

# ============================================================
# HEADER
# ============================================================
w('# Business Logic - FUW00927SFBean.storeModelData() [1127 LOC]')
w()
w('| Field | Value |')
w('|-------|-------|')
w('| Fully Qualified Name | eo.web.webview.FUW00927SF.FUW00927SFBean |')
w('| Layer | Webview / Front-End Bean (Web Presentation Layer) |')
w('| Module | FUW00927SF (Package: eo.web.webview.FUW00927SF) |')
w()

# ============================================================
# SECTION 1: ROLE
# ============================================================
w('## 1. Role')
w()
w('### FUW00927SFBean.storeModelData()')
w()
w('This method is the central data binding router for the K-Opticom FTTH (Fiber-to-the-Home) new subscription order screen (FUW00927SF - "Input Content Confirmation (Sales/Delivery)"). It receives a key/subkey/value triplet and dispatches the incoming data to the correct field setter, list item, or common-info handler based on the semantic meaning of the key.')
w()
w('The method handles four categories of data types: (1) Common information fields (key starts with "//"), which are delegated to the superclass `storeCommonInfoData` - these represent shared screen-level metadata; (2) Single-value String fields (e.g., Function Code, Screen Mode, Monthly Fees, Initial Fees, Contract Type, Customer Info, Fax Request, Display Flags), where data is routed to a `setXxx_value` or `setXxx_state` setter; (3) Single-value Boolean fields (e.g., Contract Service Area Display Flag), where `in_value` is cast to `Boolean` for the value setter and to `String` for the state setter; (4) Repeating list fields (e.g., Item Code, Value, Monthly Fee Items, Smart Link items, NH items), where an index is parsed from the key path, bounds-checked against the backing list, and the data is delegated to the individual list item\'s own `storeModelData` method - implementing recursive hierarchical data binding.')
w()
w('The design pattern implemented is a routing/dispatch pattern combined with a delegation pattern: the method acts as a central dispatcher that examines the key prefix, extracts nested indices from slash-delimited paths, and delegates to either instance setters or child bean objects. This is a shared utility called by the screen controller to populate model data into this bean\'s fields.')
w()
w('The method also supports slash-delimited hierarchical key paths (e.g., "getsu_ryokin_kmk/0") to support repeatable/variable-count fields - a common pattern in the K-Opticom web framework for representing line-item data.')
w()

# ============================================================
# SECTION 2: PROCESSING PATTERN
# ============================================================
w('## 2. Processing Pattern (Detailed Business Logic)')
w()
w('```mermaid')
w('flowchart TD')
w('    START(["storeModelData params"])')
w('    START --> CHECK_KEY_NULL{key is null?}')
w('    CHECK_KEY_NULL -->|Yes| RETURN_EARLY(["Return immediately"])')
w('    CHECK_KEY_NULL -->|No| CHECK_SUBKEY_NULL{subkey is null?}')
w('    CHECK_SUBKEY_NULL -->|Yes| SET_SUBKEY_EMPTY[subkey set to empty String]')
w('    SET_SUBKEY_EMPTY --> CHECK_SEPARATOR{key starts with //?}')
w('    CHECK_SUBKEY_NULL -->|No| CHECK_SEPARATOR')
w('    CHECK_SEPARATOR -->|Yes| DELEGATE_COMMON[super.storeCommonInfoData]')
w('    CHECK_SEPARATOR -->|No| EXTRACT_KEY_ELEMENT[Extract keyElement before first /]')
w('    DELEGATE_COMMON --> END_RETURN(["Return - Next"])')
w('    EXTRACT_KEY_ELEMENT --> CHECK_FIRST_BRANCH{Match keyElement?}')
w('    CHECK_FIRST_BRANCH -->|"\\u6a5f\\u80fd\\u30b3\\u30fc\\u30c9"| FNC_SET[setFnc_mode_value or setFnc_mode_state]')
w('    FNC_SET --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|"\\u753b\\u9762\\u30e2\\u30fc\\u30c9"| SCREEN_SET[setScreen_mode_value or setScreen_mode_state]')
w('    SCREEN_SET --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|"\\u9805\\u76ee\\u30b3\\u30fc\\u30c9"| LIST_INDEX[Parse index, bounds check, list.get]')
w('    LIST_INDEX --> LIST_CALL[(listItem.storeModelData)]')
w('    LIST_CALL --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|"\\u5024"| VALUE_LIST[Parse index, bounds check, list.get]')
w('    VALUE_LIST --> VALUE_CALL[(listItem.storeModelData)]')
w('    VALUE_CALL --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|"\\u6708\\u984d\\u6599\\u91d1\\u9805\\u76ee"| KMK_LIST[Parse index, bounds check, list.get]')
w('    KMK_LIST --> KMK_CALL[(listItem.storeModelData)]')
w('    KMK_CALL --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|"\\u6708\\u984d\\u6599\\u91d1"| GETSU_LIST[Parse index, bounds check, list.get]')
w('    GETSU_LIST --> GETSU_CALL[(listItem.storeModelData)]')
w('    GETSU_CALL --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|"\\u521d\\u671f\\u8cbb\\u7528\\u9805\\u76ee"| SHOKI_KMK[Parse index, bounds check, list.get]')
w('    SHOKI_KMK --> SHOKI_KMK_CALL[(listItem.storeModelData)]')
w('    SHOKI_KMK_CALL --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|"\\u521d\\u671f\\u8cbb\\u7528"| SHOKI_LIST[Parse index, bounds check, list.get]')
w('    SHOKI_LIST --> SHOKI_CALL[(listItem.storeModelData)]')
w('    SHOKI_CALL --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|"\\u6708\\u984d\\u6599\\u91d1\\u8a08"| KEI_LIST[Parse index, bounds check, list.get]')
w('    KEI_LIST --> KEI_CALL[(listItem.storeModelData)]')
w('    KEI_CALL --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|"other simple"| SIMPLE_FIELD[setXxx_value or setXxx_state]')
w('    SIMPLE_FIELD --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|"other list"| OTHER_LIST[Parse index, bounds check, list.get]')
w('    OTHER_LIST --> OTHER_CALL[(listItem.storeModelData)]')
w('    OTHER_CALL --> END_RETURN')
w('    CHECK_FIRST_BRANCH -->|none match| NO_MATCH([Fall through - no action])')
w('    NO_MATCH --> END_RETURN')
w('```')
w()
w('### Processing Flow Detail')
w()
w('1. **Null Guard (L3427)**: If key is null, return immediately.')
w('2. **Subkey Normalization (L3432)**: If subkey is null, set it to an empty String.')
w('3. **Common Info Check (L3438)**: Check if key starts with "//" (\\u5171\\u901a\\u60c5\\u5831\\u30d3\\u30fc\\u30f3). If yes, delegate entirely to super.storeCommonInfoData(key, in_value, isSetAsString).')
w('4. **Key Element Extraction (L3444-3447)**: Extract the first segment of the key before the first "/" character. If no "/" exists, the entire key is the element.')
w('5. **Branch Routing (L3450 onwards)**: Match keyElement against all supported field categories.')
w('6. **Index Parsing for List Fields**: For each list-based field type, extract index from key path, parse as Integer, bounds-check, and delegate to list item storeModelData.')
w('7. **No-match (L4547-4549)**: If no branch matches, the method falls through silently.')
w()
w('### Supported Field Categories')
w()
w('The method covers approximately 55+ distinct keyElement branches across these categories:')
w()
w('| Category | keyElement (Japanese) | Backend List/Setters | Data Type |')
w('|----------|----------------------|---------------------|-----------|')
w('| Function Code | \\u6a5f\\u80fd\\u30b3\\u30fc\\u30c9 | setFnc_mode_value / setFnc_mode_state | String |')
w('| Screen Mode | \\u753b\\u9762\\u30e2\\u30fc\\u30c9 | setScreen_mode_value / setScreen_mode_state | String |')
w('| Item Code (list) | \\u9805\\u76ee\\u30b3\\u30fc\\u30c9 | koumoku_code_list | X33VDataTypeStringBean |')
w('| Value (list) | \\u5024 | koumoku_value_list | X33VDataTypeStringBean |')
w('| Monthly Fee Items (list) | \\u6708\\u984d\\u6599\\u91d1\\u9805\\u76ee | getsu_ryokin_kmk_list | X33VDataTypeStringBean |')
w('| Monthly Fee (list) | \\u6708\\u984d\\u6599\\u91d1 | getsu_ryokin_list | X33VDataTypeStringBean |')
w('| Initial Fee Items (list) | \\u521d\\u671f\\u8cbb\\u7528\\u9805\\u76ee | shoki_hiyo_kmk_list | X33VDataTypeStringBean |')
w('| Initial Fee (list) | \\u521d\\u671f\\u8cbb\\u7528 | shoki_hiyo_list | X33VDataTypeStringBean |')
w('| Monthly Fee Total | \\u6708\\u984d\\u6599\\u91d1\\u8a08 | setGetsu_ryokin_kei_value / setGetsu_ryokin_kei_state | String |')
w('| Monthly Fee Total (tax excl) | \\u6708\\u984d\\u6599\\u91d1\\u8a08\\uff08\\u7a0e\\u629c\\uff09 | setGetsu_ryokin_kei_zei_value / setGetsu_ryokin_kei_zei_state | String |')
w('| Initial Fee Total | \\u521d\\u671f\\u8cbb\\u7528\\u8a08 | setShoki_hiyo_kei_value / setShoki_hiyo_kei_state | String |')
w('| Initial Fee Total (tax excl) | \\u521d\\u671f\\u8cbb\\u7528\\u8a08\\uff08\\u7a0e\\u629c\\uff09 | setShoki_hiyo_kei_zei_value / setShoki_hiyo_kei_zei_state | String |')
w('| Mobile Monthly Fee Total | \\u30e2\\u30d0\\u30a4\\u30eb\\u6708\\u984d\\u6599\\u91d1\\u8a08 | setMobile_month_value / setMobile_month_state | String |')
w('| Mobile Initial Fee Total | \\u30e2\\u30d0\\u30a4\\u30eb\\u521d\\u671f\\u8cbb\\u7528\\u8a08 | setMobile_init_value / setMobile_init_state | String |')
w('| Monthly Fee Statement | \\u6708\\u984d\\u6599\\u91d1\\u6587\\u8a00 | setGetsu_ryokin_mongon_value / setGetsu_ryokin_mongon_state | String |')
w('| Initial Fee Statement | \\u521d\\u671f\\u8cbb\\u7528\\u6587\\u8a00 | setShoki_hiyo_mongon_value / setShoki_hiyo_mongon_state | String |')
w('| Mobile Monthly Fee Statement | \\u30e2\\u30d0\\u30a4\\u30eb\\u6708\\u984d\\u6599\\u91d1\\u6587\\u8a00 | setMobile_month_mongon_value / setMobile_month_mongon_state | String |')
w('| Mobile Initial Fee Statement | \\u30e2\\u30d0\\u30a4\\u30eb\\u521d\\u671f\\u8cbb\\u7528\\u6587\\u8a00 | setMobile_init_mongon_value / setMobile_init_mongon_state | String |')
w('| Total with Tax | \\u6708\\u984d\\u6599\\u91d1\\u5408\\u8a08 | setGtgk_prc_gokei_value / setGtgk_prc_gokei_state | String |')
w('| Total with Tax (tax excl) | \\u6708\\u984d\\u6599\\u91d1\\u5408\\u8a08\\uff08\\u7a0e\\u629c\\uff09 | setGtgk_prc_gokei_zei_value / setGtgk_prc_gokei_zei_state | String |')
w('| Initial Fee Total (grand) | \\u521d\\u671f\\u8cbb\\u7528\\u5408\\u8a08 | setShkh_gokei_value / setShkh_gokei_state | String |')
w('| Initial Fee Total (grand, tax excl) | \\u521d\\u671f\\u8cbb\\u7528\\u5408\\u8a08\\uff08\\u7a0e\\u629c\\uff09 | setShkh_gokei_zei_value / setShkh_gokei_zei_state | String |')
w('| Total Statement | \\u6708\\u984d\\u6599\\u91d1\\u5408\\u8a08\\u6587\\u8a00 | setGtgk_prc_gokei_mongon_value / setGtgk_prc_gokei_mongon_state | String |')
w('| Initial Fee Total Statement | \\u521d\\u671f\\u8cbb\\u7528\\u5408\\u8a08\\u6587\\u8a00 | setShkh_gokei_mongon_value / setShkh_gokei_mongon_state | String |')
w('| Contract Type | \\u5951\\u7d04\\u7a2e\\u5225 | setKei_sbt_value / setKei_sbt_state | String |')
w('| Customer Info (Individual) - Gender | \\u3054\\u5951\\u7d04\\u8005\\u60c5\\u5831\\uff08\\u500b\\u4eba\\uff09\\u30fb\\u6027\\u5225 | setSex_value / setSex_state | String |')
w('| ID Proof Document | \\u3054\\u672c\\u4eba\\u69d8\\u78ba\\u8a8d\\u66f8\\u985e | setHnin_cfm_aticle_value / setHnin_cfm_aticle_state | String |')
w('| Installation Location - Form | \\u3054\\u5229\\u7528\\u5834\\u6240\\u8a2d\\u7f6e\\u4f4d\\u7f6e\\u30fb\\u5f62\\u614b | setSetplace_form_value / setSetplace_form_state | String |')
w('| Installation Location - Floor | \\u3054\\u5229\\u7528\\u5834\\u6240\\u8a2d\\u7f6e\\u4f4d\\u7f6e\\u30fb\\u968e\\u6570 | setSetplace_flr_value / setSetplace_flr_state | String |')
w('| Installation Location - Address | \\u3054\\u5229\\u7528\\u5834\\u6240\\u8a2d\\u7f6e\\u4f4d\\u7f6e\\u30fb\\u4f4f\\u6240\\u756a\\u5730 | setSetplace_bnchi_value / setSetplace_bnchi_state | String |')
w('| Installation Location - Active Network | \\u3054\\u5229\\u7528\\u5834\\u6240\\u8a2d\\u7f6e\\u4f4d\\u7f6e\\u30fb\\u5229\\u7528\\u4e2d\\u306e\\u30cd\\u30c3\\u30c8\\u56de\\u7dda | setUse_net_ksn_value / setUse_net_ksn_state | String |')
w('| Installation Location - Equipment Change | \\u3054\\u5229\\u7528\\u5834\\u6240\\u8a2d\\u7f6e\\u4f4d\\u7f6e\\u30fb\\u5229\\u7528\\u4e2d\\u306e\\u6a5f\\u5668\\u306e\\u8a2d\\u7f6e\\u5834\\u6240\\u5909\\u66f4\\u4e88\\u5b9a | setKiki_place_chg_value / setKiki_place_chg_state | String |')
w('| Installation Location - Same-Day Work | \\u3054\\u5229\\u7528\\u5834\\u6240\\u8a2d\\u7f6e\\u4f4d\\u7f6e\\u30fb\\u5b85\\u5185\\u8abf\\u67fb\\u3068\\u5de5\\u4e8b\\u306e\\u540c\\u65e5\\u5b9f\\u65bd | setTkc_koji_same_value / setTkc_koji_same_state | String |')
w('| Contact Preference | \\u9023\\u7d61\\u5148\\u9078\\u629e | setRrks_choice_value / setRrks_choice_state | String |')
w('| FAX Connection Request | FAX\\u9023\\u7d61\\u3054\\u5e0c\\u671b | setFax_kibo_value / setFax_kibo_state | String |')
w('| Same Place Warning Flag | \\u540c\\u4e00\\u5229\\u7528\\u5834\\u6240\\u8b66\\u544a\\u8868\\u793a\\u5236\\u5fa1\\u30d5\\u30e9\\u30b0 | setDsp_same_use_place_kkoku_flg_value / setDsp_same_use_place_kkoku_flg_state | String |')
w('| Postal Code Display Flag | \\u90f5\\u4fbf\\u756a\\u53f7\\u8868\\u793a\\u5236\\u5fa1\\u30d5\\u30e9\\u30b0 | setDsp_pcd_flg_value / setDsp_pcd_flg_state | String |')
w('| Close Button Display Flag | \\u9589\\u3058\\u308b\\u30dc\\u30bf\\u30f3\\u8868\\u793a\\u5236\\u5fa1\\u30d5\\u30e9\\u30b0 | setDsp_close_btn_flg_value / setDsp_close_btn_flg_state | String |')
w('| Register and Next Button Flag | \\u767b\\u9332\\u3057\\u3066\\u6b21\\u3078\\u30dc\\u30bf\\u30f3\\u8868\\u793a\\u30d5\\u30e9\\u30b0 | setDsp_add_btn_flg_value / setDsp_add_btn_flg_state | String |')
w('| Next Button Display Flag | \\u6b21\\u3078\\u30dc\\u30bf\\u30f3\\u8868\\u793a\\u30d5\\u30e9\\u30b0 | setDsp_next_btn_flg_value / setDsp_next_btn_flg_state | String |')
w('| Call Charge Limit Notification | \\u901a\\u8a71\\u6599\\u6307\\u5b9a\\u984d\\u5230\\u9054\\u901a\\u77e5\\u6307\\u5b9a\\u91d1\\u984d | setTwryo_stiam_ttu_tchi_stiam_value / setTwryo_stiam_ttu_tchi_stiam_state | String |')
w('| Contract Service Area Display Flag | \\u5951\\u7d04\\u4e2d\\u30b5\\u30fc\\u30d3\\u30b9\\u30a8\\u30ea\\u30a2\\u8868\\u793a\\u30d5\\u30e9\\u30b0 | setKei_svc_area_dsp_flg_value (Boolean) / setKei_svc_area_dsp_flg_state | Boolean/String |')
w('| CX Project Start Flag | CX\\u6848\\u4ef6\\u958b\\u59cb\\u30d5\\u30e9\\u30b0 | setCx_start_flg_value / setCx_start_flg_state | String |')
w('| Home Survey Inst. Pref. Display Flag | \\u5b85\\u5185\\u8abf\\u67fb\\u306e\\u30a2\\u30dd\\u67b6\\u96fb\\u5e0c\\u671b\\u8868\\u793a\\u30d5\\u30e9\\u30b0 | setTakcho_apo_kaden_kibo_um_disp_flg_value / setTakcho_apo_kaden_kibo_um_disp_flg_state | String |')
w('| Home Survey Inst. Preference | \\u5b85\\u5185\\u8abf\\u67fb\\u306e\\u30a2\\u30dd\\u67b6\\u96fb\\u5e0c\\u671b | setTakcho_apo_kaden_kibo_um_screen_value / _enabled / _state | String/Boolean |')
w('| Monthly Fee Items (Smart Link) (list) | \\u6708\\u984d\\u6599\\u91d1\\u9805\\u76ee\\uff08\\u30b9\\u30de\\u30fc\\u30c8\\u30ea\\u30f3\\u30af\\uff09 | getsu_ryokin_kmk_sml_list | X33VDataTypeStringBean |')
w('| Monthly Fee (Smart Link) (list) | \\u6708\\u984d\\u6599\\u91d1\\uff08\\u30b9\\u30de\\u30fc\\u30c8\\u30ea\\u30f3\\u30af\\uff09 | getsu_ryokin_sml_list | X33VDataTypeStringBean |')
w('| Initial Fee Items (Smart Link) (list) | \\u521d\\u671f\\u8cbb\\u7528\\u9805\\u76ee\\uff08\\u30b9\\u30de\\u30fc\\u30c8\\u30ea\\u30f3\\u30af\\uff09 | shoki_hiyo_kmk_sml_list | X33VDataTypeStringBean |')
w('| Initial Fee (Smart Link) (list) | \\u521d\\u671f\\u8cbb\\u7528\\uff08\\u30b9\\u30de\\u30fc\\u30c8\\u30ea\\u30f3\\u30af\\uff09 | shoki_hiyo_sml_list | X33VDataTypeStringBean |')
w('| Discount Valid Period (list) | \\u6708\\u984d\\u6599\\u91d1\\u5272\\u5f15\\u6587\\u8a00\\u9069\\u7528\\u671f\\u9593 | gtgk_wrib_mngn_tk_kikan_list | X33VDataTypeStringBean |')
w('| Discount Name (list) | \\u6708\\u984d\\u6599\\u91d1\\u5272\\u5f15\\u6587\\u8a00\\u5272\\u5f15\\u540d | gtgk_wrib_mngn_wrib_nm_list | X33VDataTypeStringBean |')
w('| Discount Amount (list) | \\u6708\\u984d\\u6599\\u91d1\\u5272\\u5f15\\u6587\\u8a00\\u5272\\u5f15\\u984d | gtgk_wrib_mngn_wrib_amnt_list | X33VDataTypeStringBean |')
w('| Discount Remarks (list) | \\u6708\\u984d\\u6599\\u91d1\\u5272\\u5f15\\u6587\\u8a00\\u5099\\u8003 | gtgk_wrib_mngn_biko_list | X33VDataTypeStringBean |')
w('| Monthly Fee Display Items (list) | \\u6708\\u984d\\u6599\\u91d1\\u8868\\u793a\\u9805\\u76ee | getsu_ryokin_kei_title_list | X33VDataTypeStringBean |')
w('| Monthly Fee Items (NH) (list) | \\u6708\\u984d\\u6599\\u91d1\\u9805\\u76ee\\uff08\\u30ca\\u30cb\\u30d3\\uff09 | getsu_ryokin_kmk_gh_list | X33VDataTypeStringBean |')
w('| Monthly Fee (NH) (list) | \\u6708\\u984d\\u6599\\u91d1\\uff08\\u30ca\\u30cb\\u30d3\\uff09 | getsu_ryokin_gh_list | X33VDataTypeStringBean |')
w('| Initial Fee Items (NH) (list) | \\u521d\\u671f\\u8cbb\\u7528\\u9805\\u76ee\\uff08\\u30ca\\u30cb\\u30d3\\uff09 | shoki_hiyo_kmk_gh_list | X33VDataTypeStringBean |')
w('| Initial Fee (NH) (list) | \\u521d\\u671f\\u8cbb\\u7528\\uff08\\u30ca\\u30cb\\u30d3\\uff09 | shoki_hiyo_gh_list | X33VDataTypeStringBean |')
w()

with open(path, 'w', encoding='utf-8') as f:
    f.write('
'.join(S) + '
')
print('Parts 1-2 written, size:', len(S), 'lines')
