# Business Logic — JKKKikiKaifukuWrisvcCC.execKikiKaifukuWrisvc() [89 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKKikiKaifukuWrisvcCC` |
| Layer | CC/Common Component (extends `AbstractCommonComponent`) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKKikiKaifukuWrisvcCC.execKikiKaifukuWrisvc()

This method serves as the central **equipment provisioning service contract recovery routing processor** within the K-Opticom customer backbone system. It is a shared common component (CC) invoked by multiple screen-level controllers during service contract lifecycle operations — specifically when equipment-related service contracts need to be recovered, verified, or re-registered. The method performs a **dispatch-and-delegate** design pattern: it first retrieves two CBS (Central Business System) data entities — the Service Contract Agreement (`EKK0081A010`) and the Equipment Provisioning Service Contract Agreement (`EKK0341A010`) — ensuring both exist by calling CBS lookups only when data is absent. After gathering both data sets into a temporary data HashMap, it branches based on `func_code`: if the code is `"1"` (Check & Register mode), it delegates to `execKikiTorokuWrisvc()` to perform the actual equipment service contract recovery registration; otherwise, it simply returns the parameter unchanged. This design makes the method a **conditional recovery orchestrator** — a single entry point that handles both passive data retrieval (func_code != "1") and active recovery registration (func_code == "1").

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execKikiKaifukuWrisvc"])

    START --> INIT["Initialize: dataMapKey, ccMsg, func_code"]
    INIT --> ERRCLR["Clear error flag: err_flg"]
    ERRCLR --> MSGSET["Initialize messageInfo and message_list"]
    MSGSET --> TEMP["Create temporaryData HashMap"]
    TEMP --> SCINV["Create ServiceComponentRequestInvoker"]
    SCINV --> SVCCHK["Check svc_kei_data"]

    SVCCHK --> SVCNULL{"ekk0081a010cbsMsg null?"}
    SVCNULL -->|Yes| SVCQUERY["Call EKK0081A010 CBS"]
    SVCNULL -->|No| SVCSTORE["Store svc_kei_data to temporaryData"]

    SVCQUERY --> SVCSTORE2["Store result to temporaryData"]
    SVCSTORE --> TEMPCHK["Check kktk_svc_kei_data"]
    SVCSTORE2 --> TEMPCHK

    TEMPCHK --> TEMPNULL{"ekk0341a010cbsMsg null?"}
    TEMPNULL -->|Yes| TEMPQUERY["Call EKK0341A010 CBS"]

    TEMPNULL -->|No| TEMPSTORE["Store kktk_svc_kei_data to temporaryData"]

    TEMPQUERY --> TEMPEMPTY{"Result list empty?"}
    TEMPEMPTY -->|Yes| SETERR["Set error message EKB0320-KW"]
    TEMPEMPTY -->|No| TEMPSTORE2["Store first result to message"]

    SETERR --> RETPARAM["Return param"]

    TEMPSTORE --> CHKFUNC{"func_code is check?"}
    TEMPSTORE2 --> CHKFUNC
    TEMPEMPTY -->|No| CHKFUNC

    CHKFUNC -->|Yes| EXECRECOVER["Call execKikiTorokuWrisvc"]
    CHKFUNC -->|No| RETPARAM2["Return param"]

    EXECRECOVER --> RETPARAM2
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transactional context for CBS service invocations. Used to maintain connection state and transaction boundaries when calling CBS methods (EKK0081A010, EKK0341A010). |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object carrying the request data map (`ccMsg`) and serving as the return object. Contains business data keyed by `dataMapKey` including `svc_kei_no` (service contract number), `unyo_ymd` (operation date), `kktk_svc_kei_no` (equipment provisioning service contract number), `func_code`, `svc_kei_data` (service contract CBS data), and `kktk_svc_kei_data` (equipment provisioning CBS data). Modified in-place with error flags, message lists, and retrieved CBS results. |
| 3 | `fixedText` | `String` | Data map key identifier used as the map key to retrieve the `ccMsg` HashMap from `param`. This key distinguishes different data contexts within the same request parameter object. Acts as the `dataMapKey` for all data access on `param`. |

