# Business Logic — JKKKikiKaifukuWrisvcCC.editInMsg() [54 LOC]

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

## 1. Role

### JKKKikiKaifukuWrisvcCC.editInMsg()

The `editInMsg` method is an input-message builder for the Machine Provisioning Service Contract Recovery (機器提供サービス契約回復) batch workflow. It assembles a structured `HashMap` of business request parameters and i18n message templates that will be passed to the underlying Service Component (SC) invoker. Specifically, it extracts operational metadata from the inbound request parameter object — including telegram headers (transaction ID, use-case ID, operation ID, call type) and control map data (client hostname, client IP, screen ID, operator ID) — and packages them into `paramMap`. It then constructs a `CAANMsg` template from an internationalized message resource bundle (keyed by `svcIf`), populates the template with operator and timestamp fields, and iterates over the `mappingData` array to set each message field — calling `setNull` for empty values and `set` for populated ones. The built template is wrapped in an array and stored back into `paramMap` under `TEMPLATE_LIST_KEY`. This method serves as the shared input-preparation routine called by `callSC` before every service component invocation within the service contract recovery process, ensuring consistent parameter shaping and i18n message template construction across all CBS (Call By Service) service types.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editInMsg params"])
    STEP1["Create paramMap HashMap"]
    STEP2["Extract telegram header data from param"]
    STEP3["Extract control map data from param"]
    STEP4["Extract svcIf from mappingData[0][1]"]
    STEP5["Create CAANMsg template with i18n key"]
    STEP6["Set operator ID, date, datetime on template"]
    STEP7["i = 0, i < mappingData.length"]
    STEP8["i++"]
    STEP9{"mappingData[i][1] is empty?"}
    STEP10["template.setNull mappingData[i][0]"]
    STEP11["template.set mappingData[i][0] mappingData[i][1]"]
    STEP12["Wrap template in CAANMsg array"]
    STEP13["paramMap.put TEMPLATE_LIST_KEY with templates"]
    STEP14["Return paramMap"]

    START --> STEP1 --> STEP2 --> STEP3 --> STEP4 --> STEP5 --> STEP6 --> STEP7
    STEP7 --> STEP9
    STEP9 -->|true| STEP10
    STEP9 -->|false| STEP11
    STEP10 --> STEP8
    STEP11 --> STEP8
    STEP8 --> STEP7
    STEP7 -->|false| STEP12 --> STEP13 --> STEP14
```

**Step breakdown:**
1. **Create paramMap** — Instantiates a new `HashMap<String, Object>` as the output message envelope.
2. **Extract telegram header data** (【取得元：電文ヘッダ(ヘッダ)】) — Pulls four header fields from the inbound request: Transaction ID, Use-case ID, Operation ID, and Call Type.
3. **Extract control map data** (【取得元：ユーザエリア(コントローラマップ)】) — Pulls four control fields: Client Host Name, Client IP Address, Invoke Screen ID, and Operator ID from the control map.
4. **Extract svcIf** — Reads `mappingData[0][1]` to determine the service interface name (e.g., `EKK0081A010`, `EKK0341A010`, `EKK0021A010`).
5. **Create CAANMsg template** — Constructs a `CAANMsg` using an internationalized resource bundle key pattern `eo.ejb.cbs.cbsmsg.{svcIf}CBSMsg`.
6. **Set operator/timestamp data** — Sets operator ID, operation date, and operation datetime on the template.
7. **Iterate mappingData** — Loops over all rows of `mappingData`. For each row, checks if value is empty. If empty, calls `setNull`; otherwise calls `set` with the key-value pair.
8. **Wrap and store** — Wraps the single template in a `CAANMsg` array and stores it in `paramMap`.
9. **Return** — Returns the populated `paramMap`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The inbound request parameter object carrying operational metadata — telegram headers (transaction ID, use-case ID, operation ID, call type) and control map data (client hostname, client IP, screen ID, operator ID, operation date, operation time). Represents the full request context from the calling screen or batch entry point. |
| 2 | `mappingData` | `Object[][]` | A 2D mapping array where each row is `[fieldKey, fieldValue]`. Defines which fields to populate in the outgoing CBS message template. `mappingData[0][1]` carries the service interface name (`svcIf`) that determines the i18n message bundle. Other rows map CBS message field names to their values — empty values (`""`) trigger `setNull` to explicitly nullify fields in the template. |

**External state / instance fields read:** None. This method is entirely stateless with respect to instance fields.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `param.getTelegramID` | - | - | Retrieves the transaction ID from the inbound request |
| - | `param.getUsecaseID` | - | - | Retrieves the use-case ID from the inbound request |
| - | `param.getOperationID` | - | - | Retrieves the operation ID from the inbound request |
| - | `param.getCallType` | - | - | Retrieves the service call type discriminator |
| - | `param.getControlMapData(...)` | - | - | Retrieves control map fields (hostname, IP, screen ID, operator ID, date, time) |
| - | `new CAANMsg(...)` | - | - | Creates an i18n message template instance |
| - | `template.set(...)` | - | - | Sets a value into the message template |
| - | `template.setNull(...)` | - | - | Nullifies a field in the message template |
| - | `paramMap.put(...)` | - | - | Inserts key-value pairs into the output parameter map |

**Notes:** This method is purely a data-assembly layer — it does not perform any actual database CRUD operations. All calls are to parameter read methods, `CAANMsg` template manipulation, and `HashMap` population. The actual CBS invocations (which perform R/C/U/D against database entities) are handled by the caller `callSC()` which invokes the service component via `scCall.run(paramMap, handle)`.

## 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:EK0081A010 (Service Contract Recovery — Line Item Cancellation) | `JKKKikiKaifukuWrisvcCC.ekk0081a010cbsProcess` -> `callSC` -> `editInMsg` | `setNull` [-], `setNull` [-], `setNull` [-], `setNull` [-], `setNull` [-], `getCallType` [R] |
| 2 | CBS:EK0341A010 (Service Contract Recovery — Add Order Conditions) | `JKKKikiKaifukuWrisvcCC.ekk0341a010cbsProcess` -> `callSC` -> `editInMsg` | `setNull` [-], `setNull` [-], `setNull` [-], `setNull` [-], `setNull` [-], `getCallType` [R] |
| 3 | CBS:EK0021A010 (Service Contract Recovery — Registration) | `JKKKikiKaifukuWrisvcCC.ekk0021a010cbsProcess` -> `callSC` -> `editInMsg` | `setNull` [-], `setNull` [-], `setNull` [-], `setNull` [-], `setNull` [-], `getCallType` [R] |

**Caller analysis:** `editInMsg` is called exclusively from the private `callSC` method within `JKKKikiKaifukuWrisvcCC`. The `callSC` method is invoked by three CBS process methods: `ekk0081a010cbsProcess`, `ekk0341a010cbsProcess`, and `ekk0021a010cbsProcess`, each corresponding to a different service contract recovery service type. The terminal operations are all parameter reads (`getCallType`, `getTelegramID`, etc.) and template field setters (`setNull`, `set`) — no direct database operations originate from this method.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(paramMap initialization)` (L481)

