# Business Logic — KKW02519SFLogic.kksv0372Execute() [51 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW02519SF.KKW02519SFLogic` |
| Layer | Controller / Logic (Web View tier — `eo.web.webview`) |
| Module | `KKW02519SF` (Package: `eo.web.webview.KKW02519SF`) |

## 1. Role

### KKW02519SFLogic.kksv0372Execute()

This method executes the **Telephone Option Service Contract Restoration (Update Recovery) Service**. It is responsible for reversing a prior update or cancellation of a telephone option service contract — effectively restoring a previously modified or suspended contract back to its active state. The method follows a **delegation pattern**: it orchestrates data mapping from the web form bean to service parameters, invokes the underlying Business Process (BP) via `invokeService`, and then performs a down-mapping of results back to the form bean. Specifically, it handles a single service category — **contract restoration** (recovery from an update or cancellation) — as opposed to other variants of the same screen logic that handle contract changes (`kksv0373Execute`) or cancellations (`kksv0371Execute`). Within the larger `KKW02519SF` screen (Telephone Option Service Contract Update/Recovery), this method serves as the execution entry point when the user confirms a restoration operation from the screen.

The method also prepares a **progress status note** (進捗特記事項1 — "Progress Special Item 1") that is displayed on the screen. It concatenates the service name (from `getPrgTkjkSvcNm`), the string "情報" (information), and "回復" (recovery) to produce a human-readable progress message that is stored in the form bean for display.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["kksv0372Execute(svcFormBean, funcCd)"])

    START --> GET_SVC_NAM["getPrgTkjkSvcNm(svcFormBean)"]
    GET_SVC_NAM --> BUILD_PROGRESS["Build progress note: svcName + JYOHO(情報) + KAIHK(回復)"]
    BUILD_PROGRESS --> SET_PROGRESS["Set progress note to svcFormBean"]
    SET_PROGRESS --> INIT_MAPS["Create paramMap, inputMap, outputMap"]
    INIT_MAPS --> SET_TELEGRAM["Set usecaseId=UCID_KKSV0372 and operationId=OPID_KKSV0372OP"]
    SET_TELEGRAM --> NEW_MAPPER["Create KKSV0372_KKSV0372OPDBMapper"]
    NEW_MAPPER --> MAP_01["mapper.setKKSV037201CC - Option service contract renewal CC mapping"]
    MAP_01 --> MAP_02["mapper.setKKSV037202CC - Service order CC mapping"]
    MAP_02 --> MAP_03["mapper.setKKSV037203SC - Equipment provision service contract details mapping"]
    MAP_03 --> EXEC_SERVICE["invokeService(paramMap, inputMap, outputMap)"]
    EXEC_SERVICE --> MAP_DOWN["mapper.getKKSV037201CC - Down mapping from outputMap to form"]
    MAP_DOWN --> GET_MSG_ID["Get rtnMsgId from svcFormBean"]
    GET_MSG_ID --> CHECK_MSG{"rtnMsgId != null and not empty?"}
    CHECK_MSG -->|Yes - Error occurred| SET_ERROR["JCCWebCommon.setMessageInfo(rtnMsgId)"]
    SET_ERROR --> RETURN_FALSE["return false"]
    CHECK_MSG -->|No - Success| RETURN_TRUE["return true"]
    RETURN_FALSE --> END_NODE(["End"])
    RETURN_TRUE --> END_NODE
