# Business Logic — JKKKeiNewCmnLogicUtil.getMansionBukkenNo() [23 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.commonOneStop.JKKKeiNewCmnLogicUtil` |
| Layer | Utility / Common Component |
| Module | `commonOneStop` (Package: `eo.web.webview.commonOneStop`) |

## 1. Role

### JKKKeiNewCmnLogicUtil.getMansionBukkenNo()

This method extracts the **mansion property number** (マンション物件番号) from a nested map structure that carries mansion (condominium building) search results. In the real estate / property information domain, a "mansion" is a multi-unit residential building, and each unit (棟 / bukken) has a unique property number used for identification in search and display screens. The method acts as a **safe navigation utility** — it dereferences a potentially null hierarchy of data structures (Map → List → Map → String) without throwing `NullPointerException`, returning `null` at the first null boundary encountered. It implements the **null-guard delegation pattern**, where each level of the data hierarchy is checked independently. This method is called by 11 direct callers across search, edit, and data-initialization screens, indicating it is a shared utility used throughout the web view layer to retrieve the property number of the first mansion search result.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getMansionBukkenNo(mansionMap)"])
    COND1{mansionMap is null?}
    STEP1["Get EKK0861A010CBSMsg1List from mansionMap"]
    COND2{list is null?}
    STEP2["Get index 0 from list → child"]
    COND3{child is null?}
    STEP3["Get kk0861_mansion_bukken_no from child"]
    RETURN_BUKKEN["Return bukkenNo"]
    RETURN_NULL(["Return null"])

    START --> COND1
    COND1 -- Yes --> RETURN_NULL
    COND1 -- No --> STEP1
    STEP1 --> COND2
    COND2 -- Yes --> RETURN_NULL
    COND2 -- No --> STEP2
    STEP2 --> COND3
    COND3 -- Yes --> RETURN_NULL
    COND3 -- No --> STEP3
    STEP3 --> RETURN_BUKKEN
```

The method performs a linear, four-step safe-de-reference through a nested data structure:

1. **Null check on the input map** — If the caller passes `null`, returns `null` immediately.
2. **Extract the search result list** — Retrieves the value associated with key `"EKK0861A010CBSMsg1List"` (the CBS response list for mansion search) from the map. If the list is absent or `null`, returns `null`.
3. **Select the first result** — Gets index `0` from the list (the top-ranked mansion search result). If the list has no elements or index 0 is `null`, returns `null`.
4. **Extract the property number** — Gets the value associated with key `"kk0861_mansion_bukken_no"` from the first result map. Returns the string value (or `null` if the key is absent).

There are no conditional branches based on constant values, no loops, and no external service calls. The method is purely a defensive data accessor.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `mansionMap` | `HashMap<String, Object>` | A map carrying mansion search result data. It is expected to contain a key `"EKK0861A010CBSMsg1List"` whose value is an `ArrayList` of result rows (each row is a `HashMap<String, Object>`). Each result row carries the property number at key `"kk0861_mansion_bukken_no"`. This map is typically populated by a CBS (Common Business Service) call that returns mansion search results for a user's query (e.g., apartment/mansion listing search on an EDINET / real estate portal). |

**External state / instance fields:** None. The method is stateless and static.

## 4. CRUD Operations / Called Services

This method performs **no CRUD operations** and makes **no calls to external services, CBS, or SC components**. It operates entirely within Java in-memory data structures (HashMap, ArrayList). It is a pure data accessor with no database or network interaction.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | — | — | — | No database or service calls. Pure in-memory navigation of `mansionMap`. |

## 5. Dependency Trace

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

Direct callers found: 11 methods (listed below). No screen/batch entry points found within 8 hops.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKGetMansionSearchCC.editInAddMotoEKK0861A010()` | JKKGetMansionSearchCC → `getMansionBukkenNo` | — |
| 2 | `JKKGetMansionSearchCC.getAddMotoMansion()` | JKKGetMansionSearchCC → `getMansionBukkenNo` | — |
| 3 | `JKKKktkSvcKeiDataUtil.getKktkSvcKeiIniData()` (1st call) | JKKKktkSvcKeiDataUtil → `getMansionBukkenNo` | — |
| 4 | `JKKKktkSvcKeiDataUtil.getKktkSvcKeiIniData()` (2nd call) | JKKKktkSvcKeiDataUtil → `getMansionBukkenNo` | — |
| 5 | `KKW00121SFLogic.getKaisenUcwkCheckJudgeList()` | KKW00121SFLogic → `getMansionBukkenNo` | — |
| 6 | `KKSV0080_KKSV0080OPDBMapper.setKKSV008007CC()` | KKSV0080 (Screen) → `setKKSV008007CC` → `getMansionBukkenNo` | — |
| 7 | `KKSV0080_KKSV0080OPDBMapper.setKKSV008017CC()` | KKSV0080 (Screen) → `setKKSV008017CC` → `getMansionBukkenNo` | — |
| 8 | `KKSV0082_KKSV0082OPDBMapper.setKKSV008207CC()` | KKSV0082 (Screen) → `setKKSV008207CC` → `getMansionBukkenNo` | — |
| 9 | `KKSV0082_KKSV0082OPDBMapper.setKKSV008227CC()` | KKSV0082 (Screen) → `setKKSV008227CC` → `getMansionBukkenNo` | — |
| 10 | `KKSV0083_KKSV0083OPDBMapper.setKKSV008301CC()` | KKSV0083 (Screen) → `setKKSV008301CC` → `getMansionBukkenNo` | — |
| 11 | `KKSV0538_KKSV0538OPDBMapper.setKKSV053801CC()` | KKSV0538 (Screen) → `setKKSV053801CC` → `getMansionBukkenNo` | — |

