# Business Logic — JZMEnumSwitchCC.interCompany_OPTtelno_Cancel() [52 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JZMEnumSwitchCC` |
| Layer | CC / Common Component (EJB business logic component) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JZMEnumSwitchCC.interCompany_OPTtelno_Cancel()

This method implements the **cancellation (undo) processing for inter-company transfer (OPT telephone number)** — a telecom number portability operation where a subscriber requests to withdraw a previously-submitted request to transfer their phone number between telecommunications providers under the K-Opticom ENUM (E.164 Number Mapping) system. The business context is Application Content 6 (Application Content 6 / 申請内容_6): "Inter-company Transfer (OPT Telephone Number) - Cancellation" (事業者間移転(ＯＰＴ電話番号)・取消).

The method follows a **guard-gate-delegate** design pattern. It executes three sequential validation checks — service contract status, phone number state, and aging (Ei Jing / reservation) status — and short-circuits with specific error codes if any check fails. If all validations pass, it delegates to three downstream service operations: issuing ENUM-related Service Order Data (SOD), updating the port-out receipt status, and refreshing the phone number master data.

Its role in the larger system is that of a **dedicated cancellation handler** within the ENUM switch common component routing framework. It is invoked by `JZMEnumSwitchCC.enumSwitch()`, the central dispatcher that routes all ENUM switch application types to their specialized handlers. This method handles only one specific service flow: undoing an inter-company OPT number transfer that was previously initiated but not yet finalized.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["interCompany_OPTtelno_Cancel:start"])

    CHECK_SERVICE["serviceKeiStatCheck<br/>Phone number service contract status"]

    COND_SERVICE{"serviceKeiStatCheck<br/>returns false?"}

    ERR_SERVICE["ERR_FLG = ENUMCC_ERR_FLG_6001<br/>Contract data exists error<br/>param.setData(fixedText, inMap)<br/>return param"]

    CHECK_PHONE_STAT["telnoStatJudge(handle, param, telno, TELNOSTATJUDGE_02 = 02)"]

    COND_PHONE{"telnoStatJudge<br/>returns false?"}

    COND_JUDGE{"NOT_JUDGE == 1?<br/>Judge exemption flag"}

    ERR_JUDGE02["ERR_FLG = ENUMCC_ERR_FLG_0002<br/>Phone state judgment out of scope<br/>param.setData(fixedText, inMap)<br/>return param"]

    ERR_JUDGE01["ERR_FLG = ENUMCC_ERR_FLG_6002<br/>Port-out not in progress<br/>param.setData(fixedText, inMap)<br/>return param"]

    CHECK_AGING["agingStatCheck(handle, param, fixedText, agingNo, AGING_STAT_100 = 100)"]

    COND_AGING{"agingStatCheck<br/>returns false?"}

    ERR_AGING["ERR_FLG = ENUMCC_ERR_FLG_6003<br/>Aging status not In Use<br/>param.setData(fixedText, inMap)<br/>return param"]

    CALL_SOD["callJKKHakkoSODCC(handle, param, fixedText)<br/>Issue ENUM deletion SOD + ENUM registration SOD"]

    CALL_ETU["callETU0151C010(handle, param, fixedText, funcCd)<br/>Update port-out receipt status to CSV export complete"]

    CALL_EZM["callEZM0121C010(handle, param, fixedText, funcCd)<br/>Update phone number master"]

    LOG_END["printlnEjbLog<br/>interCompany_OPTtelno_Cancel:end"]

    RETURN_PARAM["Return param with error"]

    END_NODE(["interCompany_OPTtelno_Cancel:end"])

    START --> CHECK_SERVICE
    CHECK_SERVICE --> COND_SERVICE
    COND_SERVICE -- true --> ERR_SERVICE
    ERR_SERVICE --> RETURN_PARAM
    COND_SERVICE -- false --> CHECK_PHONE_STAT
    CHECK_PHONE_STAT --> COND_PHONE
    COND_PHONE -- true --> COND_JUDGE
    COND_JUDGE -- true --> ERR_JUDGE02
    ERR_JUDGE02 --> RETURN_PARAM
    COND_JUDGE -- false --> ERR_JUDGE01
    ERR_JUDGE01 --> RETURN_PARAM
    COND_PHONE -- false --> CHECK_AGING
    CHECK_AGING --> COND_AGING
    COND_AGING -- true --> ERR_AGING
    ERR_AGING --> RETURN_PARAM
    COND_AGING -- false --> CALL_SOD
    CALL_SOD --> CALL_ETU
    CALL_ETU --> CALL_EZM
    CALL_EZM --> LOG_END
    LOG_END --> END_NODE
    RETURN_PARAM --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transactional context for all subsequent DB operations and CBS invocations. Used throughout the three service validation checks and three update operations. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object used to write back error flags and messages. On validation failure, the method sets `ERR_FLG` into the parameter map and returns it to the caller with the error surfaced to the UI. On success, it is returned as-is after update operations. |
