# Business Logic — JKKEmgRrksNmUpdCC.editInMsg() [63 LOC]

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

## 1. Role

### JKKEmgRrksNmUpdCC.editInMsg()

This method creates an inbound message payload (`HashMap<String, Object>`) that serves as the parameter map for invoking service component (SC) CBS (Common Business Service) procedures in the K-Opticom telecommunications customer management system. Its primary business responsibility is to assemble a structured message container that combines **request header metadata** (transaction ID, usecase ID, operation ID, call type) extracted from the incoming request parameter with **client control data** (client hostname, client IP address, invoke screen ID, operator ID) from the request's control map, and then wraps these into a **CAANMsg template resource bundle** that the service component expects on the inbound path.

The method implements the **builder pattern** — it constructs a `CAANMsg` template by loading a resource bundle keyed on the service interface name (e.g., `eo.ejb.cbs.cbsmsg.EKK0081B004CBSMsg`), populates it with operator and operational metadata, and then iterates over a `mappingData` 2D array to set each template field. Each mapping entry can be a scalar value, an empty string (which triggers a `setNull` on the template), or a `CAANMsg[]` array (which is set directly as a nested message list). Finally, the assembled template is wrapped in a single-element `CAANMsg[]` array and stored under the `TEMPLATE_LIST_KEY`.

As a **shared utility component**, `editInMsg` is called by the `callSC` private method within `JKKEmgRrksNmUpdCC` and by equivalent `editInMsg` methods in dozens of other mapping classes across check modules (e.g., `DKSV0141`, `CRSV0237`, `KKSV0495`). It acts as the **data transformer** between the generic `IRequestParameterReadWrite` request interface and the SC-specific `CAANMsg` message format, ensuring all inbound CBS calls carry the required header and control context.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editInMsg param mappingData"])
    START --> STEP1["Create paramMap HashMap"]
    STEP1 --> STEP2["Extract telegram header data"]
    STEP2 --> STEP2A["paramMap put TRANZACTION_ID_KEY"]
    STEP2 --> STEP2B["paramMap put USECASE_ID_KEY"]
    STEP2 --> STEP2C["paramMap put OPERATION_ID_KEY"]
    STEP2 --> STEP2D["paramMap put CALL_TYPE_KEY"]
    STEP2D --> STEP3["Extract controlled map data"]
    STEP3 --> STEP3A["paramMap put CLIENT_HOST_NAME_KEY"]
    STEP3 --> STEP3B["paramMap put CLIENT_IP_ADDRESS_KEY"]
    STEP3 --> STEP3C["paramMap put INVOKE_GAMEN_ID_KEY"]
    STEP3 --> STEP3D["paramMap put OPERATOR_ID_KEY"]
    STEP3D --> STEP4["Extract svcIf from mappingData 0 1"]
    STEP4 --> STEP5["Create CAANMsg template eo.ejb.cbs.cbsmsg svcIfCBSMsg"]
    STEP5 --> STEP6["Set template operator ID operate date operate datetime"]
    STEP6 --> STEP7["Loop mappingData length times"]
    STEP7 --> LOOP_COND{Loop continues?}
    LOOP_COND -->|Yes| STEP8["Get key mappingData i 0 and value mappingData i 1"]
    LOOP_COND -->|No| STEP10["Wrap template in CAANMsg array templates"]
    STEP8 --> COND2{value is CAANMsg array?}
    COND2 -->|Yes| STEP9A["template set key CAANMsg array value"]
    COND2 -->|No| COND3{value is empty string?}
    COND3 -->|Yes| STEP9B["template setNull key"]
    COND3 -->|No| STEP9C["template set key value"]
    STEP9A --> STEP7
    STEP9B --> STEP7
    STEP9C --> STEP7
    STEP10 --> STEP11["paramMap put TEMPLATE_LIST_KEY templates"]
    STEP11 --> STEP12["Return paramMap"]
    STEP12 --> END(["Next: callSC calls scCall.run paramMap handle"])
