# Business Logic — JKKDslRunCC.checkHteldel() [10 LOC]

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

## 1. Role

### JKKDslRunCC.checkHteldel()

This method serves as the **DSL (Domain Specific Language) entry point** for **Optical Phone and Number Cancellation** validation checks in the K-Opticom telecom service fulfillment system. It is the designated contract component (CC) that bridges the screen/business-operation layer with the underlying DSL execution engine. When a customer initiates an optical phone and number portability cancellation (migration of a service contract line item where the customer is porting out their phone number to another carrier), this method runs the preconditions and status validation logic to ensure the service line is in an eligible state before proceeding.

The method implements a **delegation pattern**: it first runs local initialization (`init`), then delegates to the common layer (`JKKBpCommon.checkHteldel`), which in turn instantiates a `JKKDslRun` object and invokes its `checkHteldel` method. The actual business logic — extracting target data from the request parameter map, determining the phone number status via `JKKTelnoStatJudgeCC`, and applying conditional error checks — is handled by the called DSL method.

Design-wise, `JKKDslRunCC.checkHteldel` follows the standard **CC (Common Component) template** used across the K-Opticom system: it provides a configurable `CCRequestBroker` hook point (configured as `target27` in `KKSV0195OPOperation`) that allows screens to invoke this validation without coupling to the DSL implementation. It acts as a **shared utility** called by multiple screens, particularly `KKSV0195` (the optical phone and number cancellation screen).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["checkHteldel handle, param, fixedText"])
    INIT1["init param, fixedText"]
    CALL_BC["JKKBpCommon.checkHteldel handle, param, fixedText"]
    INIT2["init param, fixedText"]
    GET_DATA["trgtData = param.getData fixedText"]
    CHECK_NULL["trgtData is null"]
    EXTRACT_TELNO["tmpTelno = trgtData.get TELNO"]
    EXTRACT_ENUM["tmpEnumKrkeDouji = trgtData.get ENUM_KRKE_DOUJI"]
    EXTRACT_KIDO["tmpKidoCd = trgtData.get KIDO_CD"]
    EXTRACT_IDO["tmpIdoDiv = trgtData.get IDO_DIV"]
    CHECK_KIDO["tmpKidoCd == KIDO_CD_ON = 01"]
    CHECK_IDO["tmpIdoDiv == IDO_DIV_HTELNODSL = 00043"]
    GET_TELNO_STAT["telnoJudgeDiv = getTelnoJudgeDiv handle, param, tmpTelno"]
    CHECK_STAT_06["telnoJudgeDiv is 06 or 11"]
    ERROR_E10["errCd = E10, put ERR_CD into trgtData, return early"]
    CHECK_ENUM["tmpEnumKrkeDouji is true"]
    CHECK_STAT_ENUM["telnoJudgeDiv is 04, 05, 06, 09, 10, or 11"]
    ERROR_E11["errCd = E11, put ERR_CD into trgtData, return early"]
    END_NODE(["Return param"])

    START --> INIT1 --> CALL_BC --> INIT2 --> GET_DATA --> CHECK_NULL
    CHECK_NULL -->|false| EXTRACT_TELNO --> EXTRACT_ENUM --> EXTRACT_KIDO --> EXTRACT_IDO --> CHECK_KIDO
    CHECK_NULL -->|true| END_NODE
    CHECK_KIDO -->|false| END_NODE
    CHECK_KIDO -->|true| CHECK_IDO
    CHECK_IDO -->|false| END_NODE
    CHECK_IDO -->|true| GET_TELNO_STAT --> CHECK_STAT_06
    CHECK_STAT_06 -->|true| ERROR_E10 --> END_NODE
    CHECK_STAT_06 -->|false| CHECK_ENUM
    CHECK_ENUM -->|false| END_NODE
    CHECK_ENUM -->|true| CHECK_STAT_ENUM
    CHECK_STAT_ENUM -->|true| ERROR_E11 --> END_NODE
    CHECK_STAT_ENUM -->|false| END_NODE
