# Business Logic — JKKAdchgCheckerCC.dmpsExistsCheck() [66 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKAdchgCheckerCC` |
| Layer | CC/Common Component (Shared business logic component for address/change verification) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKAdchgCheckerCC.dmpsExistsCheck()

This method performs an existence check for radio obstruction cases (電波障害案件, *Denpa Shougai Ankken*). In the telecommunications domain, a "radio obstruction" refers to a known site or area where physical conditions (such as construction, natural disasters, or infrastructure issues) prevent the installation of services like fiber-to-the-home (FTTH). The method serves as a shared utility invoked by multiple screen operation processes to validate whether a given radio obstruction case code corresponds to an existing, registered case in the system before proceeding with service contract operations. It operates as part of the broader address change and service validation workflow used in location change registration screens (e.g., KKSV0698). The method follows a read-only validation pattern: it queries the database for the existence of a matching case record and returns a simple binary flag (`0` or `1`) indicating whether a case was found, without modifying any data.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["dmpsExistsCheck(params)"])
    A1["Prepare local variables"] --> A2["Get paramMap from param.getData(fixedText)"]
    A2 --> B1["KeepSesHandle.set(handle)"]
    B1 --> C1["Get JKKAdchgMapperCC.getInstance()"]
    C1 --> C2["Create new ServiceComponentRequestInvoker()"]
    C2 --> D1["paramMap.put(dmps_check_result, 1)"]
    D1 --> E1["Get denpaShogaiCd from paramMap"]
    E1 --> E2["Check: is denpaShogaiCd null or blank?"]
    E2 -->|Yes| F1["Return param (skip check)"]
    E2 -->|No| G1["condMap.put(COND_KEY_DMPS_ANKEN_NO, denpaShogaiCd)"]
    G1 --> G2["mapper.setEKK0581A010(param, fixedText, condMap)"]
    G2 --> G3["scCall.run(reqMap, keepSesHandle.get())"]
    G3 --> G4["mapper.getEKK0581A010(param, fixedText, resMap)"]
    G4 --> G5["mapper.scResultCheck(param)"]
    G5 --> H1{"Is kk0581_a010_map empty?"}
    H1 -->|Yes, 0 cases| H2["paramMap.put(dmps_check_result, 0)"]
    H2 --> I1["Log end, return param"]
    H1 -->|No, case found| I1
    I1 --> END(["Return / Next"])
    F1 --> END
    END --> FINALLY["finally: keepSesHandle.remove()"]
```

**Processing Summary:**

1. **Setup Phase (L134–L154):** Initializes local HashMap variables for request (`reqMap`), condition (`condMap`), and response (`resMap`). Retrieves the parameter map from the input `param` object. Stores the session handle for later use by the service component request invoker. Instantiates the `JKKAdchgMapperCC` mapper and a `ServiceComponentRequestInvoker`. Pre-initializes the check result to `"1"` (case found), which will be overridden to `"0"` only if the database returns zero rows.

2. **Validation Gate (L156–L163):** Extracts the radio obstruction case code (`denpaShogaiCd`) from the parameter map using the key `dmps_anken_no`. If this value is null or blank, the method returns immediately without performing any database lookup, passing control to the caller unchanged.

3. **Database Query Phase (L165–L172):** Constructs a condition map with the radio obstruction case code and passes it through the mapper's `setEKK0581A010` method to prepare the service component request. The `ServiceComponentRequestInvoker` then executes the `EKK0581A010SC` service component (Radio Obstruction Case Unique Inquiry). The result is unmarshalled back into a HashMap via `getEKK0581A010`. Finally, `scResultCheck` validates the response for errors.

4. **Result Evaluation (L174–L179):** If the query returned zero matching records (empty map), the method sets the check result flag to `"0"` (no case exists). Otherwise, the pre-initialized value of `"1"` is retained, indicating a case was found. The method logs the end and returns the modified parameter map.

5. **Cleanup (L181–L187):** In the `finally` block, the stored session handle is removed to prevent memory leaks and resource exhaustion across successive calls.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | The active database session context used by the `ServiceComponentRequestInvoker` to execute the `EKK0581A010SC` query. Preserved via `keepSesHandle` thread-local storage for the invoker and cleaned up in the `finally` block. |
| 2 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying the model group data and control mappings. Contains the radio obstruction case code at the key specified by `dmps_anken_no` (`PARAM_KEY_DMPS_ANKEN_NO`), and is modified in-place to store the check result at key `dmps_check_result`. |
| 3 | `fixedText` | `String` | A user-provided fixed text string passed through to the mapper methods (`setEKK0581A010`, `getEKK0581A010`) for additional context during request/response mapping. Typically used for traceability or diagnostic identification. |

**Instance fields accessed:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `keepSesHandle` | (ThreadLocal\<SessionHandle\>) | Thread-local storage for the session handle, used to preserve the database session context across the service component invoker boundary. Cleaned up in `finally`. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKAdchgMapperCC.getInstance` | - | - | Gets the singleton mapper instance for address change mapping operations. |
| R | `JKKAdchgMapperCC.setEKK0581A010` | - | - | Marshals the condition map (containing `dmps_anken_no`) into the service component request message format. |
| R | `ServiceComponentRequestInvoker.run` | `EKK0581A010SC` | `EKK0581A010BS` | Executes the Radio Obstruction Case Unique Inquiry Service Component. This is a READ query that looks up a single radio obstruction case record by its case number. |
| R | `JKKAdchgMapperCC.getEKK0581A010` | - | - | Unmarshals the response from the service component into a `HashMap<String, Object>` containing the inquiry result. |
| - | `JKKAdchgMapperCC.scResultCheck` | - | - | Validates the SC response for business exceptions. Throws if the service component reported an error. |