```

**Processing Description:**

1. **Progress Note Assembly**: The method first obtains the service name for the current telephone option service by calling `getPrgTkjkSvcNm(svcFormBean)`, then concatenates it with `PRG_TKJK_1_JYOHO` ("情報" = "Information") and `PRG_TKJK_1_KAIHK` ("回復" = "Recovery") to form a progress status note like "ABC ISP Information Recovery". This note is stored in the form bean under the key `PRG_TKJK_1` ("進捗特記事項1" = "Progress Special Item 1") for display on the confirmation screen.

2. **Data Map Initialization**: Three `HashMap<String, Object>` instances are created: `paramMap` for service invocation metadata (usecase/operation IDs), `inputMap` for data flowing into the BP, and `outputMap` for results flowing back from the BP.

3. **Telegram Parameter Setup**: The `paramMap` is populated with the usecase ID (`UCID_KKSV0372`) and operation ID (`OPID_KKSV0372OP`) from `JKKCommonConst`. These identifiers route the service invocation to the correct business process.

4. **Up-Mapping (Form Bean → Service Parameters)**: A new `KKSV0372_KKSV0372OPDBMapper` instance is created, and its three mapping methods are called in sequence to populate the `inputMap`:
   - `setKKSV037201CC`: Maps option service contract renewal common data (SYSID, service contract number, option service contract number, sub-option service contract number, update datetime, error classification, operation date, progress note). Also collects error reason details from the form bean's error reason list array.
   - `setKKSV037202CC`: Maps service order common data (pre-option service contract registration datetime, service contract internal number, post-service contract internal number registration datetime).
   - `setKKSV037203SC`: Maps equipment provision service contract details query parameters (service contract number, equipment provision service code "C004" for fiber-optic phone).

5. **Business Process Invocation**: `invokeService(paramMap, inputMap, outputMap)` is called to execute the BP (Business Process) `KKSV0372_KKSV0372OP`. This is the core service that performs the actual contract restoration logic, potentially including database updates, validations, and integration with downstream systems.

6. **Down-Mapping (Service Results → Form Bean)**: `mapper.getKKSV037201CC` retrieves results from the `outputMap` and places them back into the form bean for screen display.

7. **Result Checking**: The return message ID (`rtnMsgId`) is read from the form bean. If it is non-null and non-empty, an error occurred during processing. In that case, `JCCWebCommon.setMessageInfo(this, rtnMsgId)` displays the error message to the user, and the method returns `false`. Otherwise, the method returns `true` indicating success.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `svcFormBean` | `X31SDataBeanAccess` | The service form bean that carries all UI-bound data for the Telephone Option Service Contract Update/Recovery screen. It contains the service contract numbers, option service contract details, error reason lists, progress status fields, and return message IDs. This bean flows both directions: its data is extracted as input parameters for the BP, and its fields are populated with results after BP execution. |
| 2 | `funcCd` | `String` | The function code that identifies the specific operation context. For this restoration method, it is passed through to the CC (Common Component) mappers. The caller `actionFix()` passes the function code that triggered the save operation, allowing the mapping layer to differentiate between add, modify, or restore scenarios. |

**Instance Fields / External State:**
- `PRG_TKJK_1_JYOHO` (static constant from `KKW02519SFLogic`): String "情報" — appended to progress note to indicate "information".
- `PRG_TKJK_1_KAIHK` (static constant from `KKW02519SFLogic`): String "回復" — appended to progress note to indicate "recovery/restoration".
- `KKW02519SFConst.PRG_TKJK_1` (constant): Key "進捗特記事項1" — field name in the form bean for progress special item 1.
- `KKW02519SFConst.RTN_MSG_ID` (constant): Key "返却メッセージID" — field name in the form bean for the return message ID returned by the BP.
- `getPrgTkjkSvcNm()` (private method in same class): Called to retrieve the human-readable service name from the form bean for inclusion in the progress note.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `KKSV0372_KKSV0372OPDBMapper.setKKSV037201CC` | KKSV037201CC | (Up-mapping: Form Bean → Service Parameter) | Maps option service contract renewal common data: SYSID, service contract number, option service contract number, sub-option service contract number, update datetime, error classification, operation date, progress note, and error reason detail list into the input parameter map. |
| C | `KKSV0372_KKSV0372OPDBMapper.setKKSV037202CC` | KKSV037202CC | (Up-mapping: Form Bean → Service Parameter) | Maps service order common data: pre-option service contract registration datetime, service contract internal number, post-service contract internal number registration datetime into the input parameter map. |
| C | `KKSV0372_KKSV0372OPDBMapper.setKKSV037203SC` | KKSV037203SC | (Up-mapping: Form Bean → Service Parameter) | Maps equipment provision service contract details query parameters: service contract number and equipment service code "C004" (fiber-optic phone) into the input parameter map. |
| R | `KKSV0372_KKSV0372OPDBMapper.getKKSV037201CC` | KKSV037201CC | (Down-mapping: Service Parameter → Form Bean) | Maps results from the BP output back into the form bean, making service results available for screen display. |
| - | `KKW02519SFLogic.invokeService` | KKSV0372_KKSV0372OP BP | - | Invokes the Business Process `KKSV0372_KKSV0372OP` with the prepared parameter maps. This is the core service execution that performs the actual telephone option service contract restoration logic (database updates, validations, downstream integrations). |
| R | `KKW02519SFLogic.getPrgTkjkSvcNm` | N/A | Form bean | Retrieves the service name from the form bean for inclusion in the progress note text. |
| - | `JCCWebCommon.setMessageInfo` | JCCWebCC | - | Sets the error display message on the form using the return message ID from the BP, enabling user-facing error notification. |

**How to classify:**
- The `setKKSV037201CC`, `setKKSV037202CC`, and `setKKSV037203SC` methods perform **C** (Create/Map) operations — they construct parameter maps by extracting data from the form bean and populating them as input to the BP.
- The `getKKSV037201CC` method performs an **R** (Read) operation — it reads results from the BP output map and writes them back into the form bean.
- The `invokeService` call triggers the actual **BP execution** (`KKSV0372_KKSV0372OP`), which is the central business process for contract restoration. The BP itself performs C/U/D operations on database entities (exact tables not visible at this logic level — they are internal to the BP implementation).

## 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: `setMessageInfo` [-], `sendMessageString` [-], `sendMessageString` [-], `getKKSV037201CC` [R], `invokeService` [-], `getPrgTkjkSvcNm` [R], `setKKSV037203SC` [-], `setKKSV037202CC` [-], `setKKSV037201CC` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Caller: `KKW02519SFLogic.actionFix()` | `actionFix()` → `kksv0372Execute(svcFormBean, funcCd)` | `invokeService [BP:KKSV0372_KKSV0372OP]` (Contract Restoration), `getKKSV037201CC [R]`, `setKKSV037201CC [C]`, `setKKSV037202CC [C]`, `setKKSV037203SC [C]`, `setMessageInfo [-]`, `sendMessageString [-]` |

**Description:** The `actionFix()` method is the confirmation/save handler in the same `KKW02519SFLogic` class. When a user clicks the save/confirm button on the Telephone Option Service Contract Update/Recovery screen, `actionFix()` determines the operation type (update, restoration, or cancellation) and dispatches to the appropriate execute method. For restoration, it calls `kksv0372Execute()`. The method is thus ultimately called from the `KKSV0372` screen flow.

## 6. Per-Branch Detail Blocks

**Block 1** — [METHOD ENTRY] (L858)

> Method entry: Telephone option service contract restoration execution.

| # | Type | Code |
|---|------|------|
| 1 | SET | `strPrgTkjk1 = getPrgTkjkSvcNm(svcFormBean) + PRG_TKJK_1_JYOHO + PRG_TKJK_1_KAIHK` | // 2012/10/17 [ANK-1223-00-00] Progress note compilation support ADD <br> // 20131011 OM-2013-0003124 Sub-option: output sub-option name to progress note MOD <br> // Builds progress note: service name + "情報" (Information) + "回復" (Recovery) |
| 2 | EXEC | `svcFormBean.sendMessageString(KKW02519SFConst.PRG_TKJK_1, X31CWebConst.DATABEAN_SET_VALUE, strPrgTkjk1)` | // Sets progress note "進捗特記事項1" on the form bean [-> PRG_TKJK_1="進捗特記事項1"] |

**Block 2** — [VARIABLE DECLARATIONS] (L875)

> Creates the data structures used for BP invocation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramBean = {svcFormBean}` | // Array of one form bean [-> paramBean as X31SDataBeanAccess[]] |
| 2 | SET | `paramMap = new HashMap<String, Object>()` | // Parameter map generation [-> paramMap] |
| 3 | SET | `inputMap = new HashMap<String, Object>()` | // Input map generation [-> inputMap] |
| 4 | SET | `outputMap = new HashMap<String, Object>()` | // Output map generation [-> outputMap] |

