# Business Logic — KKW00810SF01DBean.loadModelData() [80 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00810SF.KKW00810SF01DBean` |
| Layer | Web View / Screen Component (Controller-tier data binding bean) |
| Module | `KKW00810SF` (Package: `eo.web.webview.KKW00810SF`) |

## 1. Role

### KKW00810SF01DBean.loadModelData()

This method serves as the **centralized data retrieval dispatcher** for the KKW00810SF screen (a telecom service contract movement/change screen). It implements a **routing/dispatch pattern** that resolves field values and states by matching a composite `key` string (representing a field name) and a `subkey` string (representing the attribute type — typically `value` or `state`) against five supported business data types. The method is a **core data-binding entry point** for the JavaServer Faces (JSF) view layer, enabling UI components to request either the raw value or the validation state of any supported field through a single, unified API.

The five data types handled are: **SYSID** (system ID), **サービス契約番号** (Service Contract Number), **異動区分** (Movement Type — e.g., add/change/cancel), **異動理由コード** (Movement Reason Code — a multi-value list), and **異動理由メモ** (Movement Reason Memo). For scalar fields (the first, last two, and fifth types), the method returns a `String` value or a `String` validation state based on the `subkey`. For the list-typed `異動理由コード`, it supports returning the list size (when `subkey` is `*` after the slash separator), an indexed element from the list (when `subkey` is a numeric index), or delegates further property resolution to the individual list element's `loadModelData` method.

The method implements the `X33VDataTypeBeanInterface` contract, which is part of the X33 view-data framework used across K-Opticom's web application suite. It acts as a **shared utility within the screen scope**, called by the screen's no-arg `loadModelData()` overload and potentially by JSF backing bean expression bindings that resolve field values dynamically at render time.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["loadModelData key subkey"])

    START --> CheckNull{Null check}
    CheckNull -->|Yes| RetNull1["Return null"]
    CheckNull -->|No| FindSep["separaterPoint = indexOf slash"]

    FindSep --> CheckSysid{key is SYSID?}
    CheckSysid -->|Yes| CheckSysidSbt{subkey is value?}
    CheckSysidSbt -->|Yes| RetSysidVal["Return getSysid_value"]
    CheckSysidSbt -->|No| CheckSysidSt{subkey is state?}
    CheckSysidSt -->|Yes| RetSysidSt["Return getSysid_state"]
    CheckSysidSt -->|No| CheckSvc{key is service contract?}

    CheckSysid -->|No| CheckSvc
    CheckSvc -->|Yes| CheckSvcSbt{subkey is value?}
    CheckSvcSbt -->|Yes| RetSvcVal["Return getSvc_kei_no_value"]
    CheckSvcSbt -->|No| CheckSvcSt{subkey is state?}
    CheckSvcSt -->|Yes| RetSvcSt["Return getSvc_kei_no_state"]
    CheckSvcSt -->|No| CheckIdo{key is movement type?}

    CheckSvc -->|No| CheckIdo
    CheckIdo -->|Yes| CheckIdoSbt{subkey is value?}
    CheckIdoSbt -->|Yes| RetIdoVal["Return getIdo_div_value"]
    CheckIdoSbt -->|No| CheckIdoSt{subkey is state?}
    CheckIdoSt -->|Yes| RetIdoSt["Return getIdo_div_state"]
    CheckIdoSt -->|No| CheckIrcd{key is movement reason code?}

    CheckIdo -->|No| CheckIrcd
    CheckIrcd -->|Yes| ExtractKey["key = substring after slash"]
    ExtractKey --> CheckStar{key is asterisk?}
    CheckStar -->|Yes| RetListSize["Return list size"]
    CheckStar -->|No| ParseIndex["Parse key as integer"]
    ParseIndex --> CatchNb{Number format error?}
    CatchNb -->|Yes| RetNull2["Return null"]
    CatchNb -->|No| CheckIdxNull{Index null?}
    CheckIdxNull -->|Yes| RetNull3["Return null"]
    CheckIdxNull -->|No| CheckBounds{Index out of bounds?}
    CheckBounds -->|Yes| RetNull4["Return null"]
    CheckBounds -->|No| Delegate["Delegated loadModelData call"]
    Delegate --> RetDelegate["Return delegated result"]

    CheckIrcd -->|No| CheckIrmemo{key is movement reason memo?}
    CheckIrmemo -->|Yes| CheckIrmemoSbt{subkey is value?}
    CheckIrmemoSbt -->|Yes| RetIrmemoVal["Return getIdo_rsn_memo_value"]
    CheckIrmemoSbt -->|No| CheckIrmemoSt{subkey is state?}
    CheckIrmemoSt -->|Yes| RetIrmemoSt["Return getIdo_rsn_memo_state"]
    CheckIrmemoSt -->|No| RetNull5["Return null final"]

    CheckIrmemo -->|No| RetNull5
