# KKW01033SF02DBean

## Purpose

`KKW01033SF02DBean` is the primary **model data bean** for the KKW01033 screen feature (a service contract / customer management screen in a Japanese business system). It aggregates the state of roughly 30 business-domain properties — each representing a field on the screen (customer address, service contract status, pricing group codes, ticket counts, etc.) — and exposes them through a unified key/subkey access API so that the framework's generic JSP rendering layer can read and write any field by name alone, without compile-time field references.

## Design

### Architectural Role

This class is a **plain-old-data (POD) model bean** in the X33V web framework. It implements three interfaces:

| Interface | Responsibility |
|---|---|
| `X33VDataTypeBeanInterface` | Contracts for `loadModelData`, `storeModelData(String, String, Object)`, and `typeModelData(String, String)` — the framework uses these to bind HTTP/form data to the bean and back. |
| `X33VListedBeanInterface` | Contracts for `listKoumokuIds()` — returns the canonical list of all property names so the UI layer knows what fields to render. |
| `java.io.Serializable` | Standard Java serialization for request-scoped bean transfer between tiers. |

The bean sits in the package `eo.web.webview.KKW01033SF` alongside a matching `KKW01033SFBean.java`, `KKW01033SFLogic.java`, `KKW01033SFConst.java`, and `KKW01033SFChecker.java` — a standard five-component structure (master bean + child beans + logic + constants + validation).

### Field Organization

Every business property follows an identical **four-field grouping**:

| Field Suffix | Type | Meaning |
|---|---|---|
| `_value` | `String` | The current field value displayed to / submitted by the user |
| `_enabled` | `Boolean` | Whether the field is editable (`true`) or read-only (`false`) |
| `_state` | `String` | Display state code (e.g., `"0"` = normal, `"1"` = error highlight) |
| `_update` | `String` | Dirty-flag — indicates the field has been modified since load |

For example, the property **Customer Name** (`cust_nm`) consists of:

```java
protected String cust_nm_update;
protected String cust_nm_value = "";
protected Boolean cust_nm_enabled = false;
protected String cust_nm_state = "";
```

All `_value` fields default to `""` and all `_enabled` fields default to `false`, meaning every field starts as **read-only** until the logic layer explicitly enables it. A handful of properties (`tokuSokuStatus`, `router_sbt`, `p_id`, `cat_id`, `rsv_jokyo`, `rank_nm`, `tic_num`, `orsjgs_nm`, `scm_type_nm`, `scm_jgs_nm`) default to `enabled = true`.

The bean tracks a total of **31 distinct business properties** (each = 4 fields + getters/setters for each), plus an `index` field for row positioning in list rendering.

## Key Methods

### `loadModelData(String key, String subkey) → Object`

Returns the value for a named property and sub-key.

- **Parameters:**
  - `key` — Japanese property label (e.g., `"サービス契約ステータス"`, `"お客様名"`, `"チケット残枚数"`)
  - `subkey` — One of `"value"`, `"enable"`, or `"state"` (case-insensitive)
- **Returns:** The corresponding field value, or `null` if `key`/`subkey` is `null` or the key does not match any known property.

**Dispatch pattern:** A long `if-else` chain matching on the `key` string, then routing to the appropriate getter based on `subkey`. For `subkey == "value"` it calls the `_value` getter; for `"enable"` it calls the `_enabled` getter; for `"state"` it calls the `_state` getter.

```java
// Example key/subkey → getter mapping:
"サービス契約ステータス" + "value" → getSvc_kei_stat_value()
"サービス契約ステータス" + "enable" → getSvc_kei_stat_enabled()
"お客様名" + "value" → getCust_nm_value()
"チケット残枚数" + "value" → getTic_num_value()
```

This method is called by the framework to populate form fields during page rendering.

### `storeModelData(String key, String subkey, Object in_value)`

Sets a property's field to a given value. Three overloaded variants exist:

| Overload | Description |
|---|---|
| `storeModelData(key, subkey, in_value)` | Delegates to the 4-arg version with `isSetAsString = false` |
| `storeModelData(key, subkey, in_value, isSetAsString)` | Core implementation — casts `in_value` and calls the appropriate setter |
| `storeModelData(gamenId, key, subkey, in_value)` | Accepts a `gamenId` (screen ID) parameter for backward compatibility with the parent class; delegates to `storeModelData(key, subkey, in_value)` and ignores `gamenId` |

- **Parameters:**
  - `key` — Japanese property label (same keys as `loadModelData`)
  - `subkey` — `"value"`, `"enable"`, or `"state"`
  - `in_value` — The value to assign (cast to the appropriate type)
  - `isSetAsString` — Reserved flag for `Long`-type properties; currently unused in this bean

**Dispatch pattern:** Mirrors `loadModelData` — an `if-else` chain matching on `key`, then calling the appropriate setter (`setValue`, `setEnabled`, `setState`) based on `subkey`.

This method is called by the framework to apply user-submitted form data back into the bean.

### `listKoumokuIds() → ArrayList<String>`