| 3 | `fixedText` | `String` | Service message text used as a template key when populating error messages into the response via `param.setData()`. Maps to localized error descriptions. |
| 4 | `funcCd` | `String` | Business code identifying the specific business operation. Passed through to `callETU0151C010` and `callEZM0121C010` to determine which CBS logic branch to execute. |
| 5 | `inMap` | `HashMap<String, Object>` | Input parameter map carrying the telephone number (`KEY_TELNO = "key_telno"`), aging number (`KEY_AGING_NO = "key_aging_no"`), and the error flag field (`ERR_FLG`). Extracted values drive the validation checks. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `NOT_JUDGE` | `String` | Judgment exemption flag. When set to `"1"`, the phone number state judgment bypasses the normal error flow and uses error flag `0002` instead of `6002`. Default value is `"0"`. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JZMEnumSwitchCC.serviceKeiStatCheck` | N/A | N/A | Read — Validates phone number service contract status (checks for active contract data that should not exist during cancellation). |
| R | `JZMEnumSwitchCC.telnoStatJudge` | N/A | N/A | Read — Judges phone number state/port-out status against judgment type `02` (port-out related). |
| R | `JZMEnumSwitchCC.agingStatCheck` | N/A | N/A | Read — Validates aging (Ei Jing / reservation) status; expects status `100` (In Use). |
| C | `JZMEnumSwitchCC.callJKKHakkoSODCC` | N/A | SOD tables | Create — Issues ENUM deletion SOD (port-out completion) and ENUM registration SOD (port-out start). Triggers Service Order Data generation for the ENUM directory update. |
| U | `JZMEnumSwitchCC.callETU0151C010` | ETU0151C010SC | Port-out receipt status table | Update — Updates port-out receipt status to `"030"` (CSV export complete). Clears the port-out SOD issue timestamp. |
| U | `JZMEnumSwitchCC.callEZM0121C010` | EZM0121C010SC | Phone number master table | Update — Refreshes phone number master data to reflect the cancellation of the inter-company transfer. |

### Method-level classification details:

- **R — `serviceKeiStatCheck`**: Queries the service contract status for the given telephone number to verify that no active service contract data exists that would prevent cancellation. This is a pre-condition check.
- **R — `telnoStatJudge`**: Evaluates the phone number's port-out state using judgment pattern `02` (configured for inter-company transfer scenarios). Returns false if the phone number state does not match expected conditions.
- **R — `agingStatCheck`**: Checks the aging (Ei Jing / エイジング, reservation/holding) status against `100` (In Use / 使用中). Handles null or empty aging numbers by treating them as "no data."
- **C — `callJKKHakkoSODCC`**: Creates two SOD (Service Order Data) records — one for ENUM deletion (port-out completion / ポートアウトの終端) and one for ENUM registration (port-out start / ポートアウトの開始). These SODs drive the telecom provider number portability exchange.
- **U — `callETU0151C010`**: Updates the port-out receipt status from pending to `"030"` (CSV export complete / CSV出力済み), clearing the SOD issue datetime to signal the process has advanced.
- **U — `callEZM0121C010`**: Updates the phone number master record to reflect the cancellation of the inter-company transfer, restoring the number to its pre-transfer state in the operator's master data.

## 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: `printlnEjbLog` [-], `callEZM0121C010` [-], `callETU0151C010` [-], `callJKKHakkoSODCC` [-], `serviceKeiStatCheck` [-], `telnoStatJudge` [-], `agingStatCheck` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JZMEnumSwitchCC.enumSwitch` | `enumSwitch` -> `interCompany_OPTtelno_Cancel(handle, param, fixedText, funcCd, inMap)` | `callJKKHakkoSODCC [C] SOD`, `callETU0151C010 [U] Port-out Receipt Status`, `callEZM0121C010 [U] Phone Number Master` |