```

**Processing Steps Summary:**

1. **Step 1** — Create an empty `HashMap<String, Object>` named `paramMap` to serve as the inbound message container.
2. **Step 2** — Extract telegram header metadata from the `IRequestParameterReadWrite param`: transaction ID, usecase ID, operation ID, and call type. These are placed into `paramMap` under their respective `JCMConstants` keys.
3. **Step 3** — Extract client-side control data from `param.getControlMapData(...)` for hostname, IP address, screen ID, and operator ID. These provide the execution context for the service component call.
4. **Step 4** — Extract the service interface name (`svcIf`) from `mappingData[0][1]`. This value is used to construct the resource bundle path for the CAANMsg template (e.g., `eo.ejb.cbs.cbsmsg.EKK0081B004CBSMsg`).
5. **Step 5** — Instantiate a `CAANMsg` template by loading the resource bundle at path `eo.ejb.cbs.cbs.cbsmsg.{svcIf}CBSMsg`. This template carries the CBS message structure for the target service.
6. **Step 6** — Populate the template with operator ID, operate date, and operate datetime from the control map data. These are operational metadata required by the CBS procedure.
7. **Step 7** — Iterate over every row in `mappingData`. For each row, inspect the value type:
   - If it is a `CAANMsg[]` array: set it directly onto the template as a nested message list.
   - If it is an empty string: call `template.setNull(key)` to explicitly set the field as null.
   - Otherwise: set the scalar value onto the template.
8. **Step 8** — Wrap the single `CAANMsg` template in a `CAANMsg[]` array and store it in `paramMap` under `TEMPLATE_LIST_KEY`.
9. **Step 9** — Return `paramMap`. The caller (`callSC`) uses this map to invoke `scCall.run(paramMap, handle)`, which executes the actual service component.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The incoming request parameter object carrying both **telegram header metadata** (transaction ID, usecase ID, operation ID, call type) and **control map data** (client hostname, client IP, screen ID, operator ID, operation date/time). This object is the primary source of contextual information for building the inbound message. Its data determines the execution context for the downstream service component. |
| 2 | `mappingData` | `Object[][]` | A 2D array that defines the **field-to-value mapping** for the CAANMsg template. Each row is `[key, value]` where: `mappingData[0][1]` contains the service interface name (`svcIf`) used to load the resource bundle; subsequent rows contain template field keys and their values (which may be scalar objects, empty strings indicating null fields, or `CAANMsg[]` arrays for nested message lists). The mapping structure is specific to each CBS procedure and is generated by the corresponding mapper class. |

**External state / instance fields read:**
- None. This method is stateless — it reads exclusively from its parameters and creates all objects internally.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JCKMvnoCustInfoAddCC.setNull` | JCKMvnoCustInfoAddCC | - | Calls `setNull` in `JCKMvnoCustInfoAddCC` (called via `callSC` dispatch from `JKKEmgRrksNmUpdCC.execute`) |
| - | `JKKKapKeiInfoCancelCC.setNull` | JKKKapKeiInfoCancelCC | - | Calls `setNull` in `JKKKapKeiInfoCancelCC` (called via `callSC` dispatch) |
| - | `JKKKisnUwHmdkAddCC.setNull` | JKKKisnUwHmdkAddCC | - | Calls `setNull` in `JKKKisnUwHmdkAddCC` (called via `callSC` dispatch) |
| - | `JKKKojiChgPlaceNoCC.setNull` | JKKKojiChgPlaceNoCC | - | Calls `setNull` in `JKKKojiChgPlaceNoCC` (called via `callSC` dispatch) |
| - | `JKKMvnoSvcKeiStaAddCC.setNull` | JKKMvnoSvcKeiStaAddCC | - | Calls `setNull` in `JKKMvnoSvcKeiStaAddCC` (called via `callSC` dispatch) |
| R | `JKKejbCallTypeChecker.getCallType` | JKKejbCallTypeChecker | - | Calls `getCallType` in `JKKejbCallTypeChecker` (called via `callSC` dispatch) |

**Analysis of `editInMsg` direct operations:**