**Static** method that returns the canonical ordered list of all 31 property names (in Japanese). This is used by the framework to iterate over which fields the screen should render.

The returned list order:

1. サービス契約ステータス (Service Contract Status)
2. サービス契約ステータス名称 (Service Contract Status Name)
3. 異動区分 (Transfer Category)
4. 異動区分名称 (Transfer Category Name)
5. マンションID (Mansion ID)
6. マンション名 (Mansion Name)
7. お客様名 (Customer Name)
8. 契約者電話番号 (Contractor Phone Number)
9. 契約者都道府県名 (Contractor Prefecture Name)
10. 契約者市区町村名 (Contractor City/Town/Village Name)
11. 契約者大字通称名 (Contractor Major Street Name)
12. 契約者字丁目名 (Contractor Block/Chome Name)
13. 契約者番地号 (Contractor Lot Number)
14. 契約者住所補記・建物名 (Contractor Address Note / Building Name)
15. 契約者住所補記・部屋番号 (Contractor Address Note / Room Number)
16. サービス契約番号 (Service Contract Number)
17. 請求契約番号 (Billing Contract Number)
18. SYSID
19. EOID
20. 料金グループコード (Pricing Group Code)
21. 料金グループ名 (Pricing Group Name)
22. 料金コースコード (Pricing Course Code)
23. 料金コース名 (Pricing Course Name)
24. 機器提供サービス契約番号 (Equipment Provision Service Contract Number)
25. ファミリパック有無 (Family Pack Presence)
26. 勧誘状態 (Sales Status)
27. ルーター有無 (Router Presence)
28. PID
29. CATID
30. 予約状況 (Reservation Status)
31. ランク名称 (Rank Name) — added v26.00.00
32. チケット残枚数 (Ticket Remainder Count) — added ANK-3034
33. 卸先事業者名 (Wholesale Business Partner Name) — added ANK-3366
34. 定額サービス契約有無 (Flat-Rate Service Contract Presence) — added ANK-3840
35. スキームタイプ名 (Scheme Type Name) — added ANK-4075
36. スキーム事業者名 (Scheme Business Partner Name) — added ANK-4075

### `typeModelData(String key, String subkey) → Class<?>`

Returns the Java type for a property's sub-key field.

- `"value"` → `String.class`
- `"enable"` → `Boolean.class`
- `"state"` → `String.class`

This lets the framework perform type-safe binding when populating or validating fields.

### `getIndex() / setIndex(int index) → int`

Tracks the row index of this bean instance within a list/table. Useful when rendering a list of contract records — each row bean carries its position so the UI can generate row-specific actions (edit, delete, select).

### Individual Getters/Setters (300+ methods)

Each of the 31 properties has 4 fields, each with a getter and setter — yielding **248 accessor methods** (62 for the 31 properties, each with value/enabled/state/update). Plus `svc_kei_stat_nm` also has 4 fields. Together:

| Category | Count |
|---|---|
| Properties with 4 fields × 2 accessors each | 31 × 4 × 2 = 248 |
| `getIndex` / `setIndex` | 2 |
| `loadModelData` (3 overloads) | 3 |
| `storeModelData` (3 overloads) | 3 |
| `listKoumokuIds` | 1 |
| `typeModelData` | 1 |
| **Total methods** | **~258** |

All accessors are trivial field-level get/set with no validation, transformation, or side effects.

## Relationships

```mermaid
flowchart TD
    subgraph Consumer["Consumer"]
        JSP["KKW010330PJP.jsp<br/>JSP page"]
    end

    subgraph Bean["KKW01033SF02DBean<br/>Model Data Bean"]
        I1["X33VDataTypeBeanInterface"]
        I2["X33VListedBeanInterface"]
        I3["Serializable"]
    end

    JSP -->|reads/writes| Bean

    Bean --> I1
    Bean --> I2
    Bean --> I3
```

The bean is consumed by **KKW010330PJP.jsp**, which renders the screen. The JSP accesses bean properties either through direct getter/setter calls (EL expressions like `${bean.customerNameValue}`) or through the framework's generic `loadModelData`/`storeModelData` dispatch.

The bean has **no outbound references** to other application classes — it is a pure data container with no business logic.

## Data Fields Reference

```mermaid
flowchart LR
    subgraph Fields["Data Fields (per property)"]
        _value["value<br/>String"]
        _enabled["enabled<br/>Boolean"]
        _state["_state<br/>String"]
        _update["_update<br/>String"]
    end

    subgraph Properties["Example Property Groups"]
        svc["svc_kei_stat<br/>Service Contract Status"]
        cust["cust_nm<br/>Customer Name"]
        tic["tic_num<br/>Ticket Remainder Count"]
    end

    svc --> _value
    svc --> _enabled
    svc --> _state
    svc --> _update

    cust --> _value
    cust --> _enabled
    cust --> _state
    cust --> _update

    tic --> _value
    tic --> _enabled
    tic --> _state
    tic --> _update
```

### Complete Property-to-Field Map

