# Business Logic — KKW02701SFLogic.isIcjkn() [47 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW02701SF.KKW02701SFLogic` |
| Layer | Service Logic (Webview layer — screen-side business logic) |
| Module | `KKW02701SF` (Package: `eo.web.webview.KKW02701SF`) |

## 1. Role

### KKW02701SFLogic.isIcjkn()

This method performs a **lump-sum cancellation confirmation check** (一時金取消確認) by validating the status of associated construction case data (工事案件). It is a guard-check method used within a lump-sum payment cancellation flow to determine whether the cancellation should be allowed to proceed. The method operates as a **delegated validation**: it extracts construction case information from a shared service output map, resolves the case number against the current form data for data integrity, and then inspects the case status code.

The method implements a **fail-fast conditional-return pattern**: it returns `true` (cancellation confirmation passes — no valid/active construction case found) when any of the following holds: (1) no construction case key exists in the output map, (2) the construction case list is empty or null, (3) the construction case number stored in the data differs from the one on the current form (indicating a data mismatch or stale reference), or (4) the construction case status is not `KOJIAK_STAT_200` (i.e., not "construction completed"). Only when a valid construction case exists AND its status equals `200` (工事完了済 — construction completed) does it return `false`, signaling that the cancellation confirmation has found an active completed case.

This method is a **shared utility** called from within the same class (`forwardRsvClCfm`), operating as a pre-condition gate in the reservation cancellation confirmation screen. It does not modify any data — it is a pure read/validate operation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["isIcjkn(outputMap, kojiakKey)"])
    
    CHECK_CONTAINS_KEY{"outputMap contains kojiakKey?"}
    RETURN_TRUE_1(["return true<br/>No construction case data"])
    
    GET_KOJI_MSG["kojiMsg = outputMap.get(kojiakKey)"]
    GET_KOJI_LIST["kojiList = getArrayListMap(kojiMsg, EKU0011B090CBSMsg1List)"]
    
    CHECK_LIST_NULL{"kojiList == null?"}
    RETURN_TRUE_2(["return true<br/>No construction case list"])
    
    GET_FIRST_INFO["kojiInfo = kojiList.get(0)"]
    GET_STAT["kojiStat = kojiInfo.get(kojiak_stat)"]
    
    GET_FORM_BEAN["svcFormBean = getServiceFormBean()"]
    GET_KOJIAK_NO["kojiakNo = kojiInfo.get(kojiak_no)"]
    GET_MAKAK_FORM["mskm_dtl_kojiak_no = svcFormBean.sendMessageString(MSKM_DTL_KOJIAK_NO)"]
    
    COMPARE_KOJIAK_NO{"kojiakNo equals mskm_dtl_kojiak_no?"}
    RETURN_TRUE_3(["return true<br/>Case number mismatch"])
    
    COMPARE_STATUS{"kojiStat equals KOJIAK_STAT_200?"}
    RETURN_TRUE_4(["return true<br/>Case status not completed"])
    
    RETURN_FALSE(["return false<br/>Construction case is valid and completed"])
    
    END_NODE(["Next processing step"])
    
    START --> CHECK_CONTAINS_KEY
    CHECK_CONTAINS_KEY -->|No| RETURN_TRUE_1
    CHECK_CONTAINS_KEY -->|Yes| GET_KOJI_MSG
    GET_KOJI_MSG --> GET_KOJI_LIST
    GET_KOJI_LIST --> CHECK_LIST_NULL
    CHECK_LIST_NULL -->|Yes| RETURN_TRUE_2
    CHECK_LIST_NULL -->|No| GET_FIRST_INFO
    GET_FIRST_INFO --> GET_STAT
    GET_STAT --> GET_FORM_BEAN
    GET_FORM_BEAN --> GET_KOJIAK_NO
    GET_KOJIAK_NO --> GET_MAKAK_FORM
    GET_MAKAK_FORM --> COMPARE_KOJIAK_NO
    COMPARE_KOJIAK_NO -->|No| RETURN_TRUE_3
    COMPARE_KOJIAK_NO -->|Yes| COMPARE_STATUS
    COMPARE_STATUS -->|No| RETURN_TRUE_4
    COMPARE_STATUS -->|Yes| RETURN_FALSE
    RETURN_TRUE_1 --> END_NODE
    RETURN_TRUE_2 --> END_NODE
    RETURN_TRUE_3 --> END_NODE
    RETURN_TRUE_4 --> END_NODE
    RETURN_FALSE --> END_NODE
