# Business Logic — JKKSvkeiShosaBaseCC.editMapCustKojin() [49 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKSvkeiShosaBaseCC` |
| Layer | CC / Common Component (shared base class for service contract processing) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKSvkeiShosaBaseCC.editMapCustKojin()

This method performs the **customer information (individual) change mapping process** as part of a broader service contract examination and approval workflow. It takes pre-fetched customer consent data from an inquiry result map (`rsltShokai`) and merges corresponding standard customer records with individual customer records into unified output structures.

The method handles **two customer consent categories**: standard customer consent (ECK0011A010) and individual customer consent (ECK0021A010). It acts as a **data mapper and merge coordinator** — iterating over indexed pairs of consent records, fetching the underlying message templates via `getWorkData`, and delegating the actual field-level mapping and transformation to `editInMsgECK0021C010` (from `JKKSvkeiShosaShosaOkMapperCC`) and `editInMsgCmn` (from this same class).

Its **role in the larger system** is as a shared utility method called by `updCustinfo()` during the customer information update flow. It enables multi-record customer data reconciliation — for example, when a customer has both a standard (business-level) registration and an individual (person-level) registration — by aligning and merging them record-by-record. The method implements a **delegation + batching pattern**: it collects all transformed results into a single list keyed by `MAP_KEY_ECK0021C010` for downstream consumption.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editMapCustKojin param rsltShokai"])
    INIT_VARS["Initialize rsltMemberStb wkMapArray"]
    GET_CONSENT["Get workECK0011A010Array from rsltShokai MAP_KEY_ECK0011A010"]
    GET_INDIVIDUAL_CONSENT["Get workECK0021A010Array from rsltShokai MAP_KEY_ECK0021A010"]
    CHECK_ARRAY{workECK0011A010Array
equals null}
    OUTER_LOOP["For each index i in workECK0011A010Array"]
    INIT_MAP["wkMapArray = new ArrayList"]
    FETCH_STANDARD["getWorkData ECK0011A010CBSMSG1LIST workECK0011A010Array_i"]
    FETCH_INDIVIDUAL["getWorkData ECK0021A010CBSMSG1LIST workECK0021A010Array_i"]
    CHECK_TEMPLATES{wkTenplates1 null AND wkTenplates2 null}
    INNER_LOOP["For each index j in wkTenplates1 length"]
    MAP_MERGE["editInMsgECK0021C010 param childTemplate1 childTemplate2"]
    TRANSFORM["editInMsgCmn param wkCaanMsgList_0"]
    COLLECT["wkMapArray.add rslt"]
    STORE_RESULT["rsltMemberStb.put MAP_KEY_ECK0021C010 wkMapArray"]
    RETURN["Return rsltMemberStb"]
    SKIP["Skip null array"]

    START --> INIT_VARS
    INIT_VARS --> GET_CONSENT
    GET_CONSENT --> GET_INDIVIDUAL_CONSENT
    GET_INDIVIDUAL_CONSENT --> CHECK_ARRAY
    CHECK_ARRAY --> |true| OUTER_LOOP
    CHECK_ARRAY --> |false| SKIP
    OUTER_LOOP --> INIT_MAP
    INIT_MAP --> FETCH_STANDARD
    FETCH_STANDARD --> FETCH_INDIVIDUAL
    FETCH_INDIVIDUAL --> CHECK_TEMPLATES
    CHECK_TEMPLATES --> |true| INNER_LOOP
    CHECK_TEMPLATES --> |false| OUTER_LOOP
    INNER_LOOP --> MAP_MERGE
    MAP_MERGE --> TRANSFORM
    TRANSFORM --> COLLECT
    COLLECT --> INNER_LOOP
    SKIP --> RETURN
    OUTER_LOOP --> CHECK_ARRAY
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Request parameters object carrying model groups and control maps. It provides the I/O context for field-level mapping operations (read from for input data, written to for merged output). Passed through to `editInMsgECK0021C010` and `editInMsgCmn` for actual data transformation. |
| 2 | `rsltShokai` | `HashMap<String, Object>` | Inquiry result data map containing pre-fetched customer consent records. It is expected to hold two key entries: `MAP_KEY_ECK0011A010` ("ECK0011A010") for standard customer consent arrays, and `MAP_KEY_ECK0021A010` ("ECK0021A010") for individual customer consent arrays. These represent the output of a prior data retrieval step (`runShokai` or similar). |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `MAP_KEY_ECK0011A010` | `String` | Map key constant for standard customer consent ("ECK0011A010") |
| `MAP_KEY_ECK0021A010` | `String` | Map key constant for individual customer consent ("ECK0021A010") |
| `MAP_KEY_ECK0021C010` | `String` | Map key constant for the merged individual customer result output ("ECK0021C010") |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKSvkeiShosaBaseCC.getWorkData` | JKKSvkeiShosaBaseCC | - | Reads customer consent work data arrays from `rsltShokai` by CBS message type. Called twice per iteration: once for standard customer (ECK0011A010CBSMSG1LIST) and once for individual customer (ECK0021A010CBSMSG1LIST). |
| U | `JKKSvkeiShosaShosaOkMapperCC.editInMsgECK0021C010` | ECK0021C010 | - | Merges a standard customer record (`CAANMsg`) with an individual customer record (`CAANMsg`) into unified output message list. This is the core field-level mapping operation. |
| U | `JKKSvkeiShosaBaseCC.editInMsgCmn` | - | - | Applies common message transformation/validation on the first merged CAANMsg result. Normalizes the merged record for downstream use. |
| U | `JKKSvkeiShosaBaseCC.editMapCustKojin` (self) | - | - | Writes merged result list into `rsltMemberStb` with key `MAP_KEY_ECK0021C010`, and returns it to the caller. |

## 5. Dependency Trace

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKSvkeiShosaBaseCC.updCustinfo` | `updCustinfo` -> `editMapCustKojin` | `editInMsgCmn [U]`, `editInMsgECK0021C010 [U]`, `getWorkData [R]` |