**External state read by the method:**

| Field | Source Class | Business Meaning |
|-------|-------------|------------------|
| `FUNC_CODE_1` | `JKKKikiKaifukuWrisvcCC` | Function code `"1"` — Check & Register mode, triggers equipment service contract recovery registration |
| `TEMPLATE_ID_EKK0081A010` | `JKKKikiKaifukuWrisvcCC` | Template ID `"EKK0081A010"` — Service Contract Agreement CBS template identifier |
| `TEMPLATE_ID_EKK0341A010` | `JKKKikiKaifukuWrisvcCC` | Template ID `"EKK0341A010"` — Equipment Provisioning Service Contract Agreement CBS template identifier |
| `ERR_FLG_ERR` | `JKKKikiKaifukuWrisvcCC` | Error flag `"E"` — Error-level error flag used when equipment provisioning service contract data is not found |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKKikiKaifukuWrisvcCC.callSC` (EKK0081A010) | EKK0081A010SC | KK_T_SVC_KEI (Service Contract table) | Calls CBS `EKK0081A010` (Service Contract Agreement Inquiry) via `callSC` — retrieves service contract agreement data for the given service contract number. Invoked with `FUNC_CODE="2"` (inquiry mode) and the service contract number from the request data. |
| R | `JKKKikiKaifukuWrisvcCC.callSC` (EKK0341A010) | EKK0341A010SC | KK_T_KKTK_SVC_KEI (Equipment Provisioning Service Contract table) | Calls CBS `EKK0341A010` (Equipment Provisioning Service Contract Agreement Inquiry) via `callSC` — retrieves equipment provisioning service contract agreement data. Invoked with `FUNC_CODE="2"` (inquiry mode) and the equipment service contract number. Returns an array; if empty or null, triggers error `EKB0320-KW`. |
| - | `JKKKikiKaifukuWrisvcCC.execKikiTorokuWrisvc` | - | - | Delegates equipment service contract recovery registration when `func_code == "1"`. Handles the actual contract re-registration processing for equipment provisioning services. |
| - | `JKKKikiKaifukuWrisvcCC.setMessageInfo` | - | - | Sets error message `EKB0320-KW` with error flag `E` when equipment provisioning service contract inquiry returns no results. Displays exclusion error to the user. |
| R | `callSC` | (dynamic) | (varies) | Generic service component invocation router. Creates a `ServiceComponentRequestInvoker` instance and delegates CBS calls with the appropriate input message array. Returns `CAANMsg` or `CAANMsg[]` depending on the CBS. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKCoseRkRsvCanNtKojiUkCC` | `execKikiKaifukuWribikiCall()` -> `JKKKikiKaifukuWrisvcCC.execKikiKaifukuWrisvc` | `EKK0081A010CBS [R] KK_T_SVC_KEI`, `EKK0341A010CBS [R] KK_T_KKTK_SVC_KEI`, `execKikiTorokuWrisvc [-]` |
| 2 | `JKKKikiIchiranIkkatsuCC` | `execKikiKaifukuWribikiShori()` -> `JKKKikiKaifukuWrisvcCC.execKikiKaifukuWrisvc` | `EKK0081A010CBS [R] KK_T_SVC_KEI`, `EKK0341A010CBS [R] KK_T_KKTK_SVC_KEI`, `execKikiTorokuWrisvc [-]` |
| 3 | `JKKKikiIchiranKkUpdCC` | `execKikiKaifukuWribikiShori()` -> `JKKKikiKaifukuWrisvcCC.execKikiKaifukuWrisvc` | `EKK0081A010CBS [R] KK_T_SVC_KEI`, `EKK0341A010CBS [R] KK_T_KKTK_SVC_KEI`, `execKikiTorokuWrisvc [-]` |

