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

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

## 1. Role

### JKKSvkeiShosaBaseCC.editMapCustHojin()

This method performs the **mapping and merging processing for customer information changes (Legal Entity / Hojin)**. In the K-Opticom customer management system, when a corporate customer's details are updated (such as name, address, contact information), the system must consolidate data from two parallel consent records — the individual customer consent (ECK0011A010) and the corporate customer consent (ECK0031A010) — into a single merged message set for the corporate change operation (ECK0031C010).

The method implements a **batch routing/dispatch pattern**: it iterates over paired consent result arrays (one array per customer record that was validated in the inquiry/consent stage), pairs up individual and corporate child templates by index, and then calls a specialized mapper to merge the two CAANMsg template sets into a unified corporate change message. Each merged message is then routed through a common message-editing pipeline (`editInMsgCmn`) that applies standard transformation, validation, and mapping logic.

This method serves as a **shared utility** within the service contract verification framework (`Svkei Shosa` = service investigation/verification). It is called by `updCustinfo()` during the customer information update flow, specifically when the update target is a legal entity (corporation) customer. The method bridges the consent inquiry stage results (which come back as separate individual and corporate data arrays) to the corporate change message preparation stage.

The method handles one service type: **corporate customer information update**. It does not branch by service category or product type — all processing paths lead to the same merge-and-map outcome. If no individual customer consent data is present, it returns an empty result map, allowing the calling method to handle the absence gracefully.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editMapCustHojin(param, rsltShokai)"])

    START --> INIT["Initialize: rsltMemberStb = new HashMap"]
    INIT --> GET_INDIVIDUAL["Get individual consent array: workECK0011A010Array from rsltShokai.get(MAP_KEY_ECK0011A010)"]
    GET_INDIVIDUAL --> GET_CORPORATE["Get corporate consent array: workECK0031A010Array from rsltShokai.get(MAP_KEY_ECK0031A010)"]

    GET_CORPORATE --> CHECK_INDIV{"workECK0011A010Array != null?"}

    CHECK_INDIV -->|No| PUT_EMPTY["Put empty wkMapArray into rsltMemberStb with key MAP_KEY_ECK0031C010"]
    CHECK_INDIV -->|Yes| LOOP_START["For loop: i = 0 to workECK0011A010Array.size()"]

    LOOP_START --> CREATE_WORKMAP["Create new wkMapArray = new ArrayList"]
    CREATE_WORKMAP --> GET_INDIVIDUAL_DATA["Get individual customer data: wkTenplates1 = getWorkData(ECK0011A010CBSMSG1LIST, workECK0011A010Array[i])"]
    GET_INDIVIDUAL_DATA --> GET_CORPORATE_DATA["Get corporate customer data: wkTenplates2 = getWorkData(ECK0031A010CBSMSG1LIST, workECK0031A010Array[i])"]
    GET_CORPORATE_DATA --> CHECK_BOTH{"wkTenplates1 != null && wkTenplates2 != null?"}

    CHECK_BOTH -->|No| NEXT_I["i++, loop back"]
    CHECK_BOTH -->|Yes| LOOP_J["For loop: j = 0 to wkTenplates1.length"]

    LOOP_J --> GET_CHILD1["Get individual child template: childTemplate1 = wkTenplates1[j]"]
    GET_CHILD1 --> GET_CHILD2["Get corporate child template: childTemplate2 = wkTenplates2[j]"]
    GET_CHILD2 --> MERGE_CONSENT["CALL: shosaOkMapper.editInMsgECK0031C010(param, childTemplate1, childTemplate2)"]
    MERGE_CONSENT --> PROCESS_COMMON["CALL: editInMsgCmn(param, wkCaanMsgList.get(0))"]
    PROCESS_COMMON --> ADD_TO_ARRAY["Add result to wkMapArray"]
    ADD_TO_ARRAY --> NEXT_J["j++, loop back"]

    NEXT_J --> CHECK_J_END{"j < wkTenplates1.length?"}
    CHECK_J_END -->|Yes| LOOP_J
    CHECK_J_END -->|No| NEXT_I_END["i++, loop back"]

    NEXT_I_END --> CHECK_I_END{"i < workECK0011A010Array.size()?"}
    CHECK_I_END -->|Yes| LOOP_START
    CHECK_I_END -->|No| PUT_RESULT["Put wkMapArray into rsltMemberStb with key MAP_KEY_ECK0031C010"]

    PUT_RESULT --> RETURN["Return rsltMemberStb"]
    PUT_EMPTY --> RETURN

    RETURN --> END(["end"])
