# Business Logic — KKW02516SF02DBean.loadModelData() [33 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKA16801SF.KKW02516SF02DBean` |
| Layer | Web / Data Bean (WebView Data Layer — part of the X31C data bean framework) |
| Module | `KKA16801SF` (Package: `eo.web.webview.KKA16801SF`) |

## 1. Role

### KKW02516SF02DBean.loadModelData()

This method serves as a **data accessor dispatcher** within the K-Opticom web application framework, enabling UI components to retrieve field data from the `KKW02516SF02DBean` object by specifying a **business item name** (`key`) and a **data sub-type** (`subkey`). It implements the **template method pattern** from the X31C framework's `X31CBaseBean.loadModelData()` interface, overriding the base implementation to support domain-specific data retrieval for the KKA16801SF screen module.

The method handles **two business data categories**: (1) **Move Reason Code** ("異動理由コード" / `ido_rsn_cd`), which stores the classification code explaining why a service item's status changed (e.g., upgrade, downgrade, cancellation), and (2) **Move Reason Memo** ("異動理由メモ" / `ido_rsn_memo`), which stores the free-text description or comment associated with that status change. For each category, it distinguishes between two data sub-types: `value` (the actual field content) and `state` (the validation/edit state flag indicating whether the field is locked, read-only, or modifiable).

Its role in the larger system is that of a **shared data bean utility** called by the parent `KKW02516SF02DBean`'s `getModelData()` / `loadModelData()` dispatch mechanism, and by any data-binding components that need to access these fields without directly coupling to the bean's internal fields. This allows the UI layer to request field values generically — the framework iterates over a list of detail row beans and calls `loadModelData()` on each to populate form fields, dropdowns, and display labels at screen render time.

When both parameters are null, it returns null (fast path). When an unrecognized item name is requested, it also returns null, providing a safe no-op for unknown data types.

## 2. Processing Pattern (Detailed Business Logic)

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

    START --> CHECK_NULL{"key or subkey is null?"}
    CHECK_NULL -->|Yes| RETURN_NULL["Return null"]
    CHECK_NULL -->|No| COMPUTE_SEP["separaterPoint = key.indexOf('/')"]

    COMPUTE_SEP --> CHECK_KEY1{"key equals \"異動理由コード\" (ido_rsn_cd)?"}
    CHECK_KEY1 -->|Yes| CHECK_SUB1{"subkey.equalsIgnoreCase(\"value\")?"}
    CHECK_SUB1 -->|Yes| CALL_VALUE["Call getIdo_rsn_cd_value()"]
    CHECK_SUB1 -->|No| CHECK_SUB1B{"subkey.equalsIgnoreCase(\"state\")?"}
    CHECK_SUB1B -->|Yes| CALL_STATE["Call getIdo_rsn_cd_state()"]
    CHECK_SUB1B -->|No| ELSE_KEY1["Return null"]

    CHECK_KEY1 -->|No| CHECK_KEY2{"key equals \"異動理由メモ\" (ido_rsn_memo)?"}
    CHECK_KEY2 -->|Yes| CHECK_SUB2{"subkey.equalsIgnoreCase(\"value\")?"}
    CHECK_SUB2 -->|Yes| CALL_MEMO_VAL["Call getIdo_rsn_memo_value()"]
    CHECK_SUB2 -->|No| CHECK_SUB2B{"subkey.equalsIgnoreCase(\"state\")?"}
    CHECK_SUB2B -->|Yes| CALL_MEMO_STATE["Call getIdo_rsn_memo_state()"]
    CHECK_SUB2B -->|No| ELSE_KEY2["Return null"]

    CHECK_KEY2 -->|No| ELSE_DEFAULT["Return null"]

    CALL_VALUE --> END(["Return data"])
    CALL_STATE --> END
    CALL_MEMO_VAL --> END
    CALL_MEMO_STATE --> END
    ELSE_KEY1 --> END
    ELSE_KEY2 --> END
    ELSE_DEFAULT --> END
    RETURN_NULL --> END