**Caller classification:**
- **Controller / CC**: `JKKGetMansionSearchCC` — Used in mansion search edit/add flows to retrieve the property number of the selected mansion from search results.
- **Service Data Utility**: `JKKKktkSvcKeiDataUtil` — Used during service contract data initialization to read the mansion property number from cached search state.
- **SF Logic**: `KKW00121SFLogic` — Used in a kai-sai (change/cancellation) work check process.
- **Screen OP DB Mappers**: `KKSV0080`, `KKSV0082`, `KKSV0083`, `KKSV0538` — Used in mansion-related screen operations to set data into the screen parameter map.

All callers pass a `mansionMap` that was previously populated by a CBS call returning mansion search results. The method is called to extract the property number of the first (top) mansion result.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(mansionMap == null)` (L7710)

> Guard clause: if the caller passes a null input map, return null immediately to prevent NPE.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Input map is null — nothing to extract |

**Block 2** — [EXEC] `mansionMap.get("EKK0861A010CBSMsg1List")` (L7714)

> Extract the search result list from the map. The key `"EKK0861A010CBSMsg1List"` references a CBS (Common Business Service) method `EKK0861A010CBS` that returns mansion search results.

| # | Type | Code |
|---|------|------|
| 1 | SET | `list = (ArrayList) mansionMap.get("EKK0861A010CBSMsg1List");` // Cast to ArrayList |

**Block 3** — [IF] `(list == null)` (L7715)

> Guard clause: if the CBS did not populate the result list (e.g., no search was performed, or the map key is missing), return null.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Search result list is absent |

**Block 4** — [EXEC] `list.get(0)` (L7718)

> Select the first element from the search result list. Index 0 represents the top-ranked mansion in the search results.

| # | Type | Code |
|---|------|------|
| 1 | SET | `child = (HashMap) list.get(0);` // First mansion search result |

**Block 5** — [IF] `(child == null)` (L7719)

> Guard clause: if the list is empty (no elements) or index 0 is null, return null.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // First result is null |

**Block 6** — [EXEC] `child.get("kk0861_mansion_bukken_no")` (L7723)

> Extract the property number (物件番号 / bukken no) from the first mansion result map. This is the key field used throughout the system to identify a specific unit/building within a mansion complex.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bukkenNo = (String) child.get("kk0861_mansion_bukken_no");` // Mansion property number |

**Block 7** — [RETURN] (L7724)

> Return the extracted property number. May return `null` if the key was not present in the child map.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return bukkenNo;` // Property number string or null |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mansion` (マンション) | Domain term | Multi-unit residential building (condominium/apartment) in Japanese real estate context. Property listings are organized by mansion complex, with individual units called "bukken" (物件). |
| `bukken no` (物件番号) | Field | Property number — a unique identifier for a specific unit/building within a mansion complex. Used for search result display and data linkage. |
| `kk0861_mansion_bukken_no` | Field | The map key storing the property number value in the search result data structure. Named after the CBS/method `EKK0861A010` that populates it. |
| `EKK0861A010CBSMsg1List` | Field | The map key for the mansion search result list. "Msg1List" is a naming convention indicating this is the first message/result set returned by the CBS. |
| `EKK0861A010CBS` | CBS Code | Common Business Service method code for mansion search. CBS = Common Business Service, a layer that encapsulates data retrieval from the database. |
| CC | Acronym | Common Component — a controller-tier component that handles common business logic shared across multiple screens. |
| SF | Acronym | Screen Function — a screen-level processing class that coordinates data flow between the UI and the service layer. |
| JKKKeiNewCmnLogicUtil | Class | A shared utility class providing common logic methods across the JKK Kei (subscription/contract) new system. |
| EDINET | Domain term | The real estate portal / property search platform where mansion search results are displayed and managed. |
| `JKKGetMansionSearchCC` | Component | Controller/Component class handling mansion search operations (list, edit, add). |
| `JKKKktkSvcKeiDataUtil` | Component | Utility class for service contract data initialization. |
| `KKW00121SFLogic` | Component | Screen logic for kai-sai (change/cancellation) work checks related to mansion properties. |
