# Business Logic — KKW05601SFLogic.actionTokiCfmInit() [104 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW05601SF.KKW05601SFLogic` |
| Layer | Controller (Web View Layer — `eo.web.webview` package) |
| Module | `KKW05601SF` (Package: `eo.web.webview.KKW05601SF`) |

## 1. Role

### KKW05601SFLogic.actionTokiCfmInit()

This method performs the **initial display processing for the Toki (電話: telephone) registration confirmation screen** when the user accesses the confirmation view in consultation mode (`照会モード` — inquiry/read mode). It acts as the initialization entry point that prepares all view data by extracting continuation information from the previous screen, invoking a background service (KKSV0170) to fetch the latest service contract details, and populating the form bean with the retrieved telephone registration data. The method follows a **delegation pattern** — it delegates service execution to `KKSV0170` and data mapping to helper methods (`setHktgDataTo`, `setTokiInfoFromDB`, `getSvcUcwkTelBean`), while handling only the orchestration flow and null-safety validation in-line. Within the larger system, this method is the **screen initialization handler** for the Toki confirmation page in the webview layer, serving as the single entry point from `actionInit()` in the same class. It does not branch by service type; it processes a single linear flow dedicated to the telephone registration confirmation scenario, which supports operations such as number portability (携番移転), call forwarding (転送先設定), and line suspension (一時中止) for NTT East (NTT東日本) fiber-optic services.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["actionTokiCfmInit"])
    VALIDATE(["Validate bean is not null"])
    GET_CUST["Get custKeiHktgiList from continuation"]
    GET_HKTG["Get hktgKoumokuBean (dataBean[0])"]
    EXTRACT["Extract: sysId, svcKeiNo, svcKeiUcwkNo, idoDiv, itnMotoSakiFlg, taishoTelNo"]
    LOG_START["Debug log: consultation mode init start"]
    SET_HKTG["setHktgDataTo(bean, sysId, svcKeiNo, svcKeiUcwkNo, idoDiv)"]
    INVOKE_SVC["invokeServiceKKSV0170(paramBean)"]
    GET_SVC_Bean["getSvcUcwkTelBean(paramBean)"]
    SET_TOKI["setTokiInfoFromDB(bean, hktgKoumokuBean, svcUtwkEoTelBean, 1)"]
    LOG_END["Debug log: consultation mode init end"]
    RETURN_TRUE(["return true"])

    START --> VALIDATE
    VALIDATE --> GET_CUST
    GET_CUST --> GET_HKTG
    GET_HKTG --> EXTRACT
    EXTRACT --> LOG_START
    LOG_START --> SET_HKTG
    SET_HKTG --> INVOKE_SVC
    INVOKE_SVC --> GET_SVC_Bean
    GET_SVC_Bean --> SET_TOKI
    SET_TOKI --> LOG_END
    LOG_END --> RETURN_TRUE