```

**Conditional Branch Summary:**

| Branch | Condition | Return | Business Meaning |
|--------|-----------|--------|------------------|
| B1 | `outputMap` does not contain `kojiakKey` | `true` | No construction case data exists — safe to proceed with cancellation |
| B2 | `kojiList` is null | `true` | Construction case list is empty — no case to block cancellation |
| B3 | `kojiakNo` != `mskm_dtl_kojiak_no` | `true` | Case number in data differs from form data — potential stale/stale reference, allow cancellation |
| B4 | `kojiStat` != `"200"` (KOJIAK_STAT_200) | `true` | Case is not in "completed" status — cancellation is allowed (case is not yet completed) |
| B5 | `kojiStat` == `"200"` | `false` | Case is completed — cancellation confirmation found an active completed case |

**Constant Resolution:**
- `JKKCommonConst.KOJIAK_STAT_200` = `"200"` — Construction Case Status "200" means 工事完了済 (construction completed)
- `KKW02701SFConst.MSKM_DTL_KOJIAK_NO` — Form bean key for the construction case number displayed on the order-detail screen (注文詳細_工事案件)

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `outputMap` | `HashMap<String, Object>` | The service processing result map returned from a prior CBS (Common Business Service) call. It contains nested data structures keyed by constant strings, including the construction case list. The key referenced by `kojiakKey` must map to a HashMap containing the `EKU0011B090CBSMsg1List` array. |
| 2 | `kojiakKey` | `String` | The map key used to locate the construction case (工事案件) data within `outputMap`. This key acts as a discriminator to find the specific construction case record associated with the current cancellation flow. |

**Instance Fields / External State Read:**

| Field / External | Accessor Method | Business Description |
|-----------------|----------------|---------------------|
| `svcFormBean` | `getServiceFormBean()` | The service form data bean (X31SDataBeanAccess) holding the current screen's form values, used to retrieve the displayed construction case number for integrity comparison. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `KKW02701SFLogic.getArrayListMap` | KKW02701SFLogic | - | Retrieves the construction case list (ArrayList of HashMaps) from the kojiMsg map under the key `EKU0011B090CBSMsg1List`. Pure in-memory read from the service output structure. |
| R | `OneStopDataBeanAccess.sendMessageString` (via svcFormBean) | X31CWebConst | - | Retrieves the construction case number (kojiak_no) displayed on the current form screen for integrity comparison against the case number found in the data. Uses the constant key `MSKM_DTL_KOJIAK_NO` to query the form bean. |

**Analysis Notes:**
- This method performs **zero direct database operations**. All data is read from in-memory structures (`outputMap` and `svcFormBean`).
- The `getArrayListMap` helper extracts data previously loaded by a CBS (likely `EKU0011B090`).
- The `sendMessageString` call queries the current form state — a screen-level read, not a DB transaction.

## 5. Dependency Trace

### Direct Callers:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `KKW02701SFLogic.forwardRsvClCfm()` | `forwardRsvClCfm` -> `isIcjkn(outputMap, kojiakKey)` | `getArrayListMap [R] in-memory`, `sendMessageString [R] form bean` |

**Notes:**
- No screen/batch entry points (`KKSV*`) were found within 8 hops of this method.
- The method is called exclusively from `forwardRsvClCfm()` within the same class, which is a screen forwarding method in the `KKW02701SF` module.
- This module (`KKW02701SF`) relates to lump-sum reservation cancellation confirmation screens.

### Call Chain Direction:
- **Upstream**: `forwardRsvClCfm()` calls `isIcjkn()` as a pre-condition check before proceeding with the cancellation confirmation flow.
- **Downstream**: `isIcjkn()` calls `getArrayListMap()` (internal helper) and `sendMessageString()` (form bean accessor). No DB or SC-level writes occur.

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(outputMap.containsKey(kojiakKey))` (L921)

> Check if the output map contains the construction case key. If the key is absent, there is no associated construction case data, so the cancellation confirmation check passes immediately.

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | `!outputMap.containsKey(kojiakKey)` |
| 2 | RETURN | `return true;` // No construction case key found — cancellation allowed |

---

**Block 2** — IF / SEQUENTIAL PROCESSING (L927-930)

> Extract the construction case message map and retrieve the construction case list from the `EKU0011B090CBSMsg1List` key. This key was changed from `EKU0011B020CBSMsg1List` per OM-2015-0002629 (2015/10/28).

| # | Type | Code |
|---|------|------|
| 1 | SET | `kojiMsg = (HashMap<String, Object>)outputMap.get(kojiakKey)` |
| 2 | SET | `kojiList = getArrayListMap(kojiMsg, "EKU0011B090CBSMsg1List")` // Extracted construction case list (mod: OM-2015-0002629) |

---

**Block 3** — IF `(kojiList == null)` (L932)

