# Business Logic — JZMEnumSwitchCC.portOut_OPTtelno() [112 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JZMEnumSwitchCC` |
| Layer | Common Component (CC / Shared Business Logic) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JZMEnumSwitchCC.portOut_OPTtelno()

This method implements the **Port-Out (OPT Phone Number) business operation** within the ENUM (Telephone Number to Service Provider) switching system of the eo Customer Core system. It handles the complete lifecycle of a customer porting their telephone number to a different service provider — specifically the "OPT" (optional) port-out flow identified by the application content flag `SINSEI_NAIYO_FLG_1 = "1"` (Port-Out / OPT Phone Number).

The method implements a **gate-then-execute** design pattern: it first performs a series of validation checks (sequential gate checks), and if all pass, proceeds to execute a sequence of issuance and update operations that finalize the port-out. The four validation gates are: (1) service contract status check, (2) token registration check, (3) phone number status check (port-out in progress), and (4) aging status check (equipment aging status validation). Each gate can short-circuit the flow and return an error.

If the aging check passes, the method dispatches to a multi-step execution pipeline: ENUM registration Service Order Data (SOD) issuance, port-out receipt update (status to "050" work complete), phone number mask update, and then branching aging equipment schedule updates — either transitioning aging status from "recoverable" to "in-use" or from "in aging" to "usage ended" (with an additional data register if `funcCd = "1"`).

This is a **shared utility component method** called by the central `enumSwitch()` dispatcher, which routes different ENUM switch operations based on the application content flag. It is a core entry point for the port-out sub-process within the broader ENUM switching subsystem.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["portOut_OPTtelno:start"])
    
    CHECK1["serviceKeiStatCheck<br/>phone number service contract status"]
    
    ERROR1["ERR_FLG = ENUMCC_ERR_FLG_1001<br/>service contract existing data error<br/>param.setData<br/>return param"]
    
    CHECK2["chkItenToki<br/>token registration check"]
    
    ERROR2["ERR_FLG = ENUMCC_ERR_FLG_1002<br/>token registration already exists error<br/>param.setData<br/>return param"]
    
    CHECK3["telnoStatJudge<br/>phone number status check<br/>checkFlag = TELNOSTATJUDGE_01 - port-out in progress"]
    
    ERROR3["ERR_FLG = ENUMCC_ERR_FLG_0002<br/>phone number status determination excluded<br/>param.setData<br/>return param"]
    
    ERROR4["ERR_FLG = ENUMCC_ERR_FLG_1003<br/>port-out in progress error<br/>param.setData<br/>return param"]
    
    AGE_CHECK["agingStatCheck<br/>aging status check<br/>stat = AGING_STAT_200 (recoverable)"]
    
    AGE_300_BLOCK["agingStat = AGING_STAT_300 (in aging)<br/>log: AGING_STAT_300"]
    
    AGE_ERR["ERR_FLG = ENUMCC_ERR_FLG_1004<br/>aging status not recoverable error<br/>param.setData<br/>return param"]
    
    ISSUANCE["callJKKHakkoSODCC<br/>ENUM registration SOD issuance<br/>(port-out start)"]
    
    RECEIPT["callETU0151C010<br/>port-out receipt update<br/>status to 050 (work complete)"]
    
    MASK_UPDATE["callEZM0121C010<br/>phone number mask update"]
    
    AGE_200_BRANCH["agingStat = AGING_STAT_200<br/>(recoverable)"]
    
    AGE_200_CALL["callEZM0111C020<br/>aging schedule: recoverable to in-use"]
    
    AGE_300_BRANCH["agingStat = AGING_STAT_300<br/>(in aging)"]
    
    AGE_300_CALL["callEZM0111E010<br/>aging schedule: in aging to usage ended<br/>aging data delete"]
    
    FUNC_CD_CHECK["funcCd equals 1"]
    
    AGE_300_REG["callEZM0111D010<br/>aging schedule: in aging to in-use<br/>aging data register"]
    
    END_NODE["printlnEjbLog:end<br/>return param"]
    
    START --> CHECK1
    CHECK1 --> ERROR1
    ERROR1 --> END_NODE
    
    CHECK1 --> CHECK2
    CHECK2 --> ERROR2
    ERROR2 --> END_NODE
    
    CHECK2 --> CHECK3
    CHECK3 --> ERROR3
    ERROR3 --> END_NODE
    
    CHECK3 --> ERROR4
    ERROR4 --> END_NODE
    
    CHECK3 --> AGE_CHECK
    AGE_CHECK --> AGE_300_BLOCK
    AGE_300_BLOCK --> ISSUANCE
    
    AGE_CHECK --> AGE_ERR
    AGE_ERR --> END_NODE
    
    ISSUANCE --> RECEIPT
    RECEIPT --> MASK_UPDATE
    MASK_UPDATE --> AGE_200_BRANCH
    AGE_200_BRANCH --> AGE_200_CALL
    AGE_200_CALL --> END_NODE
    
    MASK_UPDATE --> AGE_300_BRANCH
    AGE_300_BRANCH --> AGE_300_CALL
    AGE_300_CALL --> FUNC_CD_CHECK
    FUNC_CD_CHECK --> AGE_300_REG
    AGE_300_REG --> END_NODE
    
    FUNC_CD_CHECK --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing transactional context and database connection for the port-out operation. |
