# Business Logic — JKKSvkeiShosaBaseCC.editMapGrp() [61 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKSvkeiShosaBaseCC` |
| Layer | CC/Common Component |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKSvkeiShosaBaseCC.editMapGrp()

This method performs the **group registration mapping processing** (グループ登録のマッピング処理) for customer group data within the service inspection/contract processing flow. It is responsible for transforming raw inquiry results into structured, screen-ready message maps for two distinct group-related entities: the customer inquiry (negotiation) records and the customer group setup status.

The method handles **two business scenarios** in sequence:
1. **Customer Inquiry Mapping** — If inquiry result data for ECK0011A010 (Customer Negotiation) exists, it iterates through all negotiation records, processes each through a message mapper (`editInMsgECK0111D010`) and a common message builder (`editInMsgCmn`), and aggregates the results.
2. **Family Member Group Setup Invalidation** — If the member type before the operation was a family member (individual `11` or corporation `21`), it retrieves the existing customer group setup number, invokes the group setup invalidation routine (`editInMsgECK0121C020`), and maps the result. This corresponds to the scenario where an existing family member's group settings must be deactivated during a membership type change.

The method implements a **data transformation/delegation pattern**: it receives pre-fetched inquiry results (`rsltShokai`), delegates message processing to dedicated mapper components (`shosaOkMapper`, `editInMsgCmn`), and returns structured `HashMap<String, Object>` results keyed by their respective message list identifiers. It acts as a shared utility within the service contract processing pipeline, called by `updCustinfo()` to assemble group-related mapping data before screen rendering.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editMapGrp()"])
    N1["Create rsltGrp HashMap"]
    N2["Get workECK0011A010Array from rsltShokai.get(MAP_KEY_ECK0011A010)"]
    N3["workECK0011A010Array != null?"]
    N4["Loop: for each element (i=0..size)"]
    N5["Create wkMapArray"]
    N6["getWorkData(ECK0011A010CBSMsg1LIST, element)"]
    N7["wkTenplates != null?"]
    N8["Loop: for each childTemplate (j=0..length)"]
    N9["shosaOkMapper.editInMsgECK0111D010(param, childTemplate)"]
    N10["editInMsgCmn(param, firstMsg)"]
    N11["Add result to wkMapArray"]
    N12["Put wkMapArray into rsltGrp with MAP_KEY_ECK0111D010"]
    N13["Check memberSbtCdBefore is FAMILY_HOJIN=21 or FAMILY_KOJIN=11?"]
    N14["Get workECK0121B020 from getWorkParentData()"]
    N15["Extract cust_grp_sette_no from first record"]
    N16["Create wkMapArray"]
    N17["shosaOkMapper.editInMsgECK0121C020(param, cust_grp_sette_no)"]
    N18["editInMsgCmn(param, firstMsg)"]
    N19["Add result to wkMapArray"]
    N20["Put wkMapArray into rsltGrp with MAP_KEY_ECK0121C020"]
    N21["Return rsltGrp"]

    START --> N1 --> N2 --> N3
    N3 -->|true| N4 --> N5 --> N6 --> N7
    N7 -->|true| N8 --> N9 --> N10 --> N11 --> N8
    N7 -->|false| N4
    N4 -->|end| N12
    N3 -->|false| N13
    N13 -->|true| N14 --> N15 --> N16 --> N17 --> N18 --> N19 --> N20 --> N21
    N13 -->|false| N21
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying model data and control maps for the current screen operation. It contains the business context needed by downstream mappers to build input messages (e.g., user session info, transaction state). |
| 2 | `userDataIndex` | `int` | The index within `param` that identifies which business data record to process. Used to scope lookups to the correct customer/service record in multi-record scenarios. |
| 3 | `rsltShokai` | `HashMap<String, Object>` | The inquiry result data map containing pre-fetched lookups from prior retrieval operations. Its contents (e.g., `MAP_KEY_ECK0011A010`, `MAP_KEY_ECK0121B020`) determine whether group mapping steps are executed. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `shosaOkMapper` | `JKKSvkeiShosaShosaOkMapperCC` | The inspection/processing OK mapper component that builds input messages for inquiry results (ECK0111D010 and ECK0121C020 processing). |
| `memberSbtCdBefore` | `String` | The member type code before the operation — indicates whether the customer was originally a family individual member (`11`) or family corporate member (`21`), used to decide if group setup invalidation is required. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `getWorkData` | JKKSvkeiShosaBaseCC | - | Retrieves work data (ECK0011A010CBSMsg templates) from the inquiry result, casting to CAANMsg array for iteration |
| CALL | `shosaOkMapper.editInMsgECK0111D010` | JKKSvkeiShosaShosaOkMapperCC | - | Maps each child template through the ECK0111D010 input message builder to create inquiry detail records |
| CALL | `editInMsgCmn` | JKKSvkeiShosaBaseCC | - | Common message builder that processes a single CAANMsg into a structured HashMap for screen consumption |
| R | `getWorkParentData` | JKKSvkeiShosaBaseCC | - | Retrieves customer group setup inquiry result data (ECK0121B020) from the inquiry result map for family member scenarios |
| CALL | `shosaOkMapper.editInMsgECK0121C020` | JKKSvkeiShosaShosaOkMapperCC | - | Invokes the customer group setup invalidation message builder using the extracted `cust_grp_sette_no` |
| CALL | `editInMsgCmn` | JKKSvkeiShosaBaseCC | - | Common message builder for the group setup invalidation result |