**Call chain analysis:** All three direct callers invoke this method from their own recovery routing processing methods (`execKikiKaifukuWribikiCall()` and `execKikiKaifukuWribikiShori()`), which are called during service contract screen operations. These controllers handle customer service contract management screens where equipment provisioning contracts need to be recovered or re-registered as part of the service lifecycle.

**Terminal operations reached from this method:** `execKikiTorokuWrisvc` (registration delegation), `setMessageInfo` (error message setting), `callSC` (CBS reads for both EKK0081A010 and EKK0341A010).

## 6. Per-Branch Detail Blocks

**Block 1** — [INITIALIZATION] (L82-L95)

> Initializes the local context for the recovery routing process. Extracts the data map from the request parameter, resets the error flag, and prepares message and temporary data containers.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dataMapKey = fixedText` — Data map key extracted from fixedText parameter [-> `fixedText`] |
| 2 | SET | `ccMsg = (HashMap) param.getData(dataMapKey)` — Retrieves the working data map from the request parameter |
| 3 | SET | `func_code = (String) ccMsg.get("func_code")` — Extracts function code that determines processing mode |
| 4 | EXEC | `ccMsg.put("err_flg", "")` // エラーフラグ (Error flag) — Clears the error flag to initialize error state |
| 5 | SET | `messageInfo = new ArrayList<HashMap<String, Object>>()` // メッセージ情報 (Message information) — Creates a list to hold message objects |
| 6 | EXEC | `ccMsg.put("message_list", messageInfo)` // メッセージコードリスト (Message code list) — Stores message list in ccMsg |
| 7 | SET | `temporaryData = new HashMap<String, Object>()` // 一時領域データ (Temporary area data) — Creates temporary storage for CBS results |
| 8 | SET | `scCall = new ServiceComponentRequestInvoker()` // SC呼び出し部品のインスタンス生成 (Instantiation of SC invocation component) — Creates the service component request invoker; passes class name to log (empty string means no log output) |

**Block 2** — [IF - Service Contract Data Retrieval] `(ekk0081a010cbsMsg == null)` (L97-L116)

> Retrieves Service Contract Agreement data (EKK0081A010) from the CBS when the data is not already present in the request. This is a read-only inquiry with FUNC_CODE="2".

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0081a010cbsMsg = (CAANMsg) ccMsg.get("svc_kei_data")` // サービス契約データが存在しない場合取得します (Retrieve if service contract data does not exist) — Extracts existing service contract CBS data |
| 2 | IF | `ekk0081a010cbsMsg == null` — Condition: service contract CBS data is absent |
| 3 | SET | `EKK0081A010CBSMsg.TEMPLATEID -> TEMPLATE_ID_EKK0081A010` — Template ID set to `"EKK0081A010"` [-> `TEMPLATE_ID_EKK0081A010 = "EKK0081A010"` (サービス契約照会 - Service Contract Inquiry)] |
| 4 | SET | `EKK0081A010CBSMsg.FUNC_CODE -> "2"` — Function code "2" indicates inquiry/read mode |
| 5 | SET | `EKK0081A010CBSMsg.KEY_SVC_KEI_NO -> ccMsg.get("svc_kei_no")` — Service contract number from request data |
| 6 | SET | `EKK0081A010CBSMsg.KEY_GENE_ADD_DTM -> ""` — Generation/addition datetime (empty string) |
| 7 | SET | `EKK0081A010CBSMsg.KEY_RSV_APLY_YMD -> ccMsg.get("unyo_ymd")` — Reservation application date from operation date |
| 8 | CALL | `callSC(handle, scCall, param, dataMapKey, ekk0081a010IN).getCAANMsgList(...)[0]` — Invokes EKK0081A010 CBS Service Contract Agreement Inquiry and stores the first result |
| 9 | ENDIF | Block 2 closes |

| # | Type | Code |
|---|------|------|
| 10 | EXEC | `temporaryData.put(TEMPLATE_ID_EKK0081A010, ekk0081a010cbsMsg)` // 検索結果を格納（サービス契約照会） (Store search results - Service Contract Inquiry) — Stores the CBS result in the temporary data map |