**Note:** `editMapCustKojin` is a private method with a single direct caller (`updCustinfo`). There are no screen (KKSV*) or batch entry points within 8 hops. The method is an internal utility within the CBS (Component-Based Service) customer update flow.

## 6. Per-Branch Detail Blocks

**Block 1** — [INIT] Local Variable Initialization (L763)

> Initializes the local working variables for result collection, array holders, and templates.

| # | Type | Code |
|---|------|------|
| 1 | SET | `rsltMemberStb = new HashMap()` // Final result container for merged individual customer data |
| 2 | SET | `rslt = null` // Per-iteration merged result holder |
| 3 | SET | `wkCaanMsgList = null` // Merged CAAN message list from editInMsgECK0021C010 |
| 4 | SET | `wkMapArray = null` // Accumulator for merged results per outer iteration |
| 5 | SET | `workECK0011A010Array = null` // [-> "お客様一致照会"] Standard customer consent array |
| 6 | SET | `workECK0021A010Array = null` // [-> "お客様一致照会(個人)"] Individual customer consent array |

**Block 2** — [INIT] Fetch Standard Customer Consent Data (L769)

> Retrieves the standard customer consent data array from the `rsltShokai` map using the `MAP_KEY_ECK0011A010` key.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workECK0011A010Array = (ArrayList)rsltShokai.get(MAP_KEY_ECK0011A010)` // [-> MAP_KEY_ECK0011A010 = "ECK0011A010"] |

**Block 3** — [INIT] Fetch Individual Customer Consent Data (L772)

> Retrieves the individual customer consent data array from the `rsltShokai` map using the `MAP_KEY_ECK0021A010` key.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workECK0021A010Array = (ArrayList)rsltShokai.get(MAP_KEY_ECK0021A010)` // [-> MAP_KEY_ECK0021A010 = "ECK0021A010"] |

**Block 4** — [IF] Null Guard on Standard Consent Array (L774)

> Checks whether standard customer consent data exists. If null, skips all processing and returns an empty `rsltMemberStb`.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `if (workECK0011A010Array != null)` |

**Block 4.1** — [FOR] Outer Loop over Standard Consent Records (L776)

> Iterates over each standard customer consent record. Each index `i` corresponds to an individual consent record at the same position in `workECK0021A010Array`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkMapArray = new ArrayList()` // Reset accumulator for this iteration |

**Block 4.1.1** — [CALL] Fetch Standard Customer Template (L780)

> Fetches the standard customer message template array from `workECK0011A010Array[i]` using the CBS message type `ECK0011A010CBSMsg.ECK0011A010CBSMSG1LIST`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkTenplates1 = getWorkData(ECK0011A010CBSMsg.ECK0011A010CBSMSG1LIST, workECK0011A010Array.get(i))` // [-> "お客様"] Standard customer templates |

**Block 4.1.2** — [CALL] Fetch Individual Customer Template (L783)

