import os

path = '.codewiki/dd/FUW00927SFBean/storeModelData.md'
os.makedirs(os.path.dirname(path), exist_ok=True)

J1 = '機能コード'
J2 = '画面モード'
J3 = '項目コード'
J4 = '値'
J5 = '月額料金項目'
J6 = '月額料金'
J7 = '初期費用項目'
J8 = '初期費用'
J9 = '月額料金計'
J10 = '月額料金計（税抜）'
J11 = '初期費用計'
J12 = '初期費用計（税抜）'
J13 = 'モバイル月額料金計'
J14 = 'モバイル初期費用計'
J15 = '月額料金文言'
J16 = '初期費用文言'
J17 = 'モバイル月額料金文言'
J18 = 'モバイル初期費用文言'
J19 = '月額料金合計'
J20 = '月額料金合計（税抜）'
J21 = '初期費用合計'
J22 = '初期費用合計（税抜）'
J23 = '月額料金合計文言'
J24 = '初期費用合計文言'
J25 = '契約種別'
J26 = 'ご契約者情報（個人）・性別'
J27 = 'ご本人様確認書類'
J28 = 'ご利用場所設置位置・形態'
J29 = 'ご利用場所設置位置・階数'
J30 = 'ご利用場所設置位置・住所番地'
J31 = 'ご利用場所設置位置・利用中のネット回線'
J32 = 'ご利用場所設置位置・利用中の機器の設置場所変更予定'
J33 = 'ご利用場所設置位置・宅内調査と工事の同日実施'
J34 = '連絡先選択'
J35 = 'FAX連絡ご希望'
J36 = '同一利用場所警告表示制御フラグ'
J37 = '郵便番号表示制御フラグ'
J38 = '閉じるボタン表示制御フラグ'
J39 = '登録して次へボタン表示フラグ'
J40 = '次へボタン表示フラグ'
J41 = '通話料指定額到達通知指定金額'
J42 = '契約中サービスエリア表示フラグ'
J43 = 'CX案件開始フラグ'
J44 = '宅内調査のアポ架電希望表示フラグ'
J45 = '宅内調査のアポ架電希望'