## 6. Per-Branch Detail Blocks

### Block 1 — START (L623)

The method entry point. Logs the start of processing.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printlnEjbLog("JZMEnumSwitchCC:interCompany_OPTtelno_Cancel:start")` |

### Block 2 — IF (service contract status check) (L633)

> Verifies the phone number service contract status. If the check fails, it means contract data exists when it should not for a cancellation, and the method returns an error.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `serviceKeiStatCheck(handle, param, fixedText, inMap.get(JZMEnumSwitchConstCC.KEY_TELNO))` |
| 2 | IF | `!serviceKeiStatCheck(...) returns false?` [KEY_TELNO="key_telno"] |

**Block 2.1 — IF true (contract data exists error)** (L634-637)

> If service contract validation fails, set error flag 6001 and return. Error 6001 means "Contract data exists error" — active contract data was found where cancellation should not encounter it.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(JZMEnumSwitchConstCC.ERR_FLG, JZMEnumSwitchConstCC.ENUMCC_ERR_FLG_6001)` [ERR_FLG="ERR_FLG", ENUMCC_ERR_FLG_6001="6001" (Contract data exists error)] |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

### Block 3 — IF (phone number state check) (L642)

> Evaluates the phone number state / port-out status. Uses judgment pattern `02` (TELNOSTATJUDGE_02) which is configured for inter-company transfer scenarios.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `telnoStatJudge(handle, param, inMap.get(JZMEnumSwitchConstCC.KEY_TELNO), TELNOSTATJUDGE_02)` [TELNOSTATJUDGE_02="02", KEY_TELNO="key_telno"] |
| 2 | IF | `!telnoStatJudge(...) returns false?` |

**Block 3.1 — IF true (phone state judgment failed)** (L643-652)

> Nested conditional: the error response depends on whether judgment exemption is enabled.

| # | Type | Code |
|---|------|------|
| 1 | IF | `this.NOT_JUDGE.equals("1")?` [NOT_JUDGE="0" by default; when "1", judgment objects are excluded] |

**Block 3.1.1 — IF true (judgment exemption enabled)** (L644-648)

> When NOT_JUDGE is `"1"`, the phone number state is outside the judgment scope. Sets error flag 0002.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(JZMEnumSwitchConstCC.ERR_FLG, JZMEnumSwitchConstCC.ENUMCC_ERR_FLG_0002)` [ENUMCC_ERR_FLG_0002="0002" (Phone state judgment out of scope)] |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

**Block 3.1.2 — IF false (port-out not in progress)** (L651-652)

> When NOT_JUDGE is NOT `"1"`, the error means port-out is not in progress. Sets error flag 6002.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(JZMEnumSwitchConstCC.ERR_FLG, JZMEnumSwitchConstCC.ENUMCC_ERR_FLG_6002)` [ENUMCC_ERR_FLG_6002="6002" (Port-out not in progress)] |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

### Block 4 — IF (aging / Ei Jing status check) (L657)

> Validates the aging (Ei Jing / エイジング = reservation/holding) number status. Expects status `"100"` (In Use / 使用中). Handles null or empty aging numbers by treating them as "no data" and returning error. If the aging number exists but its status is not "In Use", also returns error.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `agingStatCheck(handle, param, fixedText, inMap.get(JZMEnumSwitchConstCC.KEY_AGING_NO), JZMEnumSwitchConstCC.AGING_STAT_100)` [KEY_AGING_NO="key_aging_no", AGING_STAT_100="100" (In Use)] |
| 2 | IF | `!agingStatCheck(...) returns false?` |

**Block 4.1 — IF true (aging status invalid)** (L658-662)