**Block 3** — [SETUP TELEGRAM PARAMETERS] (L881)

> Sets the usecase ID and operation ID for routing the service invocation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put(X31CWebConst.TELEGRAM_INFO_USECASE_ID, JKKCommonConst.UCID_KKSV0372)` | // Sets usecase ID [-> UCID_KKSV0372] |
| 2 | SET | `paramMap.put(X31CWebConst.TELEGRAM_INFO_OPERATION_ID, JKKCommonConst.OPID_KKSV0372OP)` | // Sets operation ID [-> OPID_KKSV0372OP] |

**Block 4** — [UP-MAPPING: SERVICE PARAMETERS] (L885)

> Creates the BP mapper and calls three mapping methods to populate the inputMap with form data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapper = new KKSV0372_KKSV0372OPDBMapper()` | // Up-mapping (Service Item - DataBean Item mapping) |
| 2 | CALL | `inputMap = mapper.setKKSV037201CC(paramBean, inputMap, funcCd)` | // Option service contract renewal CC — maps common fields + error reason details |
| 3 | CALL | `inputMap = mapper.setKKSV037202CC(paramBean, inputMap, funcCd)` | // Service order CC — maps pre/post registration datetimes |
| 4 | CALL | `inputMap = mapper.setKKSV037203SC(paramBean, inputMap, JPCModelConstant.FUNC_CD_1)` | // Equipment provision service contract details (service contract number) — key service code = "C004" (光電話用ヴァッジ) |

**Block 5** — [BUSINESS PROCESS EXECUTION] (L893)

> Invokes the core business process for telephone option service contract restoration.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `invokeService(paramMap, inputMap, outputMap)` | // Telephone option service contract update recovery service execution (BP: KKSV0372_KKSV0372OP) |

