# Business Logic — KKIFE509.run() [12 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `local.gyomu.api.KKIFE509` |
| Layer | API / REST Integration (package: `local.gyomu.api`) |
| Module | `api` (Package: `local.gyomu.api`) |

## 1. Role

### KKIFE509.run()

KKIFE509 serves as the REST API integration entry point for the "Campaign Application Eligibility Check / Registration" reception processing class (外部I/F: 「KKIFE509_キャンペーン適用可否照会・登録」受付処理クラス). This method is the core business logic handler invoked by the framework after HTTP request reception and initial validation — it is not called directly by other application code.

The method implements a **delegation pattern**. It does not contain business logic itself. Instead, it delegates all processing to `logicExecute`, which routes the request to the BPM (Business Process Management) service `KKSV1029`. That BPM service then executes the campaign application eligibility check and registration logic via the Common Component class `JKKCmpAplyKhShokaiAddCC`.

The method's role in the larger system is as a **thin API adapter** — it receives business data wrapped in `ApiServerPartsBean` (the server-side API integration data structure), dispatches it to the BPM engine for processing, extracts the response payload, and returns it to the caller. No data transformation, conditional branching, or field manipulation occurs within this method itself.

This is a **shared integration interface** consumed by external systems or frontend applications that need to register campaign eligibility or query whether a campaign applies to a given customer/order.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["run(reqPartsBean)"])
    START --> CALL["logicExecute(reqPartsBean)"]
    CALL --> SET_SID["serviceId = KKSV1029"]
    SET_SID --> CALL_SVC["callBpService2(serviceId, reqPartsBean, JOB_ID, SYSTEM_ID)"]
    CALL_SVC --> INVOKE["Invoke BPM service KKSV1029 / KKSV1029OP"]
    INVOKE --> CC_EXEC["JKKCmpAplyKhShokaiAddCC.execute()"]
    CC_EXEC --> GET_RESULT["outMap.get(KKSV102901CC) -> resultMap"]
    GET_RESULT --> GET_BODY["resultMap.get(BODY_INFO) -> bodyMap"]
    GET_BODY --> CREATE_RESP["new ApiServerPartsBean()
resPartsBean.setBody(bodyMap)"]
    CREATE_RESP --> RET_RUN["Return resPartsBean"]
```

**Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `SERVICE_ID` | `"KKSV1029"` | Target BPM service ID for campaign application eligibility registration |
| `JOB_ID` | `"KKIFE509"` | Job identifier passed to the BPM framework |
| `SYSTEM_ID` | `"EAM1"` | Previous system identifier in the integration chain |
| `_01CC` | `"01CC"` | CC (Common Component) response map key suffix — forms `"KKSV102901CC"` key |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `reqPartsBean` | `ApiServerPartsBean` | Server business API integration data (request) — carries the business payload (a `Map<String, Object>` body) containing campaign application registration information submitted by the caller. The body map contains the data that will be forwarded to the BPM service KKSV1029 for campaign eligibility determination and registration. |

**Instance fields / external state read by this method:**

None directly — the method only reads fields within the passed `reqPartsBean` parameter. The class-level constants (`APIID`, `SERVICE_ID`, `SYSTEM_ID`, `JOB_ID`) are compile-time constants, not mutable instance state.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| CALL | `KKIFE509.logicExecute` | KKIFE509 | - | Delegates to internal `logicExecute` method for BPM service invocation |
| CALL | `ApiServerLocalBase.callBpService2` | (framework) | - | Invokes BPM engine with service ID, request body, job ID, and system ID |
| CALL | `KKSV1029 / KKSV1029OP` | KKSV1029 | - | BPM service for campaign application eligibility check / registration |
| CALL | `JKKCmpAplyKhShokaiAddCC.execute` | JKKCmpAplyKhShokaiAddCC | (see BPM layer) | Common Component that performs the actual campaign application eligibility determination and registration logic |

**Classification notes:**

- **CALL** is used because this method only invokes services; no direct CRUD is performed. The actual Create/Read operations are executed inside `JKKCmpAplyKhShokaiAddCC.execute()`, which handles DB-level operations against the campaign application tables.
- The SC Code for the called BPM operation class is `JKKCmpAplyKhShokaiAddCC` — this is a Common Component (CC) class, not a standard SC (Service Component). CC classes in this codebase wrap shared business logic that may span multiple SC layers.
- Database entities/tables are not directly accessible from this API layer — they reside within the BPM CC class `JKKCmpAplyKhShokaiAddCC`.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | API Endpoint: KKIFE509 (JAX-RS) | `KKIFE509.execute` -> `super.exec("KKIFE509", pRequest, pContext)` -> `ApiServerBase.run` -> `KKIFE509.run` | `logicExecute -> callBpService2 -> KKSV1029 -> JKKCmpAplyKhShokaiAddCC` |

**Downstream call chain from this method:**

| # | Method / Service | SC Code | Descendants |
|---|-----------------|---------|-------------|
| 1 | `logicExecute(ApiServerPartsBean)` | KKIFE509 | Calls `callBpService2` |
| 2 | `callBpService2(String, ApiServerPartsBean, String, String)` | (framework) | Invokes BPM `KKSV1029` |
| 3 | `KKSV1029OPOperation.run` | KKSV1029OP | Calls `JKKCmpAplyKhShokaiAddCC.execute` |
| 4 | `JKKCmpAplyKhShokaiAddCC.execute` | JKKCmpAplyKhShokaiAddCC | Campaign eligibility check & registration (CC) |

## 6. Per-Branch Detail Blocks

The `run` method contains **no conditional branches** — it is a linear, straight-through processing block. Below is the complete block-by-block analysis.

**Block 1** — [METHOD ENTRY] `(run method)` (L86)

> The method receives the request bean and delegates all processing to `logicExecute`. No local setup or validation is performed in this method.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `this.logicExecute(reqPartsBean)` // Delegate to internal logic handler |
| 2 | SET | `resPartsBean = logicExecute(reqPartsBean)` // Capture response bean |
| 3 | RETURN | `return resPartsBean;` // Return response to caller |

**Block 2** — [METHOD ENTRY + JAVADOC] `(business logic main processing)` (L86-L97)

> Japanese Javadoc: 業務ロジック処理 (Business logic processing)

| # | Type | Code |
|---|------|------|
| 1 | SET | `resPartsBean = this.logicExecute(reqPartsBean)` // Response data generation (レスポンスデータ生成) |
| 2 | EXEC | Comment: レスポンスデータ生成 (Response data generation) |
| 3 | RETURN | `return resPartsBean;` // Return the response bean |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `kkife509` | API ID | KK Integration Frontend 509 — REST API endpoint for campaign application eligibility check and registration reception processing |
| `KKSV1029` | Service ID | KK Service 1029 — BPM service for campaign application eligibility check / registration |
| `KKSV1029OP` | Operation ID | KKSV1029 Operation — the operation handler invoked within the BPM flow |
| `KKSV102901CC` | Map Key | Service ID + `_01CC` suffix — the key used to retrieve CC (Common Component) results from the BPM response map |
| `_01CC` | Constant | Common Component response map key suffix, value `"01CC"` — used to construct the response map key |
| `EAM1` | System ID | Previous system identifier in the integration chain |
| `JKKCmpAplyKhShokaiAddCC` | CC Class | KK Campaign Application Khousai (eligibility) Addition CC — Common Component that performs campaign eligibility determination and registration logic |
| `ApiServerPartsBean` | DTO | Server business API integration data — the standard request/response wrapper carrying body maps between API and BPM layers |
| BPM | Acronym | Business Process Management — the enterprise workflow engine that executes business process flows |
| CC | Acronym | Common Component — shared reusable business logic class in the BPM layer (equivalent to a shared service) |
| K-Opticom | Business term | K-Opticom — telecommunications service provider; the domain context for this system |
| Campaign Application Eligibility | Business concept | Determination of whether a customer/order qualifies for a given campaign, followed by registration of that eligibility |
| `reqPartsBean` | Field | Server business API integration data (request) — incoming request payload containing campaign registration parameters |
| `resPartsBean` | Field | Server business API integration data (response) — outgoing response payload with BPM processing results |