```

**Processing Flow Summary:**

1. **Validate bean** — Obtain the form data bean via `getServiceFormBean()`. If null, throw an `Exception` with the message "データBeanがnullです。" (The data bean is null.).
2. **Extract continuation data** — Retrieve the customer item continuation list from the bean, then extract six key fields from the first continuation data bean: `sysId`, `svcKeiNo`, `svcKeiUcwkNo`, `idoDiv`, `itnMotoSakiFlg`, and `taishoTelNo`.
3. **Set continuation data to form bean** — Delegate to `setHktgDataTo()` to populate the form bean with the extracted continuation information.
4. **Invoke background service** — Call `invokeServiceKKSV0170()` to fetch the latest service contract details from the backend (KKSV0170 is the service that retrieves Toki-related data from the database).
5. **Get service unbundling phone bean** — Call `getSvcUcwkTelBean()` to retrieve the NTT East (NTT東日本) unbundling line telephone information.
6. **Set Toki info to form bean** — Delegate to `setTokiInfoFromDB()` to map all database-fetched data (continuation info, service unbundling details) onto the form bean for display.
7. **Return true** — Indicate successful initialization to trigger the confirmation screen render.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none — instance method) | - | This method takes no external parameters. All required data is obtained from the request-scoped form bean (`X31SDataBeanAccess`) via `getServiceFormBean()`, which contains continuation data from the previous screen. |
| - | `bean` (from `getServiceFormBean()`) | `X31SDataBeanAccess` | The form data bean representing the current screen's state. It carries continuation data (`custKeiHktgiList`) from the prior step, including system ID, service contract numbers, transfer division flag, and the target phone number. |

**External state / instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `super.serviceFormBean` (inherited) | `X31SDataBeanAccess` | The base form bean provided by the parent class, containing the screen's current data model. |
| `DEBUG_LOG` | `org.apache.commons.logging.Log` | Debug logger instance for tracing the initialization flow. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `OneStopDataBeanAccessArray.getDataBeanArray` | — | — | Reads the customer continuation item list (`CUST_KEI_HKTGI_LIST`) from the form bean. |
| R | `X31SDataBeanAccess.getDataBean` | — | — | Retrieves the first element (index 0) of the continuation data bean array. |
| R | `X31SDataBeanAccess.sendMessageString` (×6) | — | — | Extracts string values for `sysId`, `svcKeiNo`, `svcKeiUcwkNo`, `idoDiv`, `itnMotoSakiFlg`, and `taishoTelNo` from the continuation bean. |
| - | `KKW05601SFLogic.setHktgDataTo` | — | — | Delegates: sets continuation item data (sysId, svcKeiNo, svcKeiUcwkNo, idoDiv) onto the form bean for display. |
| R | `KKW05601SFLogic.invokeServiceKKSV0170` | `KKSV0170` | Database (Toki registration data, service contract details) | Invokes the KKSV0170 service to fetch the latest Toki (telephone registration) data from the backend. This is the primary data read operation — it retrieves service contract details including unbundling line info, tok registration records, and related status data. |
| R | `KKW05601SFLogic.getSvcUcwkTelBean` | — | — | Delegates: retrieves the NTT East (NTT東日本) unbundling line service data bean, containing telephone number and line-specific details. |
| - | `KKW05601SFLogic.setTokiInfoFromDB` | — | — | Delegates: maps all fetched database data (continuation info, service unbundling data, tok registration records) onto the form bean for the confirmation screen. Parameter `1` indicates consultation (inquiry) mode. |
| - | `KKW05601SFLogic.sendMessageString` (write, in `setHktgDataTo`) | — | — | Writes continuation data fields to the form bean for screen rendering. |

**Classification rationale:**

- **R (Read):** `invokeServiceKKSV0170` is the key database read — KKSV0170 is a service component that queries the Toki registration and service contract tables. `getDataBeanArray` and `getDataBean` read form-state data from the request scope. `getSvcUcwkTelBean` returns data fetched from the service layer.
- **U (Update):** `setHktgDataTo` and `setTokiInfoFromDB` populate the form bean with data — these are setter/update operations on the view model.
- **No C (Create) or D (Delete):** This method is purely initialization (read + display population). It does not create or delete any records.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `setTokiInfoFromDB` [-], `getSvcUcwkTelBean` [R], `invokeServiceKKSV0170` [-], `setHktgDataTo` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `sendMessageString` [-], `getDataBean` [R], `getDataBean` [R], `getDataBean` [R], `getDataBean` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `KKW05601SFLogic` (same class) | `actionInit()` → `actionTokiCfmInit()` | `invokeServiceKKSV0170 [R] Toki registration / service contract DB`, `getSvcUcwkTelBean [R] NTT East unbundling line data`, `setTokiInfoFromDB [U] Form bean (screen display data)` |

**Notes:**
- `KKW05601SFLogic.actionInit()` is the direct caller and acts as the main initialization dispatcher for the KKW05601SF screen. It routes to `actionTokiCfmInit()` when the user selects the confirmation display path.
- The terminal operations are all within the same logic class (`KKW05601SFLogic`), meaning this method is a mid-tier orchestrator. The actual database interaction happens downstream via `invokeServiceKKSV0170`, which delegates to the KKSV0170 service component for database reads.

## 6. Per-Branch Detail Blocks

### Block 1 — GET FORM BEAN (L708)

> Obtain the form data bean from the parent class and wrap it in an array for use with `OneStopDataBeanAccess` operations.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `X31SDataBeanAccess bean = super.getServiceFormBean();` // Obtain form bean from parent |
| 2 | SET | `X31SDataBeanAccess[] paramBean = { bean };` // Wrap in single-element array |

### Block 2 — IF / VALIDATE BEAN NOT NULL (L710)

> Guard clause: ensure the form bean is not null before proceeding. This prevents `NullPointerException` on downstream operations.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (null == bean)` |
| 2 | EXEC | `throw new Exception("データBeanがnullです。");` // "The data bean is null." |

### Block 3 — DEBUG LOG START (L714)

> Log entry point for the consultation mode initialization processing.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `DEBUG_LOG.debug("###actionTokiCfmInit:照会モードで確認画面を呼ばれた時の初期表示処理 start");` // "###actionTokiCfmInit: Initial display processing when confirmation screen is called in consultation mode — start" |