| 2 | `param` | `IRequestParameterReadWrite` | Request/response parameter object used to pass business data and error results. Modified via `setData()` to include error flags on failure. |
| 3 | `fixedText` | `String` | Service message template string used when formatting error responses via `param.setData()`. |
| 4 | `funcCd` | `String` | Business code that determines the direction of processing. Value `"1"` triggers downward processing (includes aging data registration); value `"2"` skips downward processing. Used in aging schedule update logic. |
| 5 | `inMap` | `HashMap<String, Object>` | Parameter map carrying port-out context data. Contains: `KEY_TELNO` (phone number), `KEY_AGING_NO` (aging number / aging schedule ID), and `ERR_FLG` (error flag, set on failure). |

**Instance fields / external state read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `NOT_JUDGE` | `String` | Flag indicating whether phone number status determination is excluded. Value `"1"` = excluded (non-target), `"0"` = included (normal processing). Default is `"0"`. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `serviceKeiStatCheck` | (internal CC) | - | Reads service contract status for the phone number to validate no active service exists (status 010~220). |
| R | `chkItenToki` | (internal CC) | - | Checks whether token registration is already completed to prevent duplicate processing. |
| R | `telnoStatJudge` | (internal CC) | - | Evaluates phone number status with check flag `TELNOSTATJUDGE_01 = "01"` (port-out in progress) to determine port-out eligibility. |
| R | `agingStatCheck` | (internal CC) | - | Reads aging equipment schedule status to determine current aging state (200=recoverable, 300=in aging). Called twice with different stat codes. |
| C | `callJKKHakkoSODCC` | JKKHakkoSODCC | ENUM registration SOD | Creates ENUM registration Service Order Data (SOD) — initiates the port-out start process. |
| U | `callETU0151C010` | ETU0151C010 | Port-out receipt data | Updates port-out receipt info: refreshes the SOD issuance datetime and sets status to `"050"` (work complete). |
| U | `callEZM0121C010` | EZM0121C010 | Phone number mask data | Updates the phone number mask records in the system. |
| U | `callEZM0111C020` | EZM0111C020 | Aging schedule data | Updates aging schedule: transitions aging status from `200` (recoverable) to `100` (in use). Conditionally called only when agingStat equals `AGING_STAT_200`. |
| D | `callEZM0111E010` | EZM0111E010 | Aging schedule data | Deletes aging schedule data: transitions aging status from `300` (in aging) to `usage ended`. Always called when agingStat equals `AGING_STAT_300`. |
| C | `callEZM0111D010` | EZM0111D010 | Aging schedule data | Registers aging schedule data: transitions aging status from `usage ended` to `100` (in use). Conditionally called only when `funcCd = "1"` (downward processing). |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JZMEnumSwitchCC.enumSwitch` | `enumSwitch` -> `portOut_OPTtelno` | `callJKKHakkoSODCC [C]`, `callETU0151C010 [U]`, `callEZM0121C010 [U]`, `callEZM0111C020 [U]`, `callEZM0111E010 [D]`, `callEZM0111D010 [C]`, `serviceKeiStatCheck [R]`, `chkItenToki [R]`, `telnoStatJudge [R]`, `agingStatCheck [R]` |

**Terminal operations reached from this method (directly and transitively):**
- `printlnEjbLog` [logging] — debug log output
- `callEZM0111D010` [C] — aging schedule data registration
- `callEZM0111E010` [D] — aging schedule data deletion
- `callEZM0111C020` [U] — aging schedule update (recoverable to in-use)
- `callEZM0121C010` [U] — phone number mask update
- `callETU0151C010` [U] — port-out receipt update
- `callJKKHakkoSODCC` [C] — ENUM registration SOD creation
- `serviceKeiStatCheck` [R] — service contract status read
- `chkItenToki` [R] — token registration check read
- `telnoStatJudge` [R] — phone number status determination read
- `agingStatCheck` [R] — aging status check read

## 6. Per-Branch Detail Blocks

**Block 1** — [LOG] (L259)

> Initialize: log method entry for debugging.

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

---

**Block 2** — [IF] `serviceKeiStatCheck(handle, param, fixedText, inMap.get(KEY_TELNO)) == false` (L265)

> Gate Check 1: Service contract status check. If the phone number has existing service contract data (status 010~220), reject the port-out request.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `serviceKeiStatCheck(handle, param, fixedText, (String) inMap.get(JZMEnumSwitchConstCC.KEY_TELNO))` |
| 2 | IF | `!serviceKeiStatCheck(...) == true` (error path) |

**Block 2.1** — [ELSE / error path] (L266)

> Service contract exists — set error flag and return.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(ERR_FLG, ENUMCC_ERR_FLG_1001 = "1001")` |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