The `editInMsg` method itself does not directly perform any RUD (Read/Update/Delete) database operations. It is a **pure data assembly method** — its role is to construct the inbound `paramMap` that `callSC` then passes to the `ServiceComponentRequestInvoker.scCall.run()` method. The actual CRUD operations occur in the downstream service components.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `editInMsg` internal | - | - | Internal processing: assembles `paramMap` from request parameters and mapping data; no direct DB access |
| - | `CAANMsg.template.set()` | - | - | Sets template fields on the `CAANMsg` object (in-memory message population) |
| - | `CAANMsg.template.setNull()` | - | - | Explicitly nullifies template fields for empty-string mapping entries |
| R | `callSC` (downstream) | EKK0081B004SC | `KK_T_CUSTOMER`, `KK_T_CONTRACT` | Calls `callSC` internally — reads customer/contract data to create emergency notification message |
| R | `callSC` (downstream) | EKK0781A010SC | `KK_T_SERVICE_INFO` | Reads service information for FTTH auth registration emergency notification |
| R | `callSC` (downstream) | ECK0011A010SC | `KK_T_CUSTOMER_MAIN` | Reads customer master data for customer name/reading change emergency notification |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 26 methods.
Terminal operations from this method: `setNull` [-], `setNull` [-], `setNull` [-], `setNull` [-], `setNull` [-], `getCallType` [R]

This method is called **only internally** by the `callSC` method within `JKKEmgRrksNmUpdCC`. The `callSC` method is a private dispatcher that wraps the `editInMsg` result and invokes the service component via `scCall.run(paramMap, handle)`.

All `editInMsg` calls observed in the broader codebase belong to **equivalent-named methods** in different mapper classes (e.g., `dksv0141_dksv0141op_edk0091d010bsmapper.editInMsg(param)`, `kksv0495_kksv0495op_ekk0011d020bsmapper.editInMsg(param)`). These are **different methods** in different classes that follow the same pattern — they are not calling this specific `JKKEmgRrksNmUpdCC.editInMsg(Object[][])` method.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class:JKKEmgRrksNmUpdCC.callSC() | `JKKEmgRrksNmUpdCC.callSC` -> `JKKEmgRrksNmUpdCC.editInMsg` | `scCall.run(paramMap, handle)` -> downstream CBS |
| 2 | Screen:CKSV0009 | `CKSV0009OPOperation` -> `JKKEmgRrksNmUpdCC.execute` -> `callSC` -> `editInMsg` | `callSC` dispatches to EKK0081B004/EKK0781A010/etc. SC |
| 3 | Screen:CKSV0062 | `CKSV0062OPOperation` -> `JKKEmgRrksNmUpdCC` registration | `JKKEmgRrksNmUpdCC` registered as CC handler |
| 4 | Class:JCKCustAddBnktUpdCC | `JCKCustAddBnktUpdCC.execute` -> `JKKEmgRrksNmUpdCC.execute` -> `callSC` -> `editInMsg` | Customer addition business logic -> SC dispatch |
| 5 | Class:JCKKeishaChgOrsCC | `JCKKeishaChgOrsCC.execute` -> `JKKEmgRrksNmUpdCC.execute` -> `callSC` -> `editInMsg` | Keisha (owner) change service -> SC dispatch |
| 6 | Class:JKKAdInfChgCC | `JKKAdInfChgCC.execute` -> `JKKEmgRrksNmUpdCC.execute` -> `callSC` -> `editInMsg` | Address information change -> SC dispatch |

**Terminal operations from this method:**
- `scCall.run(paramMap, handle)` — invokes the target SC CBS procedure with the assembled paramMap
- `editErrorInfo` — called by `callSC` to process error information from the SC response

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `Create paramMap HashMap` (L801)

This block initializes the inbound message container.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = new HashMap<String, Object>()` // Initialize inbound message container |

**Block 2** — [SET] `Extract telegram header data` (L804-809)

Extracts header metadata from the request parameter's telegram fields. Japanese comment: `【取得元：電文ヘッダ(ヘッダ)】` (Source: Telegram Header).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.getTelegramID()` -> `paramMap.put(JCMConstants.TRANZACTION_ID_KEY, ...)` // Transaction ID [-> "transactionId"] |
| 2 | EXEC | `param.getUsecaseID()` -> `paramMap.put(JCMConstants.USECASE_ID_KEY, ...)` // Usecase ID [-> "usecaseId"] |
| 3 | EXEC | `param.getOperationID()` -> `paramMap.put(JCMConstants.OPERATION_ID_KEY, ...)` // Operation ID [-> "operationId"] |
| 4 | EXEC | `param.getCallType()` -> `paramMap.put(JCMConstants.CALL_TYPE_KEY, ...)` // Service call type dispatch key [-> "callType"] |