doc = f"""# Business Logic - FUW00927SFBean.storeModelData() [1127 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | eo.web.webview.FUW00927SF.FUW00927SFBean |
| Layer | Webview / Front-End Bean (Web Presentation Layer) |
| Module | FUW00927SF (Package: eo.web.webview.FUW00927SF) |

## 1. Role

### FUW00927SFBean.storeModelData()

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.

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.

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.

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.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["storeModelData params"])
    START --> CHECK_KEY_NULL{{key is null?}}
    CHECK_KEY_NULL -->|Yes| RETURN_EARLY(["Return immediately"])
    CHECK_KEY_NULL -->|No| CHECK_SUBKEY_NULL{{subkey is null?}}
    CHECK_SUBKEY_NULL -->|Yes| SET_SUBKEY_EMPTY[subkey set to empty String]
    SET_SUBKEY_EMPTY --> CHECK_SEPARATOR{{key starts with //?}}
    CHECK_SUBKEY_NULL -->|No| CHECK_SEPARATOR
    CHECK_SEPARATOR -->|Yes| DELEGATE_COMMON[super.storeCommonInfoData]
    CHECK_SEPARATOR -->|No| EXTRACT_KEY_ELEMENT[Extract keyElement before first /]
    DELEGATE_COMMON --> END_RETURN(["Return - Next"])
    EXTRACT_KEY_ELEMENT --> CHECK_FIRST_BRANCH{{Match keyElement?}}
    CHECK_FIRST_BRANCH -->|"{J1}"| FNC_SET[setFnc_mode_value or setFnc_mode_state]
    FNC_SET --> END_RETURN
    CHECK_FIRST_BRANCH -->|"{J2}"| SCREEN_SET[setScreen_mode_value or setScreen_mode_state]
    SCREEN_SET --> END_RETURN
    CHECK_FIRST_BRANCH -->|"{J3}"| LIST_INDEX[Parse index, bounds check, list.get]
    LIST_INDEX --> LIST_CALL[(listItem.storeModelData)]
    LIST_CALL --> END_RETURN
    CHECK_FIRST_BRANCH -->|"{J4}"| VALUE_LIST[Parse index, bounds check, list.get]
    VALUE_LIST --> VALUE_CALL[(listItem.storeModelData)]
    VALUE_CALL --> END_RETURN
    CHECK_FIRST_BRANCH -->|"{J5}"| KMK_LIST[Parse index, bounds check, list.get]
    KMK_LIST --> KMK_CALL[(listItem.storeModelData)]
    KMK_CALL --> END_RETURN
    CHECK_FIRST_BRANCH -->|"{J6}"| GETSU_LIST[Parse index, bounds check, list.get]
    GETSU_LIST --> GETSU_CALL[(listItem.storeModelData)]
    GETSU_CALL --> END_RETURN
    CHECK_FIRST_BRANCH -->|"{J7}"| SHOKI_KMK[Parse index, bounds check, list.get]
    SHOKI_KMK --> SHOKI_KMK_CALL[(listItem.storeModelData)]
    SHOKI_KMK_CALL --> END_RETURN
    CHECK_FIRST_BRANCH -->|"{J8}"| SHOKI_LIST[Parse index, bounds check, list.get]
    SHOKI_LIST --> SHOKI_CALL[(listItem.storeModelData)]
    SHOKI_CALL --> END_RETURN
    CHECK_FIRST_BRANCH -->|"{J9}"| KEI_LIST[Parse index, bounds check, list.get]
    KEI_LIST --> KEI_CALL[(listItem.storeModelData)]
    KEI_CALL --> END_RETURN
    CHECK_FIRST_BRANCH -->|other simple| SIMPLE_FIELD[setXxx_value or setXxx_state]
    SIMPLE_FIELD --> END_RETURN
    CHECK_FIRST_BRANCH -->|other list| OTHER_LIST[Parse index, bounds check, list.get]
    OTHER_LIST --> OTHER_CALL[(listItem.storeModelData)]
    OTHER_CALL --> END_RETURN
    CHECK_FIRST_BRANCH -->|none match| NO_MATCH([Fall through - no action])
    NO_MATCH --> END_RETURN
```

### Processing Flow Detail

1. **Null Guard (L3427)**: If key is null, return immediately.
2. **Subkey Normalization (L3432)**: If subkey is null, set it to an empty String.
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).
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.
5. **Branch Routing (L3450 onwards)**: Match keyElement against all supported field categories.
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.
7. **No-match (L4547-4549)**: If no branch matches, the method falls through silently.

### Supported Field Categories

The method covers approximately 55+ distinct keyElement branches across these categories:

| Category | keyElement (Japanese) | Backend List/Setters | Data Type |
|----------|----------------------|---------------------|-----------|
| Function Code | {J1} | setFnc_mode_value / setFnc_mode_state | String |
| Screen Mode | {J2} | setScreen_mode_value / setScreen_mode_state | String |
| Item Code (list) | {J3} | koumoku_code_list | X33VDataTypeStringBean |
| Value (list) | {J4} | koumoku_value_list | X33VDataTypeStringBean |
| Monthly Fee Items (list) | {J5} | getsu_ryokin_kmk_list | X33VDataTypeStringBean |
| Monthly Fee (list) | {J6} | getsu_ryokin_list | X33VDataTypeStringBean |
| Initial Fee Items (list) | {J7} | shoki_hiyo_kmk_list | X33VDataTypeStringBean |
| Initial Fee (list) | {J8} | shoki_hiyo_list | X33VDataTypeStringBean |
| Monthly Fee Total | {J9} | setGetsu_ryokin_kei_value / setGetsu_ryokin_kei_state | String |
| Monthly Fee Total (tax excl) | {J10} | setGetsu_ryokin_kei_zei_value / setGetsu_ryokin_kei_zei_state | String |
| Initial Fee Total | {J11} | setShoki_hiyo_kei_value / setShoki_hiyo_kei_state | String |
| Initial Fee Total (tax excl) | {J12} | setShoki_hiyo_kei_zei_value / setShoki_hiyo_kei_zei_state | String |
| Mobile Monthly Fee Total | {J13} | setMobile_month_value / setMobile_month_state | String |
| Mobile Initial Fee Total | {J14} | setMobile_init_value / setMobile_init_state | String |
| Monthly Fee Statement | {J15} | setGetsu_ryokin_mongon_value / setGetsu_ryokin_mongon_state | String |
| Initial Fee Statement | {J16} | setShoki_hiyo_mongon_value / setShoki_hiyo_mongon_state | String |
| Mobile Monthly Fee Statement | {J17} | setMobile_month_mongon_value / setMobile_month_mongon_state | String |
| Mobile Initial Fee Statement | {J18} | setMobile_init_mongon_value / setMobile_init_mongon_state | String |
| Total with Tax | {J19} | setGtgk_prc_gokei_value / setGtgk_prc_gokei_state | String |
| Total with Tax (tax excl) | {J20} | setGtgk_prc_gokei_zei_value / setGtgk_prc_gokei_zei_state | String |
| Initial Fee Total (grand) | {J21} | setShkh_gokei_value / setShkh_gokei_state | String |
| Initial Fee Total (grand, tax excl) | {J22} | setShkh_gokei_zei_value / setShkh_gokei_zei_state | String |
| Total Statement | {J23} | setGtgk_prc_gokei_mongon_value / setGtgk_prc_gokei_mongon_state | String |
| Initial Fee Total Statement | {J24} | setShkh_gokei_mongon_value / setShkh_gokei_mongon_state | String |
| Contract Type | {J25} | setKei_sbt_value / setKei_sbt_state | String |
| Customer Info (Individual) - Gender | {J26} | setSex_value / setSex_state | String |
| ID Proof Document | {J27} | setHnin_cfm_aticle_value / setHnin_cfm_aticle_state | String |
| Installation Location - Form | {J28} | setSetplace_form_value / setSetplace_form_state | String |
| Installation Location - Floor | {J29} | setSetplace_flr_value / setSetplace_flr_state | String |
| Installation Location - Address | {J30} | setSetplace_bnchi_value / setSetplace_bnchi_state | String |
| Installation Location - Active Network | {J31} | setUse_net_ksn_value / setUse_net_ksn_state | String |
| Installation Location - Equipment Change | {J32} | setKiki_place_chg_value / setKiki_place_chg_state | String |
| Installation Location - Same-Day Work | {J33} | setTkc_koji_same_value / setTkc_koji_same_state | String |
| Contact Preference | {J34} | setRrks_choice_value / setRrks_choice_state | String |
| FAX Connection Request | {J35} | setFax_kibo_value / setFax_kibo_state | String |
| Same Place Warning Flag | {J36} | setDsp_same_use_place_kkoku_flg_value / setDsp_same_use_place_kkoku_flg_state | String |
| Postal Code Display Flag | {J37} | setDsp_pcd_flg_value / setDsp_pcd_flg_state | String |
| Close Button Display Flag | {J38} | setDsp_close_btn_flg_value / setDsp_close_btn_flg_state | String |
| Register and Next Button Flag | {J39} | setDsp_add_btn_flg_value / setDsp_add_btn_flg_state | String |
| Next Button Display Flag | {J40} | setDsp_next_btn_flg_value / setDsp_next_btn_flg_state | String |
| Call Charge Limit Notification | {J41} | setTwryo_stiam_ttu_tchi_stiam_value / setTwryo_stiam_ttu_tchi_stiam_state | String |
| Contract Service Area Display Flag | {J42} | setKei_svc_area_dsp_flg_value (Boolean) / setKei_svc_area_dsp_flg_state | Boolean/String |
| CX Project Start Flag | {J43} | setCx_start_flg_value / setCx_start_flg_state | String |
| Home Survey Inst. Pref. Display Flag | {J44} | setTakcho_apo_kaden_kibo_um_disp_flg_value / setTakcho_apo_kaden_kibo_um_disp_flg_state | String |
| Home Survey Inst. Preference | {J45} | setTakcho_apo_kaden_kibo_um_screen_value / _enabled / _state | String/Boolean |

"""

with open(path, 'w', encoding='utf-8') as f:
    f.write(doc)

print("Section 1-2 written, lines:", doc.count('\
'))
