# Business Logic — JKKListCallWrisvcAutoAplyCC.execute() [21 LOC]

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

## 1. Role

### JKKListCallWrisvcAutoAplyCC.execute()

This method serves as a batch dispatcher for **discounted service automatic application** (割引サービス自動適用) within the K-Opticom customer core system (eo customer core system / eo顧客基幹システム). Its primary business purpose is to iterate over a list of services eligible for automatic discount application and invoke the single-service discount application component (`JKKWrisvcAutoAplyCC`) for each one in sequence.

The method implements a **batch iteration (loop-unroll) pattern** — it is not a decision-making or routing component itself, but rather a thin orchestration layer that delegates the actual business logic to `JKKWrisvcAutoAplyCC.execute()` for each individual service map. The data flows through `IRequestParameterReadWrite`, with the working key (`fixedText`) acting as the namespace for both reading and writing the per-service map context.

This method operates as a **shared utility CC** (Common Component) called during the customer order/post-processing BPM flow (screen KKSV0565, operation KKSV056503CC). It does not perform any database operations or SC calls directly — those are delegated to the called `JKKWrisvcAutoAplyCC`, which handles set-target discount eligibility determination (セット対象割引判定処理) and related service application logic. The list of services to process (`wrisvc_auto_aply_list`) is expected to be pre-populated by upstream processing before this method is invoked.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute(handle, param, fixedText)"])
    START --> GET_DATA["Get userData via param.getData(fixedText)"]
    GET_DATA --> GET_LIST["Extract wrisvc_auto_aply_list from userData map"]
    GET_LIST --> INIT_CC["Instantiate JKKWrisvcAutoAplyCC"]
    INIT_CC --> CHECK_EMPTY{"List is empty?"}
    CHECK_EMPTY -->|No| FOR_EACH["For each wrisvc_auto_aply_map in list"]
    FOR_EACH --> SET_PARAM["param.setData(fixedText, wrisvc_auto_aply_map)"]
    SET_PARAM --> EXEC_CC["wrisvcCC.execute(handle, param, fixedText)"]
    EXEC_CC --> NEXT_ITER["Next iteration"]
    NEXT_ITER --> FOR_EACH
    CHECK_EMPTY -->|Yes| RETURN["Return param unchanged"]
    FOR_EACH --> RETURN
    RETURN --> END_NODE(["End"])
```

**Processing summary:**
1. Extract user data map from `param` using `fixedText` as the key.
2. Retrieve the `wrisvc_auto_aply_list` (discount service auto-apply list) from the user data map.
3. Instantiate `JKKWrisvcAutoAplyCC` — the single-service discount application component.
4. For each service map in the list:
   a. Set the current service map into `param` under `fixedText`.
   b. Invoke `JKKWrisvcAutoAplyCC.execute()` to apply discounts for that service.
5. Return the updated `param` object.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle used for transaction and persistence context — provides the database connection and transaction boundary for all downstream DB operations triggered via `JKKWrisvcAutoAplyCC`. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object carrying business data between BPM components. It holds a user data map namespace identified by `fixedText`, which contains `wrisvc_auto_aply_list` (the pre-populated list of services to process). After processing, it carries the updated per-service context back to the caller. |
| 3 | `fixedText` | `String` | The namespace key used to read/write the working data map inside `param`. It acts as a hash key into `param`'s internal data store, isolating this method's data from other concurrent operations that may share the same `param` object. |

**External state read:**
- None directly. The method reads no instance fields — it operates entirely on method parameters and local variables.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKWrisvcAutoAplyCC.execute` | - | - | Delegates per-service discount application logic to `JKKWrisvcAutoAplyCC`. This component handles set-target discount eligibility determination, reading and writing service contract line items, order content codes, and related entities. |

**Note:** `JKKWrisvcAutoAplyCC.execute` is a large component (~25,000+ lines) that internally performs R/U database operations via its mapper layer (`JKKWrisvcAutoAplyCCMapper`) for service detail work numbers (`svc_kei_ucwk_no`), base service numbers (`baseSvcKeiNo`), and service group lists. The specific SC Codes and table names are managed within `JKKWrisvcAutoAplyCC`, not in this dispatcher method. This method's role is purely iterative delegation — it does not directly touch the database.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0565 | `KKSV0565Flow` (BPM entry) -> `KKSV0565OPOperation.execute()` -> `CCRequestBroker target6` -> `KKSV056503CC` -> `JKKListCallWrisvcAutoAplyCC.execute()` | `JKKWrisvcAutoAplyCC.execute` [R/U] (internal mapper operations for service detail work numbers, discount eligibility) |