**Block 3** — [SET] `Extract controlled map data` (L812-817)

Extracts client-side control context from the request's control map. Japanese comment: `【取得元：ユーザエリア(コントロールマップ)】` (Source: User Area (Control Map)).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.getControlMapData(SCControlMapKeys.REQ_HOSTNAME)` -> `paramMap.put(JCMConstants.CLIENT_HOST_NAME_KEY, ...)` // Client host name [-> "clientHostName"] |
| 2 | EXEC | `param.getControlMapData(SCControlMapKeys.REQ_HOSTIP)` -> `paramMap.put(JCMConstants.CLIENT_IP_ADDRESS_KEY, ...)` // Client source IP address [-> "clientIpAddress"] |
| 3 | EXEC | `param.getControlMapData(SCControlMapKeys.REQ_VIEWID)` -> `paramMap.put(JCMConstants.INVOKE_GAMEN_ID_KEY, ...)` // Client invoking screen ID [-> "invokeGamenId"] |
| 4 | EXEC | `param.getControlMapData(SCControlMapKeys.OPERATOR_ID)` -> `paramMap.put(JCMConstants.OPERATOR_ID_KEY, ...)` // Operator ID [-> "operatorId"] |

**Block 4** — [SET] `Extract svcIf and create CAANMsg template` (L820-822)