The method begins by creating the output message envelope.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = new HashMap<String, Object>()` // Creates the output parameter map |

**Block 2** — [EXEC] `(Extract telegram header data)` (L484–L487)

Extracts four telegram header fields from the inbound request parameter. (【取得元：電文ヘッダ(ヘッダ)】—"Source: Telegram Header (Header)")

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put(JCMConstants.TRANZACTION_ID_KEY, param.getTelegramID())` // Transaction ID |
| 2 | SET | `paramMap.put(JCMConstants.USECASE_ID_KEY, param.getUsecaseID())` // Use-case ID |
| 3 | SET | `paramMap.put(JCMConstants.OPERATION_ID_KEY, param.getOperationID())` // Operation ID |
| 4 | SET | `paramMap.put(JCMConstants.CALL_TYPE_KEY, param.getCallType())` // Service call type discriminator |

**Block 3** — [EXEC] `(Extract control map data)` (L490–L497)

Extracts four control fields from the control map. (【取得元：ユーザエリア(コントローラマップ)】—"Source: User Area (Control Map)")

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put(JCMConstants.CLIENT_HOST_NAME_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTNAME))` // Client host name |
| 2 | SET | `paramMap.put(JCMConstants.CLIENT_IP_ADDRESS_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTIP))` // Client IP address |
| 3 | SET | `paramMap.put(JCMConstants.INVOKE_GAMEN_ID_KEY, param.getControlMapData(SCControlMapKeys.REQ_VIEWID))` // Invoke screen ID |
| 4 | SET | `paramMap.put(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` // Operator ID |

**Block 4** — [SET] `(Extract service interface name)` (L499)

Reads the service interface identifier from the first row of mappingData to determine which i18n message bundle to use.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcIf = (String) mappingData[0][1]` // Service interface name (e.g., "EKK0081A010") |

**Block 5** — [SET] `(Create CAANMsg template)` (L501)

Instantiates an internationalized message template using the bundle key pattern `eo.ejb.cbs.cbsmsg.{svcIf}CBSMsg`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template = new CAANMsg(String.format("eo.ejb.cbs.cbsmsg.%sCBSMsg", svcIf))` // i18n message template |

**Block 6** — [EXEC] `(Set operator/timestamp fields on template)` (L504–L508)

Populates the template with operator identity and operational timestamp data.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `template.set(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` // Operator ID |
| 2 | EXEC | `template.set(JCMConstants.OPERATE_DATE_KEY, param.getControlMapData(SCControlMapKeys.OPE_DATE))` // Operation date |
| 3 | EXEC | `template.set(JCMConstants.OPERATE_DATETIME_KEY, param.getControlMapData(SCControlMapKeys.OPE_TIME))` // Operation datetime |

**Block 7** — [FOR] `(Iterate mappingData to populate template fields)` (L510–L522)

Loops over all rows of `mappingData`. Each row `[fieldKey, fieldValue]` maps a CBS message field to its value. Empty values are handled specially.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` |
| 2 | SET | `i < mappingData.length` // Loop condition |
| 3 | SET | `i++` // Increment |

**Block 7.1** — [IF] `(mappingData[i][1] is empty string)` (L512)

Checks if the value at position `[i][1]` is an empty string. If so, the field should be explicitly nulled in the template.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `template.setNull((String) mappingData[i][0])` // Nullify field in template when value is empty |

**Block 7.2** — [ELSE] `(mappingData[i][1] has a value)` (L514–L517)

When the value is non-empty, set the key-value pair into the template.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `template.set((String) mappingData[i][0], mappingData[i][1])` // Set field key-value in template |

**Block 8** — [SET] `(Wrap template and store in paramMap)` (L524–L527)

Wraps the single `CAANMsg` template in an array and stores it in `paramMap` under `TEMPLATE_LIST_KEY`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = new CAANMsg[1]` // Create array container |
| 2 | SET | `templates[0] = template` // Populate with the built template |
| 3 | SET | `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` // Store template list |

**Block 9** — [RETURN] `(Return paramMap)` (L529)

Returns the fully assembled parameter map containing both header data and the message template.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return paramMap` // Output message envelope for SC invocation |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `param` | Field | Inbound request parameter object — carries all operational and control metadata for the service contract recovery request |
| `mappingData` | Field | 2D mapping array — maps CBS message field names to values; first row's second element is the service interface name |
| `svcIf` | Field | Service interface name — the CBS service code (e.g., EKK0081A010) identifying which service contract recovery type to execute |
| `paramMap` | Field | Output parameter map — the assembled message envelope passed to the SC invoker |
| `template` | Field | CAANMsg message template — an i18n message object that carries CBS request parameters with localized text |
| telegram header | Domain term |電文ヘッダ — The header section of a service component request containing transaction tracking metadata (transaction ID, use-case ID, operation ID, call type) |
| control map | Domain term |コントローラマップ — A key-value map within the request parameter holding runtime control data such as client hostname, IP address, screen ID, and operator identity |
| SCControlMapKeys | Acronym | Service Component Control Map Keys — constant class defining the keys used to access control map data |
| JCMConstants | Acronym | Java Common Module Constants — constant class defining standard keys for transaction ID, use-case ID, operation ID, call type, operator ID, template list, return code, and status |
| CAANMsg | Acronym | Fujitsu's message model class — a business object representing an i18n message that carries CBS request/response data with localized text support |
| JKKKikiKaifukuWrisvcCC | Acronym | K-Opticom Machine Provisioning Service Contract Recovery Web Service Common Component — the shared common component for service contract recovery batch processing |
| CBS | Acronym | Call By Service — a service component invocation pattern in the Futurity framework |
| i18n | Acronym | Internationalization — the mechanism of loading message templates from resource bundles (`eo.ejb.cbs.cbsmsg.{svcIf}CBSMsg`) |
| TRANZACTION_ID_KEY | Constant | Transaction ID key — uniquely identifies a transaction in the service component request |
| USECASE_ID_KEY | Constant | Use-case ID key — identifies the business use case being executed |
| OPERATION_ID_KEY | Constant | Operation ID key — identifies the specific operation within a use case |
| CALL_TYPE_KEY | Constant | Call type key — discriminator for the service call routing type |
| CLIENT_HOST_NAME_KEY | Constant | Client host name key — the hostname of the requesting client |
| CLIENT_IP_ADDRESS_KEY | Constant | Client IP address key — the IP address of the requesting client |
| INVOKE_GAMEN_ID_KEY | Constant | Invoke screen ID key — the screen/screen ID that triggered the request (gamen = 画面/screen in Japanese) |
| OPERATOR_ID_KEY | Constant | Operator ID key — the ID of the user/operator performing the operation |
| OPERATE_DATE_KEY | Constant | Operation date key — the business date for the operation |
| OPERATE_DATETIME_KEY | Constant | Operation datetime key — the full timestamp of the operation |
| TEMPLATE_LIST_KEY | Constant | Template list key — the map key under which the CAANMsg template array is stored |
| EKK0081A010 | Service type | Service Contract Recovery — Line Item Cancellation |
| EKK0341A010 | Service type | Service Contract Recovery — Add Order Conditions |
| EKK0021A010 | Service type | Service Contract Recovery — Registration |