**Block 3** — [IF - Equipment Provisioning Service Contract Data Retrieval] `(ekk0341a010cbsMsg == null)` (L118-L153)

> Retrieves Equipment Provisioning Service Contract Agreement data (EKK0341A010) from the CBS when absent. If the inquiry returns no results, displays an exclusion error (EKB0320-KW) and returns immediately. This is a critical guard clause — without this data, subsequent processing cannot proceed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0341a010cbsMsg = (CAANMsg) ccMsg.get("kktk_svc_kei_data")` // 機器提供サービス契約データが存在しない場合取得します (Retrieve if equipment provisioning service contract data does not exist) — Extracts existing equipment provisioning service contract CBS data |
| 2 | IF | `ekk0341a010cbsMsg == null` — Condition: equipment provisioning service contract CBS data is absent |
| 3 | SET | `EKK0341A010CBSMsg.TEMPLATEID -> TEMPLATE_ID_EKK0341A010` — Template ID set to `"EKK0341A010"` [-> `TEMPLATE_ID_EKK0341A010 = "EKK0341A010"` (機器提供サービス契約照会 - Equipment Provisioning Service Contract Inquiry)] |
| 4 | SET | `EKK0341A010CBSMsg.FUNC_CODE -> "2"` — Function code "2" indicates inquiry/read mode |
| 5 | SET | `EKK0341A010CBSMsg.KEY_KKTK_SVC_KEI_NO -> ccMsg.get("kktk_svc_kei_no")` — Equipment provisioning service contract number |
| 6 | SET | `EKK0341A010CBSMsg.KEY_GENE_ADD_DTM -> ""` — Generation/addition datetime (empty string) |
| 7 | SET | `EKK0341A010CBSMsg.KEY_RSV_APLY_YMD -> ccMsg.get("unyo_ymd")` — Reservation application date |
| 8 | CALL | `callSC(handle, scCall, param, dataMapKey, ekk0341a010IN).getCAANMsgList(...)` — Invokes EKK0341A010 CBS Equipment Provisioning Service Contract Agreement Inquiry, returns CAANMsg array |
| 9 | ENDIF | Inner Block 3 closes |

**Block 3.1** — [NESTED IF - Empty Result Check] `(ekk0341a010cbsMsgList == null || ekk0341a010cbsMsgList.length == 0)` (L136-L140)

> Guard clause: If the CBS inquiry returns no equipment provisioning service contract data, sets an exclusion error message (EKB0320-KW) and returns early. This prevents null pointer exceptions downstream and provides clear user-facing error messaging.

| # | Type | Code |
|---|------|------|
| 1 | IF | `ekk0341a010cbsMsgList == null || ekk0341a010cbsMsgList.length == 0` — Condition: CBS returned no data |
| 2 | EXEC | `setMessageInfo(ccMsg, "EKB0320-KW", "", "", ERR_FLG_ERR)` // 排他エラーを表示（EKB0320-KW） (Display exclusive error EKB0320-KW) — Sets exclusion error message with error flag `E` [-> `ERR_FLG_ERR = "E"`] |
| 3 | RETURN | `return param` — Early return with error state set; processing terminates |
| 4 | ENDIF | Block 3.1 closes |

| # | Type | Code |
|---|------|------|
| 5 | SET | `ekk0341a010cbsMsg = ekk0341a010cbsMsgList[0]` — Stores the first result from the inquiry array |

| # | Type | Code |
|---|------|------|
| 6 | EXEC | `temporaryData.put(TEMPLATE_ID_EKK0341A010, ekk0341a010cbsMsg)` // 検索結果を格納（機器提供サービス契約照会） (Store search results - Equipment Provisioning Service Contract Inquiry) — Stores the CBS result in the temporary data map |

**Block 4** — [IF - Check & Register Mode Branch] `(FUNC_CODE_1.equals(func_code))` (L155-L158)

> Conditional execution: Only runs when `func_code == "1"` (Check & Register mode). In this mode, the method delegates to `execKikiTorokuWrisvc()` to perform the actual equipment service contract recovery registration. When `func_code` is any other value (typically "0" for simple display mode), this block is skipped and the method simply returns the parameter unchanged.

| # | Type | Code |
|---|------|------|
| 1 | IF | `FUNC_CODE_1.equals(func_code)` — Condition: func_code is "1" (チェック＆登録 - Check & Register) [-> `FUNC_CODE_1 = "1"`] |
| 2 | CALL | `execKikiTorokuWrisvc(handle, scCall, param, dataMapKey, temporaryData)` // 機器提供サービス契約回復呼び出し (Equipment Provisioning Service Contract Recovery Call) — Delegates to the recovery registration processor with all gathered CBS data |
| 3 | ENDIF | Block 4 closes |

**Block 5** — [RETURN] (L164)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` — Returns the modified request parameter with error flags, message lists, and CBS data stored in the data map |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service contract number — Unique identifier for a service contract line item in the K-Opticom system |
| `kktk_svc_kei_no` | Field | Equipment provisioning service contract number — Identifier for a service contract that involves equipment provisioning (hardware-related service lines) |
| `unyo_ymd` | Field | Operation date — The date on which the service contract operation is performed (YYYYMMDD format) |
| `svc_kei_data` | Field | Service contract CBS data — The CAANMsg object containing the result of the EKK0081A010 CBS inquiry |
| `kktk_svc_kei_data` | Field | Equipment provisioning service contract CBS data — The CAANMsg object containing the result of the EKK0341A010 CBS inquiry |
| `func_code` | Field | Function code — Determines the processing mode: "1" = Check & Register (triggers recovery registration), "2" = Inquiry mode (used internally for CBS calls) |
| `err_flg` | Field | Error flag — Status flag indicating processing result: empty string = normal, "E" = error, "W" = warning |
| `dataMapKey` | Field | Data map key — Key used to identify the working data map within the request parameter object |
| `message_list` | Field | Message code list — List of message objects to be displayed to the user after processing |
| `temporaryData` | Field | Temporary area data — HashMap used as intermediate storage for CBS inquiry results before they are passed to downstream processing |
| EKK0081A010 | CBS | Service Contract Agreement (サービス契約照会) — CBS method for inquiring service contract agreement information |
| EKK0341A010 | CBS | Equipment Provisioning Service Contract Agreement (機器提供サービス契約照会) — CBS method for inquiring equipment provisioning service contract agreement information |
| EKB0320-KW | Error Message | Exclusion error — Error message displayed when equipment provisioning service contract data is not found (no matching records) |
| KK_T_SVC_KEI | DB Table | Service Contract table — Database table storing service contract agreement records |
| KK_T_KKTK_SVC_KEI | DB Table | Equipment Provisioning Service Contract table — Database table storing equipment provisioning service contract records |
| SC | Acronym | Service Component — Layer that invokes CBS (Central Business System) methods |
| CBS | Acronym | Central Business System — Backend business logic and data access layer |
| CAANMsg | Class | CBS Message Object — Message container used for CBS communication, holding input/output data for CBS methods |
| ServiceComponentRequestInvoker | Class | SC Invocation Component — Component that handles the instantiation and invocation of Service Components (SC) |
| K-Opticom | Business term | Japanese telecommunications operator — The business domain for this system, focusing on broadband and IPTV service management |
| 機器提供サービス (Kiki Teiyo Service) | Business term | Equipment Provisioning Service — Service contract category involving hardware/equipment provisioning (routers, set-top boxes, etc.) |
| 契約照会 (Keiyaku Shokai) | Business term | Contract Inquiry — CBS operation that retrieves contract agreement data without modifying it |
| 回復登録 (Kaifuku Toroku) | Business term | Recovery Registration — Process to re-register or restore a service contract during contract lifecycle recovery operations |