```

**Flow summary:**
1. **Null guard**: If either `key` or `subkey` is null, return null immediately.
2. **Separator extraction**: Find the position of `/` in `key` for later substring processing (needed for the `異動理由コード` list key format).
3. **Type dispatch**: Five mutually exclusive branches check `key` against literal strings:
   - `SYSID` (system identifier) — return value or state
   - `サービス契約番号` (Service Contract Number) — return value or state
   - `異動区分` (Movement Type) — return value or state
   - `異動理由コード` (Movement Reason Code) — list-oriented: returns list count for `*`, parsed index for numbers, or delegates to the list element for arbitrary subkeys
   - `異動理由メモ` (Movement Reason Memo) — return value or state
4. **Fallback**: If no key matches, return null.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The field identifier. Maps to one of five business data types: `SYSID` (system identifier), `サービス契約番号` (Service Contract Number), `異動区分` (Movement Type), `異動理由コード` (Movement Reason Code — list type), or `異動理由メモ` (Movement Reason Memo). For the list type, the key contains a slash separator followed by an index or `*` (e.g., `異動理由コード/0` retrieves the first list element). |
| 2 | `subkey` | `String` | The attribute accessor type within the matched field. For scalar fields, accepts `value` (returns the field's data value) or `state` (returns the field's validation/state metadata). For the list type (`異動理由コード`), accepts `*` (returns list size), a numeric index string (returns the element at that index), or arbitrary property names (delegated to the element's own `loadModelData`). |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ido_rsn_cd_list` | `X33VDataTypeList` | The list of movement reason code entries, each being a `X33VDataTypeStringBean`. Accessed for size queries and indexed element retrieval. |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `KKW00810SF01DBean.getSysid_value` | KKW00810SF01DBean | - | Reads the SYSID value field (returns `sysid_value` String) |
| R | `KKW00810SF01DBean.getSysid_state` | KKW00810SF01DBean | - | Reads the SYSID validation state (returns `sysid_state` String) |
| R | `KKW00810SF01DBean.getSvc_kei_no_value` | KKW00810SF01DBean | - | Reads the Service Contract Number value (returns `svc_kei_no_value` String) |
| R | `KKW00810SF01DBean.getSvc_kei_no_state` | KKW00810SF01DBean | - | Reads the Service Contract Number validation state |
| R | `KKW00810SF01DBean.getIdo_div_value` | KKW00810SF01DBean | - | Reads the Movement Type value (returns `ido_div_value` String) |
| R | `KKW00810SF01DBean.getIdo_div_state` | KKW00810SF01DBean | - | Reads the Movement Type validation state |
| R | `KKW00810SF01DBean.getIdo_rsn_memo_value` | KKW00810SF01DBean | - | Reads the Movement Reason Memo value (returns `ido_rsn_memo_value` String) |
| R | `KKW00810SF01DBean.getIdo_rsn_memo_state` | KKW00810SF01DBean | - | Reads the Movement Reason Memo validation state |
| R | `KKW00810SF01DBean.loadModelData` | KKW00810SF01DBean | - | Recursive/self-referencing dispatch call (delegated) |
| R | `X33VDataTypeStringBean.loadModelData` | X33VDataTypeStringBean | - | Delegates subkey resolution for individual list elements in `ido_rsn_cd_list` |
| - | `String.indexOf` | String | - | Locates the `/` separator in the `key` parameter |
| - | `String.substring` | String | - | Extracts the portion after the separator for list-type keys |
| - | `String.equalsIgnoreCase` | String | - | Case-insensitive comparison of `subkey` against `value`/`state` |
| - | `String.equals` | String | - | Exact comparison of `key` against known field type identifiers |
| - | `String.equalsIgnoreCase` | String | - | Case-insensitive comparison for asterisk check on list keys |

