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

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

## 1. Role

### JKKCourseRkRtrNsIdChgCC.editInMsg()

This method acts as a **message-in preparation utility** that assembles inbound CAANMsg (Common Application Architecture Network Message) objects for service component (SC) invocations in the K-Opticom customer base system (eo Customer Base System). It implements a **builder** design pattern, constructing a message template with standardized operational metadata (transaction ID, use case ID, operator ID, operate date/time) extracted from the request parameter object, and then enriching it with field-level data from a two-dimensional mapping array. The mapping array drives the content population: each row maps a target field name to a source value, and empty target values are handled by invoking `setNull` rather than `set` on the template.

The method is a shared utility, callable from various mapper classes throughout the codebase (e.g., screen mappers like `DKSV0141OPBPCheck`, `CRSV0237OPBPCheck`, `KKSV0495OPBPCheck`, and others). It serves as a common entry point for preparing the inbound message before it is passed to a service component via `callSC()`. The method operates generically — it accepts a service interface name (`svcIf`) derived from `mappingData` to dynamically construct the CAANMsg class name, making it reusable across multiple CBS (CBS = Common Business Service) message types without modification.

In the larger system, this method bridges the gap between screen-level request parameters and the service component invocation layer. It transforms HTTP-level request data (host, IP, screen ID, operator) into the structured `CAANMsg` format expected by Fujitsu's CBS messaging framework, ensuring that operational audit fields (operator, date, datetime) are always populated alongside business field data.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editInMsg(param, mappingData)"])
    
    START --> CREATE["Create paramMap HashMap"]
    
    CREATE --> TRANZACTION["【Source: Telegram (Header)】
Extract transaction-level fields
Put TRANZACTION_ID_KEY from param.getTelegramID()
Put USECASE_ID_KEY from param.getUsecaseID()
Put OPERATION_ID_KEY from param.getOperationID()
Put CALL_TYPE_KEY from param.getCallType()"]
    
    TRANZACTION --> CLIENT["【Source: User Area (Control Map)】
Extract client-level fields
Put CLIENT_HOST_NAME_KEY from param.getControlMapData(REQ_HOSTNAME)
Put CLIENT_IP_ADDRESS_KEY from param.getControlMapData(REQ_HOSTIP)
Put INVOKE_GAMEN_ID_KEY from param.getControlMapData(REQ_VIEWID)
Put OPERATOR_ID_KEY from param.getControlMapData(OPERATOR_ID)"]
    
    CLIENT --> EXTRACT["Extract svcIf = mappingData[0][1]
(Service interface name)"]
    
    EXTRACT --> TEMPLATE["Create CAANMsg template
Class name = eo.ejb.cbs.cbsmsg.{svcIf}CBSMsg"]
    
    TEMPLATE --> SETHEADER["Set template header fields
Set OPERATOR_ID_KEY from control map
Set OPERATE_DATE_KEY from control map
Set OPERATE_DATETIME_KEY from control map"]
    
    SETHEADER --> LOOP_START{"For each row i in mappingData"}
    
    LOOP_START --> LOOP_BODY{"mappingData[i][1] is empty?"}
    
    LOOP_BODY --> EMPTY["template.setNull(mappingData[i][0])
Set field to null"]
    
    LOOP_BODY --> NOTEMPTY["template.set(mappingData[i][0], mappingData[i][1])
Set field to mapped value"]
    
    EMPTY --> LOOP_NEXT
    NOTEMPTY --> LOOP_NEXT
    LOOP_NEXT["i++"]
    LOOP_NEXT --> LOOP_CHECK{Continue loop?}
    LOOP_CHECK --> true["Yes"]
    LOOP_CHECK --> false["No"]
    true --> LOOP_BODY
    false --> ARRANGE["Arrange CAANMsg[] array
templates[0] = template"]
    
    ARRANGE --> PUTTEMPLATE["Put TEMPLATE_LIST_KEY
with templates array into paramMap"]
    
    PUTTEMPLATE --> RETURN["Return paramMap"]
    
    RETURN --> END(["Return HashMap"])
```

**Processing summary:** The method follows a linear flow: (1) create a parameter map, (2) populate it with transaction-level metadata from the request object, (3) populate it with client-level control map data, (4) extract the service interface name from `mappingData[0][1]`, (5) construct a `CAANMsg` template with the class name derived from the interface name, (6) set header fields on the template, (7) iterate over the mapping data rows, setting each field to either a value or null depending on whether the target column is empty, (8) wrap the template in an array, and (9) return the assembled parameter map containing both metadata and the template list.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying the full inbound request context. It provides access to transaction-level identifiers (telegram ID, use case ID, operation ID, call type) and a control map containing client-side metadata such as hostname, IP address, screen ID, and operator ID. This object represents the entire HTTP request envelope and is the primary source of audit/trace data. |
| 2 | `mappingData` | `Object[][]` | A two-dimensional mapping array where each row represents a target field in the CBS message. `mappingData[0][1]` contains the service interface name used to dynamically construct the CAANMsg class name. Subsequent rows contain `[fieldName, fieldValue]` pairs — the first column is the target field name in the message, and the second column is the source value. If the value column is an empty string, the field is set to null; otherwise, it receives the mapped value. |

**External state / instance fields read:** None. This method is entirely stateless and depends only on its parameters.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKCourseRkRtrNsIdChgCC.editInMsg.param.getTelegramID` | - | - | Reads telegram ID from request parameter (no DB access) |
| - | `JKKCourseRkRtrNsIdChgCC.editInMsg.param.getUsecaseID` | - | - | Reads use case ID from request parameter (no DB access) |
| - | `JKKCourseRkRtrNsIdChgCC.editInMsg.param.getOperationID` | - | - | Reads operation ID from request parameter (no DB access) |
| - | `JKKCourseRkRtrNsIdChgCC.editInMsg.param.getCallType` | - | - | Reads call type from request parameter (no DB access) |
| - | `JKKCourseRkRtrNsIdChgCC.editInMsg.param.getControlMapData` | - | - | Reads client control map data (hostname, IP, screen ID, operator ID, operate date, operate time) from request parameter (no DB access) |
| C | `CAANMsg` constructor | - | - | Creates a new CAANMsg template object with the dynamically constructed CBS message class name (e.g., `eo.ejb.cbs.cbsmsg.EKK0161B004CBSMsg`) |
| U | `CAANMsg.set` | - | - | Sets field values on the CAANMsg template for operator ID, operate date, operate datetime, and each field from the mapping data |
| U | `CAANMsg.setNull` | - | - | Sets fields to null on the CAANMsg template when the mapped value is an empty string |

**Classification rationale:** This method performs no database operations (CRUD against tables). It is purely a **message construction** method that creates and configures `CAANMsg` objects in memory. All data is sourced from the request parameter object and the mapping array, both of which are passed-in values. The only data manipulation is setting and potentially nullifying fields on the `CAANMsg` template.

## 5. Dependency Trace

### Direct Callers:

The pre-computed code graph identifies `JKKCourseRkRtrNsIdChgCC.callSC()` as a direct caller. However, searching the broader codebase reveals that `editInMsg` is actually a widely-used utility method invoked by numerous screen mapper classes across the system. The following table lists the key callers identified in the codebase.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Mapper: DKSV0141 | `DKSV0141_DKSV0141OPBPCheck` -> `editInMsg(param)` | No DB access (message builder) |
| 2 | Mapper: CRSV0237 | `CRSV0237_CRSV0237OPBPCheck` -> `editInMsg(param)` (×2 calls) | No DB access (message builder) |
| 3 | Mapper: CRSV0197 | `CRSV0197_CRSV0197OPBPCheck` -> `editInMsg(param)` | No DB access (message builder) |
| 4 | Mapper: KKSV0495 | `KKSV0495_KKSV0495OPBPCheck` -> `editInMsg(param)` (×8 calls) | No DB access (message builder) |
| 5 | Mapper: ZMSV0105 | `ZMSV0105_ZMSV0105OPBPCheck` -> `editInMsg(param)` | No DB access (message builder) |
| 6 | Mapper: CRSV0124 | `CRSV0124_CRSV0124OPBPCheck` -> `editInMsg(param)` (×2 calls) | No DB access (message builder) |
| 7 | Mapper: CHSV9001 | `CHSV9001_CHSV9001OPBPCheck` -> `editInMsg(param)` | No DB access (message builder) |
| 8 | Mapper: KKSV0557 | `KKSV0557_KKSV0557OPBPCheck` -> `editInMsg(param)` | No DB access (message builder) |
| 9 | Mapper: CRSV0101 | `CRSV0101_CRSV0101OPBPCheck` -> `editInMsg(param)` | No DB access (message builder) |
| 10 | Mapper: ZMSV0076 | `ZMSV0076_ZMSV0076OPBPCheck` -> `editInMsg(param)` (×2 calls) | No DB access (message builder) |
| 11 | CBS: EKK0161B004CBS | `callSC` in `JKKCourseRkRtrNsIdChgCC` -> `editInMsg` -> `callSC(handle, scCall, param, fixedText, ekk0161b004InMsg)` | CBS invocation (no direct DB in this method) |

**Terminal operations from this method:** All terminal operations are `CAANMsg.set` / `CAANMsg.setNull` — these configure in-memory message objects. The actual DB operations occur in the downstream CBS (Common Business Service) components that receive and process the CAANMsg, not within this method itself.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(paramMap creation) (L601)`

Initialize the return parameter map.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `paramMap = new HashMap<String, Object>()` | Create empty HashMap to hold assembled parameters |

**Block 2** — [EXEC - Telegram Header Extraction] `【Source: Telegram (Header)】 (L603–L608)`

Extract transaction-level identifiers from the request parameter. These fields provide traceability and audit capability for each request in the system.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `paramMap.put(JCMConstants.TRANZACTION_ID_KEY, param.getTelegramID())` | [-> TRANZACTION_ID_KEY="TRANZACTION_ID"] Put transaction ID from telegram header |
| 2 | SET | `paramMap.put(JCMConstants.USECASE_ID_KEY, param.getUsecaseID())` | [-> USECASE_ID_KEY="USECASE_ID"] Put use case ID (identifies the business use case) |
| 3 | SET | `paramMap.put(JCMConstants.OPERATION_ID_KEY, param.getOperationID())` | [-> OPERATION_ID_KEY="OPERATION_ID"] Put operation ID for audit tracing |
| 4 | SET | `paramMap.put(JCMConstants.CALL_TYPE_KEY, param.getCallType())` | [-> CALL_TYPE_KEY="CALL_TYPE"] Put service call type classification |

**Block 3** — [EXEC - Control Map Extraction] `【Source: User Area (Control Map)】 (L610–L615)`

Extract client-side control map data containing the request origin and operator context. The original comment translates to "Source: User Area (Control Map)".

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `paramMap.put(JCMConstants.CLIENT_HOST_NAME_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTNAME))` | [-> REQ_HOSTNAME] Put client hostname — identifies which application server handled the request |
| 2 | SET | `paramMap.put(JCMConstants.CLIENT_IP_ADDRESS_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTIP))` | [-> REQ_HOSTIP] Put client IP address — network origin of the request |
| 3 | SET | `paramMap.put(JCMConstants.INVOKE_GAMEN_ID_KEY, param.getControlMapData(SCControlMapKeys.REQ_VIEWID))` | [-> REQ_VIEWID] Put invoked screen ID (Gamens = screen pages in Japanese) |
| 4 | SET | `paramMap.put(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` | [-> OPERATOR_ID] Put operator ID — identifies the user performing the operation |

**Block 4** — [SET] `svcIf extraction (L617)`

Extract the service interface name from the first row of the mapping data. This drives dynamic CAANMsg class construction.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `svcIf = (String)mappingData[0][1]` | Cast and extract service interface name — the first row of mappingData carries the CBS interface name (e.g., "EKK0161B004") |

**Block 5** — [EXEC - Template Construction] `CAANMsg creation (L619)`

Create the CAANMsg template using dynamic class name resolution.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `template = new CAANMsg(String.format("eo.ejb.cbs.cbsmsg.%sCBSMsg", svcIf))` | Create CAANMsg template; class name follows pattern `eo.ejb.cbs.cbsmsg.{svcIf}CBSMsg` (e.g., `eo.ejb.cbs.cbsmsg.EKK0161B004CBSMsg`) |

**Block 6** — [EXEC - Template Header Setup] `(L621–L625)`

Set the header fields on the CAANMsg template. The original comments translate to: Operator ID, Operate date, Operate datetime.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `template.set(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` | Set operator ID on template (same source as Block 3, Row 4) |
| 2 | EXEC | `template.set(JCMConstants.OPERATE_DATE_KEY, param.getControlMapData(SCControlMapKeys.OPE_DATE))` | [-> OPE_DATE] Set operate date from control map |
| 3 | EXEC | `template.set(JCMConstants.OPERATE_DATETIME_KEY, param.getControlMapData(SCControlMapKeys.OPE_TIME))` | [-> OPE_TIME] Set operate datetime from control map |

**Block 7** — [WHILE LOOP] `mappingData iteration (L627–L635)`

Iterate over all rows in the mapping data array. Each row maps a target field name to a source value. If the source value is an empty string, the field is set to null; otherwise, it receives the mapped value. This loop populates all business-level fields of the CAANMsg template.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `i = 0; i < mappingData.length; i++` | Iterate over each row of the mapping data array |

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

Check whether the target field value is an empty string. This determines whether the field should be set to a value or explicitly nullified.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `template.setNull((String)mappingData[i][0])` | Set the field to null — the target value is empty, indicating an optional field that should not carry a blank value |

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

Set the field with the actual mapped value.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | EXEC | `template.set((String)mappingData[i][0], mappingData[i][1])` | Set the field with the mapped value — the first column is the target field name, the second is the source value |

**Block 8** — [SET - Template Array Arrangement] `(L637–L639)`

Wrap the single template in a CAANMsg array and attach it to the parameter map.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `templates = new CAANMsg[1]` | Create a CAANMsg array with capacity 1 |
| 2 | SET | `templates[0] = template` | Assign the constructed template to the array |
| 3 | SET | `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` | [-> TEMPLATE_LIST_KEY="TEMPLATE_LIST"] Attach the template array to the parameter map under the template list key |

**Block 9** — [RETURN] `(L641)`

Return the fully assembled parameter map.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return paramMap` | Return the parameter map containing transaction metadata, client metadata, and the CAANMsg template list |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| CAANMsg | Class | Common Application Architecture Network Message — Fujitsu's message object used for CBS (Common Business Service) communication between service components |
| CBS | Acronym | Common Business Service — the service layer that handles business logic; CBSMsg classes define the message schema for each CBS |
| SC | Acronym | Service Component — a component that encapsulates business functionality and is invoked via the service component framework |
| CJMConstants | Class | Joint Constants Manager — central constant definitions for CJM (Customer Job Management) system, including message key constants |
| TRANZACTION_ID_KEY | Constant | Message key for transaction ID — unique identifier for each transaction in the system (note: spelled "TRANZACTION" with a 'Z' in the codebase) |
| USECASE_ID_KEY | Constant | Message key for use case ID — identifies which business use case is being executed |
| OPERATION_ID_KEY | Constant | Message key for operation ID — identifies the specific operation within a use case |
| CALL_TYPE_KEY | Constant | Message key for call type — classifies the type of service call being made |
| CLIENT_HOST_NAME_KEY | Constant | Message key for client hostname — identifies the application server that handled the request |
| CLIENT_IP_ADDRESS_KEY | Constant | Message key for client IP address — the network IP address of the request origin |
| INVOKE_GAMEN_ID_KEY | Constant | Message key for invoked screen ID — "Gamens" (画面) is Japanese for screen/page; identifies which UI screen initiated the request |
| OPERATOR_ID_KEY | Constant | Message key for operator ID — identifies the user performing the operation |
| OPERATE_DATE_KEY | Constant | Message key for operate date — the business date of the operation |
| OPERATE_DATETIME_KEY | Constant | Message key for operate datetime — the full timestamp of the operation |
| TEMPLATE_LIST_KEY | Constant | Message key for the CAANMsg template list — holds the array of message templates for CBS invocation |
| SCControlMapKeys | Class | Constants class for service control map keys — defines keys for accessing control map data (REQ_HOSTNAME, REQ_HOSTIP, REQ_VIEWID, OPERATOR_ID, OPE_DATE, OPE_TIME) |
| REQ_HOSTNAME | Constant | Control map key for request hostname |
| REQ_HOSTIP | Constant | Control map key for request host IP address |
| REQ_VIEWID | Constant | Control map key for request view/screen ID |
| OPE_DATE | Constant | Control map key for operate date |
| OPE_TIME | Constant | Control map key for operate time |
| svcIf | Field | Service interface name — extracted from mappingData[0][1]; used to dynamically construct the CBS message class name |
| mappingData | Parameter | Two-dimensional mapping array — rows map target field names to source values; row 0 contains metadata (interface name), subsequent rows contain business field mappings |
| eo Customer Base System | Product | K-Opticom's customer base management system (eo = NTT East's brand); this method is part of the customer change workflow for course contract change with subscription cancellation |