---

**Block 3** — [IF] `chkItenToki(handle, param, fixedText, inMap.get(KEY_TELNO)) == false` (L273)

> Gate Check 2: Token registration check. If token is already registered, reject the port-out request.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `chkItenToki(handle, param, fixedText, (String) inMap.get(JZMEnumSwitchConstCC.KEY_TELNO))` |
| 2 | IF | `!chkItenToki(...) == true` (error path) |

**Block 3.1** — [ELSE / error path] (L274)

> Token registration already completed — set error flag and return.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(ERR_FLG, ENUMCC_ERR_FLG_1002 = "1002")` |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

---

**Block 4** — [IF] `telnoStatJudge(handle, param, inMap.get(KEY_TELNO), TELNOSTATJUDGE_01 = "01") == false` (L281)

> Gate Check 3: Phone number status check. Evaluates whether the phone number is in a "port-out in progress" state (checkFlag = `"01"`).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `telnoStatJudge(handle, param, (String) inMap.get(JZMEnumSwitchConstCC.KEY_TELNO), TELNOSTATJUDGE_01)` |
| 2 | IF | `!telnoStatJudge(...) == true` (error path) |

**Block 4.1** — [NESTED IF] `"1".equals(this.NOT_JUDGE)` (L282)

> Phone number status check determined exclusion (NOT_JUDGE = `"1"`). The phone number is outside the scope of status determination.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(ERR_FLG, ENUMCC_ERR_FLG_0002 = "0002")` |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

**Block 4.2** — [ELSE / sibling of 4.1] (L288)