Extracts the service interface name from `mappingData[0][1]` and loads the corresponding resource bundle for the CAANMsg template. Japanese comment: `サービスインターフェースID` (Service Interface ID).

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcIf = (String)mappingData[0][1]` // Service interface identifier [-> e.g., "EKK0081B004"] |
| 2 | SET | `template = new CAANMsg(String.format("eo.ejb.cbs.cbsmsg.%sCBSMsg", svcIf))` // Load resource bundle [-> "eo.ejb.cbs.cbsmsg.EKK0081B004CBSMsg"] |

**Block 5** — [EXEC] `Populate template metadata` (L825-829)

Sets operator and operational date/time fields on the CAANMsg template. Japanese comments: `オペレータID` (Operator ID), `運用日付` (Operate Date), `運用日時` (Operate Date/Time).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `template.set(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` // Set operator ID on template |
| 2 | EXEC | `template.set(JCMConstants.OPERATE_DATE_KEY, param.getControlMapData(SCControlMapKeys.OPE_DATE))` // Set operate date on template [-> "operateDate"] |
| 3 | EXEC | `template.set(JCMConstants.OPERATE_DATETIME_KEY, param.getControlMapData(SCControlMapKeys.OPE_TIME))` // Set operate datetime on template [-> "operateDatetime"] |

**Block 6** — [FOR] `Iterate over mappingData` (L831-847)

Iterates over each row of the `mappingData` 2D array to populate template fields. This is the core field-mapping logic.

**Block 6.1** — [FOR-CONDITION] `i < mappingData.length` (L831)

Loop continues while the index `i` is less than the length of `mappingData`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `key = (String)mappingData[i][0]` // Template field key from mappingData row [-> field name like "operatorId"] |
| 2 | SET | `value = mappingData[i][1]` // Template field value from mappingData row [-> any Object type] |

**Block 6.2** — [IF] `value instanceof CAANMsg[]` (L832)

Checks if the value is a nested `CAANMsg[]` array. If true, sets it directly as a message list. Japanese comment: none (implicit nested message handling).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `template.set((String)mappingData[i][0], (CAANMsg[])mappingData[i][1])` // Set nested CAANMsg array directly |

**Block 6.3** — [ELSE-IF] `value equals empty string` (L836)

Checks if the value is an empty string. If true, calls `setNull` to explicitly mark the field as null in the template. Japanese comment: none.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `template.setNull((String)mappingData[i][0])` // Explicitly nullify field in template [-> "setNull field"] |

**Block 6.4** — [ELSE] `set scalar value` (L840)

Sets the scalar value (non-array, non-empty-string) directly onto the template. Japanese comment: none.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `template.set((String)mappingData[i][0], mappingData[i][1])` // Set scalar value on template [-> "set field = value"] |

**Block 7** — [SET] `Wrap template in CAANMsg array` (L850-852)

Creates a single-element `CAANMsg[]` array containing the populated template and stores it under `TEMPLATE_LIST_KEY` in `paramMap`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = new CAANMsg[1]` // Create array of size 1 |
| 2 | SET | `templates[0] = template` // Assign populated template |
| 3 | SET | `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` // Store under template list key [-> "templateList"] |

**Block 8** — [RETURN] `Return paramMap` (L855)

Returns the assembled inbound message map to the caller (`callSC`), which then passes it to `scCall.run(paramMap, handle)` to execute the service component.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return paramMap` // Inbound message ready for SC dispatch |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `paramMap` | Variable | Inbound message container — a HashMap holding all key-value pairs that will be passed to the service component |
| `mappingData` | Parameter | Field-to-value mapping array — defines which template fields to populate and with what values; specific to each CBS procedure |
| `svcIf` | Variable | Service Interface identifier — the code (e.g., "EKK0081B004") used to locate the resource bundle for the CAANMsg template |
| `CAANMsg` | Class | Common message model — the canonical message format used across the K-Opticom system for CBS procedure communication |
| `TRANZACTION_ID_KEY` | Constant | Transaction ID key — the map key under which the request's transaction ID is stored (note: "TRANZACTION" uses "Z" per naming convention) |
| `USECASE_ID_KEY` | Constant | Usecase ID key — the map key for the logical usecase identifier |
| `OPERATION_ID_KEY` | Constant | Operation ID key — the map key for the business operation identifier |
| `CALL_TYPE_KEY` | Constant | Call type key — identifies the service call dispatch type for routing |
| `CLIENT_HOST_NAME_KEY` | Constant | Client hostname key — the map key for the originating application host name |
| `CLIENT_IP_ADDRESS_KEY` | Constant | Client IP address key — the map key for the originating client's IP address |
| `INVOKE_GAMEN_ID_KEY` | Constant | Invoke screen ID key — the map key for the originating screen (gamen = 画面/screen in Japanese) |
| `TEMPLATE_LIST_KEY` | Constant | Template list key — the map key under which the CAANMsg array is stored in the inbound paramMap |
| `OPERATOR_ID_KEY` | Constant | Operator ID key — identifies the human or system operator performing the action |
| `OPERATE_DATE_KEY` | Constant | Operate date key — the business date of the operation |
| `OPERATE_DATETIME_KEY` | Constant | Operate datetime key — the full timestamp of the operation |
| `REQ_HOSTNAME` | Constant | Request hostname — control map key for the client host name |
| `REQ_HOSTIP` | Constant | Request host IP — control map key for the client source IP |
| `REQ_VIEWID` | Constant | Request view ID — control map key for the originating screen ID |
| `OPE_DATE` | Constant | Operation date — control map key for the business operation date |
| `OPE_TIME` | Constant | Operation time — control map key for the operation timestamp |
| SC | Acronym | Service Component — a modular business service deployed as an EJB/enterprise bean |
| CBS | Acronym | Common Business Service — the service component invocation pattern used for cross-module business operations |
| CAANMsg | Acronym/Class | Common Application ANd Message — Fujitsu's enterprise message model for CBS procedure communication |
| JCMConstants | Class | Japan Call Message Constants — defines all map key constants for inbound/outbound message construction |
| IRequestParameterReadWrite | Interface | Request parameter interface — the contract for reading/writing request data including telegram headers and control maps |
| SCControlMapKeys | Class | Service Component Control Map Keys — defines keys for client-side control data in the request parameter |
| `callSC` | Method | Service Component Call Dispatcher — private method that wraps `editInMsg`, invokes the SC via `scCall.run()`, and handles error processing |
| `callType` | Field | Service call type — determines the dispatch/routing strategy for the service component invocation |
| `param.getTelegramID()` | Method Call | Extracts the unique transaction identifier from the request's telegram header |
| `param.getUsecaseID()` | Method Call | Extracts the usecase identifier for logical flow routing |
| `param.getOperationID()` | Method Call | Extracts the business operation identifier |
| `param.getCallType()` | Method Call | Extracts the service call type for routing dispatch |
| `param.getControlMapData(key)` | Method Call | Retrieves a value from the request's control map by key (hostname, IP, screen ID, operator, date, time) |
