# Business Logic — JFUTicketUseShinIraiCC.execute() [30 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.execute()

This method performs **ticket usage application request processing** (チケット利用申請依頼処理) — a common component that submits one or more ticket-based service registration requests to an external interface via a Service Component (SC) call. It operates in the domain of **telecommunications service provisioning**, specifically handling the registration of ticket-gated service add-ons (such as campaign promotions or optional contract additions) tied to a customer's service contract line.

The method implements the **delegation pattern**: it delegates the actual SC invocation to `ServiceComponentRequestInvoker` and the CBS (Component-Based System) mapping to `getInvokeCBS`, acting as a thin orchestration layer that prepares input data, dispatches each ticket, and handles error responses. The **design pattern** is a **batch dispatch router** — it iterates over a list of ticket application records and sends each one to the same external API endpoint (`EKKA0050002`) with its specific parameters.

In the larger system, this method serves as a **shared utility Common Component** called by multiple BPM workflow screens (FUSV series). It is the primary integration point between the Futurity BPM application and the external KKIFE334 ticket registration API, abstracting away the CBS parameter mapping, error handling, and debug logging.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute(handle, param, fixedText)"])
    SC["Create ServiceComponentRequestInvoker scCall"]
    GET_DATA["Get paramMap from param.getData(fixedText)"]
    GET_LIST["Extract ticket_use_shin_irai_list from paramMap"]
    CHECK_EMPTY{Is ticket list empty?}
    FOR_START["For each ticketMap in ticketList"]
    BUILD_MSG["Build ekk0050002InMsg array
(templateId=\"EKKA0050002\", funcCode=\"1\",
sysid, svcKeiNo, sisakCd, cmpAddOptntyCd,
cmpAddOptntyTgKey1-5)"]
    CALL_SC["Call callSC(handle, scCall, param,
fixedText, ekk0050002InMsg)"]
    NEXT_TICKET{"More tickets?"}
    END_RETURN["Return param"]

    START --> SC --> GET_DATA --> GET_LIST --> CHECK_EMPTY
    CHECK_EMPTY -->|No| END_RETURN
    CHECK_EMPTY -->|Yes| FOR_START --> BUILD_MSG --> CALL_SC --> NEXT_TICKET
    NEXT_TICKET -->|Yes| FOR_START
    NEXT_TICKET -->|No| END_RETURN
```

**Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|-----------------|
| `TEMPLATE_ID_EKKA0050002` | `"EKKA0050002"` | External interface template ID for ticket usage application request |
| `SYSID` | `"sysid"` | System ID — identifies the target system for the service contract |
| `SVC_KEI_NO` | `"svc_kei_no"` | Service contract number — the unique identifier for a service line |
| `SISAK_CD` | `"sisak_cd"` | Policy code — identifies the promotional/conditional policy applied |
| `CMP_ADD_OPTNTY_CD` | `"cmp_add_optnty_cd"` | Campaign registration opportunity code — what type of campaign add-on is being registered |
| `CMP_ADD_OPTNTY_TG_KEY_1` through `_5` | `"cmp_add_optnty_tg_key_1"` through `"cmp_add_optnty_tg_key_5"` | Campaign registration opportunity target keys 1-5 — parameters identifying the target objects of the campaign |
| `KKIFE334` | `"KKIFE334"` | External interface ID — the external IF system code |
| `API_MSG_ID` | `"EKF1930-KW"` | API message ID — message ID used in system error logging |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the persistence context for the current BPM transaction. Used by the SC invocation layer for DB operations and logging. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter container holding all business data for the ticket usage application. Contains user control map data (hostname, IP, view ID, operator ID), telegram ID, use case ID, and the ticket application list under the `fixedText` key. |
| 3 | `fixedText` | `String` | Service message key — identifies which data section within `param` contains the user parameter map (the `ticket_use_shin_irai_list`). Acts as a namespace selector for the parameter data. |

**Instance Fields Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `TEMPLATE_ID_EKKA0050002` | `String` | Constant — template ID passed as the API template identifier for each ticket registration request |
| `SYSID` | `String` | Constant — key name used to retrieve the system ID from the parameter map |
| `SVC_KEI_NO` | `String` | Constant — key name used to retrieve the service contract number from the parameter map |
| `SISAK_CD` | `String` | Constant — key name used to retrieve the policy code from each ticket's map |
| `CMP_ADD_OPTNTY_CD` | `String` | Constant — key name used to retrieve the campaign opportunity code from each ticket's map |
| `CMP_ADD_OPTNTY_TG_KEY_1` through `_5` | `String` | Constants — key names used to retrieve campaign target keys from each ticket's map |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `callSC` → `EKKA0050002` | `EKKA0050002` | External IF KKIFE334 (Ticket Registration) | Calls the external Service Component via `ServiceComponentRequestInvoker.run()` to submit a ticket usage application request. Each iteration sends one ticket registration to the external KKIFE334 interface API. |
| R | `getInvokeCBS` | - | - | Maps request parameters (transaction ID, use case ID, operator ID, client hostname, IP address, view ID) from the request parameter container into a HashMap for CBS invocation. |
| R | `param.getData(fixedText)` | - | - | Retrieves the user parameter map from the request parameter container using the `fixedText` key as the namespace selector. |
| R | `editErrorInfoCom` | - | - | Called by `callSC` to edit error information in the parameter container based on the SC response code. |
| R | `TemplateErrorUtil.getErrorInfo` | - | - | Called by `callSC` to extract and format error info from the SC result, populating the error control map. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | BPM: FUSV0134 | `FUSV0134OPOperation.invokeCC` → `JFUTicketUseShinIraiCC.execute` | `callSC [C] KKIFE334 (External IF)` |
| 2 | BPM: FUSV0127 | `FUSV0127OPOperation.invokeCC` → `JFUTicketUseShinIraiCC.execute` | `callSC [C] KKIFE334 (External IF)` |
| 3 | BPM: FUSV0322 | `FUSV0322OPOperation.invokeCC` → `JFUTicketUseShinIraiCC.execute` | `callSC [C] KKIFE334 (External IF)` |
| 4 | BPM: FUSV0047 | `FUSV0047OPOperation.invokeCC` → `JFUTicketUseShinIraiCC.execute` | `callSC [C] KKIFE334 (External IF)` |
| 5 | BPM: FUSV0311 | `FUSV0311OPOperation.invokeCC` → `JFUTicketUseShinIraiCC.execute` | `callSC [C] KKIFE334 (External IF)` |
| 6 | BPM: FUSV0170 | `FUSV0170OPOperation.invokeCC` → `JFUTicketUseShinIraiCC.execute` | `callSC [C] KKIFE334 (External IF)` |
| 7 | BPM: FUSV0257 | `FUSV0257OPOperation.invokeCC` → `JFUTicketUseShinIraiCC.execute` | `callSC [C] KKIFE334 (External IF)` |
| 8 | BPM: FUSV0131 | `FUSV0131OPOperation.invokeCC` → `JFUTicketUseShinIraiCC.execute` | `callSC [C] KKIFE334 (External IF)` |
| 9 | BPM: FUSV0307 | `FUSV0307OPOperation.invokeCC` → `JFUTicketUseShinIraiCC.execute` | `callSC [C] KKIFE334 (External IF)` |

All callers are BPM operation classes (`FUSVxxxxOPOperation`). Each invokes this Common Component as part of a workflow to register a ticket usage application to the external KKIFE334 interface. The request is pre-validated by `JFUTicketUseShinIraiCCReqChk` before reaching this method.

## 6. Per-Branch Detail Blocks

### Block 1 — Instantiation (L108)

> Instantiate the SC (Service Interface) invocation helper object. Pass the class name for log output; if an empty string is set, it will not be logged. (SC呼び出し部品のインスタンス生成（引数にはログに出力するクラス名を渡す。空文字を設定した場合はログに出力されない）)

| # | Type | Code |
|---|------|------|
| 1 | SET | `scCall = new ServiceComponentRequestInvoker()` |

### Block 2 — Data Extraction (L111-112)

> Extract the user parameter map and the ticket application request list from the request parameter container using the `fixedText` key as the namespace. (ユーザータタ情報 / チケット申請リスト)

| # | Type | Code |
|---|------|------|
| 1 | SET | `paramMap = (HashMap)param.getData(fixedText)` // Extract user parameter map (ユーザータタ情報) [-> fixedText is the namespace key] |
| 2 | SET | `ticketList = (List<HashMap>)paramMap.get("ticket_use_shin_irai_list")` // Extract the ticket application request list (チケット申請リスト) [-> key="ticket_use_shin_irai_list"] |

### Block 3 — Loop: For each ticket (L114)

> Iterate over each ticket record in the ticket application list. For each ticket, build the input message and dispatch it to the external API. (チケットリストの繰り返し処理)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `for (HashMap ticketMap : ticketList)` // Loop over each ticket record |

#### Block 3.1 — Build input message array (L115-124)

> Construct the CBS input message as a 2D array mapping each CBS parameter key to its value. Each field is populated from either the top-level `paramMap` (sysid, svc_kei_no) or the per-ticket `ticketMap` (sisak_cd, campaign codes). (SC呼び出し部品のインスタンス生成（引数にはログに出力するクラス名を渡す。空文字を設定した場合はログに出力されない）)

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0050002InMsg[0] = {TEMPLATEID, TEMPLATE_ID_EKKA0050002}` // Template ID = "EKKA0050002" [-> TEMPLATE_ID_EKKA0050002="EKKA0050002"] |
| 2 | SET | `ekk0050002InMsg[1] = {FUNC_CODE, "1"}` // Function code = "1" (hardcoded) |
| 3 | SET | `ekk0050002InMsg[2] = {SYSID, paramMap.get(SYSID)}` // System ID from user params [-> SYSID="sysid"] |
| 4 | SET | `ekk0050002InMsg[3] = {SVC_KEI_NO, paramMap.get(SVC_KEI_NO)}` // Service contract number from user params [-> SVC_KEI_NO="svc_kei_no"] |
| 5 | SET | `ekk0050002InMsg[4] = {SISK_CD, ticketMap.get(SISAK_CD)}` // Policy code from ticket record [-> SISAK_CD="sisak_cd"] |
| 6 | SET | `ekk0050002InMsg[5] = {CP_ADD_KEIKI_CD, ticketMap.get(CMP_ADD_OPTNTY_CD)}` // Campaign opportunity code [-> CMP_ADD_OPTNTY_CD="cmp_add_optnty_cd"] |
| 7 | SET | `ekk0050002InMsg[6] = {CP_ADD_KEIKI_KEY_1, ticketMap.get(CMP_ADD_OPTNTY_TG_KEY_1)}` // Campaign target key 1 [-> CMP_ADD_OPTNTY_TG_KEY_1="cmp_add_optnty_tg_key_1"] |
| 8 | SET | `ekk0050002InMsg[7] = {CP_ADD_KEIKI_KEY_2, ticketMap.get(CMP_ADD_OPTNTY_TG_KEY_2)}` // Campaign target key 2 [-> CMP_ADD_OPTNTY_TG_KEY_2="cmp_add_optnty_tg_key_2"] |
| 9 | SET | `ekk0050002InMsg[8] = {CP_ADD_KEIKI_KEY_3, ticketMap.get(CMP_ADD_OPTNTY_TG_KEY_3)}` // Campaign target key 3 [-> CMP_ADD_OPTNTY_TG_KEY_3="cmp_add_optnty_tg_key_3"] |
| 10 | SET | `ekk0050002InMsg[9] = {CP_ADD_KEIKI_KEY_4, ticketMap.get(CMP_ADD_OPTNTY_TG_KEY_4)}` // Campaign target key 4 [-> CMP_ADD_OPTNTY_TG_KEY_4="cmp_add_optnty_tg_key_4"] |
| 11 | SET | `ekk0050002InMsg[10] = {CP_ADD_KEIKI_KEY_5, ticketMap.get(CMP_ADD_OPTNTY_TG_KEY_5)}` // Campaign target key 5 [-> CMP_ADD_OPTNTY_TG_KEY_5="cmp_add_optnty_tg_key_5"] |

#### Block 3.2 — Call SC (L126)

> Delegate the SC invocation to the private `callSC` method. This method internally maps the parameters via `getInvokeCBS`, runs the SC via `ServiceComponentRequestInvoker`, handles error code checking, error info editing, and logs a system error message if the API returns a non-zero result. (チケット申請依頼API呼び出し)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callSC(handle, scCall, param, fixedText, ekk0050002InMsg)` |

### Block 4 — Return (L128)

> Return the original request parameter container. Any error info produced by the SC calls has already been written into the parameter container's control map by `callSC`. (リクエストパラメータ管理クラスを返す)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ticket_use_shin_irai` | Field (Japanese) | Ticket usage application request — the business process of requesting permission to use a promotional ticket or campaign offer |
| `svc_kei_no` | Field | Service contract number — unique identifier for a customer's service line (e.g., FTTH, broadband, phone line) |
| `sisak_cd` | Field | Policy code — identifies the promotional/conditional policy type applied to the service (e.g., discount plan, bundled offer) |
| `cmp_add_optnty_cd` | Field | Campaign registration opportunity code — classifies what type of campaign add-on is being registered (e.g., device discount, service upgrade) |
| `cmp_add_optnty_tg_key_1` through `_5` | Field | Campaign registration opportunity target keys 1-5 — up to five parameters identifying the specific objects eligible for the campaign add-on |
| `sysid` | Field | System ID — identifies the target system that will process the ticket registration request |
| `TEMPLATE_ID_EKKA0050002` | Constant | External interface template ID "EKKA0050002" — identifies the API contract for the ticket usage application registration external IF |
| KKIFE334 | External IF ID | External interface identifier — the system code for the external ticket registration interface |
| EKKA0050002 | CBS Template | Service Component template for ticket usage application — the CBS (Component-Based System) endpoint that processes the external API call |
| FUSVxxxx | BPM Workflow | Fujitsu Utility Service Validation workflow screens — BPM operation classes that trigger various service registration flows |
| CC | Acronym | Common Component — shared business logic class in the BPM application architecture, extending `AbstractCommonComponent` |
| SC | Acronym | Service Component / Service Interface — the middleware layer (via `ServiceComponentRequestInvoker`) that invokes CBS endpoints |
| CBS | Acronym | Component-Based System — the backend service component implementation that processes business logic |
| SC Code | Acronym | Service Component Code — typically follows the pattern `EKKnnnnnSC`, identifying a specific service component endpoint |
| KK_T_* | Pattern | Table name constant prefix — convention for database table identifiers in the codebase |
| CAANMsg | Type | Canonical message type — the message object used for CBS request/response data exchange |
| RequestParameterException | Exception | Exception thrown when request parameter retrieval fails in `getInvokeCBS` |
| FMT_YMDHMSS | Constant | Date/time format string "yyyyMMddHHmmss" — used for timestamp formatting in error messages |
| WAR | Constant | Message separator string "WAR" — used as a message boundary delimiter |
| API_MSG_ID | Constant | "EKF1930-KW" — the message ID used in system error logs for ticket usage API errors |
