# Business Logic — FUIFE198.run() [10 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `local.gyomu.api.FUIFE198` |
| Layer | Controller (REST API endpoint) |
| Module | `api` (Package: `local.gyomu.api`) |

## 1. Role

### FUIFE198.run()

FUIFE198 is the API endpoint class for **Introducing Code Validity Check** (紹介コード有効性チェック) — a service that validates whether a promotional/introducing code entered by a customer is still active and usable at the time of a service contract submission. The `run()` method serves as the core business logic entry point invoked by the JAX-RS runtime through the `execute()` HTTP POST handler. It delegates all processing to `logicExecute()`, which calls out to an external business process service (`FUSV0357`) via the `callBpService` bridge to perform the actual code validation against upstream systems. The method implements a **delegation pattern**: `run()` receives the request parts bean, hands it off to `logicExecute()`, and returns the populated response parts bean without inspecting or transforming the data itself. Error handling (error list extraction, body attachment, exception throwing) is entirely handled inside `logicExecute()`. In the larger system, this method is shared by both the **General Web** (一般WEB) and **Retail Web** (量販販売) screens where customers enter an introducing code, and also invoked programmatically by `JFUShokaishaCheckCC` during post-contract verification flows.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["run(reqPartsBean)"])
    STEP1["logicExecute(reqPartsBean)"]
    END_RETURN["Return resPartsBean"]

    START --> STEP1
    STEP1 --> END_RETURN