```

**Processing Flow:**

1. **Initialization (outer layer):** `JKKDslRunCC` calls `init(param, fixedText)` to set up the request parameter context with the `fixedText` prefix.
2. **Delegation to common layer:** `JKKBpCommon.checkHteldel(handle, param, fixedText)` is invoked, which creates a `JKKDslRun` instance and delegates to its `checkHteldel` method.
3. **DSL initialization:** Inside `JKKDslRun.checkHteldel`, `init(param, fixedText)` runs again with the same parameters.
4. **Target data extraction:** The method retrieves the target data map from `param.getData(fixedText)`. If this map is null, the method returns immediately (no validation needed).
5. **Field extraction from target data:** Four fields are extracted from the target data map: telephone number (`TELNO`), ENUM simultaneous switching flag (`ENUM_KRKE_DOUJI`), startup source code (`KIDO_CD`), and differentiation division (`IDO_DIV`).
6. **Startup source check:** The method checks if `tmpKidoCd` equals `"01"` (screen startup). If not, the method returns — validation only applies to screen-initiated cancellation requests.
7. **Differentiation division check:** Within the screen startup path, the method checks if `tmpIdoDiv` equals `"00043"` (Optical Phone and Number Cancellation). If not, the method returns — this validates the specific service type.
8. **Phone number status check (Error E10):** The method calls `getTelnoJudgeDiv` to determine the current phone number status. If the status is `"06"` (port-out return from number retrieval business operator — after switching until night batch) or `"11"` (internal port number — port-out return from number retrieval business operator — after switching until night batch), error code `"E10"` is set and the method returns early. This prevents cancellation when a number portability process is already in a post-switching state.
9. **ENUM simultaneous switching check (Error E11):** If the ENUM simultaneous switching flag is true, the method checks whether the phone number status is `"04"`, `"05"`, `"06"`, `"09"`, `"10"`, or `"11"` — any of which indicate an incompatible state for ENUM simultaneous switching. If matched, error code `"E11"` is set and the method returns early. (Added in ANK-4494-00-00 Step2 to also check status codes 09, 10, and 11 beyond the original 04 and 05.)
10. **Normal completion:** If all checks pass, control returns through the call stack and the `param` object is returned to the caller.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session management handle containing transaction context, database connection, and user session information. Passed through to underlying service components for database access and state management during phone number status determination. |
| 2 | `param` | `IRequestParameterReadWrite` | Mutable request parameter object carrying the model data group and control map for the DSL operation. Contains the target data map (keyed by `fixedText`) with fields such as telephone number, ENUM switching flag, startup source code, and differentiation division. Also used to set error codes (`ERR_CD`) when validation fails. |
| 3 | `fixedText` | `String` | User-specified fixed text string used as the key to retrieve the target data map from `param`. In practice, this is `"trgt_data"` (constant `TEMPLATE_ID` from `JKKDslRunConstCC`), which is the data group name under which the screen stores the cancellation request payload. |

**Extracted fields from target data:**

| No | Field Name | Type | Business Description |
|----|-----------|------|---------------------|
| 4 | `TELNO` | `String` | Telephone number — the phone number being cancelled. Used as input to `getTelnoJudgeDiv` to determine the current operational status of the number. Constant value: `"telno"`. |
| 5 | `ENUM_KRKE_DOUJI` | `Boolean` | ENUM simultaneous switching flag — indicates whether ENUM (telephone number portability) simultaneous switching is being performed. If true, additional phone number status checks are applied to prevent conflicts. Constant value: `"enum_krke_douji"`. |
| 6 | `KIDO_CD` | `String` | Startup source code — identifies how the operation was initiated. Value `"01"` means screen startup. If not `"01"`, no validation is performed. Constant value: `"kido_cd"`. |
| 7 | `IDO_DIV` | `String` | Differentiation division — identifies the type of service change. Value `"00043"` corresponds to Optical Phone and Number Cancellation. Only this division triggers the validation logic. Constant value: `"ido_div"`. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKDslRunCC.init` | JKKDslRunCC | - | Calls `init` in `JKKDslRunCC` for parameter initialization |
| - | `JKKBpCommon.checkHteldel` | JKKDslRun | - | Delegates to `JKKDslRun.checkHteldel` in the common layer |
| - | `JKKDslRun.init` | JKKDslRun | - | Calls `init` in `JKKDslRun` for DSL initialization |
| - | `JKKDslRun.checkHteldel` | JKKDslRun | - | Calls `checkHteldel` in `JKKDslRun` — the actual business logic |
| R | `JKKDslRun.getTelnoJudgeDiv` | JKKDslRun | - | Calls `getTelnoJudgeDiv` to query phone number status |
| R | `JKKTelnoStatJudgeCC.telnoStatJudge` | JKKTelnoStatJudgeCC | Phone Number Status Table | Calls the phone number status judgment component to determine the current state of the telephone number |

**Called Service Details:**

