# Business Logic — ZMW01904SFLogic.fix() [66 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.ZMW01904SF.ZMW01904SFLogic` |
| Layer | Controller (WebView/Logic tier — web presentation/business logic boundary) |
| Module | `ZMW01904SF` (Package: `eo.web.webview.ZMW01904SF`) |

## 1. Role

### ZMW01904SFLogic.fix()

This method implements the **Fix button press processing** (確定ボタン押下処理) for the ZMW01904SF screen, which is a telecom service modification/cancellation screen within the K-Opticom service management system. It serves as the primary confirmation handler — invoked when a user submits service changes (such as port-out requests, cancellations, or ENUM switch updates) for final processing.

The method follows a **delegation + conditional routing** pattern: it first invokes a shared ENUM (Electronic Number Mapping) switching service via `invokeService`, then inspects the result for errors. If an error flag is returned, it routes the user to an error screen (ZMW01905) with the error message. If processing succeeds, it checks the `SINSEI_NAIYO_FLG` (Application Content Flag) to determine if re-registration of e-joining data is required — specifically for port-out (value "1") or third-party cancellation (value "7") scenarios, where the e-joining number may have changed and needs updating via a secondary ENUM switch refresh. On successful completion without special flags, it proceeds to redirect to the post-operation screen (ZMW01906).

The method acts as the **terminal processing step** in the service modification workflow, consolidating all business operations into a single service call and handling navigation based on the outcome. It is the web-layer entry point for confirming service order changes.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["fix() Entry"])

    START --> GET_COMMON["Get commonInfoBean"]
    GET_COMMON --> GET_SERVICE["Get serviceFormBean"]
    GET_SERVICE --> INIT_PARAMBEAN["Create paramBean array"]
    INIT_PARAMBEAN --> INIT_MAPS["Create paramMap dataMap outputMap"]
    INIT_MAPS --> SET_USECASE["Set USECASE_ID = SV134"]
    SET_USECASE --> CREATE_MAPPER["Create ZMSV0134 Mapper"]
    CREATE_MAPPER --> SET_ENUM["mapper.setENUMSWITCHCC"]
    SET_ENUM --> INVOKE_SERVICE["invokeService"]
    INVOKE_SERVICE --> GET_ERRFLG["Get ERR_FLG from outputMap"]

    GET_ERRFLG --> ERR_CHECK{errFlg is empty?}

    ERR_CHECK -->|No - Error| ERROR_HANDLING["setMessage with errFlg"]
    ERROR_HANDLING --> SET_NEXT_ERR["Set next screen ZMW01905"]
    SET_NEXT_ERR --> FORCE_REDIRECT["setTransferPageId ZMW01905"]
    FORCE_REDIRECT --> RETURN_ERR["Return true"]

    ERR_CHECK -->|Yes - OK| CHECK_FLG{SINSEI_NAIYO_FLG?}

    CHECK_FLG -->|Value 1: Port Out| ENUM_REFRESH["mapper.getENUMSWITCHCC"]
    CHECK_FLG -->|Value 7: Cancellation| ENUM_REFRESH
    CHECK_FLG -->|Other value| SUCCESS_FLOW["Display success message"]

    ENUM_REFRESH --> SUCCESS_FLOW
    SUCCESS_FLOW --> SET_NEXT_SUCCESS["Set next screen ZMW01906"]
    SET_NEXT_SUCCESS --> RETURN_SUCCESS["Return true"]

    RETURN_ERR --> END_NODE(["fix() End"])
    RETURN_SUCCESS --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method takes no explicit parameters. All input data is obtained from the service form bean (retrieved via `getServiceFormBean()`) which carries the screen input data from the user's previous page submission. |
