# Business Logic — KKW03204SFLogic.doService() [33 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW03204SF.KKW03204SFLogic` |
| Layer | Controller / Web Business Logic (extends `JCCWebBusinessLogic`) |
| Module | `KKW03204SF` (Package: `eo.web.webview.KKW03204SF`) |

## 1. Role

### KKW03204SFLogic.doService()

The `doService` method is the core service invocation entry point for the **050 Number Change Service** (050番号発番変更サービス) — a telecommunications business process within the K-Opticom Contract Management System (契約管理システム) that handles cancellation, recovery, or contract cancellation of 050-number ported voice OP (overlay phone) services. This method acts as a thin delegation layer: it prepares a parameter map carrying the usecase and operation identifiers, resets the outgoing message result list, invokes the remote AP (Application Platform) service via the inherited `invokeService` method from `JCCWebBusinessLogic`, and returns the result. It serves as the common execution hub for all three screen action handlers (`actionFix`, `actionInit`, `actionUpd_cfm`), implementing a **delegation pattern** where the screen controllers simply call `doService` to offload the actual backend processing. The method also performs **pre- and post-execution DataBean state logging**, which is critical for tracing state mutations caused by the remote service call. The method is `private`, meaning it is an internal helper not directly accessible from screen entry points — all external callers route through the action methods.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["doService(usecase_id, operation_id)"])
    SETUP(["Declare msgResult and paramMap"])
    TRY_BEGIN(["try block start"])
    CREATE_PARAM_MAP(["Create paramMap HashMap"])
    PUT_USECASE(["paramMap.put(TELEGRAM_INFO_USECASE_ID, usecase_id)"])
    PUT_OPERATION(["paramMap.put(TELEGRAM_INFO_OPERATION_ID, operation_id)"])
    CLEAR_MSG(["clearMessageResultList()"])
    LOG_BEFORE["JSYwebLog.println(DataBean_Dump — before)"]
    CREATE_OUTPUT_MAP(["Create outputMap HashMap"])
    INVOKE["invokeService(paramMap, inputMap, outputMap)"]
    LOG_AFTER["JSYwebLog.println(DataBean_Dump — after)"]
    TRY_END(["try block end"])
    FINALLY["finally: paramMap = null"]
    RETURN(["return msgResult"])
    END(["Return X31CMessageResult"])

    START --> SETUP --> TRY_BEGIN --> CREATE_PARAM_MAP
    CREATE_PARAM_MAP --> PUT_USECASE
    PUT_USECASE --> PUT_OPERATION
    PUT_OPERATION --> CLEAR_MSG
    CLEAR_MSG --> LOG_BEFORE
    LOG_BEFORE --> CREATE_OUTPUT_MAP
    CREATE_OUTPUT_MAP --> INVOKE
    INVOKE --> LOG_AFTER
    LOG_AFTER --> TRY_END --> FINALLY --> RETURN --> END
```

**Processing summary:**

The method executes a linear, non-branching flow:
1. **Parameter Map Creation** — Constructs a `HashMap` to carry the invocation context to the AP server.
2. **Message List Reset** — Clears any residual message result list to ensure a clean slate for the current invocation.
3. **Pre-execution Logging** — Dumps the current DataBean state (all bound UI/form data) for debugging and audit purposes.
4. **Service Invocation** — Calls the inherited `invokeService(paramMap, inputMap, outputMap)` which routes the request through the X31C messaging framework to the AP server. This is the only external call and the method's sole terminal operation.
5. **Post-execution Logging** — Dumps the DataBean state again after the service call returns, capturing any state mutations made by the AP server response handler.
6. **Resource Cleanup** — The `finally` block nullifies the `paramMap` reference to prevent memory leaks.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `usecase_id` | `String` | The business usecase identifier that determines which processing scenario the AP server should execute (e.g., initial screen load, fix confirmation, update confirmation). This is a standard X31C framework field that controls the high-level workflow branch on the AP side. |
| 2 | `operation_id` | `String` | The specific operation identifier within the usecase, further refining the processing action (e.g., INIT for initialization, FIX for fix, UPD_CF for update confirmation). Together with `usecase_id`, this forms the request envelope for the AP service call. |
| 3 | `inputMap` | `HashMap<String, Object>` (instance field) | The input parameter map passed from the action handler, containing data submitted from the screen — customer identifiers, account numbers, and service selection details required for the 050 number change process. |
| 4 | `outputMap` | `HashMap<String, Object>` (instance field) | The output map populated by `invokeService` with the AP server response data, including returned entities, error messages, and processed results. |
| 5 | `clearMessageResultList` | method (instance) | Resets the internal message result list accumulator, clearing any messages from previous invocations within the same request lifecycle. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JCCBatCommon.invokeService` | JCCBatCommon | - | Calls `invokeService` in `JCCBatCommon` |

### Per-call analysis:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `invokeService(paramMap, inputMap, outputMap)` | JCCBatCommon (inherited) | AP server (remote) | Delegates to the AP server service framework via the X31C messaging infrastructure. The specific CRUD operations (Create/Read/Update/Delete) depend on the `usecase_id` and `operation_id` values passed — this is a thin invocation wrapper, not a direct data access method. |

**Note:** The actual CRUD operations performed by the AP server are not visible in this method. The `invokeService` call routes the request through the X31C framework, which communicates with remote CBS (Common Business Service) components. The specific service component codes, entity names, and table operations are determined by the AP server configuration and are defined in the CBS layer (e.g., `JBSBatKKCrsChgIktAdd`, `JBSbatKKCrsChgSmtVLAdd`), not in this web logic method.