- **`JKKTelnoStatJudgeCC.telnoStatJudge`**: This is the core read operation. It receives the telephone number in a HashMap (`telNoStatJudgeCc`), queries the system's phone number status management component, and returns a judgment division code (`telnoJudgeDiv`) that indicates the current operational state of the phone number (e.g., in use, port-out, ported, internal port, etc.). This is classified as a **Read** operation as it queries the current status without modifying any persistent data.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0195 | `KKSV0195OPOperation.target27` (CCRequestBroker) -> `JKKDslRunCC.checkHteldel` | `JKKBpCommon.checkHteldel` -> `JKKDslRun.checkHteldel` -> `JKKTelnoStatJudgeCC.telnoStatJudge [R] Phone Number Status` |

**Notes:**
- `KKSV0195OPOperation` is the Operation class for the **Optical Phone and Number Cancellation screen** (KKSV0195).
- The `CCRequestBroker target27` is configured to invoke `JKKDslRunCC.checkHteldel` as part of the screen's business operation flow (specifically in the `execute` method chain).
- The call chain flows through the common layer (`JKKBpCommon`), then to the DSL runner (`JKKDslRun`), which performs the actual validation logic.
- The terminal operation is `JKKTelnoStatJudgeCC.telnoStatJudge`, which reads phone number status data and returns a judgment code used for conditional error checks.

## 6. Per-Branch Detail Blocks

**Block 1** — [CALL] `(JKKDslRunCC.checkHteldel entry point)` (L162)

> The outer CC method is the entry point. It performs initialization, delegates to the common layer, and returns the parameter.

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | CALL | `init(param, fixedText)` | Initialize request parameters with fixed text [Japanese: 初期処理 — initialization] |
| 2 | CALL | `JKKBpCommon.checkHteldel(handle, param, fixedText)` | Delegate to common layer to invoke DSL runner [Japanese: 光電話・番号解約処理のチェック処理を呼び出す — invoke optical phone and number cancellation check processing] |
| 3 | RETURN | `return param` | Return the (possibly modified) request parameter object |

---

**Block 2** — [CALL] `(JKKDslRun.checkHteldel entry — actual logic)` (L11050)

> The DSL runner's implementation. Contains the full validation logic: data extraction, startup source check, differentiation division check, phone number status check, and ENUM simultaneous switching check.

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | CALL | `init(param, fixedText)` | DSL initialization [Japanese: 初期処理] |
| 2 | SET | `HashMap<String, Object> trgtData = (HashMap<String, Object>)param.getData(fixedText)` | Retrieve target data map [Japanese: リクエストパラメータの取得処理 — request parameter acquisition] |
| 3 | SET | `String tmpTelno = null` | Telephone number variable [Japanese: 電話番号] |
| 4 | SET | `Boolean tmpEnumKrkeDouji = null` | ENUM simultaneous switching flag variable [Japanese: ENUMの切り替えも実施する — ENUM switching also executed] |
| 5 | SET | `String tmpKidoCd = null` | Startup source code variable [Japanese: 起動元コード] |
| 6 | SET | `String tmpIdoDiv = null` | Differentiation division variable [Japanese: 異動区分] |
| 7 | SET | `String errCd = null` | Error code variable [Japanese: エラーコード] |

**Block 2.1** — [IF] `(trgtData != null)` (L11070)

> If the target data map is null, skip field extraction entirely. This is a guard clause — if there's no data to validate, return early.

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | SET | `tmpTelno = (String)trgtData.get(JKKDslRunConstCC.TELNO)` [-> TELNO="telno"] | Extract telephone number |
| 2 | SET | `tmpEnumKrkeDouji = (Boolean)trgtData.get(JKKDslRunConstCC.ENUM_KRKE_DOUJI)` [-> ENUM_KRKE_DOUJI="enum_krke_douji"] | Extract ENUM switching flag |
| 3 | SET | `tmpKidoCd = (String)trgtData.get(JKKDslRunConstCC.KIDO_CD)` [-> KIDO_CD="kido_cd"] | Extract startup source code |
| 4 | SET | `tmpIdoDiv = (String)trgtData.get(JKKDslRunConstCC.IDO_DIV)` [-> IDO_DIV="ido_div"] | Extract differentiation division |

**Block 2.2** — [IF] `(KIDO_CD_ON.equals(tmpKidoCd))` [-> KIDO_CD_ON="01"] (L11084)

> Startup source code check. Only proceed with validation when the operation was initiated from a screen (startup source code = "01"). If the operation was initiated from batch or another non-screen source, skip validation.

> Japanese comment: `起動元コード判定処理` — Startup source code determination processing

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | IF | `KIDO_CD_ON.equals(tmpKidoCd)` [-> "01" = screen startup] | Japanese: 起動元コード判定処理 |