| - | `commoninfoBean` | `X31SDataBeanAccess` | Common form bean — shared context bean obtained via `getCommonInfoBean()`. Carries session-wide data including next-screen navigation parameters (NEXT_SCREEN_ID, NEXT_SCREEN_NAME). |
| - | `bean` | `X31SDataBeanAccess` | Service form bean — retrieved via `getServiceFormBean()`. Contains all user-submitted form data for the service modification screen, including SINSEI_NAIYO_FLG (application content flag), ENUM switch data, and order details. |
| - | `paramBean` | `X31SDataBeanAccess[]` | Array wrapping the service form bean. Passed to the mapper and `invokeService` as the input payload for the service call. |
| - | `paramMap` | `HashMap<String, Object>` | Use-case identification map. Stores the use-case ID (SV134 = ZMSV0134) to identify which processing scenario is being invoked. |
| - | `dataMap` | `HashMap<String, Object>` | Mapping intermediate data map — holds data exchanged between the mapper and the invoked service. |
| - | `outputMap` | `HashMap<String, Object>` | Service execution result data map — holds the output from `invokeService`, including the ERR_FLG for error handling. |
| - | `mapper` | `ZMSV0134_ZMSV0134OPDBMapper` | Data mapper instance for ZMSV0134 processing. Handles ENUM switching configuration and data transformation between form beans and service output. |

**External state / constants read:**
| No | Name | Type | Business Description |
|----|------|------|---------------------|
| 1 | `JZMWebConst.SV134` | `String = "ZMSV0134"` | Use-case identifier for the ENUM switching service. |
| 2 | `JPCModelConstant.FUNC_CD_1` | `String = "1"` | Function code "1" — passed to `setENUMSWITCHCC` to specify the ENUM switching function type. |
| 3 | `SINSEI_NAIYO_FLG_1` | `String = "1"` | Application content flag value "1" — represents Port Out (FTTH Phone Number) requests. Triggers ENUM refresh for re-registration. |
| 4 | `SINSEI_NAIYO_FLG_7` | `String = "7"` | Application content flag value "7" — represents Third-party Cancellation (他社受取) requests. Triggers ENUM refresh for re-registration. |
| 5 | `JPCOnlineMessageConstant.EKB4390__I` | `String` | Success message code displayed on the confirmation completion screen. |
| 6 | `MSG_VALUE_ADD` | `String` | Message value qualifier indicating an "addition" type notification (service modification confirmation). |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `ZMSV0134_ZMSV0134OPDBMapper.setENUMSWITCHCC` | ZMSV0134 | - | Sets ENUM switching configuration in the data mapper — prepares ENUM switch parameters from the form bean for the service call. |
| C | `JCCBatCommon.invokeService` | ZMSV0134 | ZM_M_ENUM_SWITCH, ZM_M_ENUM_SWITCH_HISTORY | Invokes the core ENUM switching business service — performs the ENUM number mapping update/registration based on the application content flag. |
| R | `ZMSV0134_ZMSV0134OPDBMapper.getENUMSWITCHCC` | ZMSV0134 | ZM_M_ENUM_SWITCH | Re-reads ENUM switching data from the database after port-out or cancellation processing, to refresh the e-joining number for re-registration. |
| - | `ZMW01904SFLogic.getStringSearch` | ZMW01904SFLogic | - | Utility method to extract the ERR_FLG error flag from the service output map. |
| - | `ZMW01904SFLogic.setMessage` | ZMW01904SFLogic | - | Sets the error message using the error flag obtained from service output. |
| - | `ZMW03701SFLogic.setTransferPageId` | ZMW03701SFLogic | - | Sets the forced redirect page URL for error screen navigation. |
| - | `OneStopDataBeanAccess.sendMessageString` | OneStopDataBeanAccess | - | Sets session-level navigation data (NEXT_SCREEN_ID, NEXT_SCREEN_NAME) in the common info bean for screen routing. |
| - | `JZMWebCommon.setMessageInfo` | JZMWebCommon | - | Displays the success message on the confirmation completion screen. |

**How to classify:**
- The core business operation is the ENUM switching service call via `invokeService`, which performs a **Create** (registration/update of ENUM number mapping records) and potentially **Update** (modifying existing ENUM entries) against the ENUM switching tables.
- `getENUMSWITCHCC` is a **Read** operation — retrieves current ENUM switching data for refresh/re-registration.
- All other calls are supporting operations (navigation, messaging, data setup).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:ZMW01904SF | `ZMW01904SFOPOperation.fix` -> `ZMW01904SFLogic.fix` | `invokeService [C] ZM_M_ENUM_SWITCH, ZM_M_ENUM_SWITCH_HISTORY` |

**Notes:** The `ZMW01904SF` module is a self-contained screen module. The `fix()` method is the confirmation/submit handler typically invoked from the screen's OPOperation class (e.g., `ZMW01904SFOPOperation`) when the user clicks the "Fix" (確定/Confirm) button. No other external callers were found in the codebase. The method delegates to the ZMSV0134 ENUM switching service (SC code) and performs CRUD operations on ENUM switching master and history tables.

