# Business Logic — KKIFE403.execute() [12 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `local.gyomu.api.KKIFE403` |
| Layer | Controller (JAX-RS REST API entry point) |
| Module | `api` (Package: `local.gyomu.api`) |

## 1. Role

### KKIFE403.execute()

KKIFE403 is a REST API entry point that handles incoming requests for **"Discount-Linked Contract Information Lookup"** (割引関連契約情報照会) — a business operation that retrieves and returns contract details associated with discount programs for the e-_customer backbone system (eo顧客基幹システム). This method implements the **delegation** and **template method** design patterns: it serves as a thin JAX-RS POST endpoint that delegates all actual business processing up the inheritance chain to `ApiServerLocalBase.exec()`, which in turn invokes the BPM-based business service `KKSV0909`. The method's role in the larger system is that of an **API facade** — it is the single public entry point for external clients (such as web screens or partner systems) to query discount-linked contract information, abstracting away the underlying BPM workflow invocation and response mapping logic. The method is annotated with `@POST` and mapped to the path `KKIFE403` via JAX-RS `@Path`, making it accessible as a REST endpoint. Error handling for business-level validation errors is pre-configured via the `GYOMU_ERR_CODES` array (`"1001"`, `"1002"`, `"1003"`, `"2001"`, `"1000"`), which the parent class uses to classify and respond to business exceptions raised during downstream processing.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute(pRequest, pContext)"])
    CHECK["@POST endpoint /KKIFE403
HTTP Request arrives"]
    DELEGATE["Call super.exec(APIID=\"KKIFE403\",
           pRequest, pContext)"]
    EXEC_FLOW["ApiServerLocalBase.exec()
  -> invokes BPM service KKSV0909"]
    BPM_OP["KKSV0909OPOperation.run()
  -> calls JKKWrbkKnrnKeiInfoListCC"]
    CC_SEARCH["JKKWrbkKnrnKeiInfoListCC.searchKeiInfoList()
  -> calls KKSV090901SC (EKK0081B043CBS)"]
    CBS_CALL["EKK0081B043CBS.run()
  FUNC_CODE=\"1\" (Lookup)
  KEY: inputAcceptanceNum"]
    DATA_RETURN["EKK0081B043CBS returns
  contract info data"]
    CC_RETURN["CC returns
  RequestParameter with resultMap"]
    BPM_RETURN["BPM returns
  ApiServerPartsBean"]
    LOGIC["logicExecute()
  -> extract resultMap
  -> wrap in response bean"]
    RETURN["return response"]
    ENDPOINT_RETURN["Return Response to caller"]

    START --> CHECK --> DELEGATE --> EXEC_FLOW --> BPM_OP --> CC_SEARCH --> CBS_CALL --> DATA_RETURN --> CC_RETURN --> BPM_RETURN --> LOGIC --> RETURN --> ENDPOINT_RETURN
```

**Processing Description:**

1. **HTTP POST receives request** at the `KKIFE403` endpoint. The `@Context`-annotated `HttpServletRequest` and `ServletContext` are injected by the JAX-RS container.
2. **Delegation to parent class**: The method immediately delegates to `super.exec("KKIFE403", pRequest, pContext)`. This is a template method pattern — the actual processing is handled by `ApiServerLocalBase`.
3. **BPM service invocation**: The parent class `exec()` method internally:
   - Builds the request payload from the HTTP request
   - Invokes the BPM service identified by `SERVICE_ID = "KKSV0909"` via `callBpService()`
   - Passes `GYOMU_ERR_CODES_LIST` (containing `"1001"`, `"1002"`, `"1003"`, `"2001"`, `"1000"`) as the business error code classifier
4. **Operation layer**: `KKSV0909OPOperation.run()` executes, which calls the common component `JKKWrbkKnrnKeiInfoListCC.searchKeiInfoList()` with SC code `KKSV090901SC`.
5. **Service Component call**: `KKSV090901SC` invokes CBS `EKK0081B043CBS` with `FUNC_CODE="1"` (lookup/照会) using `inputAcceptanceNum` as the key.
6. **Response mapping**: Results flow back up the chain — the CBS returns data, the CC wraps it in a map keyed by `"KKSV090901SC"`, and the `logicExecute()` method extracts this map and sets it as the body of the response bean.
7. **HTTP Response**: The `Response` object containing the `ApiServerPartsBean` is returned to the JAX-RS runtime, which serializes it (typically as JSON) back to the caller.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `pRequest` | `@Context final HttpServletRequest` | The incoming HTTP request from the client. Contains query parameters, headers, and the request body that include the input data for the contract information lookup (e.g., acceptance number / 受付番号 for the discount-linked contract inquiry). Injected by the JAX-RS container. |
| 2 | `pContext` | `@Context final ServletContext` | The servlet context providing access to the web application's initialization parameters and application-level resources. Used by the parent `ApiServerLocalBase.exec()` for application-wide configuration access. |

**Static fields used by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `APIID` | `String = "KKIFE403"` | The API identifier used to route the request through the parent class's execution framework. Identifies this specific REST endpoint. |
| `SERVICE_ID` | `String = "KKSV0909"` | The business service identifier for the BPM workflow. Points to `KKSV0909Flow`, the BPM service responsible for discount-linked contract information lookup operations. |
| `GYOMU_ERR_CODES` / `GYOMU_ERR_CODES_LIST` | `String[]` / `List<String>` | Business error code list: `{"1001", "1002", "1003", "2001", "1000"}. Passed to `callBpService()` to define which error codes the business service should raise as business exceptions rather than system errors. |

## 4. CRUD Operations / Called Services

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

This method itself (lines 66–77) performs **no direct CRUD operations**. It delegates entirely to the parent class framework, which in turn calls the BPM service. The full chain of operations is traced below:

| # | CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|---|------|----------|---------|-------------|----------------------|
| 1 | C | `callBpService` | KKSV0909 | - | Invokes BPM service KKSV0909 with business error codes (delegation) |
| 2 | R | `JKKWrbkKnrnKeiInfoListCC.searchKeiInfoList` | KKSV090901SC | KK_T_(contract info tables) | Discount-linked contract information lookup — retrieves contract data by input acceptance number (受付番号). Calls EKK0081B043CBS with FUNC_CODE="1" (照会/lookup mode). |
| 3 | R | `EKK0081B043CBS` | EKK0081B043CBS | Contract info entity | Core business component that performs the database query for contract information. Template ID: "EKK0081B043". |

**CRUD Summary:** The KKIFE403 endpoint performs a **Read (R)** operation — it retrieves discount-linked contract information from the database and returns it to the caller. No Create, Update, or Delete operations are performed.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | REST Client (Screen: KKSV0909) | HTTP POST `/KKIFE403` -> `KKIFE403.execute(pRequest, pContext)` | `JKKWrbkKnrnKeiInfoListCC.searchKeiInfoList [R] Contract Info (EKK0081B043CBS)` |

**Note:** The primary caller of `KKIFE403.execute()` is the external HTTP client (web screen KKSV0909) making a REST API call. The `KKSV0909` screen is the UI that invokes this API to display discount-linked contract information to the operator. The call chain terminates at `EKK0081B043CBS` which queries the contract information database.

## 6. Per-Branch Detail Blocks

**Block 1** — [METHOD ENTRY] `execute(HttpServletRequest pRequest, ServletContext pContext)` (L66)

> The REST API entry point annotated with @POST. Receives the HTTP request and servlet context, then delegates all processing to the parent class.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `super.exec(APIID, pRequest, pContext)` | Delegates to `ApiServerLocalBase.exec()` with APIID="KKIFE403" (-> CONSTANT "KKIFE403"). This triggers the full BPM service invocation chain for discount-linked contract information lookup. |

**Block 2** — [RETURN] (L76)

> Returns the Response object produced by the parent class's exec() method after completing the full BPM service processing chain.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return response;` | Returns the HTTP Response containing the ApiServerPartsBean with the contract info result set as the body. |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `割引関連契約情報` (Waribiki Kanren Keiyaku Jouhou) | Japanese term | Discount-Linked Contract Information — contract data associated with bundled discount programs (e.g., eo光 x eo電気 x mineo set discounts). This is the primary business domain of KKIFE403. |
| `受付番号` (Uketsuke Bangou) | Field | Acceptance Number — the unique identifier used to look up contract records. Passed as `inputAcceptanceNum` to the SC. |
| `APIID` | Field | API Identifier — constant `"KKIFE403"` used to identify this endpoint in the framework routing layer. |
| `SERVICE_ID` | Field | Business Service Identifier — constant `"KKSV0909"` that identifies the BPM workflow responsible for discount-linked contract information operations. |
| `GYOMU_ERR_CODES` | Field | Business Error Codes — array of codes `{"1001", "1002", "1003", "2001", "1000"}` that the BPM service raises as business exceptions for validation errors. |
| `KKSV0909` | Screen/BPM | Discount-linked Contract Information Lookup Screen/BPM — the business screen and its associated BPM workflow that performs the actual contract data retrieval. |
| `KKSV0909OPOperation` | CBS | KKSV0909 Operation — the BPM operation layer for KKSV0909 that orchestrates the CC calls. |
| `JKKWrbkKnrnKeiInfoListCC` | CC | Discount-Linked Contract Info List Common Component — a shared common component (CC) that handles the business logic for retrieving discount-linked contract information lists. |
| `KKSV090901SC` | SC | KKSV0909 Screen 01 Service Component — the service component invoked by the CC to perform the actual database access for contract info lookup. |
| `EKK0081B043CBS` | CBS | Contract Info Lookup CBS — the core business component service that performs the database query for contract information. FUNC_CODE="1" means lookup/照会 mode. |
| `FUNC_CODE` | Field | Function Code — parameter passed to CBS to determine operation mode. `"1"` indicates lookup/照会 (query), other values may indicate create/update/delete. |
| `ApiServerPartsBean` | Class | Server Parts Bean — the DTO that carries request/response data between the REST API layer and the BPM service. Contains the body (result map) and metadata. |
| `@Context` | JAX-RS | JAX-RS context injection annotation — tells the container to inject the `HttpServletRequest` and `ServletContext` into the method parameters. |
| `@Path("KKIFE403")` | JAX-RS | JAX-RS path annotation — maps HTTP requests to this resource class. |
| `@POST` | JAX-RS | JAX-RS HTTP method annotation — this endpoint handles POST requests. |
| `eo顧客基幹システム` (eo Kokaku Kikan System) | Japanese term | e-_customer Backbone System — Fujitsu's customer relationship management backbone system for telecom services, including customer data, contract management, and billing. |
| `Template ID "EKK0081B043"` | Constant | Template identifier for the EKK0081B043 CBS, used for logging and tracing within the CBS framework. |