```

**Processing Flow Summary:**

1. **Initialization**: Creates the result HashMap `rsltMemberStb` to hold the merged output.
2. **Retrieve Consent Arrays**: Extracts individual customer consent data (`MAP_KEY_ECK0011A010 = "ECK0011A010"`) and corporate customer consent data (`MAP_KEY_ECK0031A010 = "ECK0031A010"`) from the inquiry result map `rsltShokai`.
3. **Guard Check**: If individual consent array is null, skips all processing and returns an empty result map. This handles edge cases where no individual customer data exists.
4. **Outer Loop** (per customer record): Iterates over each paired set of individual/corporate consent data arrays, indexed by `i`.
5. **Per-Record Processing**: For each record, retrieves the individual customer templates and corporate customer templates using `getWorkData()` — a factory method that converts raw HashMap data into `CAANMsg` template arrays.
6. **Both-Data Guard**: Skips the current record if either individual or corporate template data is null, ensuring both data sources are present for merging.
7. **Inner Loop** (per child template pair): For each indexed pair of individual and corporate child templates, merges them into a unified corporate change message.
8. **Merge and Map**: Calls `shosaOkMapper.editInMsgECK0031C010()` to merge the individual and corporate templates, then passes the result through `editInMsgCmn()` for common message processing and transformation.
9. **Accumulate Results**: Each merged and processed result is added to `wkMapArray`.
10. **Store Result**: After all records are processed, the accumulated `wkMapArray` is stored in `rsltMemberStb` under `MAP_KEY_ECK0031C010 = "ECK0031C010"`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | Request parameter object carrying the customer update context, including session handle, operator information, and shared data needed by downstream message-editing methods. It provides read-write access to request-scoped parameters passed through the service layer. |
| 2 | `rsltShokai` | `HashMap<String, Object>` | Inquiry result data map populated by prior consent inquiry processing. Contains arrays of consent result data keyed by map constants (`ECK0011A010` for individual customer consent, `ECK0031A010` for corporate customer consent). Each entry maps to an `ArrayList<HashMap>` where each HashMap represents one customer record's consent data. |

**Fields/External State Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `shosaOkMapper` | `JKKSvkeiShosaShosaOkMapperCC` | Protected instance field holding the mapper component responsible for CAANMsg template merging operations. Injected or available through inheritance chain for performing template-level edit operations. |
| `MAP_KEY_ECK0011A010` | `String` (constant = `"ECK0011A010"`) | Key for retrieving individual customer consent inquiry results from `rsltShokai`. |
| `MAP_KEY_ECK0031A010` | `String` (constant = `"ECK0031A010"`) | Key for retrieving corporate customer consent inquiry results from `rsltShokai`. |
| `MAP_KEY_ECK0031C010` | `String` (constant = `"ECK0031C010"`) | Key under which the merged result array is stored in the return map. |

## 4. CRUD Operations / Called Services

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

No additional SC/CBS or entity data was found in the called methods beyond what the caller graph provides. The following table classifies the method calls identified in the source code:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `getWorkData` (in JKKSvkeiShosaBaseCC) | JKKSvkeiShosaBaseCC | - | Factory method that converts a HashMap entry from the consent inquiry result into a `CAANMsg` template array. Called twice per outer loop iteration — once for individual customer templates and once for corporate customer templates. |
| U | `shosaOkMapper.editInMsgECK0031C010` | JKKSvkeiShosaShosaOkMapperCC | - | Mapper method that merges individual customer CAANMsg template with corporate customer CAANMsg template into a unified corporate change message set. Returns a `List<CAANMsg>` containing the merged template(s). |
| U | `editInMsgCmn` (abstract, overridden in subclasses) | JKKSvkeiShosaBaseCC | - | Common message editing method that applies standard transformation, validation, and mapping logic to a single merged CAANMsg. Returns a `HashMap<String, Object>` with the processed message data. Called on the first element of the merged list. |

**CRUD Classification Rationale:**

- **`getWorkData`** → **R (Read)**: It reads raw HashMap data from the consent inquiry result and transforms it into structured `CAANMsg` template objects. This is a data retrieval/conversion operation.
- **`shosaOkMapper.editInMsgECK0031C010`** → **U (Update)**: The `editInMsg` naming pattern and the merge semantics (combining individual + corporate data into a single change message) indicate an update/merge operation on the message structure.
- **`editInMsgCmn`** → **U (Update)**: The common message editing method applies standard processing rules to transform the merged message. The `editInMsg` prefix and its role in the message processing pipeline confirm update semantics.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `editInMsgCmn` [U], `editInMsgECK0031C010` [U], `getWorkData` [R], `getWorkData` [R]

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

**Caller Details:**

- **`JKKSvkeiShosaBaseCC.updCustinfo()`** — This is a business component method within the same class (`JKKSvkeiShosaBaseCC`) that handles the customer information update flow. It invokes `editMapCustHojin()` after consent inquiry processing is complete and before final customer record persistence. The method is called specifically for corporate (Hojin) customer update operations.

## 6. Per-Branch Detail Blocks

**Block 1** — [INITIALIZATION] (L818)

Variable declarations and result map setup.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `rsltMemberStb = new HashMap<String, Object>()` | Create the return result map to accumulate merged corporate change messages [-> MAP_KEY_ECK0031C010] |
| 2 | SET | `rslt = null` | Local result variable, initialized to null |
| 3 | SET | `wkCaanMsgList = null` | Local list to hold merged CAANMsg templates [-> temporary storage for editInMsgECK0031C010 return] |
| 4 | SET | `wkMapArray = null` | Local array list to accumulate per-record processed results |
| 5 | SET | `workECK0011A010Array = null` | Variable for individual customer consent data [-> "お客様一意照会" (Individual Customer Inquiry)] |
| 6 | SET | `workECK0031A010Array = null` | Variable for corporate customer consent data [-> "お客様個人一意照会" (Corporate Customer Individual Inquiry)] |

**Block 2** — [DATA RETRIEVAL] (L823-L826)

Retrieve consent arrays from the inquiry result map.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `workECK0011A010Array = (ArrayList)rsltShokai.get(MAP_KEY_ECK0011A010)` | Retrieve individual customer consent result array [-> "同意照会の結果データを取得" (Get consent inquiry result data)] |
| 2 | EXEC | `workECK0031A010Array = (ArrayList)rsltShokai.get(MAP_KEY_ECK0031A010)` | Retrieve corporate customer consent result array [-> "同意照会(法人)の結果データを取得" (Get corporate customer consent result data)] |

**Block 3** — [GUARD CHECK: Individual Consent Null] (L828)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `if (workECK0011A010Array != null)` | Guard: skip all processing if no individual customer consent data exists. The entire loop body is conditional on this check. |

**Block 3.1** — [OUTER FOR LOOP: Per Customer Record] `(i = 0; i < workECK0011A010Array.size(); i++)` (L830)

Iterate over each customer record's consent data pair.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `wkMapArray = new ArrayList()` | Create fresh result accumulator for this record's processed messages |
| 2 | CALL | `wkTenplates1 = getWorkData(ECK0011A010CBSMsg.ECK0011A010CBSMSG1LIST, (Map)workECK0011A010Array.get(i))` | Retrieve individual customer template array from consent data [-> "お客様" (Customer)] |
| 3 | CALL | `wkTenplates2 = getWorkData(ECK0031A010CBSMsg.ECK0031A010CBSMSG1LIST, (Map)workECK0031A010Array.get(i))` | Retrieve corporate customer template array from consent data [-> "お客様<法人>" (Customer <Legal Entity>)] |

**Block 3.1.1** — [GUARD CHECK: Both Templates Present] `(wkTenplates1 != null && wkTenplates2 != null)` (L838)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | IF | `if (wkTenplates1 != null && wkTenplates2 != null)` | Guard: both individual and corporate template data must be non-null to proceed with merging. Skip this record if either is null. |

**Block 3.1.1.1** — [INNER FOR LOOP: Per Child Template Pair] `(j = 0; j < wkTenplates1.length; j++)` (L839)

Iterate over each pair of individual and corporate child templates within the current customer record.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `childTemplate1 = wkTenplates1[j]` | Get individual customer child template at index j [-> first element of merged pair] |
| 2 | SET | `childTemplate2 = wkTenplates2[j]` | Get corporate customer child template at index j [-> second element of merged pair] |
| 3 | CALL | `wkCaanMsgList = shosaOkMapper.editInMsgECK0031C010(param, childTemplate1, childTemplate2)` | Merge individual + corporate templates into unified corporate change message set. Returns List<CAANMsg>. [-> Merges customer data from both consent types into the corporate change format] |
| 4 | CALL | `rslt = editInMsgCmn(param, wkCaanMsgList.get(0))` | Apply common message processing to the first merged template. Returns HashMap with processed result data. |
| 5 | EXEC | `wkMapArray.add(rslt)` | Accumulate the processed result into this record's result array. |

**Block 4** — [STORE RESULT] (L861)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `rsltMemberStb.put(MAP_KEY_ECK0031C010, wkMapArray)` | Store the accumulated merged result array in the return map under key "ECK0031C010" [-> "お客様<法人>内容変更" (Customer <Legal Entity> Content Change)] |

**Block 5** — [RETURN] (L863)

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return rsltMemberStb` | Return the result map containing the merged corporate customer change messages. If no individual consent data was present, returns an empty HashMap. |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `MAP_KEY_ECK0011A010` | Constant | "Individual Customer Inquiry" — map key for retrieving individual customer (personal) consent inquiry results. Value: `"ECK0011A010"` |
| `MAP_KEY_ECK0031A010` | Constant | "Corporate Customer Inquiry" — map key for retrieving corporate customer (legal entity) consent inquiry results. Value: `"ECK0031A010"` |
| `MAP_KEY_ECK0031C010` | Constant | "Corporate Customer Change" — map key for storing the merged corporate customer change result. Value: `"ECK0031C010"` |
| `rsltShokai` | Field | Inquiry result map — contains the output from the consent inquiry (shokai) stage, holding arrays of individual and corporate customer consent data |
| `shosaOkMapper` | Field | Verification OK mapper component — a `JKKSvkeiShosaShosaOkMapperCC` instance that performs template-level merge and edit operations |
| `wkCaanMsgList` | Field | Working CAANMsg list — temporary storage for the list of merged CAANMsg templates returned by the mapper |
| `wkMapArray` | Field | Working map array — accumulator for processed result HashMaps, one per child template pair |
| `workECK0011A010Array` | Field | Individual customer consent array — ArrayList of HashMap entries from individual customer consent inquiry |
| `workECK0031A010Array` | Field | Corporate customer consent array — ArrayList of HashMap entries from corporate customer consent inquiry |
| `childTemplate1` | Local | Individual customer child template — a single `CAANMsg` object representing individual customer data within a consent inquiry result |
| `childTemplate2` | Local | Corporate customer child template — a single `CAANMsg` object representing corporate customer data within a consent inquiry result |
| CAANMsg | Type | Customer Approval/Agreement Notification Message — Fujitsu's messaging framework class used to carry structured business data between service components. Contains typed fields for each business attribute. |
| ECK0011A010 | SC Code | Individual Customer Inquiry Service — CBS (Code Base System) for individual customer consent inquiry |
| ECK0011A010CBSMSG1LIST | CBS Message | Individual customer inquiry message list — CAANMsg list type for individual customer data |
| ECK0021A010 | SC Code | Individual Customer Inquiry (Alternative) — CBS for individual customer data inquiry |
| ECK0031A010 | SC Code | Corporate Customer Inquiry Service — CBS (Code Base System) for corporate (legal entity) customer consent inquiry |
| ECK0031A010CBSMsg | CBS Message | Corporate customer inquiry message class — defines the field schema for corporate customer inquiry data |
| ECK0031C010 | SC Code | Corporate Customer Change Service — CBS (Code Base System) for corporate customer information change/update |
| EKK0081B519CBSMsg | CBS Message | Additional service-related message schema (imported but not used by this method directly) |
| Svkei Shosa | Business term | Service Investigation / Service Verification — the business process of verifying and processing service contract data. "Svkei" = service (services), "Shosa" = investigation/verification. |
| Hojin | Japanese term | Legal Entity / Corporation — in the customer management system, distinguishes corporate (法人/Hojin) customers from individual (個人/Kojin) customers. Customer data, consent records, and CBS codes are partitioned by this distinction. |
| Itchi Shokai | Japanese term | Unique Inquiry / Single Record Inquiry — the consent inquiry process that retrieves the single matching customer record for a given identifier. "Itchi" = unique/single, "Shokai" = inquiry. |
| editInMsg | Method prefix | Edit Input Message — naming convention for message-editing mapper methods that transform, merge, or prepare CAANMsg templates for downstream processing |
| getWorkData | Method | Work Data Factory — a method in `JKKSvkeiShosaBaseCC` that converts a HashMap entry into a `CAANMsg` template array for processing |
| `IRequestParameterReadWrite` | Interface | Request Parameter Read-Write Interface — the contract for request parameter objects that provide mutable access to request-scoped data in the X21 BPM framework |
|updCustinfo| Method | Update Customer Information — the caller method in `JKKSvkeiShosaBaseCC` that orchestrates the customer information update flow |