**Classification rationale:**
This method performs **pure read operations** (R). It never modifies any fields, inserts/updates/deletes database records, or invokes service components (SC/CBS). It is a **view-state accessor** that reads in-memory field values and delegates to sub-elements within a list structure. The `indexOf`, `substring`, and `equals` calls are standard Java string operations, not business-level CRUD.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `KKW00810SF01DBean` (Screen Bean) | `KKW00810SF01DBean.loadModelData()` (no-arg overload) → `storeModelData(key, subkey, ...)` chain → `loadModelData(String key, String subkey)` | Reads scalar field values/states from KKW00810SF01DBean instance fields |

**Notes:**
- The only pre-computed direct caller is the **no-arg overload** of `loadModelData` within `KKW00810SF01DBean` itself. This overload acts as a delegation bridge, likely invoked by the JSF lifecycle or a framework hook that calls the no-arg variant during screen initialization.
- The broader codebase search for `KKW00810SF01DBean.loadModelData(` returned no cross-file callers, indicating this is an **internal screen-level accessor** scoped to the KKW00810SF screen, not a shared utility called by other screens.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `key == null || subkey == null` (L203)

> Null guard: Returns null early if either parameter is null. This prevents NullPointerException in subsequent string operations.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `if (key == null || subkey == null)` |
| 2 | RETURN | `return null;` // Returns null when key or subkey is null (key,subkeyがnullの場合、nullを返す) |

**Block 2** — [EXEC] Separator computation (L207)

> Computes the index of the `/` character in `key` for later substring extraction. This is only meaningful for the `異動理由コード` list-type key.

| # | Type | Code |
|---|------|------|
| 1 | SET | `int separaterPoint = key.indexOf("/");` // Finds the position of the slash separator |

**Block 3** — [IF] `key.equals("SYSID")` (L210)

> Branch: The data type is SYSID (system identifier). Subkey determines whether to return the value or the state.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `if (key.equals("SYSID"))` // Checks if the field type is SYSID (データタイプがStringの項目"SYSID"(項目ID:sysid)) |
| 2 | IF | **Block 3.1** — `subkey.equalsIgnoreCase("value")` (L211) |
| 3 | | |

**Block 3.1** — [IF] `subkey.equalsIgnoreCase("value")` (L211)

> Sub-branch: Returns the SYSID value field.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return getSysid_value();` // Returns the sysid_value field |

**Block 3.2** — [ELSE-IF] `subkey.equalsIgnoreCase("state")` (L214)

> Sub-branch: Returns the SYSID validation state. (subkeyが"state"の場合、ステータスを返す。)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return getSysid_state();` // Returns the sysid_state field |

**Block 4** — [ELSE-IF] `key.equals("サービス契約番号")` (L219)

> Branch: The data type is Service Contract Number (サービス契約番号). Subkey determines value or state return.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `else if (key.equals("サービス契約番号"))` // Checks if the field type is Service Contract Number (データタイプがStringの項目"サービス契約番号"(項目ID:svc_kei_no)) |
| 2 | IF | **Block 4.1** — `subkey.equalsIgnoreCase("value")` (L220) |
| 3 | | |

**Block 4.1** — [IF] `subkey.equalsIgnoreCase("value")` (L220)

> Sub-branch: Returns the service contract number value.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return getSvc_kei_no_value();` // Returns the svc_kei_no_value field |

**Block 4.2** — [ELSE-IF] `subkey.equalsIgnoreCase("state")` (L223)

> Sub-branch: Returns the service contract number validation state. (subkeyが"state"の場合、ステータスを返す。)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return getSvc_kei_no_state();` // Returns the svc_kei_no_state field |