**Block 6** — [DOWN-MAPPING: RESULTS TO FORM] (L896)

> Retrieves BP results and places them back into the form bean.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `mapper.getKKSV037201CC(paramBean, outputMap)` | // Down-mapping: retrieves results from outputMap into form bean |
| 2 | SET | `rtnMsgId = svcFormBean.sendMessageString(KKW02519SFConst.RTN_MSG_ID, X31CWebConst.DATABEAN_GET_VALUE)` | // Gets return message ID from form bean [-> RTN_MSG_ID="返却メッセージID"] |

**Block 7** — [IF] `(null != rtnMsgId && !"".equals(rtnMsgId))` (L897)

> Error handling branch: If the BP returned a non-null, non-empty message ID, it indicates an error occurred. The error message is set on the form and the method returns `false`.

> Business description: When the BP detects an error during contract restoration (e.g., contract not found, invalid state, validation failure), it returns a message ID via the form bean. This branch catches that condition, displays the error message to the user, and aborts processing.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JCCWebCommon.setMessageInfo(this, rtnMsgId)` | // Option service contract cancellation CC single-item single-associated check error — displays error message to user |
| 2 | RETURN | `return false` | // Indicates abnormal termination (error) |

**Block 8** — [ELSE-IMPLICIT / FALLTHROUGH] (L904)

> Success branch: If `rtnMsgId` is null or empty, processing completed successfully.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true` | // Indicates normal termination (success) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svcFormBean` | Field | Service Form Bean — the X31SDataBeanAccess object that carries all screen data for the Telephone Option Service Contract Update/Recovery screen |
| `funcCd` | Field | Function Code — identifies the operation type (e.g., add, modify, restore, cancel) for the screen |
| `rtnMsgId` | Field | Return Message ID — the error/success message identifier returned by the BP and stored in the form bean |
| PRG_TKJK_1 | Constant | Progress Special Item 1 (進捗特記事項1) — a field on the screen that displays progress notes about the service operation |
| PRG_TKJK_1_JYOHO | Constant | "情報" (Information) — suffix appended to progress notes to indicate informational content |
| PRG_TKJK_1_KAIHK | Constant | "回復" (Recovery) — suffix appended to progress notes to indicate a restoration/recovery operation |
| RTN_MSG_ID | Constant | Return Message ID (返却メッセージID) — key for retrieving the BP return message from the form bean |
| OP_SVC_KEI_NO | Constant | Option Service Contract Number (オプションサービス契約番号) — unique identifier for an option service contract |
| SVC_KEI_NO | Constant | Service Contract Number (サービス契約番号) — unique identifier for a service contract |
| SVC_KEI_UCWK_NO | Constant | Service Contract Internal Number (サービス契約内訳番号) — internal tracking ID for service contract line items |
| SBOP_SVC_KEI_NO | Constant | Sub-Option Service Contract Number (サブオプションサービス契約番号) — identifier for a sub-option service contract |
| IDO_RSN_CD | Constant | Error Reason Code (異動理由コード) — code indicating why a contract change failed or was cancelled |
| UPD_DTM | Constant | Update Datetime (更新年月日時刻秒) — timestamp of the last update to a service contract |
| UNYO_YMD | Constant | Operation Date (運用年月日) — the effective date for service contract operations |
| IDO_DIV | Constant | Error Classification (異動区分) — classification code indicating the type of contract change (add, modify, cancel) |
| KKSV0372 | Screen ID | Telephone Option Service Contract Update/Recovery screen — the web screen for managing telephone option service contracts |
| KKSV0372OP | Operation | Option Service Contract Update Recovery operation — the business operation ID for this screen's processing |
| UCID_KKSV0372 | Constant | Use Case ID for KKSV0372 — the usecase identifier used for routing and logging |
| OPID_KKSV0372OP | Constant | Operation ID for KKSV0372 Option |
| KKW02519SF | Module | Telephone Option Service Contract Update/Recovery module — the screen module for managing telephone option services |
| BP | Acronym | Business Process — the backend service execution layer (KKSV0372_KKSV0372OP) that performs actual database operations |
| CC | Acronym | Common Component — shared utility components (e.g., KKSV037201CC) for data mapping and validation |
| SC | Acronym | Service Component — the service layer components (e.g., KKSV037203SC) that interface with business logic |
| BP Check | Acronym | Business Process Check — validation logic within the BP that ensures data integrity before processing |
| C004 | Constant | Fiber-Optic Phone (光電話) — the equipment provision service code for phone services |
| invokeService | Method | Invokes the BP service with prepared parameter maps |
| setMessageInfo | Method | Sets a message (error/success) on the form for display on the screen |
| sendMessageString | Method | X31SDataBeanAccess method for getting/setting string values in the data bean |