**How to classify:**
- The sole database operation is a **Read (R)** — this method does not create, update, or delete any records. It queries for the existence of a radio obstruction case and returns a binary flag.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0698 | `KKSV0698OPOperation` -> `CCRequestBroker(target1a)` -> `JKKAdchgCheckerCC.dmpsExistsCheck` | `EKK0581A010SC [R] Radio Obstruction Case` |

**Notes:**
- `KKSV0698` is the screen operation process for location change registration (specifically, the "e-Net Registration" SC path). The method is invoked via a `CCRequestBroker` (`target1a`) within the BPM operation chain. The check result flag (`dmps_check_result`) influences downstream validation logic to determine whether the service contract can proceed or if the radio obstruction case should be flagged.

## 6. Per-Branch Detail Blocks

**Block 1** — [SETUP/INITIALIZATION] (L134)

> Local variable declarations and initial setup phase.

| # | Type | Code |
|---|------|------|
| 1 | SET | `reqMap` (local `HashMap<String, Object>`) | Uninitialized request map reference |
| 2 | SET | `condMap = new HashMap<String, String>()` | Creates empty condition map for query parameters |
| 3 | CALL | `paramMap = (HashMap<String, Object>)( param.getData(fixedText) )` | Retrieves the parameter map from `param` keyed by `fixedText` |
| 4 | SET | `resMap` (local `Map<?, ?>`) | Uninitialized response map reference |

**Block 2** — [EXEC / SESSION HANDLE PRESERVATION] (L144)

> Stores the session handle in thread-local storage for later use by the service component invoker.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `keepSesHandle.set(handle)` | Preserves the session handle for the `ServiceComponentRequestInvoker` |

**Block 3** — [SETUP / MAPPER AND INVOKER CREATION] (L147–L153)

> Obtains the mapper singleton and creates the service component request invoker.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapper = JKKAdchgMapperCC.getInstance()` | Gets the singleton mapper [-> `JKKAdchgMapperCC.getInstance()`] |
| 2 | SET | `scCall = new ServiceComponentRequestInvoker()` | Creates a new service component request invoker |
| 3 | SET | `paramMap.put("dmps_check_result", "1")` | Pre-initializes check result to `"1"` (case found), [-> `PARAM_KEY_DMPS_ANKEN_NO="dmps_anken_no"` (JKKAdchgConstCC.java:1822)] |

**Block 4** — [SETUP / EXTRACT RADIO OBSTRUCTION CASE CODE] (L156–L157)

> Extracts the radio obstruction case code from the parameter map for the existence check.

| # | Type | Code |
|---|------|------|
| 1 | SET | `denpaShogaiCd = (String)paramMap.get(JKKAdchgConstCC.PARAM_KEY_DMPS_ANKEN_NO)` | Gets the radio obstruction case code [-> `PARAM_KEY_DMPS_ANKEN_NO="dmps_anken_no"` (JKKAdchgConstCC.java:1822)] |

**Block 5** — [IF / NULL BLANK CHECK] `(denpaShogaiCd is null or blank)` (L159)

> If the radio obstruction case code is not provided, skip the check and return unchanged. This is an early-exit guard that avoids unnecessary database calls when the caller has not supplied a case code.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JKKStringUtil.isNullBlank(denpaShogaiCd)` | Validates whether the code is null, empty, or whitespace-only |
| 2 | RETURN | `return param` | Returns immediately without DB query; `dmps_check_result` remains `"1"` |