**CRUD classification rationale:**

- **R (Read)**: `getWorkData` and `getWorkParentData` are read operations that extract pre-fetched data from the `rsltShokai` map. They do not write to any persistent store.
- **CALL (Delegation)**: `editInMsgECK0111D010`, `editInMsgECK0121C020`, and `editInMsgCmn` are service component calls that build input message structures from the retrieved data. They are part of the mapping/delegation chain rather than direct database operations.

## 5. Dependency Trace

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

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

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

**Call chain:** The method is invoked by `updCustinfo()` within the same class `JKKSvkeiShosaBaseCC`. `updCustinfo()` is a customer information update processing method that coordinates the full lifecycle of updating customer service contracts. `editMapGrp()` is called to assemble group-related mapping data as part of that update flow.

**Terminal operations** (operations this method ultimately delegates to):
- `editInMsgCmn` [U] — Updates/builds input message structures
- `editInMsgECK0111D010` [U] — Builds inquiry detail input messages
- `editInMsgECK0121C020` [U] — Builds group setup invalidation input messages
- `getWorkData` [R] — Reads work data from inquiry results
- `getWorkParentData` [R] — Reads parent-level inquiry data for group setup

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Initialization (L1025)

> Initializes all local variables and result containers. This is a preparatory block that sets up working arrays and maps before any conditional logic.

| # | Type | Code |
|---|------|------|
| 1 | SET | `rsltGrp = new HashMap<String, Object>()` — Result group map to return |
| 2 | SET | `rslt = null` — Temporary result variable |
| 3 | SET | `wkCaanMsgList = null` — Working CAAN message list |
| 4 | SET | `wkMapArray = null` — Working map array for accumulated results |
| 5 | SET | `workECK0011A010Array = null` — Customer inquiry (negotiation) data array |

**Block 2** — [SET] Get Customer Inquiry Data (L1031)

> Retrieves the pre-fetched customer inquiry (negotiation) result array from `rsltShokai` using the map key `MAP_KEY_ECK0011A010 = "ECK0011A010"` [-> MAP_KEY_ECK0011A010="ECK0011A010" (JKKSvkeiShosaBaseCC.java:74)].

| # | Type | Code |
|---|------|------|
| 1 | SET | `workECK0011A010Array = (ArrayList)rsltShokai.get(MAP_KEY_ECK0011A010)` // Cast to ArrayList from inquiry result [-> MAP_KEY_ECK0011A010="ECK0011A010" (JKKSvkeiShosaBaseCC.java:74)] |

**Block 3** — [IF] Inquiry Result Not Null (L1033)

> If the customer inquiry (negotiation) data exists, iterates through all records to process them.

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

**Block 3.1** — [FOR] Iterate Over Inquiry Records (L1035)

> Loops through each inquiry record in the negotiation data array. For each record, it retrieves CAAN message templates and processes them.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (int i = 0; i < workECK0011A010Array.size(); i++)` (L1035) |

**Block 3.1.1** — [SET] Create Working Map Array (L1037)

> Creates a new `wkMapArray` per inquiry record to accumulate the processed message maps for that record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkMapArray = new ArrayList()` (L1037) |

**Block 3.1.2** — [SET] Retrieve Work Templates (L1038)

> Retrieves CAAN message templates for the current inquiry record by calling `getWorkData()` with the ECK0011A010CBSMsg message list identifier.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkTenplates = getWorkData(ECK0011A010CBSMsg.ECK0011A010CBSMSG1LIST, (Map)workECK0011A010Array.get(i))` // Get message templates for current record |

**Block 3.1.3** — [IF] Templates Not Null (L1040)

> If the retrieved templates are not null, iterates through each template to build input messages.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (wkTenplates != null)` (L1040) |

