# Business Logic — JFUTicketUseShinIraiCC.getInvokeCBS() [53 LOC]

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

## 1. Role

### JFUTicketUseShinIraiCC.getInvokeCBS()

This method performs **CBS (Core Business System) message preparation** for the Check Ticket Use Application (チェケッ利用依頼) workflow within the K-Opticom customer core system (eo顧客基幹システム). Its business purpose is to assemble all data required by the `CAANMsg` framework — the inter-component messaging infrastructure used to invoke CBS microservices via the Service Component (SC) layer.

The method implements a **data mapping and message assembly pattern**. It collects request metadata from two independent sources — the telegram header (session-level identifiers) and the user control map (client-side request context) — and populates a parameter map that the `callSC()` caller will pass to the SC invocation runtime. For the service-specific payload, it instantiates a `CAANMsg` template by resolving a Java resource bundle key constructed from the service interface name, populates operator and operation date fields, then iterates over a mapping data table to fill template fields with their corresponding values (or sets them as null when the source data is empty).

In the larger system architecture, this method serves as a **shared data transformer** within the `JFUTicketUseShinIraiCC` common component. It is the only method called by `callSC()`, which acts as the SC invocation gateway for ticket use application requests. The `getInvokeCBS` method does not branch on service type; instead, it follows a single deterministic path: collect headers, build the message template, populate fields, and return the complete parameter map. Its role is to decouple CBS message construction from the SC invocation mechanism so that the caller only needs to pass mapping data without knowing message formatting details.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getInvokeCBS(params)"])

    START --> INIT["Create paramMap (HashMap)"]

    INIT --> H1["Source: Telegram Header
Read telegramID, usecaseID, operationID, callType
→ paramMap.put(JCMConstants keys)"]

    H1 --> H2["Source: User Control Map
Read REQ_HOSTNAME, REQ_HOSTIP, REQ_VIEWID, OPERATOR_ID
→ paramMap.put(JCMConstants keys)"]

    H2 --> S2["Read mappingData[0][1] as svcIf
Create CAANMsg with resource key: eo.ejb.cbs.cbsmsg.{svcIf}CBSMsg"]

    S2 --> T1["Set template: OPERATOR_ID, OPERATE_DATE, OPERATE_DATETIME"]

    T1 --> LOOP["For each mappingData row i from 0 to length-1"]

    LOOP --> COND{"mappingData[i][1] equals empty string?"}

    COND -->|Yes| SN["template.setNull(mappingData[i][0])"]

    COND -->|No| ST["template.set(mappingData[i][0], mappingData[i][1])"]

    SN --> NEXT
    ST --> NEXT["Next iteration"]

    NEXT --> ARR["Create CAANMsg[] array
Set templates[0] = template"]

    ARR --> PUT["paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)"]

    PUT --> RET["Return paramMap"]

    RET --> END(["getInvokeCBS return"])

    LOOP -->|Loop end| ARR
```

**Processing summary:**
- The method does not use switch-case or constant-based branching. It follows a linear flow with one conditional branch inside the for-loop.
- Two independent data sources feed into the parameter map: **Telegram Header** (system session data) and **User Control Map** (client request context).
- The CAANMsg template is built dynamically from the `svcIf` value embedded in `mappingData[0][1]`, enabling the same method to support multiple service interfaces.
- The for-loop processes each mapping row: if the value is an empty string, the field is explicitly set to null in the template (preserving the field in the message but with no value); otherwise, the value is set as-is.
- The final template array is wrapped in a single-element array and stored in the parameter map under the `JCMConstants.TEMPLATE_LIST_KEY`, which the caller's `callSC()` method will extract to pass to the SC invocation runtime.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying the current request context. Contains both **telegram header** data (transaction ID, use case ID, operation ID, call type) retrieved via `getTelegramID()`, `getUsecaseID()`, `getOperationID()`, `getCallType()`, and **control map data** (client host name, IP address, screen ID, operator ID, operation date/time) retrieved via `getControlMapData()` with keys like `REQ_HOSTNAME`, `REQ_HOSTIP`, `REQ_VIEWID`, `OPERATOR_ID`, `OPE_DATE`, `OPE_TIME`. This object represents the active request session from the user's point of view. |
| 2 | `mappingData` | `Object[][]` | A 2D mapping table where each row represents a key-value pair for the CBS message template. Row index 0, column 1 (`mappingData[0][1]`) contains the **service interface name** (`svcIf`) used to construct the resource bundle key for the CAANMsg template. Subsequent rows contain field keys at column 0 and field values at column 1. An empty string value (`""`) at column 1 indicates the field should be explicitly nullified in the template. This table is typically pre-built by a mapping configuration and encodes which CBS message fields need to be populated for the specific service interface being invoked. |

**External state / constants referenced:**
| Constant / Class | Source | Business Meaning |
|-----------------|--------|-----------------|
| `JCMConstants.TRANZACTION_ID_KEY` | External JCM library | Key for transaction ID in the parameter map |
| `JCMConstants.USECASE_ID_KEY` | External JCM library | Key for use case ID in the parameter map |
| `JCMConstants.OPERATION_ID_KEY` | External JCM library | Key for operation ID in the parameter map |
| `JCMConstants.CALL_TYPE_KEY` | External JCM library | Key for service call type discriminator |
| `JCMConstants.CLIENT_HOST_NAME_KEY` | External JCM library | Key for client hostname in the parameter map |
| `JCMConstants.CLIENT_IP_ADDRESS_KEY` | External JCM library | Key for client IP address in the parameter map |
| `JCMConstants.INVOKE_GAMEN_ID_KEY` | External JCM library | Key for invoking screen ID in the parameter map |
| `JCMConstants.OPERATOR_ID_KEY` | External JCM library | Key for operator/user ID |
| `JCMConstants.OPERATE_DATE_KEY` | External JCM library | Key for operation date |
| `JCMConstants.OPERATE_DATETIME_KEY` | External JCM library | Key for operation date-time |
| `JCMConstants.TEMPLATE_LIST_KEY` | External JCM library | Key under which the CAANMsg array is stored; read back by `callSC()` |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JCKMvnoCustInfoAddCC.setNull` | - | - | Calls `setNull` in `JCKMvnoCustInfoAddCC` |
| - | `JKKKapKeiInfoCancelCC.setNull` | - | - | Calls `setNull` in `JKKKapKeiInfoCancelCC` |
| - | `JKKKikiModelKappuInfoCC.setNull` | - | - | Calls `setNull` in `JKKKikiModelKappuInfoCC` |
| - | `JKKKisnUwHmdkAddCC.setNull` | - | - | Calls `setNull` in `JKKKisnUwHmdkAddCC` |
| - | `JKKMvnoSvcKeiStaAddCC.setNull` | - | - | Calls `setNull` in `JKKMvnoSvcKeiStaAddCC` |
| R | `JKKejbCallTypeChecker.getCallType` | JKKejbCallTypeChecker | - | Calls `getCallType` in `JKKejbCallTypeChecker` |

### Direct method calls within `getInvokeCBS`:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| E | `CAANMsg.template.setNull(String field)` | - | - | Sets a CAANMsg template field to null. Called when a mapping data value is an empty string. |
| E | `CAANMsg.template.set(String field, Object value)` | - | - | Sets a CAANMsg template field with the mapping data value. Called when the mapping value is non-empty. |

**Classification notes:**
- `CAANMsg.setNull()` and `CAANMsg.set()` are classified as **E** (Execute) — they are internal message construction operations, not direct database CRUD. They manipulate in-memory message objects that will be serialized and transmitted to the CBS layer.
- The `CAANMsg` constructor is also an Execute operation — it instantiates a message template by resolving a Java resource bundle key for localized message definition lookup.
- The `paramMap.put()` calls are Execute operations — they populate the parameter map that serves as the input to the SC invocation.
- No direct database reads, creates, updates, or deletes occur within this method. All data flow is through in-memory parameter objects.

## 5. Dependency Trace

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

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

### Caller Trace:

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | JFUTicketUseShinIraiCC.execute | `execute` → `callSC` → `getInvokeCBS` | `CAANMsg.setNull` [E], `CAANMsg.set` [E] |

**Call chain detail:**
1. `JFUTicketUseShinIraiCC.execute(SessionHandle, IRequestParameterReadWrite, String)` — Public entry point for Check Ticket Use Application processing. Iterates over a list of ticket use application records and invokes `callSC()` for each record.
2. `JFUTicketUseShinIraiCC.callSC(SessionHandle, ServiceComponentRequestInvoker, IRequestParameterReadWrite, String, Object[][])` — Private SC invocation gateway. Calls `getInvokeCBS()` to build the parameter map, then uses `scCall.run()` to invoke the CBS microservice, and handles error response processing.
3. `JFUTicketUseShinIraiCC.getInvokeCBS(IRequestParameterReadWrite, Object[][])` — The current method. Prepares the CBS message parameters.

**Note:** The `execute()` method loops over `ticket_use_shin_irai_list` (Check Ticket Use Application List) and calls `callSC()` once per record. Each call to `callSC()` triggers a fresh `getInvokeCBS()` invocation. The CBS being invoked is determined by the `EKKA0050002CBSMsg` constants in the caller's mapping data, which points to the EKKA0050002 service.

## 6. Per-Branch Detail Blocks

### Block 1 — [SET] `paramMap` Initialization (L209)

> Creates the result parameter map that will hold both header metadata and the CAANMsg template array.

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = new HashMap<String, Object>()` // Result map for CBS parameters |

### Block 2 — [SET] Header Extraction from Telegram Header (L211–L215)

> Copies session-level identifiers from the request's telegram header into the parameter map. These fields identify the transaction and call context for CBS audit and routing purposes. The Javadoc comment states: 【取得元：電文ヘッダ(ヘッダ)】(Source: Telegram Header (Header)).

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put(JCMConstants.TRANZACTION_ID_KEY, param.getTelegramID())` // 電文ID (Transaction ID) [from telegram header] |
| 2 | SET | `paramMap.put(JCMConstants.USECASE_ID_KEY, param.getUsecaseID())` // ユーザケースID (Use Case ID) [from telegram header] |
| 3 | SET | `paramMap.put(JCMConstants.OPERATION_ID_KEY, param.getOperationID())` // オペレーションID (Operation ID) [from telegram header] |
| 4 | SET | `paramMap.put(JCMConstants.CALL_TYPE_KEY, param.getCallType())` // サービス呼び出し区分 (Service Call Type) [from telegram header] |

### Block 3 — [SET] Header Extraction from User Control Map (L217–L223)

> Copies client-side request context from the control map into the parameter map. The Javadoc comment states: 【取得元：ユーザエリア(コントロールマップ)】(Source: User Area (Control Map)).

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap.put(JCMConstants.CLIENT_HOST_NAME_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTNAME))` // 依頼先ホスト名 (Request Destination Hostname) |
| 2 | SET | `paramMap.put(JCMConstants.CLIENT_IP_ADDRESS_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTIP))` // 依頼元IPアドレス (Request Source IP Address) |
| 3 | SET | `paramMap.put(JCMConstants.INVOKE_GAMEN_ID_KEY, param.getControlMapData(SCControlMapKeys.REQ_VIEWID))` // 依頼元画面ID (Request Source Screen ID) |
| 4 | SET | `paramMap.put(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` // オペレータID (Operator ID) |

### Block 4 — [SET] CAANMsg Template Instantiation (L225–L227)

> Reads the service interface name from the first row of mapping data and constructs a CAANMsg template using a Java resource bundle key pattern. The format `eo.ejb.cbs.cbsmsg.{svcIf}CBSMsg` resolves to a properties file containing field definitions and labels for the specific CBS message type.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcIf = (String)mappingData[0][1]` // Service interface name extracted from mappingData row 0, column 1 |
| 2 | SET | `template = new CAANMsg(String.format("eo.ejb.cbs.cbsmsg.%sCBSMsg", svcIf))` // Instantiate CAANMsg with resource bundle key for localized field definitions |

### Block 5 — [SET] Template Header Population (L229–L233)

> Populates the CAANMsg template with operator and operation date fields. These fields are set directly on the template (not through the mapping loop) because they are structural metadata rather than service-specific message fields.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template.set(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID))` // オペレータID (Operator ID) — on template |
| 2 | SET | `template.set(JCMConstants.OPERATE_DATE_KEY, param.getControlMapData(SCControlMapKeys.OPE_DATE))` // 運用日付 (Operation Date) |
| 3 | SET | `template.set(JCMConstants.OPERATE_DATETIME_KEY, param.getControlMapData(SCControlMapKeys.OPE_TIME))` // 運用日時 (Operation Date-Time) |

### Block 6 — [FOR] Mapping Data Iteration (L235–L245)

> Iterates over all rows in the mapping data table. Each row contains a field key at column 0 and a field value at column 1. This loop populates the service-specific message fields in the CAANMsg template based on the mapping data provided by the caller.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` // Loop counter initialized to 0 |
| 2 | COND | `i < mappingData.length` // Loop condition: process all rows |

#### Block 6.1 — [IF] Empty String Check — `mappingData[i][1]` is empty (L236)

> If the mapping data value for this field is an empty string, the field is explicitly nullified in the CAANMsg template. This ensures the field exists in the message structure but carries no value — required by CBS messages that expect all defined fields to be present even when unset.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `template.setNull((String)mappingData[i][0])` // Set field to null — value at column 1 is empty string (L237) |
| 2 | SET | `continue` // Proceed to next iteration |

#### Block 6.2 — [ELSE-IF] Non-empty Value — `mappingData[i][1]` is not empty (L238–L241)

> If the mapping data value is non-empty, set the field to that value in the CAANMsg template. This populates all service-specific message fields with their actual values.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `template.set((String)mappingData[i][0], mappingData[i][1])` // Set field to the mapping data value (L239) |
| 2 | SET | `continue` // Proceed to next iteration |

### Block 7 — [SET] Template Array Packaging (L247–L248)

> Wraps the single CAANMsg template in a one-element array and stores it in the parameter map under `JCMConstants.TEMPLATE_LIST_KEY`. The caller (`callSC()`) reads this key to extract the template and pass it to the SC invocation runtime. The Javadoc comment for `callSC()` confirms: `CAANMsg[] templates = (CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY)`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templates = new CAANMsg[1]` // Create single-element CAANMsg array |
| 2 | SET | `templates[0] = template` // Assign the built template to array index 0 |
| 3 | SET | `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates)` // Store template array in parameter map |

### Block 8 — [RETURN] Return Parameter Map (L250)

> Returns the fully assembled parameter map. The map contains:
> - Telegram header metadata (transaction ID, use case ID, operation ID, call type)
> - User control map data (hostname, IP, screen ID, operator ID)
> - Template list (CAANMsg array with fully populated message template)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return paramMap` // Return: HashMap with header metadata + CAANMsg template array |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `TRANZACTION_ID_KEY` | Field | Transaction ID key — unique identifier for the inter-component message exchange. Note: the constant name uses the spelling "TRANZACTION" (with 'Z') which matches the JCM library convention. |
| `usecaseID` | Field | Use Case ID — identifies the business use case context for the current request. |
| `callType` | Field | Service Call Type — classifies the type of service invocation (e.g., CBS call, external API call). |
| `REQ_HOSTNAME` | Field | Request Destination Hostname — the hostname of the target server processing the request. |
| `REQ_HOSTIP` | Field | Request Source IP Address — the IP address of the client that originated the request. |
| `REQ_VIEWID` | Field | Request Source Screen ID — the screen/page identifier from which the request was initiated. |
| `OPERATOR_ID` | Field | Operator ID — the ID of the user performing the operation. |
| `OPE_DATE` | Field | Operation Date — the business date of the operation in the system. |
| `OPE_TIME` | Field | Operation Date-Time — the timestamp of the operation. |
| `svcIf` | Field | Service Interface — the name of the CBS service interface being invoked, used to resolve the message template resource bundle. |
| `CAANMsg` | Class | CBS Message Framework — Fujitsu's inter-component messaging class that wraps field data with localized labels and metadata. Used to construct and serialize requests to CBS microservices. |
| `paramMap` | Field | Parameter Map — HashMap containing header metadata and the CAANMsg template array, passed as input to the SC invocation. |
| `mappingData` | Parameter | Mapping Data Table — a 2D array of key-value pairs that define which fields to populate in the CBS message and with what values. Row 0, column 1 holds the service interface name; subsequent rows hold field mappings. |
| `TEMPLATE_LIST_KEY` | Constant | Template List Key — the parameter map key under which the CAANMsg array is stored for the caller to retrieve. |
| `callSC` | Method | Service Component Call — private method that invokes the CBS microservice using the parameter map built by `getInvokeCBS()`. |
| `execute` | Method | Check Ticket Use Application Entry Point — public method that iterates over ticket use application records and calls `callSC()` for each. |
| JCM | Acronym | Java Communication Module — Fujitsu's inter-component messaging library providing constants and utilities for transaction/session management. |
| SC (Service Component) | Term | Service Component — the SOA-style microservice invocation layer used to call CBS business logic modules. |
| CBS (Core Business System) | Term | Core Business System — the back-end business processing engine that handles telecom service order fulfillment (subscription, modification, cancellation). |
| テケッ利用依頼 (Check Ticket Use Application) | Japanese Term | Check Ticket Use Application — a business process in the K-Opticom system for requesting check ticket usage, typically related to service contract changes or new subscriptions. |
| eo顧客基幹システム | Japanese Term | eo Customer Core System — the main customer management system for K-Opticom's eo brand telecommunications services. |
| FKKA0050002CBSMsg | Constant | CBS Message class for the EKKA0050002 service — defines field constants like TEMPLATEID, FUNC_CODE, SYSID, SVC_KEI_NO, SISK_CD, and CP_ADD_KEIKI_CD used in the calling method's mapping data. |
| `SVC_KEI_NO` | Field | Service Contract Number — the unique identifier for a service contract line item in the telecom ordering system. |
| `SISK_CD` | Field | Service Code — classifies the type of telecom service (e.g., FTTH, DSL, Mail). |
| `CP_ADD_KEIKI_CD` | Field | Campaign Registration Opportunity Code — identifies a promotional campaign or offer associated with the service. |
| CHAKUWEI | Japanese Term |着信 (Incoming Call) — in the broader system context, a concept related to service routing and call handling. |