**Details:**
- `KKSV0565` is the BPM (Business Process Management) flow for customer order post-processing operations.
- `KKSV0565OPOperation` is the operation class that wires CCRequestBroker instances (`target6`) to invoke target CCs.
- `KKSV056503CC` is the CC gateway that calls `JKKListCallWrisvcAutoAplyCC.execute()` as part of the order processing chain.
- The terminal CRUD operations are performed inside `JKKWrisvcAutoAplyCC`, which reads and updates service contract lines, order content data, and related SOD (Service Order Data) entities.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(Extract user data from param)` (L46)

> Retrieve the user data map stored under `fixedText` key in the request parameter object.

| # | Type | Code |
|---|------|------|
| 1 | SET | `userData = param.getData(fixedText)` // Cast to HashMap<String, Object> — retrieves working data namespace |

**Block 2** — [SET] `(Extract auto-apply list from user data)` (L49)

> Pull the list of services eligible for automatic discount application from the user data map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wrisvc_auto_aply_list = userData.get("wrisvc_auto_aply_list")` // Extract ArrayList<HashMap<String, Object>> — list of service maps for discount application processing |

**Block 3** — [SET] `(Instantiate single-service CC)` (L52)

> Create an instance of the discount application component that will handle each individual service.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wrisvcCC = new JKKWrisvcAutoAplyCC()` // Instantiate the per-service discount auto-apply common component |

**Block 4** — [FOR EACH] `(Iterate over wrisvc_auto_aply_list)` (L53)

> Loop through each service map, applying discounts one at a time. This is a standard for-each loop over the pre-populated list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wrisvc_auto_aply_map` // Iterator variable — each map represents one service eligible for discount auto-application |
| 2 | EXEC | `param.setData(fixedText, wrisvc_auto_aply_map)` // Replace the working data in param with the current service map — sets context for the called CC |
| 3 | CALL | `wrisvcCC.execute(handle, param, fixedText)` // Delegate to JKKWrisvcAutoAplyCC.execute() to apply discounts for this specific service. This method performs set-target discount eligibility determination (セット対象割引判定処理), reads base service number from the map, and processes discount application against eligible service detail work numbers. |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `wrisvc_auto_aply_list` | Field | Discount service auto-apply list — an `ArrayList<HashMap<String, Object>>` containing service maps, each representing a service line item eligible for automatic discount application. |
| `fixedText` | Field | Fixed text key / namespace identifier — the string key used to isolate this method's working data within the shared `param` object. |
| `userData` | Field | User data map — a `HashMap<String, Object>` retrieved from `param` that holds all working data for the current processing context. |
| `wrisvc_auto_aply_map` | Field | Individual service map within the auto-apply list — a `HashMap<String, Object>` containing data for one service (including base service number, service detail work number, service group lists, and discount eligibility flags). |
| wrisvc | Abbreviation | Wireless Service — used in this codebase to refer to telecom/wireless service contract line items. |
| AutoAply | Abbreviation | Automatic Application — automated discount/service application without manual user intervention. |
| CC | Abbreviation | Common Component — a reusable shared business logic component extending `AbstractCommonComponent` in the K-Opticom BPM framework. |
| Set (セット) | Business term | Set / Bundle — a bundled package of services (e.g., FTTH + Mobile + Mail) that receives group discount eligibility. In this context, `セット対象割引判定処理` means "set-target discount eligibility determination." |
| SOD | Abbreviation | Service Order Data — the service order entity holding customer contract and order information. |
| KKSV0565 | Screen ID | BPM flow for customer order post-processing operations — handles operations after a customer order is placed. |
| KKSV056503CC | CC ID | The specific common component invoked within KKSV0565 that calls the discount service auto-apply list dispatcher. |
| eo customer core system | Business term | K-Opticom's customer core system (eo顧客基幹システム) — the central system managing customer contracts, orders, services, and billing for Japan Telecom / K-Opticom. |
| 割引サービス自動適用 | Japanese | Discount service automatic application — the business operation of automatically applying eligible discounts to service line items without manual confirmation. |