**Block 3.1.3.1** — [FOR] Iterate Over Templates (L1042)

> For each CAAN message template in the retrieved array, processes it through the mapper chain.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (int j = 0; j < wkTenplates.length; j++)` (L1042) |

**Block 3.1.3.1.1** — [SET] Extract Child Template (L1044)

> Extracts the individual child template at index `j` from the templates array.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childTemplate = wkTenplates[j]` (L1044) |

**Block 3.1.3.1.2** — [CALL] Map Inquiry Detail Message (L1045)

> Delegates to `shosaOkMapper.editInMsgECK0111D010()` to build input messages for this child template. This is the core mapping step that transforms a CAANMsg into screen-ready input data structures.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `wkCaanMsgList = shosaOkMapper.editInMsgECK0111D010(param, childTemplate)` (L1045) |

**Block 3.1.3.1.3** — [CALL] Common Message Build (L1046)

> Calls `editInMsgCmn()` to build a single structured result from the first message in the list. This is a shared method that applies common processing logic (field mapping, default values, validation).

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

**Block 3.1.3.1.4** — [SET] Accumulate Result (L1047)

> Adds the processed result map to the working array for this inquiry record.

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

**Block 3.1.4** — [SET] Store Processed Inquiry Data (L1051)

> After processing all records, stores the accumulated `wkMapArray` into the result group map under key `MAP_KEY_ECK0111D010 = "ECK0111D010"` [-> MAP_KEY_ECK0111D010="ECK0111D010" (JKKSvkeiShosaBaseCC.java:93)].

| # | Type | Code |
|---|------|------|
| 1 | SET | `rsltGrp.put(MAP_KEY_ECK0111D010, wkMapArray)` // Store mapped inquiry results [-> MAP_KEY_ECK0111D010="ECK0111D010" (JKKSvkeiShosaBaseCC.java:93)] |

**Block 4** — [IF] Family Member Group Setup Invalidation (L1057)

> Conditional branch for invalidating existing customer group setup when the member before the operation was a family member (individual or corporation). This corresponds to annotation `2012-09-24追加 ロット2追加案件 ANK-0024-05-00` (added as part of lot 2 enhancement ANK-0024-05-00).

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (JCKStrConst.CD00039_FAMILY_HOJIN.equals(memberSbtCdBefore) || JCKStrConst.CD00039_FAMILY_KOJIN.equals(memberSbtCdBefore))` (L1060) |

**Condition detail:**
- `CD00039_FAMILY_HOJIN = "21"` [-> CD00039_FAMILY_HOJIN="21" (JCKStrConst.java:253)] — Family member (corporation)
- `CD00039_FAMILY_KOJIN = "11"` [-> CD00039_FAMILY_KOJIN="11" (JCKStrConst.java:247)] — Family member (individual)
- Business meaning: If the member type before the operation was either a family individual or family corporation, the existing customer group setup must be invalidated.

**Block 4.1** — [SET] Initialize cust_grp_sette_no (L1062)

> Declares the variable to hold the customer group setup number, initialized to null.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cust_grp_sette_no = null` (L1062) |

**Block 4.2** — [SET] Retrieve Customer Group Setup Inquiry Result (L1066)

> Gets the customer group setup inquiry result data (ECK0121B020) from `rsltShokai` by calling `getWorkParentData()`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workECK0121B020 = getWorkParentData(ECK0121B020CBSMsg.ECK0121B020CBSMSG1LIST, rsltShokai, MAP_KEY_ECK0121B020)` // Get customer group setup inquiry results [-> MAP_KEY_ECK0121B020="ECK0121B020" (JKKSvkeiShosaBaseCC.java:97)] |

**Block 4.3** — [IF] Setup Inquiry Data Exists (L1067)

> If the customer group setup inquiry data exists (non-null and length > 0), extract the setup number.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (null != workECK0121B020 && 0 < workECK0121B020.length)` (L1067) |

**Block 4.3.1** — [SET] Extract Customer Group Setup Number (L1069)

> Extracts the customer group setup number from the first record of the inquiry result.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cust_grp_sette_no = workECK0121B020[0].getString(ECK0121B020CBSMsg1List.CUST_GRP_SETTE_NO)` (L1069) // "Customer group setup number" (お客様グループ設定番号) |

**Block 4.4** — [SET] Create Working Map Array (L1072)

> Creates a new `wkMapArray` for accumulating the group setup invalidation results.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wkMapArray = new ArrayList()` (L1072) |