> If the construction case list is null (empty or not found), treat as no active case and allow cancellation.

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | `kojiList == null` |
| 2 | RETURN | `return true;` // No construction case list — cancellation allowed |

---

**Block 4** — SEQUENTIAL DATA EXTRACTION (L936-937)

> Retrieve the first element of the construction case list and extract the case status code. The first element (index 0) is assumed to be the relevant case.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kojiInfo = (HashMap<String, Object>)kojiList.get(0)` |
| 2 | SET | `kojiStat = kojiInfo.get("kojiak_stat").toString()` // Construction case status code |

---

**Block 5** — OM-2016-0001061 ADD: Case Number Integrity Check (L941-951)

> Extract the current form bean and compare the construction case number stored in the data against the one displayed on the form. If they differ, the data is considered stale or mismatched, and the cancellation confirmation check passes (returns true).

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcFormBean = super.getServiceFormBean()` // Get current form data bean |
| 2 | SET | `kojiakNo = kojiInfo.get("kojiak_no").toString()` // Case number from data |
| 3 | SET | `mskm_dtl_kojiak_no = svcFormBean.sendMessageString(KKW02701SFConst.MSKM_DTL_KOJIAK_NO, X31CWebConst.DATABEAN_GET_VALUE)` // Case number from form (注文詳細_工事案件) |

**Block 5.1** — IF `(kojiakNo != mskm_dtl_kojiak_no)` (L948)

> If the case number from data does not match the form-displayed case number, the records are inconsistent — allow cancellation.

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | `!kojiakNo.equals(mskm_dtl_kojiak_no)` |
| 2 | RETURN | `return true;` // Case number mismatch — cancellation allowed |

---

**Block 6** — IF `(KOJIAK_STAT_200 check)` (L953)

> Check if the construction case status is "200" (工事完了済 — construction completed). If the status is anything other than "200", cancellation is allowed because the case is not yet completed. The constant `JKKCommonConst.KOJIAK_STAT_200` resolves to `"200"`.

| # | Type | Code |
|---|------|------|
| 1 | CONDITION | `!JKKCommonConst.KOJIAK_STAT_200.equals(kojiStat)` // KOJIAK_STAT_200 = "200" (construction completed) |
| 2 | RETURN | `return true;` // Case status is not "200" — cancellation allowed |

---

**Block 7** — ELSE (L955)

> The only path that reaches here is when: (a) construction case data exists, (b) the list is non-null, (c) the case number matches the form, AND (d) the status is exactly "200" (completed). In this case, return `false` to indicate the cancellation confirmation found an active completed construction case.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return false;` // Construction case is valid, case number matches, status = 200 (completed) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| 一時金取消確認 (Ichijikin Torikeshi Kakunin) | Japanese term | Lump-sum cancellation confirmation — the business process this method guards |
| 工事案件 (Kojiak) | Japanese term | Construction case / work order — a record tracking field construction activities |
| 工事完了済 (Koji Kanryozumi) | Japanese term | Construction completed — the completed status of a construction case |
| KOJIAK_STAT_200 | Constant | Construction case status code "200" meaning 工事完了済 (construction completed) |
| KOJIAK_STAT | Field | Construction case status field — stored as a string in the case info HashMap |
| KOJIAK_NO | Field | Construction case number — the unique identifier for a construction case |
| MSKM_DTL_KOJIAK_NO | Constant | Form bean key for the construction case number displayed on the order-detail screen (注文詳細_工事案件) |
| EKU0011B090CBSMsg1List | Constant | Map key for the construction case list within the CBS message map |
| EKU0011B020CBSMsg1List | Deprecated Constant | Previous version of the construction case list key, replaced by EKU0011B090CBSMsg1List per OM-2015-0002629 |
| outputMap | Parameter | Service processing result map — the shared data structure holding all CBS response data |
| kojiakKey | Parameter | Map key to locate construction case data within outputMap |
| X31SDataBeanAccess | Class | Service form data bean — holds current screen/form field values |
| OneStopDataBeanAccess | Interface/Class | Data bean access interface — used via sendMessageString to query form bean values |
| X31CWebConst | Class | Web constants class — provides constants like DATABEAN_GET_VALUE for form data retrieval |
| KKW02701SF | Module | Screen module for lump-sum reservation cancellation confirmation processing |
| forwardRsvClCfm | Method | Forward/Reservation Cancellation Confirmation — the screen method that calls isIcjkn |
| getArrayListMap | Helper Method | Internal utility that extracts an ArrayList<HashMap> from a HashMap by key |
| OM-2015-0002629 | Change ticket | OM ticket that changed the construction case list key from EKU0011B020 to EKU0011B090 |
| OM-2016-0001061 | Change ticket | OM ticket that added the case number integrity check between data and form |