> Phone number is in port-out in progress state.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(ERR_FLG, ENUMCC_ERR_FLG_1003 = "1003")` |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

---

**Block 5** — [VARIABLE DECLARATION] (L295)

> Initialize `agingStat` local variable for tracking aging equipment status (added in ANK-4494-00-00 STEP2).

| # | Type | Code |
|---|------|------|
| 1 | SET | `String agingStat = ""` |

---

**Block 6** — [IF] `agingStatCheck(..., AGING_STAT_200 = "200") == false` (L308)

> Aging Status Check: First check if aging status is NOT 200 (recoverable). If the aging equipment is NOT in a recoverable state, further branch.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `agingStatCheck(handle, param, fixedText, (String) inMap.get(JZMEnumSwitchConstCC.KEY_AGING_NO), JZMEnumSwitchConstCC.AGING_STAT_200)` |
| 2 | IF | `!agingStatCheck(..., AGING_STAT_200) == true` (not recoverable) |

**Block 6.1** — [NESTED IF] `agingStatCheck(..., AGING_STAT_300 = "300") == false` (L309)

> Aging is NOT 300 either — meaning the aging status is neither 200 (recoverable) nor 300 (in aging). Either the aging number is null/empty (aging schedule has no data), or the status is something other than recoverable or in-aging. This is an error condition.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `agingStatCheck(handle, param, fixedText, (String) inMap.get(JZMEnumSwitchConstCC.KEY_AGING_NO), JZMEnumSwitchConstCC.AGING_STAT_300)` |
| 2 | IF | `!agingStatCheck(..., AGING_STAT_300) == true` (not in aging either) |

**Block 6.1.1** — [ELSE / error path] (L313)

> Aging status is neither recoverable (200) nor in-aging (300). Error — aging number is null/empty or status is invalid.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap.put(ERR_FLG, ENUMCC_ERR_FLG_1004 = "1004")` |
| 2 | EXEC | `param.setData(fixedText, inMap)` |
| 3 | RETURN | `return param` |

**Block 6.2** — [NESTED ELSE] (L318)

> Aging status is 300 (in aging). Record this and proceed to issuance.

| # | Type | Code |
|---|------|------|
| 1 | SET | `agingStat = JZMEnumSwitchConstCC.AGING_STAT_300 = "300"` |
| 2 | EXEC | `printlnEjbLog("JZMEnumSwitchCC:portOut_OPTtelno:agingStatCheck:AGING_STAT_300")` |

**Block 6.2.1** — [ELSE / outer block 6.2] (L324)

> Aging status IS 200 (recoverable). Record this and proceed to issuance.

| # | Type | Code |
|---|------|------|
| 1 | SET | `agingStat = JZMEnumSwitchConstCC.AGING_STAT_200 = "200"` |
| 2 | EXEC | `printlnEjbLog("JZMEnumSwitchCC:portOut_OPTtelno:agingStatCheck:AGING_STAT_200")` |

---

**Block 7** — [EXEC / Issuance] (L333)

> Execute port-out start processing: issue ENUM registration SOD.

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

---

**Block 8** — [EXEC / Receipt Update] (L336)

> Update port-out receipt: refresh SOD issuance datetime and set status to "050" (work complete).

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

---

**Block 9** — [EXEC / Mask Update] (L339)

> Update phone number mask data.

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

---

**Block 10** — [IF] `AGING_STAT_200 = "200".equals(agingStat)` (L345)

> Post-execution aging schedule update: aging is in recoverable (200) state. Update aging schedule from "recoverable" to "in use" (100).

| # | Type | Code |
|---|------|------|
| 1 | IF | `JZMEnumSwitchConstCC.AGING_STAT_200.equals(agingStat)` |

**Block 10.1** — [THEN] (L347)

> Aging status 200 (recoverable) -> update to 100 (in use).

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

**Block 10.2** — [ELSE IF] `AGING_STAT_300 = "300".equals(agingStat)` (L350)

> Aging status is 300 (in aging). Delete aging schedule data and optionally re-register.

| # | Type | Code |
|---|------|------|
| 1 | IF | `JZMEnumSwitchConstCC.AGING_STAT_300.equals(agingStat)` |

**Block 10.2.1** — [THEN] (L352)