> Fetches the individual customer message template array from `workECK0021A010Array[i]` using the CBS message type `ECK0021A010CBSMsg.ECK0021A010CBSMSG1LIST`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkTenplates2 = getWorkData(ECK0021A010CBSMsg.ECK0021A010CBSMSG1LIST, workECK0021A010Array.get(i))` // [-> "お客様<個人>"] Individual customer templates |

**Block 4.1.3** — [IF] Null Guard on Both Template Arrays (L786)

> Ensures both standard and individual customer templates are available before attempting to merge. Both must be non-null.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `if (wkTenplates1 != null && wkTenplates2 != null)` |

**Block 4.1.3.1** — [FOR] Inner Loop over Template Pairs (L788)

> Iterates over each paired set of standard and individual customer templates, merging them record-by-record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childTemplate1 = wkTenplates1[j]` // Standard customer template at index j |
| 2 | SET | `childTemplate2 = wkTenplates2[j]` // Individual customer template at index j |

**Block 4.1.3.1.1** — [CALL] Merge Standard and Individual Customer Records (L790)

> Delegates to `editInMsgECK0021C010` to merge the standard customer record (`childTemplate1`) with the individual customer record (`childTemplate2`) into a unified list of `CAANMsg`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkCaanMsgList = editInMsgECK0021C010(param, childTemplate1, childTemplate2)` |

**Block 4.1.3.1.2** — [CALL] Apply Common Message Transformation (L791)

> Applies common transformation/validation on the first element of the merged list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `rslt = editInMsgCmn(param, wkCaanMsgList.get(0))` |

**Block 4.1.3.1.3** — [EXEC] Accumulate Merged Result (L792)

> Adds the transformed result to the working map array.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `wkMapArray.add(rslt)` |

**Block 4.2** — [EXEC] Store Final Merged Result (L795)

> Stores the accumulated merged result list under `MAP_KEY_ECK0021C010` in `rsltMemberStb`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `rsltMemberStb.put(MAP_KEY_ECK0021C010, wkMapArray)` // [-> MAP_KEY_ECK0021C010 = "ECK0021C010"] |

**Block 5** — [RETURN] Return Result (L798)

> Returns the result map. If the outer null guard was false, returns an empty `rsltMemberStb`; otherwise, returns the map containing the merged individual customer data.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return rsltMemberStb` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `rsltShokai` | Field | Inquiry result data — pre-fetched customer consent records retrieved by a prior `runShokai` (inquiry/registration data retrieval) operation |
| `shosaOkMapper` | Field | Service contract examination result mapping component — handles the actual field-level data merging between customer record types |
| `MAP_KEY_ECK0011A010` | Constant | Map key for standard customer consent data ("ECK0011A010") — represents customer consent records at the standard (non-individual) level |
| `MAP_KEY_ECK0021A010` | Constant | Map key for individual customer consent data ("ECK0021A010") — represents customer consent records for individual (person-level) customers |
| `MAP_KEY_ECK0021C010` | Constant | Map key for merged individual customer result output ("ECK0021C010") — the key under which final merged data is stored |
| `ECK0011A010CBSMSG1LIST` | Constant | CBS message type identifier for standard customer consent data list |
| `ECK0021A010CBSMSG1LIST` | Constant | CBS message type identifier for individual customer consent data list |
| `wkTenplates1` | Field | Standard customer message template array — contains field-level data structures for standard customer records |
| `wkTenplates2` | Field | Individual customer message template array — contains field-level data structures for individual customer records |
| `wkMapArray` | Field | Working map accumulator — collects merged result entries across iterations before final storage |
| `rsltMemberStb` | Field | Result member storage — the final output map returned by this method, keyed by `MAP_KEY_ECK0021C010` |
| CAANMsg | Type | Fujitsu internal message/DTO class used for carrying structured data between layers (message templates) |
| `IRequestParameterReadWrite` | Type | Request/Response parameter interface providing read-write access to request data and control maps |
| `editInMsgECK0021C010` | Method | Individual customer record merge service — merges a standard customer record with an individual customer record into a unified message list |
| `editInMsgCmn` | Method | Common message transformation service — applies standard transformation and validation to a merged CAANMsg record |
| `getWorkData` | Method | Work data retrieval utility — extracts data from a map by CBS message type key and returns a typed array of CAANMsg templates |
| 一致照会 (Ichishi Shokai) | Japanese term | Customer consent inquiry — a data retrieval process that checks and fetches customer consent records before modification |
| 個人 (Kojin) | Japanese term | Individual (person) — customer type designation for natural-person (as opposed to corporate/legal entity) customers |
| マッピング処理 (Mapping Shori) | Japanese term | Mapping processing — the data transformation and field alignment operation performed during customer record merging |
| updCustinfo | Method | Update customer information CBS — the calling CBS that orchestrates the full customer information update flow and invokes `editMapCustKojin` for individual customer record processing |