**Block 2.2.1** — [IF] `(IDO_DIV_HTELNODSL.equals(tmpIdoDiv))` [-> IDO_DIV_HTELNODSL="00043"] (L11094)

> Differentiation division check. Within the screen startup path, verify that this is specifically an "Optical Phone and Number Cancellation" operation (ido_div = "00043"). Only this service type triggers the phone number status checks.

> Japanese comment: `画面起動の場合` — When screen is started; `異動区分「光電話・番号解約」` — Differentiation division "Optical Phone and Number Cancellation"

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | CALL | `String telnoJudgeDiv = getTelnoJudgeDiv(handle, param, tmpTelno)` | Query phone number status from service component [Japanese: 電話番号状態区分を取得 — acquire telephone number status division] |

**Block 2.2.1.1** — [IF] `(TELNOJUDGEDIV_06.equals(telnoJudgeDiv) \|\| TELNOJUDGEDIV_11.equals(telnoJudgeDiv))` [-> 06 or 11] (L11098, ANK-4494-00-00 Step2)

> Phone number status check — **Error E10**. If the phone number is in status "06" (port-out return from number retrieval business operator — after switching until night batch) or "11" (internal port number — port-out return from number retrieval business operator — after switching until night batch), set error code "E10" and return early. This prevents cancellation when a number portability process is already in a post-switching state that would conflict with cancellation.

> Japanese comment: `電話番号状態チェック` — Telephone number status check

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | SET | `errCd = "E10"` | Set error code for incompatible phone number status |
| 2 | EXEC | `trgtData.put("ERR_CD", errCd)` | Add error information to target data map [Japanese: エラー情報を追加 — add error information] |
| 3 | RETURN | `return` | Exit method early with error set |

**Block 2.2.1.2** — [IF] `(tmpEnumKrkeDouji)` (L11108)

> ENUM simultaneous switching check. If ENUM (telephone number portability) simultaneous switching is being performed, additional phone number status validation applies. A wider range of statuses are considered incompatible.

> Japanese comment: `ENUM同時切替チェック` — ENUM simultaneous switching check

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | IF | `tmpEnumKrkeDouji` | ENUM switching flag is set |

**Block 2.2.1.2.1** — [IF] `(TELNOJUDGEDIV_04 \|\| 05 \|\| 06 \|\| 09 \|\| 10 \|\| 11).equals(telnoJudgeDiv)` [-> 04, 05, 06, 09, 10, or 11] (L11111, ANK-4494-00-00 Step2 MOD)

> ENUM-specific phone number status check — **Error E11**. If ENUM simultaneous switching is enabled and the phone number status is any of "04" (no port number — port-out state), "05" (no port number — port-out return before switching), "06" (no port number — port-out return after switching until night batch), "09" (internal port — port-out state), "10" (internal port — port-out return before switching), or "11" (internal port — port-out return after switching until night batch), set error code "E11" and return early.

> This check was expanded in ANK-4494-00-00 Step2 from only statuses "04" and "05" to also include "06", "09", "10", and "11" to prevent ENUM switching conflicts in additional portability states.

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | SET | `errCd = "E11"` | Set error code for ENUM switching conflict |
| 2 | EXEC | `trgtData.put("ERR_CD", errCd)` | Add error information to target data map [Japanese: エラー情報を追加] |
| 3 | RETURN | `return` | Exit method early with error set |

---

**Block 3** — [CALL] `(getTelnoJudgeDiv — called sub-method)` (L11180)

> Retrieves the phone number status judgment division code by calling `JKKTelnoStatJudgeCC.telnoStatJudge`.