## 6. Per-Branch Detail Blocks

**Block 1** — SET (L403-404)

> Obtain the common form bean (共通フォームBean) to get shared session context for navigation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `commoninfoBean = getCommonInfoBean()` |

**Block 2** — SET (L407-408)

> Obtain the service form bean (サービスフォームBean) containing all user input data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bean = getServiceFormBean()` |

**Block 3** — SET (L411)

> Wrap the service form bean in an array for passing to the mapper.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramBean = { bean }` |

**Block 4** — EXEC (L414-415)

> Create the use-case identification map and set the use-case ID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = new HashMap<String, Object>()` |
| 2 | EXEC | `paramMap.put(X31CWebConst.TELEGRAM_INFO_USECASE_ID, JZMWebConst.SV134 = "ZMSV0134")` |

**Block 5** — EXEC (L418-421)

> Create intermediate data maps for mapping and service output.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dataMap = new HashMap<String, Object>()` |
| 2 | SET | `outputMap = new HashMap<String, Object>()` |

**Block 6** — EXEC (L424)

> Create the ENUM switching data mapper instance.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapper = new ZMSV0134_ZMSV0134OPDBMapper()` |

**Block 7** — CALL (L426)

> Configure ENUM switching in the mapper with function code "1".

| # | Type | Code |
|---|------|------|
| 1 | CALL | `mapper.setENUMSWITCHCC(paramBean, dataMap, JPCModelConstant.FUNC_CD_1 = "1")` |

**Block 8** — CALL (L429)

> Invoke the core ENUM switching business service. This is the main processing step that performs the actual ENUM number mapping update/registration.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `invokeService(paramMap, dataMap, outputMap)` |

**Block 9** — SET (L432)

> Retrieve the error flag from the service output.

| # | Type | Code |
|---|------|------|
| 1 | SET | `errFlg = getStringSearch("ZMSV013401CC", outputMap, "ERR_FLG")` |

**Block 10** — IF [`!StringUtils.isEmpty(errFlg)`] (L434)

> **Error Handling Branch**: If the service returned a non-empty error flag, handle the error and redirect to the error screen (ZMW01905).

| # | Type | Code |
|---|------|------|
| 1 | SET | `setMessage(errFlg)` // Set error message based on flag |
| 2 | EXEC | `commoninfoBean.sendMessageString(NEXT_SCREEN_ID, DATABEAN_SET_VALUE, JZMScreenConst.SCREEN_ID_ZMW01905)` |
| 3 | EXEC | `commoninfoBean.sendMessageString(NEXT_SCREEN_NAME, DATABEAN_SET_VALUE, JZMScreenConst.SCREEN_NAME_ZMW01905)` |
| 4 | CALL | `setTransferPageId(JZMScreenConst.SCREEN_ID_ZMW01905 + JZMWebConst.PJP)` // Forced screen redirect |
| 5 | RETURN | `return true` |

**Block 11** — IF [SINSEI_NAIYO_FLG check] (L436-440)

> **ENUM Refresh Branch**: If the application content flag is "1" (Port Out / FTTH Phone Number) or "7" (Third-party Cancellation / Cancel), re-read the ENUM switching data for re-registration of e-joining data. This is necessary because the e-joining number changes when these specific operation types are processed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `SINSEI_NAIYO_FLG_1 = "1" (Port Out / FTTH Phone Number)` |
| 2 | SET | `SINSEI_NAIYO_FLG_7 = "7" (Third-party Cancellation / Cancel)` |
| 3 | CALL | `paramBean[0].sendMessageString(ZMW01904SFConst.SINSEI_NAIYO_FLG, X31CWebConst.DATABEAN_GET_VALUE)` |
| 4 | CALL | `mapper.getENUMSWITCHCC(paramBean, outputMap)` |

> Business description: For SINSEI_NAIYO_FLG = "1", the e-joining status is in state 300 and a switch registration was made, so the e-joining number changes. For SINSEI_NAIYO_FLG = "7", the third-party cancellation process also changes the e-joining number. In both cases, the ENUM data must be refreshed.

**Block 12** — SET (L444-450)

> **Success Flow**: Set the success message and configure navigation to the post-processing screen (ZMW01906).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JZMWebCommon.setMessageInfo(this, JPCOnlineMessageConstant.EKB4390__I, MSG_VALUE_ADD)` // Display confirmation completion message |
| 2 | EXEC | `commoninfoBean.sendMessageString(NEXT_SCREEN_ID, DATABEAN_SET_VALUE, JZMScreenConst.SCREEN_ID_ZMW01906)` |
| 3 | EXEC | `commoninfoBean.sendMessageString(NEXT_SCREEN_NAME, DATABEAN_SET_VALUE, JZMScreenConst.SCREEN_NAME_ZMW01906)` |
| 4 | RETURN | `return true` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `SINSEI_NAIYO_FLG` | Field | Application Content Flag — determines the type of service operation (port-out, cancellation, etc.) being processed. |
| `SINSEI_NAIYO_FLG_1` | Constant | Flag value "1" — Port Out (ポートアウト) / FTTH Phone Number request. |
| `SINSEI_NAIYO_FLG_7` | Constant | Flag value "7" — Third-party Cancellation (他社受取取消) — cancellation of a service that was received from a competitor carrier. |
| ENUM | Business term | Electronic Number Mapping — telecom number mapping service that routes calls between carriers during port-out/switching. |
| E-joining | Business term | E-joining (エイジョイン) — the process where a customer's phone number is registered in the ENUM system for inter-carrier routing. |
| ZM_M_ENUM_SWITCH | Entity | ENUM Switch Master Table — stores ENUM number mapping records (active switches). |
| ZM_M_ENUM_SWITCH_HISTORY | Entity | ENUM Switch History Table — stores historical ENUM switching records for audit trail. |
| `invokeService` | Method | Core service invocation method — delegates to the ENUM switching business service component (ZMSV0134). |
| `setENUMSWITCHCC` | Method | ENUM switching configuration method — prepares ENUM switch data from form beans for processing. |
| `getENUMSWITCHCC` | Method | ENUM switching read-back method — retrieves current ENUM switch data after processing for refresh/re-registration. |
| ERR_FLG | Field | Error Flag — output field from the service indicating whether processing succeeded or failed. |
| NEXT_SCREEN_ID | Field | Next screen identifier — session variable used for screen navigation routing. |
| NEXT_SCREEN_NAME | Field | Next screen name — session variable carrying the display name of the next screen. |
| TELEGRAM_INFO_USECASE_ID | Constant | Use-case identification key — identifies which processing scenario is being invoked. |
| SV134 | Constant | "ZMSV0134" — the ENUM switching service identifier. |
| FUNC_CD_1 | Constant | Function code "1" — specifies the ENUM switching function type passed to the mapper. |
| EKB4390__I | Constant | Success message code — informational message displayed on the confirmation completion screen. |
| MSG_VALUE_ADD | Constant | Message value qualifier — indicates an "addition" type notification (service modification confirmation). |
| ZMW01904SF | Screen ID | Screen for service modification/cancellation — the current screen where the fix button is pressed. |
| ZMW01905 | Screen ID | Error handling screen — displayed when ENUM switching processing encounters an error. |
| ZMW01906 | Screen ID | Post-processing confirmation screen — displayed after successful service modification/cancellation. |
| DATABEAN_SET_VALUE | Constant | Data bean set value indicator — used when setting values in the data bean. |
| DATABEAN_GET_VALUE | Constant | Data bean get value indicator — used when reading values from the data bean. |
| PJP | Constant | Page jump suffix — appended to screen IDs for forced page redirection. |
| ZMW01904SFConst | Class | Constants class for ZMW01904SF module — contains field names and configuration constants. |
| ZMSV0134 | Screen ID | ENUM switching processing screen ID — the use-case identifier for ENUM number mapping operations. |
| JCCBatCommon | Class | Common batch service invocation class — provides the `invokeService` method for delegating to batch/SC services. |
| JPCModelConstant | Class | JPC model constants — contains function code constants used in ENUM switching configuration. |
| Fix button (確定ボタン) | UI element | Confirm/Fix button — the button the user clicks to submit service modification changes for processing. |
| Port Out (ポートアウト) | Business term | Telecommunications port-out — the process of transferring a phone number from one carrier to another. |
| Third-party Cancellation (他社受取) | Business term | Cancellation of service received from a competitor carrier — a type of service modification where a previously transferred service is cancelled. |