**Block 4.5** — [CALL] Invalidating Customer Group Setup (L1073)

> Invokes `shosaOkMapper.editInMsgECK0121C020()` with the customer parameter and the extracted group setup number to build invalidation input messages. This is the core operation that processes the deactivation of the existing family member group setup.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `wkCaanMsgList = shosaOkMapper.editInMsgECK0121C020(param, cust_grp_sette_no)` (L1073) |

**Block 4.6** — [CALL] Common Message Build (L1074)

> Builds the common message structure for the first result from the invalidation processing.

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

**Block 4.7** — [SET] Accumulate Result (L1075)

> Adds the processed result to the working array.

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

**Block 4.8** — [SET] Store Group Invalidation Result (L1076)

> Stores the accumulated invalidation results into the result group map under key `MAP_KEY_ECK0121C020 = "ECK0121C020"` [-> MAP_KEY_ECK0121C020="ECK0121C020" (JKKSvkeiShosaBaseCC.java:100)].

| # | Type | Code |
|---|------|------|
| 1 | SET | `rsltGrp.put(MAP_KEY_ECK0121C020, wkMapArray)` // Store group setup invalidation results [-> MAP_KEY_ECK0121C020="ECK0121C020" (JKKSvkeiShosaBaseCC.java:100)] |

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

> Returns the assembled result group map containing all mapped group data.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return rsltGrp` (L1080) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `editMapGrp` | Method | Group registration mapping processing — builds structured data maps for customer group-related operations during service contract processing |
| `rsltShokai` | Parameter | Inquiry result data — pre-fetched lookup data from prior database/screen queries, used to drive conditional processing |
| `MAP_KEY_ECK0011A010` | Constant | Map key "ECK0011A010" — identifies customer inquiry (negotiation) data in the result map |
| `MAP_KEY_ECK0111D010` | Constant | Map key "ECK0111D010" — identifies processed inquiry detail mapping results |
| `MAP_KEY_ECK0121B020` | Constant | Map key "ECK0121B020" — identifies customer group setup inquiry data (PMP integration) in the result map |
| `MAP_KEY_ECK0121C020` | Constant | Map key "ECK0121C020" — identifies customer group setup invalidation mapping results |
| `memberSbtCdBefore` | Field | Member type code before operation — the membership classification of the customer prior to the current update |
| `CD00039_FAMILY_KOJIN` | Constant | Member type "11" — Family member (individual person / 個人) |
| `CD00039_FAMILY_HOJIN` | Constant | Member type "21" — Family member (corporation / 法人) |
| `cust_grp_sette_no` | Field | Customer group setup number (お客様グループ設定番号) — internal identifier for a customer's group configuration |
| `shosaOkMapper` | Instance Field | Inspection/processing OK mapper component — handles input message construction for inquiry results |
| `editInMsgCmn` | Method | Common message builder — shared method that applies standard field mapping and default value logic to build input message structures |
| `editInMsgECK0111D010` | Method | ECK0111D010 input message builder — maps child CAANMsg templates into structured inquiry detail records |
| `editInMsgECK0121C020` | Method | ECK0121C020 input message builder — processes customer group setup invalidation data |
| `getWorkData` | Method | Retrieves working data (CAANMsg templates) from a work data map, casting to array for iteration |
| `getWorkParentData` | Method | Retrieves parent-level working data from the inquiry result map, used for group setup inquiry results |
| CAANMsg | Technical | Customer Application ANalysis Message — Fujitsu's internal message format for structured business data exchange between components |
| ECK | Abbreviation | Entry Check — screen/data validation and mapping component naming convention (ECK prefix) |
| CBSMsg | Abbreviation | Call Back System Message — the CBS (Call Back System) message template format used throughout the platform |
| `updCustinfo` | Method | Update customer information — the parent method that coordinates the full customer data update flow, calling editMapGrp to assemble group mapping data |
| PMP | Abbreviation | Partner Management Platform — external partner system integration for customer group data (referenced in the comment "PMP連携用") |
| Group Setup Invalidation (グループ設定無効) | Business term | Process of deactivating an existing customer group setup, performed when a family member's type changes (e.g., from individual to non-family) |
| ANK-0024-05-00 | Change ticket | Enhancement ticket that added the family member group setup invalidation logic in Block 4 (lot 2 additions) |