### Block 4 — EXTRACT CONTINUATION DATA (L717–L730)

> Retrieve the continuation item list from the previous screen and extract six key fields from the first data bean. This data represents the customer context carried over from the prior step.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `X31SDataBeanAccessArray custKeiHktgiList = (X31SDataBeanAccessArray)paramBean[0].getDataBeanArray(KKW05601SFConst.CUST_KEI_HKTGI_LIST);` // Get continuation item list |
| 2 | CALL | `X31SDataBeanAccess hktgKoumokuBean = custKeiHktgiList.getDataBean(0);` // Get first continuation data bean |
| 3 | EXEC | `String sysId = hktgKoumokuBean.sendMessageString(KKW05601SFConst.SYSID_11, X31CWebConst.DATABEAN_GET_VALUE);` // Extract System ID |
| 4 | EXEC | `String svcKeiNo = hktgKoumokuBean.sendMessageString(KKW05601SFConst.SVC_KEI_NO_11, X31CWebConst.DATABEAN_GET_VALUE);` // Extract Service Contract Number |
| 5 | EXEC | `String svcKeiUcwkNo = hktgKoumokuBean.sendMessageString(KKW05601SFConst.SVC_KEI_UCWK_NO_11, X31CWebConst.DATABEAN_GET_VALUE);` // Extract Service Contract Detail Number |
| 6 | EXEC | `String idoDiv = hktgKoumokuBean.sendMessageString(KKW05601SFConst.IDO_DIV_11, X31CWebConst.DATABEAN_GET_VALUE);` // Extract Transfer Division (transfer-type classification) |
| 7 | EXEC | `String itnMotoSakiFlg = hktgKoumokuBean.sendMessageString(KKW05601SFConst.ITN_MOTO_SAKI_11, X31CWebConst.DATABEAN_GET_VALUE);` // Extract Before-Transfer-Target Flag (0 = pre-connect, 1 = post-connect, from residence change screen) |
| 8 | EXEC | `String taishoTelNo = hktgKoumokuBean.sendMessageString(KKW05601SFConst.TOKI_TG_TELNO_11, X31CWebConst.DATABEAN_GET_VALUE);` // Extract Toki Target Phone Number |

### Block 5 — DEBUG LOG FIELDS (L732–L737)

> Log extracted values for debugging the initialization flow, including the `itnMotoSakiFlg` description: "0: pre-connect, 1: post-connect (from residence change screen)".

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `DEBUG_LOG.debug("###actionTokiCfmInit start:svcKeiNo=" + svcKeiNo);` |
| 2 | EXEC | `DEBUG_LOG.debug("###actionTokiCfmInit start:svcKeiUcwkNo=" + svcKeiUcwkNo);` |
| 3 | EXEC | `DEBUG_LOG.debug("###actionTokiCfmInit start:idoDiv" + idoDiv);` |
| 4 | EXEC | `DEBUG_LOG.debug("###actionTokiCfmInit start:itnMotoSakiFlg（住所変更画面より、0:開通前、1:開通後）" + itnMotoSakiFlg);` // "itnMotoSakiFlg (from residence change screen, 0: pre-connect, 1: post-connect)" |
| 5 | EXEC | `DEBUG_LOG.debug("###actionTokiAddInit start:トーキ対象電話番号=" + taishoTelNo);` // "Toki target phone number=" |

### Block 6 — CALL setHktgDataTo (L741)

> Delegate: set the continuation item data onto the form bean for screen display.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setHktgDataTo(bean, sysId, svcKeiNo, svcKeiUcwkNo, idoDiv);` // Set continuation data to form bean |

### Block 7 — CALL invokeServiceKKSV0170 (L744)

> Core business operation: invoke the KKSV0170 service to fetch Toki (telephone registration) data from the backend. This includes querying service contract details, unbundling line information, and registration status.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `KKSV0170_KKSV0170OPDBMapper mapper = invokeServiceKKSV0170(paramBean);` // Execute KKSV0170 service to fetch backend data |

### Block 8 — CALL getSvcUcwkTelBean (L747)

> Delegate: retrieve the NTT East unbundling line service data bean containing telephone number and line-specific details.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `X31SDataBeanAccess svcUtwkEoTelBean = getSvcUcwkTelBean(paramBean);` // Get service unbundling EO (NTT East) telephone bean |

### Block 9 — CALL setTokiInfoFromDB (L751)

> Core display population: map all fetched database data onto the form bean for the confirmation screen. The `1` parameter indicates consultation (inquiry/read) mode, meaning data is displayed but not modified.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setTokiInfoFromDB(bean, hktgKoumokuBean, svcUtwkEoTelBean, 1);` // Set Toki info from DB to form bean (mode=1: consultation/inquiry) |