```

**Processing flow summary:**

1. **Null guard**: If either `key` or `subkey` is `null`, immediately return `null` (early exit). This prevents `NullPointerException` on downstream `equals()` and `equalsIgnoreCase()` calls.
2. **Separator computation**: Compute `separaterPoint = key.indexOf('/')`. This value is calculated but **never used** in this method — it appears to be a leftover from a previous routing design that would have parsed hierarchical key names (e.g., `"category/subitem"`).
3. **First branch** — "異動理由コード" (Move Reason Code): When the key matches this Japanese string literal, delegate to either `getIdo_rsn_cd_value()` for the field value or `getIdo_rsn_cd_state()` for the field state.
4. **Second branch** — "異動理由メモ" (Move Reason Memo): When the key matches this Japanese string literal, delegate to either `getIdo_rsn_memo_value()` for the field value or `getIdo_rsn_memo_state()` for the field state.
5. **Default fall-through**: When no key matches any known item name, return `null`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The **business item name** that identifies which field's data to retrieve. It carries the display name of a domain field (e.g., `"異動理由コード"` for Move Reason Code, `"異動理由メモ"` for Move Reason Memo). Case-sensitive string comparison is used. |
| 2 | `subkey` | `String` | The **data sub-type** that specifies what aspect of the field to return. It takes values like `"value"` (the actual data content) or `"state"` (the field's validation/edit state). Case-**insensitive** comparison is used, allowing callers to pass "VALUE", "Value", "state", etc. |

**Instance fields read by this method:**

| No | Field Name | Type | Business Description |
|----|-----------|------|---------------------|
| 1 | `ido_rsn_cd_value` | `String` | The actual move reason code value — the classification code that explains why a service item's status changed |
| 2 | `ido_rsn_cd_state` | `String` | The validation/edit state of the move reason code field — indicates whether the field is locked, read-only, or modifiable |
| 3 | `ido_rsn_memo_value` | `String` | The actual move reason memo text — free-text comment describing the status change |
| 4 | `ido_rsn_memo_state` | `String` | The validation/edit state of the move reason memo field |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `KKW02516SF02DBean.getIdo_rsn_cd_state` | KKW02516SF02DBean | - | Returns the `ido_rsn_cd_state` field value (field state flag) |
| R | `KKW02516SF02DBean.getIdo_rsn_cd_value` | KKW02516SF02DBean | - | Returns the `ido_rsn_cd_value` field value (move reason code content) |
| R | `KKW02516SF02DBean.getIdo_rsn_memo_state` | KKW02516SF02DBean | - | Returns the `ido_rsn_memo_state` field value (memo field state flag) |
| R | `KKW02516SF02DBean.getIdo_rsn_memo_value` | KKW02516SF02DBean | - | Returns the `ido_rsn_memo_value` field value (move reason memo content) |

**Classification rationale:** All four called methods are simple getter accessors within the same bean class. They perform no external I/O, no database access, and no service component invocation. They simply return the internal field values. Hence all are classified as **R** (Read / in-memory data retrieval).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW02516SF (koptWebA) | `KKW02516SFBean.getModelData` -> `KKW02516SF02DBean.loadModelData` | `getIdo_rsn_cd_value [R]`<br>`getIdo_rsn_cd_state [R]`<br>`getIdo_rsn_memo_value [R]`<br>`getIdo_rsn_memo_state [R]` |
| 2 | Screen:KKW02516SF (koptWebB) | `KKW02516SFBean.getModelData` -> `KKW02516SF02DBean.loadModelData` | `getIdo_rsn_cd_value [R]`<br>`getIdo_rsn_cd_state [R]`<br>`getIdo_rsn_memo_value [R]`<br>`getIdo_rsn_memo_state [R]` |

**Caller details:**

- **`KKW02516SFBean` (koptWebA)** — The parent screen bean (line 1948). It creates `KKW02516SF02DBean` instances for the "異動理由リスト" (Move Reason List) detail row items. When the framework needs to render a field on the screen, it calls `KKW02516SF02DBean.loadModelData()` through the bean's overridden method to populate field values and states.
- **`KKW02516SFBean` (koptWebB)** — The parallel screen bean in the koptWebB package, following the same pattern.

**Important note:** No other screens or batches directly call `KKW02516SF02DBean.loadModelData()` as an entry point. It is invoked indirectly through the X31C framework's data-binding layer, which calls `getModelData()` on list items. Other DBean classes (e.g., `KKW00825SF19DBean`, `KKW00825SF09DBean`, `KKW00147SF24DBean`, `KKW03204SF02DBean`) share similar patterns for their own fields but do not call this specific method.

## 6. Per-Branch Detail Blocks

**Block 1** — IF (null guard) `(key == null || subkey == null)` (L131)

> Early-exit guard: if either parameter is null, return null immediately to prevent NullPointerException on downstream string operations.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // key, subkey がnullの場合、nullを返す [Return null if key/subkey is null] |

**Block 2** — EXEC (separator computation) (L135)

> Compute the position of '/' in key. This value is never used in the method — appears to be a leftover from a prior hierarchical-key design.

| # | Type | Code |
|---|------|------|
| 1 | SET | `int separaterPoint = key.indexOf("/");` // 区切り点の位置を取得 [Compute separator position] |

**Block 3** — IF-ELSE chain — First category: "異動理由コード" (Move Reason Code) (L138)

> Branch 1: Route to Move Reason Code data access. The key must match the Japanese string literal `"異動理由コード"` (item ID: `ido_rsn_cd`).

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(key.equals("異動理由コード"))` // データタイプがStringの項目"異動理由コード"(項目ID:ido_rsn_cd) [Data type is String field "Move Reason Code" (item ID: ido_rsn_cd)] |

