# KKW00844SFBean

## Purpose

`KKW00844SFBean` is a **view-layer data transfer object (DTO) / form bean** for the KKW00844 screen in a Japanese business application built on the Fujitsu Futurity X33/X31 web framework. It aggregates all form-field data for a single service contract modification/execution screen, holding both **primitive String fields** (with per-field update flags and UI state flags) and **two typed-data-list fields** (repeatable table rows). It acts as the central data hub bridging the presentation layer (JSP) and any downstream business logic.

## Design

The class follows the **Front Controller / MVC Form Bean** pattern common in the X33 framework:

- **Extends** `X33VViewBaseBean` — the framework's base class for view beans, providing shared behavior for common-info (common information screen component) data binding and list management.
- **Implements** `X33VListedBeanInterface` — marks the bean as a listed/data-bound component that participates in the framework's form-list lifecycle (data loading, storing, type checking).
- **Implements** `X31CBaseBean` — binds the bean into the X31 component model.
- **Implements** `Serializable` — enables the bean to be serialized (e.g., for HTTP session storage or cluster failover).

The bean does **not** contain business logic. Instead, it provides a rich **key-based data access API** (`loadModelData`, `storeModelData`, `typeModelData`) that routes lookups by Japanese field-name keys (e.g., `利用開始日` for "service start date", `顧客契約引継リスト` for "customer contract succession list"). This indirection decouples the JSP view from the Java field names and allows the framework to drive form binding via metadata-driven reflection.

Every primitive field follows a **three-part naming convention**:

| Suffix | Purpose |
|---|---|
| `_value` | The actual form data value (String) |
| `_update` | A flag indicating whether the field was modified by the user (String) |
| `_state` | UI state metadata such as read-only, disabled, or error state (String) |

`use_staymd` (service start date) is an exception — it also has a `_enabled` (Boolean) flag controlling UI enablement.

Two fields are **repeating list items** backed by `X33VDataTypeList`, each containing `KKW00844SF01DBean` or `KKW00844SF02DBean` row objects respectively. These correspond to table-style UI sections where the user can add/remove rows dynamically.

## Key Methods

### Constructor

```java
public KKW00844SFBean()
```

Initializes the two list fields:
- `cust_kei_hktgi_list_list` is created with a capacity of 1 and populated with one empty `KKW00844SF01DBean`.
- `ido_rsn_list_list` is created with default capacity.

### loadModelData

```java
public Object loadModelData(String key, String subkey)
```

The central getter. Retrieves a field's value by its **Japanese name key** and **subkey** (e.g., `"利用開始日"` with subkey `"value"`, `"enable"`, or `"state"`). The routing logic:

1. **Common-info fields** — If `key` starts with `//`, delegates to `super.loadCommonInfoData(key)`.
2. **Primitive fields** — Extracts the key element (before the first `/`), matches it against a long chain of `if-else` comparisons by Japanese field name, then returns the appropriate getter result. Subkey `"value"` calls `getXxx_value()`, `"enable"` calls `getXxx_enabled()`, and `"state"` calls `getXxx_state()`.
3. **List fields** — For `顧客契約引継リスト` (`cust_kei_hktgi_list_list`) and `異動理由リスト` (`ido_rsn_list_list`):
   - If `subkey` is `"*"` (key format: `フィールド名/*`), returns the list's element count as `Integer`.
   - Otherwise, parses the key for an index (`フィールド名/0/プロ文件名`), retrieves the bean at that index, and delegates to `((X33VDataTypeBeanInterface) list.get(index)).loadModelData(keyElement, subkey)`.

Returns `null` for unknown keys, out-of-range indices, or malformed subkeys.

### storeModelData

```java
public void storeModelData(String key, String subkey, Object in_value)
public void storeModelData(String key, String subkey, Object in_value, boolean isSetAsString)
```

The setter counterpart to `loadModelData`. Routes incoming data to the appropriate setter based on the same key/subkey matching logic:

- For primitive fields: calls the corresponding `setXxx_value()` or `setXxx_state()`. For `use_staymd`, also supports `setXxx_enabled()` for the `"enable"` subkey.
- For list fields: parses the index from the key, retrieves the row bean, and delegates `storeModelData()` to it.
- For common-info fields (key starting with `//`): delegates to `super.storeCommonInfoData(key, in_value, isSetAsString)`.
- The `isSetAsString` boolean flag (passed through from the 4-arg overload) is used to indicate whether a Long-type property should be set from a String value (relevant for the framework's type system).

### typeModelData

```java
public Class<?> typeModelData(String key, String subkey)
```

Returns the **Java type** of a field's value by key/subkey. This is used by the X33 framework for type-safe data binding:

- Primitive fields with `"value"` subkey → `String.class`.
- `use_staymd` with `"enable"` subkey → `Boolean.class`.
- List fields with `"*"` subkey → `Integer.class` (returning list size).
- List fields with an index → delegates to the row bean's `typeModelData()`.
- Unknown combinations → `null`.

### listServiceFormIds

```java
public String[] listServiceFormIds()
```

Returns the list of service form IDs associated with this screen. Currently returns `null` (unused).

### listKoumokuIds

```java
public ArrayList<String> listKoumokuIds(String key)
```

Returns a list of available field names (koumoku IDs). This is used for dynamic form rendering and validation:

- If `key` is `null`, returns **all** field names as a list of 24 Japanese strings (the complete field inventory of this bean).
- If `key` starts with `//` and is longer than 2 characters, delegates to the superclass for common-info field metadata.
- If `key` is `顧客契約引継リスト`, delegates to `KKW00844SF01DBean.listKoumokuIds()` to get the child bean's field names.
- If `key` is `異動理由リスト`, delegates to `KKW00844SF02DBean.listKoumokuIds()`.
- Otherwise returns an empty list.

### addListDataInstance

```java
public int addListDataInstance(String key) throws X33SException
```

Adds a new row to a list field and returns the index of the newly added element:

- For `顧客契約引継リスト`: creates the list if `null` (with a fixed initial size of 1), checks max element count constraints, then appends a new `KKW00844SF01DBean`. Throws `X31SException` if max count exceeded.
- For `異動理由リスト`: creates the list if `null`, then appends a new `KKW00844SF02DBean` without max count restriction.
- For common-info keys (starting with `//`), delegates to the superclass.
- Returns `-1` for unknown keys.

### removeElementFromListData

```java
public void removeElementFromListData(String key, int index) throws X33SException
```

Removes the element at `index` from the specified list field. Validates bounds before removal. Delegates common-info list removal to the superclass.

### clearListDataInstance

```java
public void clearListDataInstance(String key) throws X33SException
```

Clears all elements from the specified list field by calling `clear()` on the `X33VDataTypeList`. Common-info lists are handled by the superclass.

### Helper Methods: JSF Select Item Lists

```java
public ArrayList<SelectItem> getJsflist_typelist_cust_kei_hktgi_list()
public ArrayList<SelectItem> getJsflist_typelist_ido_rsn_list()
```

Build and return `ArrayList<SelectItem>` from the respective list fields, where each item's label is the row's `value` and its value is the row index as a string. Used to populate HTML `<select>` dropdowns in the JSF/HTML view.

### Standard Getters / Setters

The bean exposes 70+ pairs of getters and setters for primitive fields, following the three-part naming pattern. Some notable ones:

| Field Group | Fields |
|---|---|
| Service info | `svc_kei_no` (contract number), `sysid`, `svc_kei_stat` (contract status), `mskm_dtl_no` (detail number), `mskm_stat_skbt_cd_shonin` (approval status code), `mskm_sbt_cd` (application type code) |
| Operation codes | `op_svc_cd` (operation service code), `op_pcrs_cd` (operation cost code), `op_pplan_cd` (operation plan code), `oya_kei_skbt_cd` (parent contract ID code) |
| Progress tracking | `prg_memo` (progress memo), `prg_stat` (progress status), `prg_tkjk_1` (special item 1) |
| Dates/times | `unyo_ymd` (operation date), `unyo_dtm` (operation date-time), `ido_dtm` (move date-time), `upd_dtm_bf` (update timestamp before), `use_staymd` (service start date) |
| Misc | `ido_div` (move division), `rule0059_auto_aply` (rule auto-apply flag), `net_tab_op_if_ctl_cd` (network tab operation control code), `haiso_hmpin_stat_cd` (return status code) |

## Relationships

### Class Diagram

```mermaid
classDiagram
  class KKW00844SFBean {
    +X33VDataTypeList cust_kei_hktgi_list_list
    +X33VDataTypeList ido_rsn_list_list
    +String use_staymd_value, svc_kei_no_value
    +String sysid_value, ido_div_value
    +String unyo_ymd_value, unyo_dtm_value
    +String svc_kei_stat_value, mskm_dtl_no_value
    +String op_svc_cd_value, op_pplan_cd_value
    +String prg_memo_value, prg_stat_value
    +String ido_dtm_value, haiso_hmpin_stat_cd_value
    +String[] update_fields
    +String[] state_fields
    +loadModelData(key, subkey) Object
    +storeModelData(key, subkey, in_value) void
    +typeModelData(key, subkey) Class
    +listServiceFormIds() String[]
    +listKoumokuIds(key) ArrayList
    +addListDataInstance(key) int
    +removeElementFromListData(key, index) void
    +clearListDataInstance(key) void
    +getJsflist_typelist_cust_kei_hktgi_list() SelectItem[]
    +getJsflist_typelist_ido_rsn_list() SelectItem[]
  }
  class X33VViewBaseBean
  class X33VListedBeanInterface
  class X31CBaseBean
  class X33VDataTypeList
  class KKW00844SF01DBean
  class KKW00844SF02DBean
  KKW00844SFBean --|> X33VViewBaseBean : extends
  KKW00844SFBean ..|> X33VListedBeanInterface : implements
  KKW00844SFBean ..|> X31CBaseBean : implements
  KKW00844SFBean --> X33VDataTypeList : manages 2 list fields
  KKW00844SFBean --> KKW00844SF01DBean : element type
  KKW00844SFBean --> KKW00844SF02DBean : element type
```

### Dependencies

**Inbound (3 dependents):**

| Dependent | Relationship |
|---|---|
| `KKW008440PJP.jsp` | References `KKW00844SFBean` to bind form fields to the view |
| `WEBGAMEN_KKW008440PJP.xml` | Configuration mapping the screen to this bean |
| `WEBGAMEN_KKW008450PJP.xml` | Configuration mapping a related screen to this bean |

**Outbound:** No direct outbound Java references — all dependencies are through the X33 framework base classes and the `KKW00844SF01DBean`/`KKW00844SF02DBean` child row beans (which are referenced by type in the list initializers and `listKoumokuIds` calls).

### Data Flow Diagram

```mermaid
flowchart TD
    A["KKW008440PJP.jsp
(view)"] -->|"form binding"| B["KKW00844SFBean
(form data hub)"]
    B -->|"delegate"| C["KKW00844SF01DBean
(customer contract row)"]
    B -->|"delegate"| D["KKW00844SF02DBean(move reason row)"]
    B -->|"delegate"| E["X33VViewBaseBean
(superclass)"]
    B -->|"holds"| F["X33VDataTypeList
(cust_kei_hktgi_list)"]
    B -->|"holds"| G["X33VDataTypeList
(ido_rsn_list)"]
```

## Usage Example

### Loading a field by Japanese name

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

// Get the value of "service start date"
String startDate = (String) bean.loadModelData("利用開始日", "value");

// Get the UI state
String state = (String) bean.loadModelData("利用開始日", "state");

// Get the enabled flag (only use_staymd has this)
Boolean enabled = (Boolean) bean.loadModelData("利用開始日", "enable");

// Get the type for type-safe binding
Class<?> type = bean.typeModelData("利用開始日", "value"); // String.class
```

### Setting a field value

```java
// Set the value and state for "contract number"
bean.storeModelData("サービス契約番号", "value", "SVC-2023-0001");
bean.storeModelData("サービス契約番号", "state", "disabled");
```

### Working with repeat lists

```java
// Add a new row to the customer contract succession list
int newIndex = bean.addListDataInstance("顧客契約引継リスト");

// Set data on the new row via loadModelData
bean.loadModelData("顧客契約引継リスト/" + newIndex + "/顧客契約引継リスト", "value");

// Get all rows as JSF dropdown items
ArrayList<SelectItem> items = bean.getJsflist_typelist_cust_kei_hktgi_list();

// Remove a row
bean.removeElementFromListData("顧客契約引継リスト", 0);

// Clear all rows
bean.clearListDataInstance("顧客契約引継リスト");

// Get the list size (via wildcard key)
Integer size = (Integer) bean.loadModelData("顧客契約引継リスト/*", "");
```

### Getting the full field inventory

```java
// Returns all 24 field names for this screen
ArrayList<String> fields = bean.listKoumokuIds(null);
// ["利用開始日", "顧客契約引継リスト", "異動理由リスト", ...]
```

## Notes for Developers

1. **All field keys are in Japanese.** The `loadModelData`/`storeModelData`/`typeModelData` methods match against Japanese strings (e.g., `利用開始日`). Do not attempt to pass English field IDs or `@_` prefixed IDs through these methods — those are routed through the superclass for common-info handling.

2. **Each primitive field has a 3-part naming convention.** For almost every field: `xxx_value` holds the data, `xxx_update` holds an edit flag, and `xxx_state` holds UI state. The `use_staymd` field additionally has `use_staymd_enabled` (Boolean). All `update` and `state` fields are declared `protected` and default to `null` (not initialized), so callers should handle null checks.

3. **List fields have special routing.** The two `X33VDataTypeList` fields (`cust_kei_hktgi_list_list`, `ido_rsn_list_list`) use a 3-level key path: `フィールド名/インデックス/データタイプアイテム名`. For example, `顧客契約引継リスト/0/プロ文件名`. Be careful that the index is a valid integer string and within bounds.

4. **The constructor pre-populates `cust_kei_hktgi_list_list` with one `KKW00844SF01DBean`.** `ido_rsn_list_list` starts empty. If you clear a list, you may need to re-initialize it before adding new rows.

5. **Thread safety is not provided.** This is a standard HTTP-session-bound form bean; each request should get its own instance. Do not share a `KKW00844SFBean` instance across threads.

6. **The `isSetAsString` flag in `storeModelData`** is a framework artifact for handling Long-typed properties where the source is a String. This bean's fields are all `String`, but the flag is passed through to child beans that may have typed properties.

7. **`listServiceFormIds()` returns `null`.** This method is a hook for multi-screen services and is not implemented in this bean.

8. **The class is auto-generated** (as indicated by the header comment `generated by Web Client tool V01/L01`), so manual edits to this file may be overwritten by future tool runs. Modifications should typically be done in the generator configuration or in override classes.

9. **The `@SuppressWarnings("serial")` annotation** indicates the class has a `serialVersionUID` but suppresses the compiler warning — likely the IDE generated the class without the explicit ID.