**Block 5** — [ELSE-IF] `key.equals("異動区分")` (L228)

> Branch: The data type is Movement Type (異動区分 — e.g., add/change/cancel operation type). Subkey determines value or state return.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `else if (key.equals("異動区分"))` // Checks if the field type is Movement Type (データタイプがStringの項目"異動区分"(項目ID:ido_div)) |
| 2 | IF | **Block 5.1** — `subkey.equalsIgnoreCase("value")` (L229) |
| 3 | | |

**Block 5.1** — [IF] `subkey.equalsIgnoreCase("value")` (L229)

> Sub-branch: Returns the movement type value.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return getIdo_div_value();` // Returns the ido_div_value field |

**Block 5.2** — [ELSE-IF] `subkey.equalsIgnoreCase("state")` (L232)

> Sub-branch: Returns the movement type validation state. (subkeyが"state"の場合、ステータスを返す。)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return getIdo_div_state();` // Returns the ido_div_state field |

**Block 6** — [ELSE-IF] `key.equals("異動理由コード")` (L238)

> Branch: The data type is Movement Reason Code (異動理由コード — a list of code values). This is the most complex branch, handling three sub-modes: list count (`*`), indexed access (numeric key), and delegated resolution. The key is modified via substring to extract the part after the slash separator.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `else if (key.equals("異動理由コード"))` // Checks if the field type is Movement Reason Code (リスト型。項目ID:ido_rsn_cd) |
| 2 | SET | `key = key.substring(separaterPoint + 1);` // Extracts the element after the slash in the key keyの次の要素を取得 |
| 3 | IF | **Block 6.1** — `key.equals("*")` (L242) |
| 4 | ELSE | **Block 6.2** — `try` / `catch` block for index parsing (L247) |

**Block 6.1** — [IF] `key.equals("*")` (L242)

> Sub-branch: Returns the size of the movement reason code list when `*` is specified as the index placeholder. (インデックス値の代わりに"*"が指定されていたら、リストの要素数を返す。)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return Integer.valueOf(ido_rsn_cd_list.size());` // Returns the number of elements in the list |

**Block 6.2** — [ELSE] Try-catch: index parsing (L247)

> Sub-branch: Attempts to parse `key` as a numeric index. If the key is not a valid integer, catches the exception and returns null. (インデックス値が数値文字列でない場合は、ここでnullを返す。)

| # | Type | Code |
|---|------|------|
| 1 | SET | `Integer tmpIndexInt = null;` // Declares a nullable integer variable for the parsed index |
| 2 | TRY | `try { tmpIndexInt = Integer.valueOf(key); }` // Parses key as an integer |
| 3 | CATCH | **Block 6.2.1** — `NumberFormatException` (L250) |

**Block 6.2.1** — [CATCH] `NumberFormatException` (L250)

> Exception handler: Returns null when the key string is not a valid number. (インデックス値が数値文字列でない場合は、ここでnullを返す。)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Returns null for non-numeric index keys |

**Block 6.3** — [IF] `tmpIndexInt == null` (L253)

> Post-parse null check: If for any reason the parsed index is null, return null.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Early return if parsed index is null |

**Block 6.4** — [IF] `tmpIndex < 0 || tmpIndex >= ido_rsn_cd_list.size()` (L259)

> Bounds check: Ensures the parsed index is within the valid range [0, list size). (インデックス値がリスト個数-1を超える場合、ここでnullを返す。)

| # | Type | Code |
|---|------|------|
| 1 | SET | `int tmpIndex = tmpIndexInt.intValue();` // Unboxes the Integer to a primitive int |
| 2 | RETURN | `return null;` // Returns null for out-of-bounds index |

**Block 6.5** — [RETURN] List element delegation (L261)

> Final case: Retrieves the element at the parsed index, casts it to `X33VDataTypeStringBean`, and delegates subkey resolution to its own `loadModelData` method.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `((X33VDataTypeStringBean)ido_rsn_cd_list.get(tmpIndex)).loadModelData(subkey);` // Casts list element and delegates subkey resolution to its loadModelData method |

**Block 7** — [ELSE-IF] `key.equals("異動理由メモ")` (L265)

> Branch: The data type is Movement Reason Memo (異動理由メモ — a free-text memo field). Subkey determines value or state return.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `else if (key.equals("異動理由メモ"))` // Checks if the field type is Movement Reason Memo (データタイプがStringの項目"異動理由メモ"(項目ID:ido_rsn_memo)) |
| 2 | IF | **Block 7.1** — `subkey.equalsIgnoreCase("value")` (L266) |
| 3 | | |

**Block 7.1** — [IF] `subkey.equalsIgnoreCase("value")` (L266)

> Sub-branch: Returns the movement reason memo value.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return getIdo_rsn_memo_value();` // Returns the ido_rsn_memo_value field |