**Block 6** — [SETUP / BUILD CONDITION MAP] (L165)

> Constructs the condition map with the radio obstruction case code as the lookup key.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `condMap.put(JKKAdchgMapperCC.COND_KEY_DMPS_ANKEN_NO, denpaShogaiCd)` | Puts the case code into condition map [-> `COND_KEY_DMPS_ANKEN_NO="cond_key_dmps_anken_no"` (JKKAdchgMapperCC.java:1704)] |

**Block 7** — [CALL / SERVICE COMPONENT INVOKE] (L167–L172)

> Executes the database query via the service component layer.

| # | Type | Code |
|---|------|------|
| 1 | SET | `reqMap = mapper.setEKK0581A010(param, fixedText, condMap)` | Marshals condition into request message [-> `EKK0581A010` (SC Code)] |
| 2 | SET | `resMap = scCall.run(reqMap, keepSesHandle.get())` | Executes the SC query [-> `EKK0581A010SC`] |
| 3 | SET | `kk0581_a010_map = mapper.getEKK0581A010(param, fixedText, resMap)` | Unmarshals response to HashMap [-> `EKK0581A010`] |
| 4 | EXEC | `mapper.scResultCheck(param)` | Validates SC response for errors |

**Block 8** — [IF / EMPTY MAP CHECK] `(kk0581_a010_map.isEmpty())` (L174)

> If the database returned zero records, set the check result to `"0"` (no case exists). Otherwise, the pre-initialized `"1"` value is retained, meaning a case was found.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put("dmps_check_result", "0")` | Overrides result to `"0"` — no matching radio obstruction case found |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `dmps_anken_no` | Field | Radio obstruction case number — the unique identifier for a registered radio obstruction case used to look up whether an obstruction exists at a given location |
| `dmps_check_result` | Field | Check result flag — `"1"` means a radio obstruction case exists; `"0"` means no case was found (or the input was blank) |
| `denpaShogaiCd` | Field | Radio obstruction code (電波障害コード) — the extracted case code from the parameter map used as the lookup key for the existence check |
| `EKK0581A010` | SC Code | Radio Obstruction Case Unique Inquiry — the service component responsible for querying a single radio obstruction case record by its case number |
| `EKK0581A010SC` | SC Code | Service Component for EKK0581A010 — the SC-layer implementation that executes the database query |
| `EKK0581A010BS` | CBS Code | Business Service for EKK0581A010 — the business service that performs the actual database access for the radio obstruction case lookup |
| EKK | Abbreviation | Address Change / Customer Data entity prefix (from Japanese 変更, *Henkou* = Change) |
| DMPS | Abbreviation | Denpa Shougai (電波障害) — Radio Obstruction; refers to known installation obstacle locations in the telecom service domain |
| ANKEN (案件) | Term | Case — a registered record/entity in the system, in this context a radio obstruction case |
| `COND_KEY_DMPS_ANKEN_NO` | Constant | Condition key for the DMPS case number in the condition map — `"cond_key_dmps_anken_no"` |
| `PARAM_KEY_DMPS_ANKEN_NO` | Constant | Parameter key for the DMPS case number in the parameter map — `"dmps_anken_no"` |
| `keepSesHandle` | Field | Thread-local session handle — stores the database session context for cross-component invocation via `ServiceComponentRequestInvoker` |
| `ServiceComponentRequestInvoker` | Class | Invoker that bridges the CC layer to the SC layer, executing service components with a given request map and session handle |
| KKSV0698 | Screen ID | Location change registration screen (e-Net Registration) — the primary consumer of this method, invoked during the service contract validation phase |