```

The `run()` method contains a single linear flow: it delegates to `logicExecute()` and returns the result. All branching, service invocation, and error handling logic resides inside `logicExecute()`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `reqPartsBean` | `ApiServerPartsBean` | Request parts bean carrying the API invocation context — includes request headers, authentication info, and the request body containing the introducing code validation data (e.g., the code value, customer info, and originating screen context). This bean is passed through to the business process service and populated with error information if validation fails. |

**External state / instance fields read:** None. The method relies solely on `logicExecute()` which reads static constants defined in the class (`SERVICE_ID`, `JOB_ID`, `SYSTEM_ID`) and inherited state from `ApiServerLocalBase`.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| CALL | `FUIFE198.logicExecute` | FUIFE198 | - | Delegates to `logicExecute()` for service dispatch and response processing |
| CALL | `ApiServerLocalBase.callBpService` | FUSV0357 | - | Invokes business process service FUSV0357 with request context, job ID (`FUIFE198`), and originating system ID (`FRN1`) |

**Details:**
- `logicExecute()` calls `callBpService("FUSV0357", reqPartsBean, "FUIFE198", "FRN1")` which routes to the business process layer. The SC Code `FUSV0357` represents the external service responsible for the introducing code validation logic.
- The `callBpService` method bridges to the EJB-based business process layer, passing the service ID, request bean, job identifier, and source system ID. It returns a `Map<String, Object>` containing the service response keyed by `"FUSV035701CC"` (serviceId + `_01CC` = `"FUSV0357" + "01CC"`).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | API Endpoint: FUIFE198 | `FUIFE198.execute(pRequest, pContext)` → `super.exec("FUIFE198", pRequest, pContext)` → `FUIFE198.run(reqPartsBean)` | `callBpService [CALL] FUSV0357` |
| 2 | CC: JFUShokaishaCheckCC | `JFUShokaishaCheckCC` (post-contract check component) → invokes API `FUIFE198` (Introducing Code Validity Check) | `callBpService [CALL] FUSV0357` |

**Call chain detail:**
- `execute()` is the JAX-RS POST endpoint (`@Path("FUIFE198")`). It calls `super.exec(APIID, pRequest, pContext)` which is inherited from `ApiServerLocalBase`. The base `exec()` method orchestrates request parsing, authentication, and invokes the subclass's `run()` method.
- `JFUShokaishaCheckCC` references FUIFE198 in comments indicating it is called from the "Introducing Code Validity Check" flow during post-contract processing — specifically in front (一般WEB/量販販売) screens and programmatically during shokaisha (initial customer) validation.

## 6. Per-Branch Detail Blocks

**Block 1** — METHOD `(run)` (L79)

> The entry point of the business logic. Delegates to `logicExecute()` and returns the result bean.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `this.logicExecute(reqPartsBean)` // Invoke business logic main processing (業務ロジックメイン処理) |
| 2 | SET | `resPartsBean = logicExecute(reqPartsBean)` // Response data generation (レスポンスデータ生成) [L81] |
| 3 | RETURN | `return resPartsBean` // Return the response parts bean [L87] |

**Block 1.1** — NESTED METHOD `(logicExecute)` (L94)

> Business logic main processing. Calls the designated service and sets the result into the response information. (指定されたサービスを呼び出し、結果をレスポンス情報に設定します。)

| # | Type | Code |
|---|------|------|
| 1 | SET | `serviceId = SERVICE_ID` // Service ID to call = `"FUSV0357"` [L102] |
| 2 | CALL | `callBpService(serviceId, reqPartsBean, JOB_ID, SYSTEM_ID)` // Call business process service [L103] |
| 3 | SET | `outMap = callBpService(...)` // Service invocation result (サービス呼び出し結果) [L103] |
| 4 | SET | `resultMap = (Map<String, Object>)outMap.get(serviceId + _01CC)` // Extract service response from map [L106] |
| 5 | SET | `resultMap = (Map<String, Object>)outMap.get("FUSV035701CC")` // serviceId("FUSV0357") + _01CC("01CC") [L106] |
| 6 | SET | `errInfo = resultMap.get(ApiBpInterface.ERROR_INFO)` // Get error info from business data map (業務データMapからエラー情報を取得する) [L109] |

**Block 1.1.1** — IF (error handling branch) `(errInfo != null && errInfo instanceof List<?>)` (L111)

> If the service returned error information, extract the error list, set it on the request bean, remove it from the result map, set the remaining body data, and throw a business exception. (業務データMapからエラー情報を取得する。エラー情報がある場合はリクエストビーンに設定し、例外をスローする。)

| # | Type | Code |
|---|------|------|
| 1 | SET | `errList = (List<Object>)errInfo` // Cast error info to List<Object> [L113] |
| 2 | EXEC | `reqPartsBean.setErrList(errList)` // Set error list directly on reqPartsBean (reqPartsBeanにそのまま設定する) [L116] |
| 3 | EXEC | `resultMap.remove(ApiBpInterface.ERROR_INFO)` // Remove error info from business data map (業務データMapからエラー情報を削除する) [L119] |
| 4 | EXEC | `reqPartsBean.setBody(resultMap)` // Set remaining response information as body (レスポンス情報をセット) [L122] |
| 5 | CALL | `throw new ApiServerExceptionGyomuErr(reqPartsBean)` // Throw business error exception [L124] |

**Block 1.1.2** — ELSE (implicit — successful response path) (L127)

> No error occurred. Create a fresh response bean, set the result map as its body, and return it.

| # | Type | Code |
|---|------|------|
| 1 | SET | `resPartsBean = new ApiServerPartsBean()` // Create new response parts bean [L127] |
| 2 | EXEC | `resPartsBean.setBody(resultMap)` // Set the service result as body (レスポンス情報をセット) [L128] |
| 3 | RETURN | `return resPartsBean` // Return successful response [L130] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `紹介コード` | Field | Introducing Code — a promotional/referral code entered by customers during service contract submission to track referral sources |
| 有効性チェック | Business term | Validity Check — validation process that confirms whether an introducing code is still active and applicable at the time of use |
| `FUSV0357` | Service ID | External business process service responsible for the introducing code validation logic, invoked via the BP (Business Process) bridge |
| `FRN1` | System ID | Originating system identifier — the source system initiating the request (前システムID) |
| `FUIFE198` | API ID / Job ID | API endpoint identifier and job tracking ID for the Introducing Code Validity Check service |
| `ApiServerPartsBean` | Entity | Server-side parts bean — carries request/response context including headers, body data, and error information across the API layer |
| `callBpService` | Method | Business Process Service bridge method — invokes EJB-based business process layer from the REST API layer |
| `_01CC` | Constant | Map key suffix `"01CC"` — used as a prefix to extract the service response from the returned map (serviceId + "01CC" = `"FUSV035701CC"`) |
| `ERROR_INFO` | Constant | Map key `"ERROR_INFO"` — key under which error information is returned by the business process service |
| `ApiServerExceptionGyomuErr` | Exception | Business error exception — thrown when the called service returns error details; carries the populated `ApiServerPartsBean` with error list |
| 一般WEB | Business term | General Web — the standard customer-facing web application for service contract submissions |
| 量販販売WEB | Business term | Retail Sales Web — the web application used in retail channel sales for service contract submissions |
| JFUShokaishaCheckCC | Component | Post-contract verification component — calls FUIFE198 during initial customer (初期契約) validation workflows |
| BP | Acronym | Business Process — the EJB-based service layer that handles core domain logic |