## 5. Dependency Trace

### Direct callers:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | KKW03204SFLogic.actionFix | `actionFix` -> `doService` | `invokeService -> JCCBatCommon.invokeService` |
| 2 | KKW03204SFLogic.actionInit | `actionInit` -> `doService` | `invokeService -> JCCBatCommon.invokeService` |
| 3 | KKW03204SFLogic.actionUpd_cfm | `actionUpd_cfm` -> `doService` | `invokeService -> JCCBatCommon.invokeService` |

**Call chain details:**

- **actionInit** — The initialization action handler. Called when the user first navigates to the 050 number change screen. Passes an INIT usecase/operation to set up the initial screen state and populate form fields.
- **actionFix** — The fix confirmation action. Triggered when the user confirms the changes on the screen. Passes a FIX usecase/operation to apply the 050 number change to the backend systems.
- **actionUpd_cfm** — The update confirmation action. Triggered when the user confirms update operations. Passes an UPD_CF usecase/operation to process the update.

All three callers are methods within the same `KKW03204SFLogic` class, and each provides a different `usecase_id` / `operation_id` combination to control the AP server behavior.

## 6. Per-Branch Detail Blocks

**Block 1** — [VARIABLE DECLARATION] (L577)

> Declares the return value variable and parameter map for the service call.

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgResult = null` // Return value holder [-> X31CMessageResult] |
| 2 | SET | `paramMap = null` // Map for information to delegate to AP server [-> HashMap<String, Object>] |

**Block 2** — [TRY] (L582)

> Start of the try block. All service invocation logic is wrapped for exception safety.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = new HashMap<String, Object>()` // Create the parameter map |
| 2 | CALL | `paramMap.put(X31CWebConst.TELEGRAM_INFO_USECASE_ID, usecase_id)` // Set usecase ID [-> Constant: TELEGRAM_INFO_USECASE_ID] |
| 3 | CALL | `paramMap.put(X31CWebConst.TELEGRAM_INFO_OPERATION_ID, operation_id)` // Set operation ID [-> Constant: TELEGRAM_INFO_OPERATION_ID] |
| 4 | EXEC | `clearMessageResultList()` // Initialize message result list |
| 5 | EXEC | `JSYwebLog.println(JSYwebLog.DataBean_Dump, getClass(), dumpDatabean(), null, null, null)` // Pre-execution DataBean dump — logs the DataBean state before service call for debugging |
| 6 | SET | `outputMap = new HashMap<String, Object>()` // Create the output map for AP server response |
| 7 | CALL | `msgResult = invokeService(paramMap, inputMap, outputMap)` // Invoke AP server service |
| 8 | EXEC | `JSYwebLog.println(JSYwebLog.DataBean_Dump, getClass(), dumpDatabean(), null, null, null)` // Post-execution DataBean dump — logs DataBean state after service call |

**Block 3** — [FINALLY] (L597)

> Cleanup block ensuring the parameter map reference is released to prevent memory leaks.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = null` // Nullify parameter map reference in finally block |

**Block 4** — [RETURN] (L600)

> Returns the result of the service invocation.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return msgResult` // Returns error message object if AP server error occurred; null on normal completion [-> X31CMessageResult] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `050番号発番変更` | Business term | 050 Number Change — the process of changing the telephone number assigned to a 050-number VoIP line. 050 numbers are virtual phone numbers used by K-Opticom for overlay phone (OP) services. |
| `契約管理システム` | Business term | Contract Management System — the core billing and contract management platform for K-Opticom telecommunications services. |
| `invokeService` | Method | The inherited service invocation method from `JCCWebBusinessLogic` that delegates requests to the AP server via the X31C framework. |
| `X31C` | Technology | Fujitsu's X31C application framework — a middleware layer for request/response messaging between web-tier logic and AP-server-side business components. |
| `TELEGRAM_INFO_USECASE_ID` | Constant | The map key constant used to store the usecase identifier in the parameter map passed to the AP server. |
| `TELEGRAM_INFO_OPERATION_ID` | Constant | The map key constant used to store the operation identifier in the parameter map. |
| `DataBean` | Technology | A data binding object (typically `X31SDataBeanAccess`) that holds form/screen data for automatic serialization between the web tier and AP server. |
| `DataBean_Dump` | Log constant | A logging level constant that triggers a full dump of the DataBean state to the application log. |
| `msgResult` | Field | `X31CMessageResult` — the message result object containing error information if the AP server encounters an error, or `null` on normal completion. |
| `paramMap` | Field | Parameter map — a `HashMap<String, Object>` that carries the invocation context (usecase_id, operation_id) to the AP server. |
| `outputMap` | Field | Output map — a `HashMap<String, Object>` populated by `invokeService` with data returned from the AP server. |
| `JCCWebBusinessLogic` | Class | Parent class — the base web business logic class providing common service invocation, logging, and data bean utilities. |
| `JCCBatCommon.invokeService` | SC/CBS | AP-side service component that handles the actual business processing dispatched by `invokeService`. The specific CBS code depends on the usecase_id and operation_id. |
| `clearMessageResultList` | Method | Resets the internal message result accumulator to ensure no residual messages from prior operations appear in the current response. |
| AP サーバ | Business term | AP Server — the Application Platform server hosting the CBS (Common Business Service) components that execute the actual 050 number change business logic. |