**Block 3.1** — IF (subkey = value) (L139)

> Sub-block: Return the actual move reason code value.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(subkey.equalsIgnoreCase("value"))` |
| 2 | CALL | `return getIdo_rsn_cd_value();` // [Returns the ido_rsn_cd_value field] |

**Block 3.2** — ELSE-IF (subkey = state) (L142)

> Sub-block: Return the move reason code field's validation/edit state.

| # | Type | Code |
|---|------|------|
| 1 | ELSE IF | `else if(subkey.equalsIgnoreCase("state"))` // subkeyが"state"の場合、ステータスを返す [If subkey is "state", return the status] |
| 2 | CALL | `return getIdo_rsn_cd_state();` // [Returns the ido_rsn_cd_state field] |

**Block 4** — ELSE-IF chain — Second category: "異動理由メモ" (Move Reason Memo) (L147)

> Branch 2: Route to Move Reason Memo data access. The key must match the Japanese string literal `"異動理由メモ"` (item ID: `ido_rsn_memo`).

| # | Type | Code |
|---|------|------|
| 1 | ELSE IF | `else if(key.equals("異動理由メモ"))` // データタイプがStringの項目"異動理由メモ"(項目ID:ido_rsn_memo) [Data type is String field "Move Reason Memo" (item ID: ido_rsn_memo)] |

**Block 4.1** — IF (subkey = value) (L148)

> Sub-block: Return the actual move reason memo text.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(subkey.equalsIgnoreCase("value"))` |
| 2 | CALL | `return getIdo_rsn_memo_value();` // [Returns the ido_rsn_memo_value field] |

**Block 4.2** — ELSE-IF (subkey = state) (L151)

> Sub-block: Return the move reason memo field's validation/edit state.

| # | Type | Code |
|---|------|------|
| 1 | ELSE IF | `else if(subkey.equalsIgnoreCase("state"))` // subkeyが"state"の場合、ステータスを返す [If subkey is "state", return the status] |
| 2 | CALL | `return getIdo_rsn_memo_state();` // [Returns the ido_rsn_memo_state field] |

**Block 5** — RETURN (default) (L155)

> Catch-all: when no key matches any known item name, return null.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // 条件に合致するプロパティが存在しない場合は、nullを返す [No matching property found, return null] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `異動理由コード` | Field (Japanese) | Move Reason Code — the classification code that identifies why a service item's status was changed (e.g., upgrade, downgrade, cancellation) |
| `異動理由メモ` | Field (Japanese) | Move Reason Memo — free-text comment describing the reason for a service item status change |
| `ido_rsn_cd` | Field ID | Internal identifier for the Move Reason Code field (`rsn` = reason, `cd` = code) |
| `ido_rsn_memo` | Field ID | Internal identifier for the Move Reason Memo field (`rsn` = reason) |
| `subkey = "value"` | Concept | Data sub-type that returns the actual field content (the stored value itself) |
| `subkey = "state"` | Concept | Data sub-type that returns the field's validation/edit state (whether the field is locked, read-only, or modifiable by the user) |
| X31C | Acronym | K-Opticom's proprietary web application framework — provides base bean classes, data binding, and screen lifecycle management |
| DBean | Acronym | Data Bean — a UI-bound data container class in the X31C framework that holds field values and states for screen rendering |
| Bean | Acronym | JavaBean — a convention for Java classes with private fields and public getter/setter methods, used here as data containers |
| SC | Acronym | Service Component — the middle-tier service layer that handles business logic and data access (not invoked by this method) |
| X33VDataTypeBeanInterface | Interface | X31C framework interface for typed data beans that support value/state property access via `loadModelData()` |
| `separaterPoint` | Field (code variable) | Computed position of "/" in the key string — unused in this method, likely a legacy from a hierarchical-key routing design |
| koptWebA / koptWebB | Module | Two deployment variants of the K-Opticom web application, differing in database/tenant configuration |
| KKA16801SF | Module | The screen module responsible for service detail screen — this bean belongs to the "Move Reason" detail section |