| Property (Japanese) | Property ID | _value Type | _enabled Default |
|---|---|---|---|
| サービス契約ステータス | `svc_kei_stat` | String | `false` |
| サービス契約ステータス名称 | `svc_kei_stat_nm` | String | `false` |
| 異動区分 | `ido_div` | String | `false` |
| 異動区分名称 | `ido_div_nm` | String | `false` |
| マンションID | `mansion_id` | String | `false` |
| マンション名 | `mansion_nm` | String | `false` |
| お客様名 | `cust_nm` | String | `false` |
| 契約者電話番号 | `keisha_telno` | String | `false` |
| 契約者都道府県名 | `keisha_state_nm` | String | `false` |
| 契約者市区町村名 | `keisha_city_nm` | String | `false` |
| 契約者大字通称名 | `keisha_oaztsu_nm` | String | `false` |
| 契約者字丁目名 | `keisha_azcho_nm` | String | `false` |
| 契約者番地号 | `keisha_bnchigo` | String | `false` |
| 契約者住所補記・建物名 | `keisha_adrttm` | String | `false` |
| 契約者住所補記・部屋番号 | `keisha_adrrm` | String | `false` |
| サービス契約番号 | `svc_kei_no` | String | `false` |
| 請求契約番号 | `seiky_kei_no` | String | `false` |
| SYSID | `sysid` | String | `false` |
| EOID | `eoid` | String | `false` |
| 料金グループコード | `prc_grp_cd` | String | `false` |
| 料金グループ名 | `prc_grp_nm` | String | `false` |
| 料金コースコード | `pcrs_cd` | String | `false` |
| 料金コース名 | `pcrs_nm` | String | `false` |
| 機器提供サービス契約番号 | `kktk_svc_kei_no` | String | `false` |
| ファミリパック有無 | `family_pack_um` | String | `false` |
| 勧誘状態 | `tokuSokuStatus` | String | `true` |
| ルーター有無 | `router_sbt` | String | `true` |
| PID | `p_id` | String | `true` |
| CATID | `cat_id` | String | `true` |
| 予約状況 | `rsv_jokyo` | String | `true` |
| ランク名称 | `rank_nm` | String | `true` |
| チケット残枚数 | `tic_num` | String | `true` |
| 卸先事業者名 | `orsjgs_nm` | String | `true` |
| 定額サービス契約有無 | `tegak_svc_um` | String | `false` |
| スキームタイプ名 | `scm_type_nm` | String | `true` |
| スキーム事業者名 | `scm_jgs_nm` | String | `true` |

## Usage Example

The framework (not this bean itself) uses the key/subkey API to bind form data:

```java
KKW01033SF02DBean bean = new KKW01033SF02DBean();

// Load all fields for a property
Object value = bean.loadModelData("お客様名", "value");       // → getCust_nm_value()
Object enabled = bean.loadModelData("お客様名", "enable");     // → getCust_nm_enabled()
Object type = bean.typeModelData("お客様名", "value");         // → String.class

// Set a field from form submission
bean.storeModelData("お客様名", "value", "山田太郎");           // → setCust_nm_value("山田太郎")
bean.storeModelData("お客様名", "enable", true);                // → setCust_nm_enabled(true)

// Iterate all fields for screen rendering
for (String prop : KKW01033SF02DBean.listKoumokuIds()) {
    String val = (String) bean.loadModelData(prop, "value");
    Boolean en = bean.loadModelData(prop, "enable");
    // ... render row
}
```

## Notes for Developers

- **No validation or business logic.** This bean is a pure data carrier. Validation is handled by `KKW01033SFChecker.java`; business logic by `KKW01033SFLogic.java`.
- **All properties share the same four-field pattern.** Do not add new field types (e.g., `Date`, `Integer`) to a property — the `typeModelData` method assumes `value` and `state` are always `String`, and `enable` is always `Boolean`. Adding a new property type requires updating `typeModelData`, `loadModelData`, `storeModelData`, and `listKoumokuIds` in lockstep.
- **`isSetAsString` parameter is unused.** The 4-arg `storeModelData` overload has an `isSetAsString` flag documented for `Long`-type properties, but this bean contains no `Long` fields — the flag is dead code inherited from the parent framework contract.
- **Thread safety.** The bean is not thread-safe and is expected to be request-scoped (one instance per HTTP request). Do not share instances across threads or request handlers.
- **New properties are versioned.** New fields are added with branch markers like `// v26.00.00 ADD START`, `// ANK-3034-00-00 ADD START`. When adding new properties, update all four locations: field declarations, `loadModelData`, `storeModelData`, `typeModelData`, and `listKoumokuIds`.
- **Japanese property names are keys.** The `loadModelData`/`storeModelData`/`typeModelData` methods dispatch on literal Japanese strings. These are the display labels shown to end users. Any change to these strings requires corresponding changes in the JSP and the key-based dispatch chains.
- **`_state` field convention.** The `_state` field appears to be a display-mode indicator used by the framework's UI theme engine — typical values include `"0"` (normal) and `"1"` (error/alert styling), though exact semantics are framework-level, not in this bean.
- **`listKoumokuIds` is static.** This means it can be called without instantiating the bean, which is useful for metadata queries and screen introspection.