### Block 10 — DEBUG LOG END (L782)

> Log completion of the consultation mode initialization processing.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `DEBUG_LOG.debug("###actionTokiCfmInit:照会モードで確認画面を呼ばれた時の初期表示処理 end");` // "###actionTokiCfmInit: Initial display processing when confirmation screen is called in consultation mode — end" |

### Block 11 — RETURN (L784)

> Indicate successful initialization. The `true` return value signals the caller (`actionInit()`) that the initialization completed successfully and the confirmation screen should be rendered.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true;` |

### Commented-out blocks (L753–L811)

> The source contains a large block of commented-out code (lines 753–811) that was part of an earlier implementation. This code performed manual field extraction and setting (phone number, tok registration division, tok type, desired date, etc.) and called `actionTokiAddCfmInit()`. The current refactored implementation delegates all of this to `setTokiInfoFromDB()`, resulting in cleaner, more maintainable code. The commented-out block is preserved as historical reference.

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `actionTokiCfmInit` | Method | Toki (電話: telephone) Registration Confirmation Initialization — initializes the confirmation screen for telephone registration operations in consultation (read-only) mode |
| `照会モード` (Shoukai Mode) | Business term | Consultation/Inquiry mode — a read-only screen mode where data is displayed but not modified; the user can view details but cannot submit changes |
| `トーキ` (Toki) | Business term | Telephone Registration — refers to the registration of telephone services with NTT (Nippon Telegraph and Telephone), including number portability, call forwarding setup, and line suspension operations |
| `custKeiHktgiList` | Field | Customer Item Continuation List — the list of item continuation data passed from the previous screen, containing context about the customer's service contract |
| `hktgKoumokuBean` | Field | Hktg (NTT East / 東日本) Item Bean — the continuation data bean containing NTT East-specific item information carried over from the previous step |
| `sysId` | Field | System ID — the identifier of the target system (NTT East region code, e.g., "11" for NTT East) |
| `svcKeiNo` | Field | Service Contract Number — the primary identifier for a service contract in the system |
| `svcKeiUcwkNo` | Field | Service Contract Detail Number — a secondary identifier for a specific line item within a service contract (internal work number) |
| `idoDiv` | Field | Transfer Division — the type of transfer operation (e.g., number portability, call forwarding, suspension) |
| `itnMotoSakiFlg` | Field | Before-Transfer-Target Flag — indicates whether the transfer occurred before or after connection: "0" = pre-connect, "1" = post-connect (relevant when navigating from the residence change screen) |
| `taishoTelNo` | Field | Toki Target Phone Number — the telephone number that is the subject of the Toki (telephone registration) operation |
| `KKSV0170` | Service | Backend service component that retrieves Toki (telephone registration) registration data and service contract details from the database |
| `svcUtwkEoTelBean` | Field | Service Unbundling EO (East) Telephone Bean — the data bean containing NTT East unbundling line telephone information, including the unbundled telephone number and related service details |
| `setTokiInfoFromDB` | Method | Sets all Toki-related information from the database onto the form bean for screen display |
| `X31SDataBeanAccess` | Technical | A form bean access class providing data bean retrieval and messaging methods for screen data management |
| `X31SDataBeanAccessArray` | Technical | An array-based data bean access class for handling lists of continuation data items |
| `KKW05601SF` | Module | Webview module — the screen module for Toki (telephone) registration confirmation operations in the NTT East region |
| KKSV | Acronym | Koushiki Service Service Verification (公式サービスサービス検証) — NTT internal service component naming convention; KKSV0170 is the service that fetches Toki registration data |
| NTT East | Business term | Nippon Telegraph and Telephone East Corporation — one of Japan's two major regional telephone companies, serving the eastern region of Japan |
| 携番移転 (Keibangitent) | Business term | Mobile/Line Number Portability — the operation of transferring an existing telephone number to a new service or provider |
| 転送先設定 (Tenzensaki Settei) | Business term | Call Forwarding Destination Setup — configuring where incoming calls should be forwarded |
| 一時中止 (Ichiteishi) | Business term | Temporary Suspension — temporarily suspending a telephone line (e.g., during residence relocation) |
| 住所変更 (Juusho Henkou) | Business term | Residence Change — the process of updating a customer's registered address, which may trigger telephone service reconfiguration |
| `DATABEAN_GET_VALUE` | Constant | A message type constant indicating a "get value" operation on a data bean field |
| `DATABEAN_SET_VALUE` | Constant | A message type constant indicating a "set value" operation on a data bean field |