> Sets error flag 6003 when the aging number is null, empty, or its status is not "In Use."

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(JZMEnumSwitchConstCC.ERR_FLG, JZMEnumSwitchConstCC.ENUMCC_ERR_FLG_6003)` [ENUMCC_ERR_FLG_6003="6003" (Aging status not 'In Use')] |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

### Block 5 — EXEC (SOD issuance) (L666)

> Issues both ENUM deletion SOD (port-out completion / ポートアウトの終端) and ENUM registration SOD (port-out start / ポートアウトの開始). These Service Order Data records drive the telecom number portability exchange between operators.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callJKKHakkoSODCC(handle, param, fixedText)` |

### Block 6 — EXEC (port-out receipt status update) (L669)

> Updates the port-out receipt status to `"030"` (CSV export complete / CSV出力済み). Clears the port-out SOD issue datetime.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callETU0151C010(handle, param, fixedText, funcCd)` |

### Block 7 — EXEC (phone number master update) (L672)

> Updates the phone number master data to reflect the cancellation of the inter-company transfer.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEZM0121C010(handle, param, fixedText, funcCd)` |

### Block 8 — END (L673-674)

Logs completion and returns the parameter object.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `printlnEjbLog("JZMEnumSwitchCC:interCompany_OPTtelno_Cancel:end")` |
| 2 | RETURN | `return param` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `key_telno` | Field | Telephone number — the phone number being transferred in the inter-company portability operation |
| `key_aging_no` | Field | Aging (Ei Jing) number — a reservation/holding number assigned during the number portability process; used to track the holding period between operators |
| `ERR_FLG` | Field | Error flag — a map key used to communicate error conditions back to the caller via the request parameter object |
| `NOT_JUDGE` | Field | Judgment exemption flag — when set to `"1"`, causes the phone number state judgment to return error `0002` instead of `6002`, indicating the judgment is outside the processing scope |
| ENUM | Business term | E.164 Number Mapping — a telecommunication protocol that maps telephone numbers to multiple internet-based services; used by K-Opticom for number portability |
| SOD | Acronym | Service Order Data — order fulfillment records generated to coordinate service changes between telecom providers during number portability |
| OPT | Business term | OPT (ＯＰＴ) — Telephone Number portability / 電話番号ポータビリティ — the regulatory framework allowing subscribers to retain their phone number when switching telecom providers |
| エイジング (Aging) | Field | Reservation/Holding — a temporary number assignment during the portability process; the "エイジング番号" is the holding number given to a subscriber during the transfer period |
| 使用中 (In Use) | Constant | Status `100` — the aging number is currently active and in use by the system |
| ポートアウト (Port-out) | Business term | The act of transferring a phone number away from the current provider to another provider; ポートアウトの開始 = port-out start, ポートアウトの終端 = port-out completion |
| 事業者間移転 (Inter-company Transfer) | Business term | Number portability between different telecommunications companies; the specific scenario handled by Application Content 6 (Application Content 6 / 申請内容_6) |
| 取消 (Cancellation) | Business term | Undo/withdrawal of a previously submitted port-out request; restores the number to its pre-request state |
| CSV出力済み (CSV Export Complete) | Constant | Status `030` — the port-out receipt data has been exported to CSV format and is ready for provider exchange |
| ENUMCC_ERR_FLG_6001 | Constant | Error code `6001` — "Contract data exists error"; active service contract data was found during cancellation processing |
| ENUMCC_ERR_FLG_0002 | Constant | Error code `0002` — "Phone state judgment out of scope"; the phone number state judgment determined the number is outside the expected processing scope |
| ENUMCC_ERR_FLG_6002 | Constant | Error code `6002` — "Port-out not in progress"; the port-out process has not been initiated for this phone number |
| ENUMCC_ERR_FLG_6003 | Constant | Error code `6003` — "Aging status not In Use"; the aging number is null, empty, or has a status other than `100` (In Use) |
| TELNOSTATJUDGE_02 | Constant | Phone number state judgment pattern `02` — configured for inter-company transfer (OPT telephone number) scenarios |
| JOKEN | Acronym | 拒否/条件 — Rejection conditions / restrictions; appears in related method names (e.g., `executeOdrHakkoJokenAdd`) for order rejection handling |
| SC | Acronym | Service Component — a discrete business service module identified by codes like `ETU0151C010SC`, `EZM0121C010SC` |
| CBS | Acronym | Central Business System — the core business logic layer; CBS messages like `ETU0151C010CBSMsg` define request/response contracts |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service (referenced in the ENUM switch system context) |