> Aging status 300 (in aging) -> delete aging schedule data (transition to "usage ended").

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callEZM0111E010(handle, param, fixedText, funcCd)` |
| 2 | IF | `"1".equals(funcCd)` (business code 1 = downward processing) |

**Block 10.2.1.1** — [NESTED IF] `funcCd = "1"` (L354)

> Business code is 1 (downward processing). Since business code 2 already handles upward deletion, downward processing requires explicit aging data registration.

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

---

**Block 11** — [LOG + RETURN] (L367)

> Log method completion and return the modified parameter object.

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `portOut_OPTtelno` | Method | Port-Out (OPT Phone Number) processing — handles telephone number port-out operations for ENUM switching |
| `KEY_TELNO` | Field | Phone number key — the telephone number being ported out, stored as a key in the `inMap` parameter |
| `KEY_AGING_NO` | Field | Aging number key — the aging schedule / equipment ID, stored as a key in the `inMap` parameter |
| `ERR_FLG` | Field | Error flag — indicator set on the `inMap` when an error condition is detected |
| `SINSEI_NAIYO_FLG_1` | Constant | Application content flag "1" — Port-Out (OPT Phone Number) service type |
| `SINSEI_NAIYO_FLG` | Field | Application content flag — classifies the type of ENUM switch operation (port-out, inter-carrier transfer, cancellation, etc.) |
| `ENUMCC_ERR_FLG_1001` | Constant | Error flag "1001" — Service contract existing data error (active contract data prevents port-out) |
| `ENUMCC_ERR_FLG_1002` | Constant | Error flag "1002" — Token registration already exists error (duplicate token processing blocked) |
| `ENUMCC_ERR_FLG_1003` | Constant | Error flag "1003" — Port-out in progress error (phone number is already in port-out state) |
| `ENUMCC_ERR_FLG_1004` | Constant | Error flag "1004" — Aging status not recoverable error (aging equipment status is not in a valid state for port-out) |
| `ENUMCC_ERR_FLG_0002` | Constant | Error flag "0002" — Phone number status determination excluded (phone number is outside status check scope) |
| `AGING_STAT_100` | Constant | Aging status "100" — In use (aging equipment is actively in use) |
| `AGING_STAT_200` | Constant | Aging status "200" — Recoverable (aging equipment can be recovered/reused) |
| `AGING_STAT_300` | Constant | Aging status "300" — In aging (aging equipment is in the aging process) |
| `TELNOSTATJUDGE_01` | Constant | Phone number status check flag "01" — port-out in progress check |
| `funcCd` | Field | Business code — determines processing direction. "1" = downward processing (includes aging data registration); "2" = upward processing (skips aging registration) |
| `NOT_JUDGE` | Field | Phone number status determination exclusion flag — "1" means the number is excluded from status checks, "0" means normal processing |
| SOD | Acronym | Service Order Data — telecom order fulfillment document that triggers service provisioning workflows |
| ENUM | Business term | ENUM (Telephone Number to Service Provider) switching — system that routes telephone numbers to service providers |
| Port-Out | Business term | Telephone number port-out — customer transfers their existing phone number from one service provider to another |
| OPT (OPT電話番号) | Business term | Optional phone number — an additional/opt-in phone number service in the K-Opticom portfolio |
| トーク登録済み (Token Registration) | Field | Token registration completed — a prerequisite state indicating the customer has been issued a port-out authorization token |
| エイジングスケジュール (Aging Schedule) | Business term | Aging equipment schedule — tracks the lifecycle of network equipment from "in use" to "recoverable" to "in aging" to "usage ended" |
| エイジング同意照会 (Aging Agreement Inquiry) | Business term | Aging agreement inquiry — a template-based lookup that retrieves aging equipment status and agreement details |
| ポートアウト受付情報 (Port-out Receipt Info) | Business term | Port-out receipt information — tracks the port-out processing status, including SOD issuance datetime and work completion status |
| 電話番号マスタ (Phone Number Master) | Business term | Phone number master data — the central reference table for all phone number assignments and masking |
| 工事完了 (Work Complete) | Business term | Work complete — port-out receipt status "050" indicating the port-out installation work has finished |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service |
| `inMap` | Field | Input parameter map — carries all port-out context data between methods including phone number, aging number, and error flags |
| `fixedText` | Field | Service message template — used for formatting error messages passed to the calling screen |