| # | Type | Code | Comment |
|---|------|------|---------|
| 1 | SET | `HashMap<String, Object> telNoStatJudgeCc = new HashMap<String, Object>()` | Create status judgment data map |
| 2 | EXEC | `telNoStatJudgeCc.put(JKKTelnoStatJudgeConstCC.TELNO, telno)` | Set telephone number in the judgment map |
| 3 | SET | `JKKTelnoStatJudgeCC TelnoStatJudgeCC = new JKKTelnoStatJudgeCC()` | Instantiate phone number status judgment component |
| 4 | EXEC | `param.setData("telnoStatJudgeCc", telNoStatJudgeCc)` | Store data map in request parameter |
| 5 | CALL | `TelnoStatJudgeCC.telnoStatJudge(handle, param, "telnoStatJudgeCc")` | Invoke status judgment SC |
| 6 | SET | `HashMap<String, Object> telnoStatJudgeCcHashMap = (HashMap<String, Object>)param.getData("telnoStatJudgeCc")` | Retrieve result from request parameter |
| 7 | SET | `ArrayList telNoStatJudgeCcList = (ArrayList)telnoStatJudgeCcHashMap.get(JKKTelnoStatJudgeConstCC.TELNOSTATJUDGECC_LIST)` | Extract status judgment list |
| 8 | SET | `HashMap telNoStatJudgeCcListHashMap = (HashMap)telNoStatJudgeCcList.get(0)` | Get first entry from list |
| 9 | SET | `String telnoJudgeDiv = (String)telNoStatJudgeCcListHashMap.get(JKKTelnoStatJudgeConstCC.TELNOJUDGEDIV)` | Extract the judgment division code |
| 10 | RETURN | `return telnoJudgeDiv` | Return the phone number status code |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `telno` | Field | Telephone number — the customer's phone number being processed for cancellation |
| `enum_krke_douji` | Field | ENUM simultaneous switching flag — boolean indicating whether ENUM (Electronic Number Mapping) simultaneous switching is being performed during this cancellation |
| `kido_cd` | Field | Startup source code — identifies the source that initiated the operation (e.g., "01" = screen startup) |
| `ido_div` | Field | Differentiation division — code that identifies the type of service change/migration being performed |
| `err_cd` | Field | Error code — output field where validation error codes are stored (e.g., "E10", "E11") |
| `telnoJudgeDiv` | Field | Telephone number status division — the current operational status code of a telephone number as determined by the status judgment component |
| KIDO_CD_ON | Constant | Startup source code for screen startup — value `"01"`, indicates the operation was initiated from a screen rather than batch or API |
| IDO_DIV_HTELNODSL | Constant | Differentiation division for Optical Phone and Number Cancellation — value `"00043"`, identifies the specific service cancellation type |
| TELNOJUDGEDIV_04 | Constant | Phone number status: No port number — port-out state (番号なし — ポートアウト状態) |
| TELNOJUDGEDIV_05 | Constant | Phone number status: No port number — port-out return before switching (番号なし — 番号取得事業者返り)(切替前) |
| TELNOJUDGEDIV_06 | Constant | Phone number status: No port number — port-out return after switching until night batch (番号なし — 番号取得事業者返り)(切替後〜夜間バッチ前) |
| TELNOJUDGEDIV_09 | Constant | Phone number status: Internal port number — port-out state (番号なし — 網内番号)(ポートアウト状態) |
| TELNOJUDGEDIV_10 | Constant | Phone number status: Internal port number — port-out return before switching (番号なし — 網内番号)(番号取得事業者返り)(切替前) |
| TELNOJUDGEDIV_11 | Constant | Phone number status: Internal port number — port-out return after switching until night batch (番号なし — 網内番号)(番号取得事業者返り)(切替後〜夜間バッチ前) |
| ERR_CD = "E10" | Error code | Phone number status error — the number is in a post-switching port-out state incompatible with cancellation |
| ERR_CD = "E11" | Error code | ENUM simultaneous switching error — the number is in a status incompatible with ENUM simultaneous switching |
| ENUM | Acronym | Electronic Number Mapping — a telephone number portability (number portability) technology that allows customers to retain their phone number when switching carriers |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service (contextual, referenced in system domain) |
| KKSV0195 | Screen | Optical Phone and Number Cancellation screen — the K-Opticom operation screen for initiating optical phone and number cancellation |
| DSL | Acronym | Domain Specific Language — the framework pattern used to route and execute business operations through a layered CC -> Common -> DSL Run architecture |
| CC | Acronym | Common Component — a business operation component in the K-Opticom architecture that sits between screen logic and the DSL execution layer |
| BP | Acronym | Business Process — layer designation in the package structure (`com.fujitsu.futurity.bp`) |
| ANK-4494-00-00 | Jira ID | Change request that added expanded ENUM switching status checks (Step2) to also include status codes 09, 10, and 11 |
| JKKDslRunCC | Class | DSL Run Common Component — the CC-layer class that provides configurable CCRequestBroker hooks for DSL operations |
| JKKDslRun | Class | DSL Run — the core DSL execution engine class containing the actual business logic for service order processing |
| JKKTelnoStatJudgeCC | Class | Telephone Number Status Judgment Common Component — the component that queries and determines the current operational status of a telephone number |
| 光電話・番号解約 | Japanese term | Optical Phone and Number Cancellation — the business operation of cancelling an optical phone service line along with its associated phone number (number portability context) |
| 電話番号状態区分 | Japanese term | Telephone number status division — the classification code for the current state of a telephone number (in use, port-out, ported, etc.) |