**Block 7.2** — [ELSE-IF] `subkey.equalsIgnoreCase("state")` (L269)

> Sub-branch: Returns the movement reason memo validation state. (subkeyが"state"の場合、ステータスを返す。)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return getIdo_rsn_memo_state();` // Returns the ido_rsn_memo_state field |

**Block 8** — [RETURN] No-match fallback (L273)

> Default return: No key matched any known data type. (条件に合致するプロパティが存在しない場合は、nullを返す。)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Returns null when no matching property is found |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `sysid` | Field | System ID — an internal system-generated identifier for the record, stored in `sysid_value` and `sysid_state` fields |
| `svc_kei_no` | Field | Service Contract Number — the unique identifier for a telecom service contract line item. "Kei" (計) refers to the service plan/category |
| `ido_div` | Field | Movement Type — classifies the type of contract change operation (e.g., add/新規, change/変更, cancel/取消). "Ido" (異動) means "movement" or "change" in the context of telecom service orders |
| `ido_rsn_cd` | Field | Movement Reason Code — a list of codes explaining why a contract change was made. Each element is a `X33VDataTypeStringBean` with its own `loadModelData` method |
| `ido_rsn_memo` | Field | Movement Reason Memo — a free-text memo field providing additional context for the contract change. "Memo" (メモ) is directly from English |
| `sysid_update` | Field | SYSID update flag — tracks whether the sysid field has been modified |
| `sysid_state` | Field | SYSID validation state — holds validation error/success status for the sysid field |
| `svc_kei_no_update` | Field | Service contract number update flag |
| `svc_kei_no_state` | Field | Service contract number validation state |
| `ido_div_update` | Field | Movement type update flag |
| `ido_div_state` | Field | Movement type validation state |
| `ido_rsn_cd_list` | Field | Movement reason code list — an `X33VDataTypeList` containing `X33VDataTypeStringBean` elements, each representing a reason code entry |
| `ido_rsn_memo_update` | Field | Movement reason memo update flag |
| `ido_rsn_memo_state` | Field | Movement reason memo validation state |
| `X33VDataTypeBeanInterface` | Interface | K-Opticom X33 view-data framework contract — defines the contract for beans that can load/store model data via `loadModelData`/`storeModelData` methods |
| `X33VListedBeanInterface` | Interface | X33 framework interface for beans that support list data types |
| `X33VDataTypeStringBean` | Class | X33 framework string data type bean — individual elements in the `ido_rsn_cd_list` use this class and implement their own `loadModelData` for property resolution |
| `X33VDataTypeList` | Class | X33 framework list data type — a typed list container for holding list elements like movement reason codes |
| JSF | Acronym | JavaServer Faces — the Java web framework used for building the screen UI. This bean serves as a JSF backing bean |
| SC | Acronym | Service Contract — a telecom service contract. The prefix `svc_kei` (サービス計) refers to service plan/contract details |
| SYSID | Business term | System ID — a system-generated unique identifier for database records in the K-Opticom order management system |
| `/` separator | Concept | Slash character used as a delimiter in the `key` parameter for list-type fields (e.g., `異動理由コード/0`). The `separaterPoint` captures the position of this character |
| `*` index | Concept | Wildcard index value for list-type fields — when used as the index portion of the key (e.g., `異動理由コード/*`), it requests the list size rather than a specific element |
